diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-04-06 00:00:49 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-19 15:32:12 +0100 |
commit | 4aab2ae2afedc01434638e22f13867ed4100310b (patch) | |
tree | a0e8cff86071ade0562f7bce16da5de745029847 /gcc/rust/resolve/rust-finalize-imports-2.0.cc | |
parent | 333a4cbff7ef62208647c234af12caa35271b59c (diff) | |
download | gcc-4aab2ae2afedc01434638e22f13867ed4100310b.zip gcc-4aab2ae2afedc01434638e22f13867ed4100310b.tar.gz gcc-4aab2ae2afedc01434638e22f13867ed4100310b.tar.bz2 |
gccrs: imports: Create ImportData class and use it in import_mappings
gcc/rust/ChangeLog:
* resolve/rust-early-name-resolver-2.0.cc (Early::resolve_glob_import):
Use ImportData class.
(Early::resolve_simple_import): Likewise.
(Early::resolve_rebind_import): Likewise.
(Early::build_import_mapping): Likewise.
* resolve/rust-early-name-resolver-2.0.h: Likewise.
* resolve/rust-finalize-imports-2.0.cc (finalize_simple_import): Likewise.
(finalize_glob_import): Likewise.
(finalize_rebind_import): Likewise.
(FinalizeImports::go): Likewise.
* resolve/rust-finalize-imports-2.0.h: Likewise.
* resolve/rust-name-resolution-context.h: Likewise.
* resolve/rust-rib.h: Define ImportData class.
Diffstat (limited to 'gcc/rust/resolve/rust-finalize-imports-2.0.cc')
-rw-r--r-- | gcc/rust/resolve/rust-finalize-imports-2.0.cc | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/gcc/rust/resolve/rust-finalize-imports-2.0.cc b/gcc/rust/resolve/rust-finalize-imports-2.0.cc index 1725e71..f5c8157 100644 --- a/gcc/rust/resolve/rust-finalize-imports-2.0.cc +++ b/gcc/rust/resolve/rust-finalize-imports-2.0.cc @@ -125,25 +125,30 @@ GlobbingVisitor::visit (AST::UseDeclaration &use) } void -finalize_simple_import (TopLevel &toplevel, - const std::pair<TopLevel::ImportKind, NodeId> &mapping) +finalize_simple_import ( + TopLevel &toplevel, + const std::pair<TopLevel::ImportKind, Early::ImportData> &mapping) { // FIXME: We probably need to store namespace information auto locus = mapping.first.to_resolve.get_locus (); - auto def = mapping.second; + auto data = mapping.second; auto identifier = mapping.first.to_resolve.get_final_segment ().get_segment_name (); // FIXME: Fix the namespace in which we insert the new definition - toplevel.insert_or_error_out (identifier, locus, def, Namespace::Values); + toplevel.insert_or_error_out (identifier, locus, + data.definition.get_node_id (), + data.ns.value ()); } void -finalize_glob_import (NameResolutionContext &ctx, - const std::pair<TopLevel::ImportKind, NodeId> &mapping) +finalize_glob_import ( + NameResolutionContext &ctx, + const std::pair<TopLevel::ImportKind, Early::ImportData> &mapping) { - auto module = Analysis::Mappings::get ().lookup_ast_module (mapping.second); + auto module = Analysis::Mappings::get ().lookup_ast_module ( + mapping.second.definition.get_node_id ()); rust_assert (module); GlobbingVisitor glob_visitor (ctx); @@ -151,14 +156,15 @@ finalize_glob_import (NameResolutionContext &ctx, } void -finalize_rebind_import (TopLevel &toplevel, - const std::pair<TopLevel::ImportKind, NodeId> &mapping) +finalize_rebind_import ( + TopLevel &toplevel, + const std::pair<TopLevel::ImportKind, Early::ImportData> &mapping) { // We can fetch the value here as `resolve_rebind` will only be called on // imports of the right kind auto &path = mapping.first.to_resolve; auto &rebind = mapping.first.rebind.value (); - auto def = mapping.second; + auto data = mapping.second; location_t locus = UNKNOWN_LOCATION; std::string declared_name; @@ -180,12 +186,15 @@ finalize_rebind_import (TopLevel &toplevel, } // FIXME: Fix the namespace in which we insert the new definition - toplevel.insert_or_error_out (declared_name, locus, def, Namespace::Values); + toplevel.insert_or_error_out (declared_name, locus, + data.definition.get_node_id (), + data.ns.value ()); } void -FinalizeImports::go (std::map<TopLevel::ImportKind, NodeId> import_mappings, - TopLevel &toplevel, NameResolutionContext &ctx) +FinalizeImports::go ( + std::map<TopLevel::ImportKind, Early::ImportData> import_mappings, + TopLevel &toplevel, NameResolutionContext &ctx) { for (const auto &mapping : import_mappings) switch (mapping.first.kind) |