aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-path.h
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2020-12-10 17:55:45 +0000
committerPhilip Herron <herron.philip@googlemail.com>2020-12-17 17:23:46 +0000
commit97d2003e8c0027601648364c3561b6aa479c842e (patch)
tree8bb1986fe2d890cadcddaa0ead2bac84cc195352 /gcc/rust/ast/rust-path.h
parent6c89617fc9525b726a494d4b44d19178049169a0 (diff)
downloadgcc-97d2003e8c0027601648364c3561b6aa479c842e.zip
gcc-97d2003e8c0027601648364c3561b6aa479c842e.tar.gz
gcc-97d2003e8c0027601648364c3561b6aa479c842e.tar.bz2
Add generated NodeId's to the AST
NodeIds are going to be used for Hir->Ast lookups later on.
Diffstat (limited to 'gcc/rust/ast/rust-path.h')
-rw-r--r--gcc/rust/ast/rust-path.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/gcc/rust/ast/rust-path.h b/gcc/rust/ast/rust-path.h
index 392fc18..20138b6 100644
--- a/gcc/rust/ast/rust-path.h
+++ b/gcc/rust/ast/rust-path.h
@@ -240,6 +240,8 @@ public:
rust_assert (has_generic_args ());
return generic_args;
}
+
+ PathIdentSegment &get_ident_segment () { return segment_name; }
};
// AST node representing a pattern that involves a "path" - abstract base class
@@ -276,6 +278,15 @@ public:
// TODO: this seems kinda dodgy
std::vector<PathExprSegment> &get_segments () { return segments; }
const std::vector<PathExprSegment> &get_segments () const { return segments; }
+
+ void iterate_path_segments (std::function<bool (PathExprSegment &)> cb)
+ {
+ for (auto it = segments.begin (); it != segments.end (); it++)
+ {
+ if (!cb (*it))
+ return;
+ }
+ }
};
/* AST node representing a path-in-expression pattern (path that allows generic
@@ -328,6 +339,7 @@ public:
// Invalid if path is empty (error state), so base stripping on that.
void mark_for_strip () override { remove_all_segments (); }
bool is_marked_for_strip () const override { return is_error (); }
+ bool opening_scope_resolution () { return has_opening_scope_resolution; }
protected:
/* Use covariance to implement clone function as returning this object rather
@@ -404,6 +416,13 @@ public:
// not pure virtual as class not abstract
virtual void accept_vis (ASTVisitor &vis);
+
+ bool get_separating_scope_resolution () const
+ {
+ return has_separating_scope_resolution;
+ }
+
+ PathIdentSegment get_ident_segment () { return ident_segment; };
};
// Segment used in type path with generic args
@@ -689,6 +708,17 @@ public:
{
return segments;
}
+
+ size_t get_num_segments () const { return segments.size (); }
+
+ void iterate_segments (std::function<bool (TypePathSegment *)> cb)
+ {
+ for (auto it = segments.begin (); it != segments.end (); it++)
+ {
+ if (!cb ((*it).get ()))
+ return;
+ }
+ }
};
struct QualifiedPathType