aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-expr.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/ast/rust-expr.h')
-rw-r--r--gcc/rust/ast/rust-expr.h346
1 files changed, 0 insertions, 346 deletions
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h
index a6882c7..f26ed98 100644
--- a/gcc/rust/ast/rust-expr.h
+++ b/gcc/rust/ast/rust-expr.h
@@ -1852,352 +1852,6 @@ protected:
}
};
-// aka EnumerationVariantExpr
-// Base AST node representing creation of an enum variant instance - abstract
-class EnumVariantExpr : public ExprWithoutBlock
-{
- std::vector<Attribute> outer_attrs;
- PathInExpression enum_variant_path;
-
-protected:
- // Protected constructor for initialising enum_variant_path
- EnumVariantExpr (PathInExpression path_to_enum_variant,
- std::vector<Attribute> outer_attribs)
- : outer_attrs (std::move (outer_attribs)),
- enum_variant_path (std::move (path_to_enum_variant))
- {}
-
-public:
- const PathInExpression &get_enum_variant_path () const
- {
- return enum_variant_path;
- }
- PathInExpression &get_enum_variant_path () { return enum_variant_path; }
-
- // Invalid if path is in error state, so base stripping on that.
- void mark_for_strip () override
- {
- enum_variant_path = PathInExpression::create_error ();
- }
- bool is_marked_for_strip () const override
- {
- return enum_variant_path.is_error ();
- }
-
- const std::vector<Attribute> &get_outer_attrs () const { return outer_attrs; }
- std::vector<Attribute> &get_outer_attrs () { return outer_attrs; }
-
- void set_outer_attrs (std::vector<Attribute> new_attrs) override
- {
- outer_attrs = std::move (new_attrs);
- }
-};
-
-/* Base AST node for a single enum expression field (in enum instance creation)
- * - abstract */
-class EnumExprField
-{
-public:
- virtual ~EnumExprField () {}
-
- // Unique pointer custom clone function
- std::unique_ptr<EnumExprField> clone_enum_expr_field () const
- {
- return std::unique_ptr<EnumExprField> (clone_enum_expr_field_impl ());
- }
-
- virtual std::string as_string () const = 0;
-
- virtual void accept_vis (ASTVisitor &vis) = 0;
-
- virtual Location get_locus () const = 0;
-
-protected:
- // Clone function implementation as pure virtual method
- virtual EnumExprField *clone_enum_expr_field_impl () const = 0;
-};
-
-// Identifier-only variant of EnumExprField AST node
-class EnumExprFieldIdentifier : public EnumExprField
-{
- Identifier field_name;
- Location locus;
-
-public:
- EnumExprFieldIdentifier (Identifier field_identifier, Location locus)
- : field_name (std::move (field_identifier)), locus (locus)
- {}
-
- void accept_vis (ASTVisitor &vis) override;
-
- std::string as_string () const override { return field_name; }
-
- Location get_locus () const override final { return locus; }
-
-protected:
- /* Use covariance to implement clone function as returning this object rather
- * than base */
- EnumExprFieldIdentifier *clone_enum_expr_field_impl () const override
- {
- return new EnumExprFieldIdentifier (*this);
- }
-};
-
-/* Base AST node for a single enum expression field with an assigned value -
- * abstract */
-class EnumExprFieldWithVal : public EnumExprField
-{
- std::unique_ptr<Expr> value;
-
-protected:
- EnumExprFieldWithVal (std::unique_ptr<Expr> field_value)
- : value (std::move (field_value))
- {}
-
- // Copy constructor must clone unique_ptr value
- EnumExprFieldWithVal (EnumExprFieldWithVal const &other)
- : value (other.value->clone_expr ())
- {}
-
- // Overload assignment operator to clone
- EnumExprFieldWithVal &operator= (EnumExprFieldWithVal const &other)
- {
- value = other.value->clone_expr ();
-
- return *this;
- }
-
- // move constructors
- EnumExprFieldWithVal (EnumExprFieldWithVal &&other) = default;
- EnumExprFieldWithVal &operator= (EnumExprFieldWithVal &&other) = default;
-
-public:
- std::string as_string () const override;
-
- // TODO: is this better? Or is a "vis_block" better?
- std::unique_ptr<Expr> &get_value ()
- {
- rust_assert (value != nullptr);
- return value;
- }
-};
-
-// Identifier and value variant of EnumExprField AST node
-class EnumExprFieldIdentifierValue : public EnumExprFieldWithVal
-{
- Identifier field_name;
- Location locus;
-
-public:
- EnumExprFieldIdentifierValue (Identifier field_name,
- std::unique_ptr<Expr> field_value,
- Location locus)
- : EnumExprFieldWithVal (std::move (field_value)),
- field_name (std::move (field_name)), locus (locus)
- {}
-
- std::string as_string () const override;
-
- void accept_vis (ASTVisitor &vis) override;
-
- Location get_locus () const override final { return locus; }
-
-protected:
- /* Use covariance to implement clone function as returning this object rather
- * than base */
- EnumExprFieldIdentifierValue *clone_enum_expr_field_impl () const override
- {
- return new EnumExprFieldIdentifierValue (*this);
- }
-};
-
-// Tuple index and value variant of EnumExprField AST node
-class EnumExprFieldIndexValue : public EnumExprFieldWithVal
-{
- TupleIndex index;
- // TODO: implement "with val" as a template with EnumExprField as type param?
-
- Location locus;
-
-public:
- EnumExprFieldIndexValue (TupleIndex field_index,
- std::unique_ptr<Expr> field_value, Location locus)
- : EnumExprFieldWithVal (std::move (field_value)), index (field_index),
- locus (locus)
- {}
-
- std::string as_string () const override;
-
- void accept_vis (ASTVisitor &vis) override;
-
- Location get_locus () const override final { return locus; }
-
-protected:
- /* Use covariance to implement clone function as returning this object rather
- * than base */
- EnumExprFieldIndexValue *clone_enum_expr_field_impl () const override
- {
- return new EnumExprFieldIndexValue (*this);
- }
-};
-
-// Struct-like syntax enum variant instance creation AST node
-class EnumExprStruct : public EnumVariantExpr
-{
- std::vector<std::unique_ptr<EnumExprField> > fields;
- Location locus;
-
-public:
- std::string as_string () const override;
-
- EnumExprStruct (PathInExpression enum_variant_path,
- std::vector<std::unique_ptr<EnumExprField> > variant_fields,
- std::vector<Attribute> outer_attribs, Location locus)
- : EnumVariantExpr (std::move (enum_variant_path),
- std::move (outer_attribs)),
- fields (std::move (variant_fields)), locus (locus)
- {}
-
- // copy constructor with vector clone
- EnumExprStruct (EnumExprStruct const &other)
- : EnumVariantExpr (other), locus (other.locus)
- {
- fields.reserve (other.fields.size ());
- for (const auto &e : other.fields)
- fields.push_back (e->clone_enum_expr_field ());
- }
-
- // overloaded assignment operator with vector clone
- EnumExprStruct &operator= (EnumExprStruct const &other)
- {
- EnumVariantExpr::operator= (other);
- locus = other.locus;
-
- fields.reserve (other.fields.size ());
- for (const auto &e : other.fields)
- fields.push_back (e->clone_enum_expr_field ());
-
- return *this;
- }
-
- // move constructors
- EnumExprStruct (EnumExprStruct &&other) = default;
- EnumExprStruct &operator= (EnumExprStruct &&other) = default;
-
- Location get_locus () const override final { return locus; }
-
- void accept_vis (ASTVisitor &vis) override;
-
- // TODO: this mutable getter seems really dodgy. Think up better way.
- std::vector<std::unique_ptr<EnumExprField> > &get_fields () { return fields; }
- const std::vector<std::unique_ptr<EnumExprField> > &get_fields () const
- {
- return fields;
- }
-
-protected:
- /* Use covariance to implement clone function as returning this object rather
- * than base */
- EnumExprStruct *clone_expr_without_block_impl () const override
- {
- return new EnumExprStruct (*this);
- }
-};
-
-// Tuple-like syntax enum variant instance creation AST node
-class EnumExprTuple : public EnumVariantExpr
-{
- std::vector<std::unique_ptr<Expr> > values;
- Location locus;
-
-public:
- std::string as_string () const override;
-
- EnumExprTuple (PathInExpression enum_variant_path,
- std::vector<std::unique_ptr<Expr> > variant_values,
- std::vector<Attribute> outer_attribs, Location locus)
- : EnumVariantExpr (std::move (enum_variant_path),
- std::move (outer_attribs)),
- values (std::move (variant_values)), locus (locus)
- {}
-
- // copy constructor with vector clone
- EnumExprTuple (EnumExprTuple const &other)
- : EnumVariantExpr (other), locus (other.locus)
- {
- values.reserve (other.values.size ());
- for (const auto &e : other.values)
- values.push_back (e->clone_expr ());
- }
-
- // overloaded assignment operator with vector clone
- EnumExprTuple &operator= (EnumExprTuple const &other)
- {
- EnumVariantExpr::operator= (other);
- locus = other.locus;
-
- values.reserve (other.values.size ());
- for (const auto &e : other.values)
- values.push_back (e->clone_expr ());
-
- return *this;
- }
-
- // move constructors
- EnumExprTuple (EnumExprTuple &&other) = default;
- EnumExprTuple &operator= (EnumExprTuple &&other) = default;
-
- Location get_locus () const override final { return locus; }
-
- void accept_vis (ASTVisitor &vis) override;
-
- const std::vector<std::unique_ptr<Expr> > &get_elems () const
- {
- return values;
- }
- std::vector<std::unique_ptr<Expr> > &get_elems () { return values; }
-
-protected:
- /* Use covariance to implement clone function as returning this object rather
- * than base */
- EnumExprTuple *clone_expr_without_block_impl () const override
- {
- return new EnumExprTuple (*this);
- }
-};
-
-// No-field enum variant instance creation AST node
-class EnumExprFieldless : public EnumVariantExpr
-{
- Location locus;
-
-public:
- std::string as_string () const override
- {
- // return enum_variant_path.as_string();
- return get_enum_variant_path ().as_string ();
- }
-
- EnumExprFieldless (PathInExpression enum_variant_path,
- std::vector<Attribute> outer_attribs, Location locus)
- : EnumVariantExpr (std::move (enum_variant_path),
- std::move (outer_attribs)),
- locus (locus)
- {}
-
- Location get_locus () const override final { return locus; }
-
- void accept_vis (ASTVisitor &vis) override;
-
-protected:
- /* Use covariance to implement clone function as returning this object rather
- * than base */
- EnumExprFieldless *clone_expr_without_block_impl () const override
- {
- return new EnumExprFieldless (*this);
- }
-};
-
// Forward decl for Function - used in CallExpr
class Function;