aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-expr.h
diff options
context:
space:
mode:
authorSimplyTheOther <simplytheother@gmail.com>2021-01-08 15:09:08 +0800
committerSimplyTheOther <simplytheother@gmail.com>2021-01-08 15:09:08 +0800
commit238a31b33f79cddfaa40c5fd748495a5f2b34630 (patch)
treebc217d37b5e3ee41b0a69265341945389d1f4dfb /gcc/rust/ast/rust-expr.h
parentb5f86dca7e6b53ca3701ef01ae36070a760dff78 (diff)
parentaf04ea2222b6407fb3e83759ae332d600495380c (diff)
downloadgcc-238a31b33f79cddfaa40c5fd748495a5f2b34630.zip
gcc-238a31b33f79cddfaa40c5fd748495a5f2b34630.tar.gz
gcc-238a31b33f79cddfaa40c5fd748495a5f2b34630.tar.bz2
Merge branch 'master' of https://github.com/redbrain/gccrs
Diffstat (limited to 'gcc/rust/ast/rust-expr.h')
-rw-r--r--gcc/rust/ast/rust-expr.h25
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; }