gccrs: Handle ribs in GlobbingVisitor
Improves import resolution by allowing GlobbingVisitor to copy definitions between 'ribs'.
The GlobbingVisitor in gccrs has been updated to handle ‘ribs’ by copying existing definitions rather than always creating new ones from the AST. This change refactors the import resolution process, making GlobbingVisitor more efficient and accurate when dealing with nested modules and imports. It removes redundant member functions and introduces new ones focused on visiting and globbing definitions within these ‘ribs’.
In Details
In gccrs's import resolution stage (specifically rust-finalize-imports-2.0.cc), the GlobbingVisitor's core logic has been refactored. It no longer inherits from DefaultASTVisitor and its visit methods are streamlined. The visitor now uses a visit_container function to manage the traversal and copying of definitions between different 'ribs' (namespaces or scopes), leveraging glob_definitions and glob_definition for efficient resolution and avoiding redundant AST node creation.
- import resolution
- The compiler phase that determines where specific names (like functions, types, or modules) are defined, especially when they are brought into scope via
usedeclarations or module imports. - AST
- Abstract Syntax Tree. A tree representation of the abstract syntactic structure of source code. It's an intermediate representation used by compilers after parsing.
- rib
- In gccrs, a 'rib' refers to a scope or namespace that holds definitions. It's part of the compiler's internal representation for managing names and visibility during name resolution.