Skip to content

Commit 5536d36

Browse files
committed
ast: SimplePath{Segment}: Add NodeId fields
1 parent a936265 commit 5536d36

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

gcc/rust/ast/rust-ast.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,14 @@ class SimplePathSegment : public PathSegment
325325
{
326326
std::string segment_name;
327327
Location locus;
328+
NodeId node_id;
328329

329330
// only allow identifiers, "super", "self", "crate", or "$crate"
330331
public:
331332
// TODO: put checks in constructor to enforce this rule?
332333
SimplePathSegment (std::string segment_name, Location locus = Location ())
333-
: segment_name (std::move (segment_name)), locus (locus)
334+
: segment_name (std::move (segment_name)), locus (locus),
335+
node_id (Analysis::Mappings::get ()->get_next_node_id ())
334336
{}
335337

336338
/* Returns whether simple path segment is in an invalid state (currently, if
@@ -346,6 +348,7 @@ class SimplePathSegment : public PathSegment
346348
std::string as_string () const override;
347349

348350
Location get_locus () const { return locus; }
351+
NodeId get_node_id () const { return node_id; }
349352

350353
// TODO: visitor pattern?
351354
};
@@ -356,14 +359,16 @@ class SimplePath
356359
bool has_opening_scope_resolution;
357360
std::vector<SimplePathSegment> segments;
358361
Location locus;
362+
NodeId node_id;
359363

360364
public:
361365
// Constructor
362366
SimplePath (std::vector<SimplePathSegment> path_segments,
363367
bool has_opening_scope_resolution = false,
364368
Location locus = Location ())
365369
: has_opening_scope_resolution (has_opening_scope_resolution),
366-
segments (std::move (path_segments)), locus (locus)
370+
segments (std::move (path_segments)), locus (locus),
371+
node_id (Analysis::Mappings::get ()->get_next_node_id ())
367372
{}
368373

369374
// Creates an empty SimplePath.
@@ -378,6 +383,7 @@ class SimplePath
378383
std::string as_string () const;
379384

380385
Location get_locus () const { return locus; }
386+
NodeId get_node_id () const { return node_id; }
381387

382388
// does this need visitor if not polymorphic? probably not
383389

0 commit comments

Comments
 (0)