diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-04-06 00:32:57 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-19 15:32:12 +0100 |
commit | 28fe1dac18bc054822ecbf177a9a6cb129f9b1e8 (patch) | |
tree | 1ff5a08e003cb1f689b18125a5de3993e8c7dfae /gcc | |
parent | 4aab2ae2afedc01434638e22f13867ed4100310b (diff) | |
download | gcc-28fe1dac18bc054822ecbf177a9a6cb129f9b1e8.zip gcc-28fe1dac18bc054822ecbf177a9a6cb129f9b1e8.tar.gz gcc-28fe1dac18bc054822ecbf177a9a6cb129f9b1e8.tar.bz2 |
gccrs: imports: Start storing Ribs in ImportKind
gcc/rust/ChangeLog:
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add debug call.
* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Store
imports using the new classes.
* resolve/rust-toplevel-name-resolver-2.0.h: Use new classes.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/resolve/rust-late-name-resolver-2.0.cc | 1 | ||||
-rw-r--r-- | gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc | 13 | ||||
-rw-r--r-- | gcc/rust/resolve/rust-toplevel-name-resolver-2.0.h | 29 |
3 files changed, 31 insertions, 12 deletions
diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc index 068d231..fa759d7 100644 --- a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc @@ -201,6 +201,7 @@ Late::visit (AST::PathInExpression &expr) // in a function item` error here? // do we emit it in `get<Namespace::Labels>`? + rust_debug ("[ARTHUR]: %s", expr.as_simple_path ().as_string ().c_str ()); auto value = ctx.values.resolve_path (expr.get_segments ()); if (!value.has_value ()) rust_unreachable (); // Should have been resolved earlier 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 b6695f6..f2f8f35 100644 --- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc @@ -455,6 +455,10 @@ TopLevel::visit (AST::UseDeclaration &use) auto rebind_path = std::vector<std::pair<AST::SimplePath, AST::UseTreeRebind>> (); + auto &values_rib = ctx.values.peek (); + auto &types_rib = ctx.types.peek (); + auto ¯os_rib = ctx.macros.peek (); + // FIXME: How do we handle `use foo::{self}` imports? Some beforehand cleanup? // How do we handle module imports in general? Should they get added to all // namespaces? @@ -463,14 +467,17 @@ TopLevel::visit (AST::UseDeclaration &use) flatten (tree.get (), paths, glob_path, rebind_path, this->ctx); for (auto &&path : paths) - imports_to_resolve.emplace_back (ImportKind::Simple (std::move (path))); + imports_to_resolve.emplace_back ( + ImportKind::Simple (std::move (path), values_rib, types_rib, macros_rib)); for (auto &&glob : glob_path) - imports_to_resolve.emplace_back (ImportKind::Glob (std::move (glob))); + imports_to_resolve.emplace_back ( + ImportKind::Glob (std::move (glob), values_rib, types_rib, macros_rib)); for (auto &&rebind : rebind_path) imports_to_resolve.emplace_back ( - ImportKind::Rebind (std::move (rebind.first), std::move (rebind.second))); + ImportKind::Rebind (std::move (rebind.first), std::move (rebind.second), + values_rib, types_rib, macros_rib)); } } // namespace Resolver2_0 diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.h b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.h index 7b505cb..92a964d 100644 --- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.h +++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.h @@ -64,21 +64,26 @@ public: Rebind, } kind; - static ImportKind Glob (AST::SimplePath &&to_resolve) + static ImportKind Glob (AST::SimplePath &&to_resolve, Rib &values_rib, + Rib &types_rib, Rib ¯os_rib) { - return ImportKind (Kind::Glob, std::move (to_resolve)); + return ImportKind (Kind::Glob, std::move (to_resolve), values_rib, + types_rib, macros_rib); } - static ImportKind Simple (AST::SimplePath &&to_resolve) + static ImportKind Simple (AST::SimplePath &&to_resolve, Rib &values_rib, + Rib &types_rib, Rib ¯os_rib) { - return ImportKind (Kind::Simple, std::move (to_resolve)); + return ImportKind (Kind::Simple, std::move (to_resolve), values_rib, + types_rib, macros_rib); } static ImportKind Rebind (AST::SimplePath &&to_resolve, - AST::UseTreeRebind &&rebind) + AST::UseTreeRebind &&rebind, Rib &values_rib, + Rib &types_rib, Rib ¯os_rib) { - return ImportKind (Kind::Rebind, std::move (to_resolve), - std::move (rebind)); + return ImportKind (Kind::Rebind, std::move (to_resolve), values_rib, + types_rib, macros_rib, std::move (rebind)); } // The path for `Early` to resolve. @@ -87,11 +92,17 @@ public: // The path to rebind an import to - only present if kind is Kind::Rebind tl::optional<AST::UseTreeRebind> rebind; + Rib &values_rib; + Rib &types_rib; + Rib ¯os_rib; + private: - ImportKind (Kind kind, AST::SimplePath &&to_resolve, + ImportKind (Kind kind, AST::SimplePath &&to_resolve, Rib &values_rib, + Rib &types_rib, Rib ¯os_rib, tl::optional<AST::UseTreeRebind> &&rebind = tl::nullopt) : kind (kind), to_resolve (std::move (to_resolve)), - rebind (std::move (rebind)) + rebind (std::move (rebind)), values_rib (values_rib), + types_rib (types_rib), macros_rib (macros_rib) {} }; |