diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-04-04 17:07:54 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-19 15:32:12 +0100 |
commit | 333a4cbff7ef62208647c234af12caa35271b59c (patch) | |
tree | df096abd47cc2b4612162f15ecd16e8eec2fa925 /gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc | |
parent | 2f743673232dc87b85e802ea5256a36bb1988172 (diff) | |
download | gcc-333a4cbff7ef62208647c234af12caa35271b59c.zip gcc-333a4cbff7ef62208647c234af12caa35271b59c.tar.gz gcc-333a4cbff7ef62208647c234af12caa35271b59c.tar.bz2 |
gccrs: imports: Add FinalizeImports class
gcc/rust/ChangeLog:
* Make-lang.in: Add new object file.
* ast/rust-item.h: Constify method.
* resolve/rust-early-name-resolver-2.0.cc (Early::go): Call into
the imports finalizer.
(Early::resolve_glob_import): Remove old resolution.
(Early::resolve_rebind_import): Likewise.
* resolve/rust-toplevel-name-resolver-2.0.cc (GlobbingVisitor::go):
New function.
(GlobbingVisitor::visit): Likewise.
(TopLevel::visit): Do not call into handle_use_* functions anymore.
* resolve/rust-toplevel-name-resolver-2.0.h (class GlobbingVisitor):
New.
* resolve/rust-finalize-imports-2.0.cc: New file.
* resolve/rust-finalize-imports-2.0.h: New file.
Diffstat (limited to 'gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc')
-rw-r--r-- | gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc | 112 |
1 files changed, 0 insertions, 112 deletions
diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc index 8a1d8be..b6695f6 100644 --- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc @@ -26,105 +26,6 @@ namespace Rust { namespace Resolver2_0 { -void -GlobbingVisitor::go (AST::Module *module) -{ - for (auto &i : module->get_items ()) - visit (i); -} - -void -GlobbingVisitor::visit (AST::Module &module) -{ - if (module.get_visibility ().is_public ()) - ctx.insert_shadowable (module.get_name (), module.get_node_id (), - Namespace::Types); -} - -void -GlobbingVisitor::visit (AST::MacroRulesDefinition ¯o) -{ - if (macro.get_visibility ().is_public ()) - ctx.insert_shadowable (macro.get_rule_name (), macro.get_node_id (), - Namespace::Macros); -} - -void -GlobbingVisitor::visit (AST::Function &function) -{ - if (function.get_visibility ().is_public ()) - ctx.insert_shadowable (function.get_function_name (), - function.get_node_id (), Namespace::Values); -} - -void -GlobbingVisitor::visit (AST::StaticItem &static_item) -{ - if (static_item.get_visibility ().is_public ()) - ctx.insert_shadowable (static_item.get_identifier (), - static_item.get_node_id (), Namespace::Values); -} - -void -GlobbingVisitor::visit (AST::StructStruct &struct_item) -{ - if (struct_item.get_visibility ().is_public ()) - { - ctx.insert_shadowable (struct_item.get_identifier (), - struct_item.get_node_id (), Namespace::Types); - if (struct_item.is_unit_struct ()) - ctx.insert_shadowable (struct_item.get_identifier (), - struct_item.get_node_id (), Namespace::Values); - } -} - -void -GlobbingVisitor::visit (AST::TupleStruct &tuple_struct) -{ - if (tuple_struct.get_visibility ().is_public ()) - { - ctx.insert_shadowable (tuple_struct.get_identifier (), - tuple_struct.get_node_id (), Namespace::Types); - - ctx.insert_shadowable (tuple_struct.get_identifier (), - tuple_struct.get_node_id (), Namespace::Values); - } -} - -void -GlobbingVisitor::visit (AST::Enum &enum_item) -{ - if (enum_item.get_visibility ().is_public ()) - ctx.insert_shadowable (enum_item.get_identifier (), - enum_item.get_node_id (), Namespace::Types); -} - -void -GlobbingVisitor::visit (AST::Union &union_item) -{ - if (union_item.get_visibility ().is_public ()) - ctx.insert_shadowable (union_item.get_identifier (), - union_item.get_node_id (), Namespace::Values); -} - -void -GlobbingVisitor::visit (AST::ConstantItem &const_item) -{ - if (const_item.get_visibility ().is_public ()) - ctx.insert_shadowable (const_item.get_identifier (), - const_item.get_node_id (), Namespace::Values); -} - -void -GlobbingVisitor::visit (AST::ExternCrate &crate) -{} - -void -GlobbingVisitor::visit (AST::UseDeclaration &use) -{ - // Handle cycles ? -} - TopLevel::TopLevel (NameResolutionContext &resolver) : DefaultResolver (resolver) {} @@ -564,25 +465,12 @@ TopLevel::visit (AST::UseDeclaration &use) for (auto &&path : paths) imports_to_resolve.emplace_back (ImportKind::Simple (std::move (path))); - // if (!handle_use_dec (path)) - // rust_error_at (path.get_final_segment ().get_locus (), ErrorCode::E0433, - // "unresolved import %qs", path.as_string ().c_str ()); - for (auto &&glob : glob_path) imports_to_resolve.emplace_back (ImportKind::Glob (std::move (glob))); - // if (!handle_use_glob (glob)) - // rust_error_at (glob.get_final_segment ().get_locus (), ErrorCode::E0433, - // "unresolved import %qs", glob.as_string ().c_str ()); - for (auto &&rebind : rebind_path) imports_to_resolve.emplace_back ( ImportKind::Rebind (std::move (rebind.first), std::move (rebind.second))); - - // if (!handle_rebind (rebind)) - // rust_error_at (rebind.first.get_final_segment ().get_locus (), - // ErrorCode::E0433, "unresolved import %qs", - // rebind.first.as_string ().c_str ()); } } // namespace Resolver2_0 |