public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] ast: SimplePath{Segment}: Add NodeId fields
@ 2022-06-08 12:37 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:37 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:5536d363074d07d84acb8111f6b1ae2cb1f6d0c3
commit 5536d363074d07d84acb8111f6b1ae2cb1f6d0c3
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date: Mon Apr 25 16:38:25 2022 +0200
ast: SimplePath{Segment}: Add NodeId fields
Diff:
---
gcc/rust/ast/rust-ast.h | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index 785af818729..fa261754bcb 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-08 12:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 12:37 [gcc/devel/rust/master] ast: SimplePath{Segment}: Add NodeId fields Thomas Schwinge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).