aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2024-04-03 17:41:47 +0200
committerP-E-P <32375388+P-E-P@users.noreply.github.com>2024-09-26 22:48:32 +0000
commitdcc146b341a2865cfa240739d2cc8e4604d82eb4 (patch)
treebab3083c0acdf715b7227afb73a15312889e5f9f /gcc
parent5e8da717fe1321fe1bcbb8979da8375faedbd90c (diff)
downloadgcc-dcc146b341a2865cfa240739d2cc8e4604d82eb4.zip
gcc-dcc146b341a2865cfa240739d2cc8e4604d82eb4.tar.gz
gcc-dcc146b341a2865cfa240739d2cc8e4604d82eb4.tar.bz2
toplevel: Add note for resolving use declarations
gcc/rust/ChangeLog: * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::handle_use_dec): Add notes on the problem. * resolve/rust-toplevel-name-resolver-2.0.h: Likewise.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc11
-rw-r--r--gcc/rust/resolve/rust-toplevel-name-resolver-2.0.h2
2 files changed, 12 insertions, 1 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 6524a30..0054a9a 100644
--- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
@@ -452,6 +452,13 @@ TopLevel::handle_use_dec (AST::SimplePath &path)
auto locus = path.get_final_segment ().get_locus ();
auto declared_name = path.get_final_segment ().as_string ();
+ // In that function, we only need to declare a new definition - the use path.
+ // the resolution needs to happpen in the EarlyNameResolver. So the
+ // definitions we'll add will be the path's NodeId - that makes sense, as we
+ // need one definition per path declared in a Use tree. so all good.
+ // alright, now in what namespace do we declare them? all of them? do we only
+ // declare them in the EarlyNameResolver? this is dodgy
+
// in what namespace do we perform path resolution? All of them? see which one
// matches? Error out on ambiguities?
// so, apparently, for each one that matches, add it to the proper namespace
@@ -464,6 +471,10 @@ TopLevel::handle_use_dec (AST::SimplePath &path)
const AST::SimplePath &path) {
tl::optional<Rib::Definition> resolved = tl::nullopt;
+ insert_or_error_out (declared_name, locus, path.get_node_id (), ns);
+ // what do we do here with the full simplepath? do we add it to an extra
+ // map?
+
// FIXME: resolve_path needs to return an `expected<NodeId, Error>` so
// that we can improve it with hints or location or w/ever. and maybe
// only emit it the first time.
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 fb16866..7edc70c 100644
--- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.h
+++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.h
@@ -84,7 +84,7 @@ private:
std::unordered_map<NodeId, location_t> node_locations;
// Store node forwarding for use declaration, the link between a
- // "new" local name and its definition.
+ // definition and its new local name.
std::unordered_map<NodeId, NodeId> node_forwarding;
void visit (AST::Module &module) override;