aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/resolve/rust-name-resolver.h
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-06-03 13:13:35 +0100
committerPhilip Herron <philip.herron@embecosm.com>2022-06-10 17:09:34 +0100
commitfc3ef6c4b1fad0d88a65043df8102437416b1df3 (patch)
tree2ec71d2e2b0a412ab1cc6647fd9607a13c0f51ef /gcc/rust/resolve/rust-name-resolver.h
parente6d32d59f1e6524df667262c509910e44151bbf2 (diff)
downloadgcc-fc3ef6c4b1fad0d88a65043df8102437416b1df3.zip
gcc-fc3ef6c4b1fad0d88a65043df8102437416b1df3.tar.gz
gcc-fc3ef6c4b1fad0d88a65043df8102437416b1df3.tar.bz2
Refactor how we track the current module scope id
This adds a module scope stack to the resolver class such that we don't have to continually update our constructors but are able to track it as part of this context class instead. Addresses #1227
Diffstat (limited to 'gcc/rust/resolve/rust-name-resolver.h')
-rw-r--r--gcc/rust/resolve/rust-name-resolver.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/rust/resolve/rust-name-resolver.h b/gcc/rust/resolve/rust-name-resolver.h
index ab7cb55..23a9d82 100644
--- a/gcc/rust/resolve/rust-name-resolver.h
+++ b/gcc/rust/resolve/rust-name-resolver.h
@@ -166,6 +166,23 @@ public:
void set_unit_type_node_id (NodeId id) { unit_ty_node_id = id; }
NodeId get_unit_type_node_id () { return unit_ty_node_id; }
+ void push_new_module_scope (NodeId module_id)
+ {
+ current_module_stack.push_back (module_id);
+ }
+
+ void pop_module_scope ()
+ {
+ rust_assert (!current_module_stack.empty ());
+ current_module_stack.pop_back ();
+ }
+
+ NodeId peek_current_module_scope () const
+ {
+ rust_assert (!current_module_stack.empty ());
+ return current_module_stack.back ();
+ }
+
private:
Resolver ();
@@ -211,6 +228,9 @@ private:
std::map<NodeId, bool> decl_mutability;
// map of resolved names and set of assignments to the decl
std::map<NodeId, std::set<NodeId>> assignment_to_decl;
+
+ // keep track of the current module scope ids
+ std::vector<NodeId> current_module_stack;
};
} // namespace Resolver