aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-expr.h
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2020-12-20 23:58:33 +0000
committerPhilip Herron <herron.philip@googlemail.com>2020-12-23 14:47:34 +0000
commitf701ad5352c7bc8dad53a1ee7f666c8365b35307 (patch)
treec31ad210626efa0fdfd6f0be109439a1429b003d /gcc/rust/ast/rust-expr.h
parentaa2fbb5e48f6218035d7bde1336345cebf120d3e (diff)
downloadgcc-f701ad5352c7bc8dad53a1ee7f666c8365b35307.zip
gcc-f701ad5352c7bc8dad53a1ee7f666c8365b35307.tar.gz
gcc-f701ad5352c7bc8dad53a1ee7f666c8365b35307.tar.bz2
This brings arrays back into the new framework. It resolves ArrayType
ArrayExpr, ArrayExprElems and ArrayIndexExpr. Still need to do ArrayElemsCopied. I expect there to be some changes to cleanup the rust-tyty-resolver this code is to resolve all ribs within a scope but its getting a bit hairy in there now.
Diffstat (limited to 'gcc/rust/ast/rust-expr.h')
-rw-r--r--gcc/rust/ast/rust-expr.h17
1 files changed, 8 insertions, 9 deletions
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h
index 8e60557..cc87498 100644
--- a/gcc/rust/ast/rust-expr.h
+++ b/gcc/rust/ast/rust-expr.h
@@ -952,9 +952,15 @@ public:
virtual void accept_vis (ASTVisitor &vis) = 0;
+ NodeId get_node_id () const { return node_id; }
+
protected:
+ ArrayElems () : node_id (Analysis::Mappings::get ()->get_next_node_id ()) {}
+
// pure virtual clone implementation
virtual ArrayElems *clone_array_elems_impl () const = 0;
+
+ NodeId node_id;
};
// Value array elements
@@ -966,7 +972,7 @@ class ArrayElemsValues : public ArrayElems
public:
ArrayElemsValues (std::vector<std::unique_ptr<Expr> > elems)
- : values (std::move (elems))
+ : ArrayElems (), values (std::move (elems))
{}
// copy constructor with vector clone
@@ -1032,7 +1038,7 @@ public:
// Constructor requires pointers for polymorphism
ArrayElemsCopied (std::unique_ptr<Expr> copied_elem,
std::unique_ptr<Expr> copy_amount)
- : elem_to_copy (std::move (copied_elem)),
+ : ArrayElems (), elem_to_copy (std::move (copied_elem)),
num_copies (std::move (copy_amount))
{}
@@ -1091,10 +1097,6 @@ class ArrayExpr : public ExprWithoutBlock
// TODO: find another way to store this to save memory?
bool marked_for_strip = false;
- // this is a reference to what the inferred type is based on
- // this init expression
- Type *inferredType;
-
public:
std::string as_string () const override;
@@ -1159,9 +1161,6 @@ public:
return internal_elements;
}
- Type *get_inferred_type () { return inferredType; }
- void set_inferred_type (Type *type) { inferredType = type; }
-
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */