aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-expr.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-expr.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-expr.h')
-rw-r--r--gcc/rust/ast/rust-expr.h41
1 files changed, 31 insertions, 10 deletions
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h
index f86aa54..864ee1d 100644
--- a/gcc/rust/ast/rust-expr.h
+++ b/gcc/rust/ast/rust-expr.h
@@ -1647,7 +1647,8 @@ class StructExprFieldIdentifierValue : public StructExprFieldWithVal
public:
StructExprFieldIdentifierValue (Identifier field_identifier,
- std::unique_ptr<Expr> field_value, Location locus)
+ std::unique_ptr<Expr> field_value,
+ Location locus)
: StructExprFieldWithVal (std::move (field_value)),
field_name (std::move (field_identifier)), locus (locus)
{}
@@ -1679,7 +1680,8 @@ class StructExprFieldIndexValue : public StructExprFieldWithVal
public:
StructExprFieldIndexValue (TupleIndex tuple_index,
std::unique_ptr<Expr> field_value, Location locus)
- : StructExprFieldWithVal (std::move (field_value)), index (tuple_index), locus (locus)
+ : StructExprFieldWithVal (std::move (field_value)), index (tuple_index),
+ locus (locus)
{}
std::string as_string () const override;
@@ -2039,7 +2041,8 @@ class EnumExprFieldIdentifierValue : public EnumExprFieldWithVal
public:
EnumExprFieldIdentifierValue (Identifier field_name,
- std::unique_ptr<Expr> field_value, Location locus)
+ std::unique_ptr<Expr> field_value,
+ Location locus)
: EnumExprFieldWithVal (std::move (field_value)),
field_name (std::move (field_name)), locus (locus)
{}
@@ -2071,7 +2074,8 @@ class EnumExprFieldIndexValue : public EnumExprFieldWithVal
public:
EnumExprFieldIndexValue (TupleIndex field_index,
std::unique_ptr<Expr> field_value, Location locus)
- : EnumExprFieldWithVal (std::move (field_value)), index (field_index), locus (locus)
+ : EnumExprFieldWithVal (std::move (field_value)), index (field_index),
+ locus (locus)
{}
std::string as_string () const override;
@@ -2325,6 +2329,20 @@ public:
void mark_for_strip () override { function = nullptr; }
bool is_marked_for_strip () const override { return function == nullptr; }
+ void iterate_params (std::function<bool (Expr *)> cb)
+ {
+ for (auto it = params.begin (); it != params.end (); it++)
+ {
+ if (!cb (it->get ()))
+ return;
+ }
+ }
+
+protected:
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ CallExpr *clone_expr_impl () const override { return new CallExpr (*this); }
+
// TODO: this mutable getter seems really dodgy. Think up better way.
const std::vector<std::unique_ptr<Expr> > &get_params () const
{
@@ -2793,13 +2811,16 @@ public:
void accept_vis (ASTVisitor &vis) override;
// Can be completely empty, so have to have a separate flag.
- void mark_for_strip () override
- {
- marked_for_strip = true;
- }
- bool is_marked_for_strip () const override
+ void mark_for_strip () override { marked_for_strip = true; }
+ bool is_marked_for_strip () const override { return marked_for_strip; }
+
+ void iterate_stmts (std::function<bool (Stmt *)> cb)
{
- return marked_for_strip;
+ for (auto it = statements.begin (); it != statements.end (); it++)
+ {
+ if (!cb (it->get ()))
+ return;
+ }
}
// TODO: this mutable getter seems really dodgy. Think up better way.