diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-04-25 19:14:00 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-25 19:14:00 +0000 |
commit | b74044fb6278e373da607a8f1f5df2193ce27d65 (patch) | |
tree | 6713b11e9b0a7de36b00b96ffed1d2322a93a239 /gcc/rust/ast/rust-ast.h | |
parent | 2b1cb4ba8693e2c148e7aa406b4f03d34ffc0439 (diff) | |
parent | d0c75495dda7943078771d792a6e380315c7d604 (diff) | |
download | gcc-b74044fb6278e373da607a8f1f5df2193ce27d65.zip gcc-b74044fb6278e373da607a8f1f5df2193ce27d65.tar.gz gcc-b74044fb6278e373da607a8f1f5df2193ce27d65.tar.bz2 |
Merge #1164
1164: Add `NodeId`s to `SimplePath{Segment}`s r=CohenArthur a=CohenArthur
This is a necessary first step which addresses #1158
I am working on the visibility resolver and simple-path name resolver in parallel and will need those changes.
I'm not sure if the `has_path` method is necessary since we will have `HIR::Visibilities` in the visibility resolver, which will be desugared. Maybe I am doing this wrong and we should be working on `AST::Visibilities` instead?
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
Diffstat (limited to 'gcc/rust/ast/rust-ast.h')
-rw-r--r-- | gcc/rust/ast/rust-ast.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index 785af81..fa26175 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -325,12 +325,14 @@ class SimplePathSegment : public PathSegment { std::string segment_name; Location locus; + NodeId node_id; // only allow identifiers, "super", "self", "crate", or "$crate" public: // TODO: put checks in constructor to enforce this rule? SimplePathSegment (std::string segment_name, Location locus = Location ()) - : segment_name (std::move (segment_name)), locus (locus) + : segment_name (std::move (segment_name)), locus (locus), + node_id (Analysis::Mappings::get ()->get_next_node_id ()) {} /* Returns whether simple path segment is in an invalid state (currently, if @@ -346,6 +348,7 @@ public: std::string as_string () const override; Location get_locus () const { return locus; } + NodeId get_node_id () const { return node_id; } // TODO: visitor pattern? }; @@ -356,6 +359,7 @@ class SimplePath bool has_opening_scope_resolution; std::vector<SimplePathSegment> segments; Location locus; + NodeId node_id; public: // Constructor @@ -363,7 +367,8 @@ public: bool has_opening_scope_resolution = false, Location locus = Location ()) : has_opening_scope_resolution (has_opening_scope_resolution), - segments (std::move (path_segments)), locus (locus) + segments (std::move (path_segments)), locus (locus), + node_id (Analysis::Mappings::get ()->get_next_node_id ()) {} // Creates an empty SimplePath. @@ -378,6 +383,7 @@ public: std::string as_string () const; Location get_locus () const { return locus; } + NodeId get_node_id () const { return node_id; } // does this need visitor if not polymorphic? probably not |