@@ -325,12 +325,14 @@ class SimplePathSegment : public PathSegment
325
325
{
326
326
std::string segment_name;
327
327
Location locus;
328
+ NodeId node_id;
328
329
329
330
// only allow identifiers, "super", "self", "crate", or "$crate"
330
331
public:
331
332
// TODO: put checks in constructor to enforce this rule?
332
333
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 ())
334
336
{}
335
337
336
338
/* Returns whether simple path segment is in an invalid state (currently, if
@@ -346,6 +348,7 @@ class SimplePathSegment : public PathSegment
346
348
std::string as_string () const override ;
347
349
348
350
Location get_locus () const { return locus; }
351
+ NodeId get_node_id () const { return node_id; }
349
352
350
353
// TODO: visitor pattern?
351
354
};
@@ -356,14 +359,16 @@ class SimplePath
356
359
bool has_opening_scope_resolution;
357
360
std::vector<SimplePathSegment> segments;
358
361
Location locus;
362
+ NodeId node_id;
359
363
360
364
public:
361
365
// Constructor
362
366
SimplePath (std::vector<SimplePathSegment> path_segments,
363
367
bool has_opening_scope_resolution = false ,
364
368
Location locus = Location ())
365
369
: 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 ())
367
372
{}
368
373
369
374
// Creates an empty SimplePath.
@@ -378,6 +383,7 @@ class SimplePath
378
383
std::string as_string () const ;
379
384
380
385
Location get_locus () const { return locus; }
386
+ NodeId get_node_id () const { return node_id; }
381
387
382
388
// does this need visitor if not polymorphic? probably not
383
389
0 commit comments