diff options
Diffstat (limited to 'gcc/rust/ast/rust-expr.h')
-rw-r--r-- | gcc/rust/ast/rust-expr.h | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h index d531342..eee654b 100644 --- a/gcc/rust/ast/rust-expr.h +++ b/gcc/rust/ast/rust-expr.h @@ -50,10 +50,10 @@ public: Literal::LitType get_lit_type () const { return literal.get_lit_type (); } LiteralExpr (std::string value_as_string, Literal::LitType type, - Location locus, + PrimitiveCoreType type_hint, Location locus, std::vector<Attribute> outer_attrs = std::vector<Attribute> ()) : ExprWithoutBlock (std::move (outer_attrs)), - literal (std::move (value_as_string), type), locus (locus) + literal (std::move (value_as_string), type, type_hint), locus (locus) {} LiteralExpr (Literal literal, Location locus, @@ -1572,9 +1572,16 @@ public: virtual Location get_locus_slow () const = 0; + NodeId get_node_id () const { return node_id; } + protected: // pure virtual clone implementation virtual StructExprField *clone_struct_expr_field_impl () const = 0; + + StructExprField () : node_id (Analysis::Mappings::get ()->get_next_node_id ()) + {} + + NodeId node_id; }; // Identifier-only variant of StructExprField AST node @@ -1585,7 +1592,8 @@ class StructExprFieldIdentifier : public StructExprField public: StructExprFieldIdentifier (Identifier field_identifier, Location locus) - : field_name (std::move (field_identifier)), locus (locus) + : StructExprField (), field_name (std::move (field_identifier)), + locus (locus) {} std::string as_string () const override { return field_name; } @@ -1612,7 +1620,7 @@ class StructExprFieldWithVal : public StructExprField protected: StructExprFieldWithVal (std::unique_ptr<Expr> field_value) - : value (std::move (field_value)) + : StructExprField (), value (std::move (field_value)) {} // Copy constructor requires clone @@ -1770,6 +1778,15 @@ public: return fields; } + void iterate (std::function<bool (StructExprField *)> cb) + { + for (auto &field : fields) + { + if (!cb (field.get ())) + return; + } + } + StructBase &get_struct_base () { return struct_base; } const StructBase &get_struct_base () const { return struct_base; } |