aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-expr.h
diff options
context:
space:
mode:
authorSimplyTheOther <simplytheother@gmail.com>2020-09-02 14:05:31 +0800
committerPhilip Herron <philip.herron@embecosm.com>2020-11-28 21:13:20 +0000
commit8a633e3ca4d151d6bbee849a1ef2d265d95bc2a7 (patch)
treea4ad4b385fa736a030c11940d6a197386ea7e733 /gcc/rust/ast/rust-expr.h
parent318a91e6baec6dfb406bc069866789c0a11b01e0 (diff)
downloadgcc-8a633e3ca4d151d6bbee849a1ef2d265d95bc2a7.zip
gcc-8a633e3ca4d151d6bbee849a1ef2d265d95bc2a7.tar.gz
gcc-8a633e3ca4d151d6bbee849a1ef2d265d95bc2a7.tar.bz2
Attempt to modify buffered_queue to take ownership of a source rather than reference, other cleanup
Attempt to fix compile errors caused by make_shared with private constructor Attempt to fix compile errors Attempt to fix appearance of no characters in lexer
Diffstat (limited to 'gcc/rust/ast/rust-expr.h')
-rw-r--r--gcc/rust/ast/rust-expr.h3194
1 files changed, 1147 insertions, 2047 deletions
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h
index 91e176f..727cf3c 100644
--- a/gcc/rust/ast/rust-expr.h
+++ b/gcc/rust/ast/rust-expr.h
@@ -10,128 +10,84 @@ namespace AST {
* "has_whatever" pairs with
* optional types (std::optional or boost::optional)? */
-// forward decls: defined in rust-path.h, rust-type.h, rust-pattern.h, and
-// rust-stmt.h
-/*class PathInExpression;
-class QualifiedPathInExpression;
-class PathExprSegment;*/ // decls no longer required as "rust-path.h" is included
-/*class Type;
-class TypeNoBounds;
-class Lifetime;
-class Pattern;
-class Statement;*/ // decls no longer required as definitions moved to rust-ast.h
-
-// Decl as definition moved to rust-ast.h
-class ExprWithoutBlock;
-class Function;
-
// AST node for an expression with an accompanying block - abstract
class ExprWithBlock : public Expr
{
// TODO: should this mean that a BlockExpr should be a member variable?
protected:
- ExprWithBlock (::std::vector<Attribute> outer_attrs
- = ::std::vector<Attribute> ())
- : Expr (::std::move (outer_attrs))
+ ExprWithBlock (std::vector<Attribute> outer_attrs = std::vector<Attribute> ())
+ : Expr (std::move (outer_attrs))
{}
// pure virtual clone implementation
virtual ExprWithBlock *clone_expr_with_block_impl () const = 0;
// prevent having to define multiple clone expressions
- virtual ExprWithBlock *clone_expr_impl () const OVERRIDE
+ ExprWithBlock *clone_expr_impl () const override
{
return clone_expr_with_block_impl ();
}
public:
// Unique pointer custom clone function
- ::std::unique_ptr<ExprWithBlock> clone_expr_with_block () const
+ std::unique_ptr<ExprWithBlock> clone_expr_with_block () const
{
- return ::std::unique_ptr<ExprWithBlock> (clone_expr_with_block_impl ());
+ return std::unique_ptr<ExprWithBlock> (clone_expr_with_block_impl ());
}
};
// Literals? Or literal base?
class LiteralExpr : public ExprWithoutBlock
{
- /*public:
- enum LitType {
- CHAR,
- STRING,
- RAW_STRING,
- BYTE,
- BYTE_STRING,
- RAW_BYTE_STRING,
- INT,
- FLOAT,
- BOOL
- };
-
- private:
- // TODO: maybe make subclasses of each type of literal with their typed
- values (or
- // generics)
- ::std::string value_as_string;
- LitType type;*/
- // moved to Literal
-
public:
Literal literal;
-
Location locus;
- ::std::string as_string () const { return literal.as_string (); }
+ std::string as_string () const override { return literal.as_string (); }
- inline Literal::LitType get_lit_type () const
- {
- return literal.get_lit_type ();
- }
+ Literal::LitType get_lit_type () const { return literal.get_lit_type (); }
- LiteralExpr (::std::string value_as_string, Literal::LitType type,
+ LiteralExpr (std::string value_as_string, Literal::LitType type,
Location locus,
- ::std::vector<Attribute> outer_attrs
- = ::std::vector<Attribute> ())
- : ExprWithoutBlock (::std::move (outer_attrs)),
- literal (::std::move (value_as_string), type), locus (locus)
+ std::vector<Attribute> outer_attrs = std::vector<Attribute> ())
+ : ExprWithoutBlock (std::move (outer_attrs)),
+ literal (std::move (value_as_string), type), locus (locus)
{}
LiteralExpr (Literal literal, Location locus,
- ::std::vector<Attribute> outer_attrs
- = ::std::vector<Attribute> ())
- : ExprWithoutBlock (::std::move (outer_attrs)),
- literal (::std::move (literal)), locus (locus)
+ std::vector<Attribute> outer_attrs = std::vector<Attribute> ())
+ : ExprWithoutBlock (std::move (outer_attrs)), literal (std::move (literal)),
+ locus (locus)
{}
// Unique pointer custom clone function
- ::std::unique_ptr<LiteralExpr> clone_literal_expr () const
+ std::unique_ptr<LiteralExpr> clone_literal_expr () const
{
- return ::std::unique_ptr<LiteralExpr> (clone_literal_expr_impl ());
+ return std::unique_ptr<LiteralExpr> (clone_literal_expr_impl ());
}
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual LiteralExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ LiteralExpr *clone_expr_impl () const override
{
return new LiteralExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual LiteralExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ LiteralExpr *clone_expr_without_block_impl () const override
{
return new LiteralExpr (*this);
}
- // not virtual as currently no subclasses of LiteralExpr, but could be in
- // future
+ /* not virtual as currently no subclasses of LiteralExpr, but could be in
+ * future */
/*virtual*/ LiteralExpr *clone_literal_expr_impl () const
{
return new LiteralExpr (*this);
@@ -142,8 +98,7 @@ protected:
class AttrInputLiteral : public AttrInput
{
// Literal expression WITHOUT SUFFIX
- // LiteralExpr* literal_expr;
- //::std::unique_ptr<LiteralExpr> literal_expr;
+ // std::unique_ptr<LiteralExpr> literal_expr;
LiteralExpr
literal_expr; // as not using polymorphic behaviour, doesn't require pointer
// TODO: will require pointer if LiteralExpr is changed to have subclassing
@@ -151,57 +106,51 @@ class AttrInputLiteral : public AttrInput
// TODO: should this store location data?
public:
- AttrInputLiteral (LiteralExpr lit_expr)
- : literal_expr (::std::move (lit_expr))
+ AttrInputLiteral (LiteralExpr lit_expr) : literal_expr (std::move (lit_expr))
{}
- /*~AttrInputLiteral() {
- delete literal_expr;
- }*/
- ::std::string as_string () const { return " = " + literal_expr.as_string (); }
+ std::string as_string () const override
+ {
+ return " = " + literal_expr.as_string ();
+ }
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
- // this can never be a cfg predicate - cfg and cfg_attr require a token-tree
- // cfg
- virtual bool
- check_cfg_predicate (const Session &session ATTRIBUTE_UNUSED) const OVERRIDE
+ /* this can never be a cfg predicate - cfg and cfg_attr require a token-tree
+ * cfg */
+ bool
+ check_cfg_predicate (const Session &session ATTRIBUTE_UNUSED) const override
{
- // TODO: ensure this is true
- // DEBUG
- fprintf (stderr, "check_cfg_predicate call went to AttrInputLiteral - "
- "should not happen?\n");
-
return false;
}
protected:
- // Use covariance to implement clone function as returning an AttrInputLiteral
- // object
- virtual AttrInputLiteral *clone_attr_input_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ AttrInputLiteral *clone_attr_input_impl () const override
{
return new AttrInputLiteral (*this);
}
};
-// literal expr only meta item inner - TODO possibly replace with inheritance of
-// LiteralExpr itself?
+/* literal expr only meta item inner - TODO possibly replace with inheritance of
+ * LiteralExpr itself? */
class MetaItemLitExpr : public MetaItemInner
{
LiteralExpr lit_expr;
public:
- MetaItemLitExpr (LiteralExpr lit_expr) : lit_expr (::std::move (lit_expr)) {}
+ MetaItemLitExpr (LiteralExpr lit_expr) : lit_expr (std::move (lit_expr)) {}
- ::std::string as_string () const OVERRIDE { return lit_expr.as_string (); }
+ std::string as_string () const override { return lit_expr.as_string (); }
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
- virtual bool check_cfg_predicate (const Session &session) const OVERRIDE;
+ bool check_cfg_predicate (const Session &session) const override;
protected:
// Use covariance to implement clone function as returning this type
- virtual MetaItemLitExpr *clone_meta_item_inner_impl () const OVERRIDE
+ MetaItemLitExpr *clone_meta_item_inner_impl () const override
{
return new MetaItemLitExpr (*this);
}
@@ -215,84 +164,30 @@ class MetaItemPathLit : public MetaItem
public:
MetaItemPathLit (SimplePath path, LiteralExpr lit_expr)
- : path (::std::move (path)), lit (::std::move (lit_expr))
+ : path (std::move (path)), lit (std::move (lit_expr))
{}
- ::std::string as_string () const OVERRIDE
+ std::string as_string () const override
{
return path.as_string () + " = " + lit.as_string ();
}
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
- virtual bool check_cfg_predicate (const Session &session) const OVERRIDE;
- // TODO: return true if "ident" is defined and value of it is "lit", return
- // false otherwise
+ bool check_cfg_predicate (const Session &session) const override;
+ /* TODO: return true if "ident" is defined and value of it is "lit", return
+ * false otherwise */
protected:
// Use covariance to implement clone function as returning this type
- virtual MetaItemPathLit *clone_meta_item_inner_impl () const OVERRIDE
+ MetaItemPathLit *clone_meta_item_inner_impl () const override
{
return new MetaItemPathLit (*this);
}
};
-// AST node for a non-qualified path expression - FIXME: should this be
-// inheritance instead?
-/*class PathExprNonQual : public PathExpr {
- PathInExpression path;
-
- public:
- ::std::string as_string() const {
- return path.as_string();
- }
-
- PathExprNonQual(PathInExpression path, ::std::vector<Attribute>
-outer_attribs) : PathExpr(::std::move(outer_attribs)), path(::std::move(path))
-{}
-
- protected:
- // Use covariance to implement clone function as returning this object
-rather than base virtual PathExprNonQual* clone_expr_impl() const OVERRIDE {
- return new PathExprNonQual(*this);
- }
-
- // Use covariance to implement clone function as returning this object
-rather than base virtual PathExprNonQual* clone_expr_without_block_impl() const
-OVERRIDE { return new PathExprNonQual(*this);
- }
-};*/
-// converted to inheritance
-
-// AST node for a qualified path expression - FIXME: should this be inheritance
-// instead?
-/*class PathExprQual : public PathExpr {
- QualifiedPathInExpression path;
-
- public:
- ::std::string as_string() const {
- return path.as_string();
- }
-
- PathExprQual(QualifiedPathInExpression path, ::std::vector<Attribute>
-outer_attribs) : PathExpr(::std::move(outer_attribs)), path(::std::move(path))
-{}
-
- protected:
- // Use covariance to implement clone function as returning this object
-rather than base virtual PathExprQual* clone_expr_impl() const OVERRIDE { return
-new PathExprQual(*this);
- }
-
- // Use covariance to implement clone function as returning this object
-rather than base virtual PathExprQual* clone_expr_without_block_impl() const
-OVERRIDE { return new PathExprQual(*this);
- }
-};*/
-// replaced with inheritance
-
-// Represents an expression using unary or binary operators as AST node. Can be
-// overloaded.
+/* Represents an expression using unary or binary operators as AST node. Can be
+ * overloaded. */
class OperatorExpr : public ExprWithoutBlock
{
// TODO: create binary and unary operator subclasses?
@@ -300,37 +195,22 @@ public:
Location locus;
protected:
- // Variable must be protected to allow derived classes to use it as a first
- // class citizen Expr* main_or_left_expr;
- ::std::unique_ptr<Expr> main_or_left_expr;
+ /* Variable must be protected to allow derived classes to use it as a first
+ * class citizen */
+ std::unique_ptr<Expr> main_or_left_expr;
// Constructor (only for initialisation of expr purposes)
- OperatorExpr (::std::unique_ptr<Expr> main_or_left_expr,
- ::std::vector<Attribute> outer_attribs, Location locus)
- : ExprWithoutBlock (::std::move (outer_attribs)), locus (locus),
- main_or_left_expr (::std::move (main_or_left_expr))
+ OperatorExpr (std::unique_ptr<Expr> main_or_left_expr,
+ std::vector<Attribute> outer_attribs, Location locus)
+ : ExprWithoutBlock (std::move (outer_attribs)), locus (locus),
+ main_or_left_expr (std::move (main_or_left_expr))
{}
// Copy constructor (only for initialisation of expr purposes)
OperatorExpr (OperatorExpr const &other)
- : ExprWithoutBlock (other),
- locus (
- other
- .locus) /*, main_or_left_expr(other.main_or_left_expr->clone_expr())*/
- {
- // DEBUG: moved main_or_left_expr into body - move back later
-
- if (other.main_or_left_expr == NULL)
- {
- fprintf (stderr, "other operator expr's main_or_left_expr is null!\n");
- }
-
- fprintf (stderr, "called operator expr copy constructor - about to clone "
- "main_or_left_expr\n");
- main_or_left_expr = other.main_or_left_expr->clone_expr ();
- fprintf (stderr, "successfully cloned main_or_left_expr\n");
- // this occurred successfully, so something else must be the issue
- }
+ : ExprWithoutBlock (other), locus (other.locus),
+ main_or_left_expr (other.main_or_left_expr->clone_expr ())
+ {}
// Overload assignment operator to deep copy expr
OperatorExpr &operator= (OperatorExpr const &other)
@@ -348,58 +228,42 @@ protected:
OperatorExpr &operator= (OperatorExpr &&other) = default;
public:
- /*virtual ~OperatorExpr() {
- delete main_or_left_expr;
- }*/
-
Location get_locus () const { return locus; }
-
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
+ Location get_locus_slow () const override { return get_locus (); }
};
-// Unary prefix & or &mut (or && and &&mut) borrow operator. Cannot be
-// overloaded.
+/* Unary prefix & or &mut (or && and &&mut) borrow operator. Cannot be
+ * overloaded. */
class BorrowExpr : public OperatorExpr
{
bool is_mut;
bool double_borrow;
public:
- ::std::string as_string () const;
+ std::string as_string () const override;
- BorrowExpr (::std::unique_ptr<Expr> borrow_lvalue, bool is_mut_borrow,
- bool is_double_borrow, ::std::vector<Attribute> outer_attribs,
+ BorrowExpr (std::unique_ptr<Expr> borrow_lvalue, bool is_mut_borrow,
+ bool is_double_borrow, std::vector<Attribute> outer_attribs,
Location locus)
- : OperatorExpr (::std::move (borrow_lvalue), ::std::move (outer_attribs),
+ : OperatorExpr (std::move (borrow_lvalue), std::move (outer_attribs),
locus),
is_mut (is_mut_borrow), double_borrow (is_double_borrow)
{}
- // Copy constructor - define here if required
-
- // Destructor - define here if required
-
- // Overload assignment operator here if required
-
- // Move semantics here if required
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual BorrowExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ BorrowExpr *clone_expr_impl () const override
{
return new BorrowExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual BorrowExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ BorrowExpr *clone_expr_without_block_impl () const override
{
- // DEBUG
- fprintf (stderr, "called clone_expr_without_block_impl() on borrowexpr\n");
-
return new BorrowExpr (*this);
}
};
@@ -408,41 +272,28 @@ protected:
class DereferenceExpr : public OperatorExpr
{
public:
- ::std::string as_string () const;
+ std::string as_string () const override;
// Constructor calls OperatorExpr's protected constructor
- DereferenceExpr (::std::unique_ptr<Expr> deref_lvalue,
- ::std::vector<Attribute> outer_attribs, Location locus)
- : OperatorExpr (::std::move (deref_lvalue), ::std::move (outer_attribs),
- locus)
+ DereferenceExpr (std::unique_ptr<Expr> deref_lvalue,
+ std::vector<Attribute> outer_attribs, Location locus)
+ : OperatorExpr (std::move (deref_lvalue), std::move (outer_attribs), locus)
{}
- // Copy constructor - define here if required
-
- // Destructor - define here if required
-
- // Overload assignment operator here if required
-
- // Move semantics here if required
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual DereferenceExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ DereferenceExpr *clone_expr_impl () const override
{
return new DereferenceExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual DereferenceExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ DereferenceExpr *clone_expr_without_block_impl () const override
{
- // DEBUG
- fprintf (stderr,
- "called clone_expr_without_block_impl() on dereferenceexpr\n");
-
return new DereferenceExpr (*this);
}
};
@@ -451,42 +302,29 @@ protected:
class ErrorPropagationExpr : public OperatorExpr
{
public:
- ::std::string as_string () const;
+ std::string as_string () const override;
// Constructor calls OperatorExpr's protected constructor
- ErrorPropagationExpr (::std::unique_ptr<Expr> potential_error_value,
- ::std::vector<Attribute> outer_attribs, Location locus)
- : OperatorExpr (::std::move (potential_error_value),
- ::std::move (outer_attribs), locus)
+ ErrorPropagationExpr (std::unique_ptr<Expr> potential_error_value,
+ std::vector<Attribute> outer_attribs, Location locus)
+ : OperatorExpr (std::move (potential_error_value),
+ std::move (outer_attribs), locus)
{}
- // Copy constructor - define here if required
-
- // Destructor - define here if required
-
- // Overload assignment operator here if required
-
- // Move semantics here if required
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual ErrorPropagationExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ ErrorPropagationExpr *clone_expr_impl () const override
{
return new ErrorPropagationExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual ErrorPropagationExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ ErrorPropagationExpr *clone_expr_without_block_impl () const override
{
- // DEBUG
- fprintf (
- stderr,
- "called clone_expr_without_block_impl() on errorpropagationexpr\n");
-
return new ErrorPropagationExpr (*this);
}
};
@@ -501,53 +339,40 @@ public:
NOT
};
- // Note: overload negation via std::ops::Neg and not via std::ops::Not
- // Negation only works for signed integer and floating-point types, NOT only
- // works for boolean and integer types (via bitwise NOT)
+ /* Note: overload negation via std::ops::Neg and not via std::ops::Not
+ * Negation only works for signed integer and floating-point types, NOT only
+ * works for boolean and integer types (via bitwise NOT) */
NegationType negation_type;
public:
- ::std::string as_string () const;
+ std::string as_string () const override;
- inline NegationType get_negation_type () const { return negation_type; }
+ NegationType get_negation_type () const { return negation_type; }
// Constructor calls OperatorExpr's protected constructor
- NegationExpr (::std::unique_ptr<Expr> negated_value,
- NegationType negation_kind,
- ::std::vector<Attribute> outer_attribs, Location locus)
- : OperatorExpr (::std::move (negated_value), ::std::move (outer_attribs),
+ NegationExpr (std::unique_ptr<Expr> negated_value, NegationType negation_kind,
+ std::vector<Attribute> outer_attribs, Location locus)
+ : OperatorExpr (std::move (negated_value), std::move (outer_attribs),
locus),
negation_type (negation_kind)
{}
- // Copy constructor - define here if required
-
- // Destructor - define here if required
-
- // Overload assignment operator here if required
-
- // Move semantics here if required
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
Expr *get_expr () { return main_or_left_expr.get (); }
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual NegationExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ NegationExpr *clone_expr_impl () const override
{
return new NegationExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual NegationExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ NegationExpr *clone_expr_without_block_impl () const override
{
- // DEBUG
- fprintf (stderr,
- "called clone_expr_without_block_impl() on negationexpr\n");
-
return new NegationExpr (*this);
}
};
@@ -573,25 +398,19 @@ public:
// Note: overloading trait specified in comments
ExprType expr_type;
- // Expr* right_expr;
- ::std::unique_ptr<Expr> right_expr;
+ std::unique_ptr<Expr> right_expr;
public:
- /*~ArithmeticOrLogicalExpr() {
- delete right_expr;
- }*/
-
- ::std::string as_string () const;
+ std::string as_string () const override;
- inline ExprType get_expr_type () const { return expr_type; }
+ ExprType get_expr_type () const { return expr_type; }
// Constructor calls OperatorExpr's protected constructor
- ArithmeticOrLogicalExpr (::std::unique_ptr<Expr> left_value,
- ::std::unique_ptr<Expr> right_value,
+ ArithmeticOrLogicalExpr (std::unique_ptr<Expr> left_value,
+ std::unique_ptr<Expr> right_value,
ExprType expr_kind, Location locus)
- : OperatorExpr (::std::move (left_value), ::std::vector<Attribute> (),
- locus),
- expr_type (expr_kind), right_expr (::std::move (right_value))
+ : OperatorExpr (std::move (left_value), std::vector<Attribute> (), locus),
+ expr_type (expr_kind), right_expr (std::move (right_value))
{}
// outer attributes not allowed
@@ -601,8 +420,6 @@ public:
right_expr (other.right_expr->clone_expr ())
{}
- // Destructor - define here if required
-
// Overload assignment operator
ArithmeticOrLogicalExpr &operator= (ArithmeticOrLogicalExpr const &other)
{
@@ -619,32 +436,25 @@ public:
ArithmeticOrLogicalExpr &operator= (ArithmeticOrLogicalExpr &&other)
= default;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
Expr *get_lhs () { return main_or_left_expr.get (); }
void visit_lhs (ASTVisitor &vis) { main_or_left_expr->accept_vis (vis); }
-
void visit_rhs (ASTVisitor &vis) { right_expr->accept_vis (vis); }
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual ArithmeticOrLogicalExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ ArithmeticOrLogicalExpr *clone_expr_impl () const override
{
return new ArithmeticOrLogicalExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual ArithmeticOrLogicalExpr *
- clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ ArithmeticOrLogicalExpr *clone_expr_without_block_impl () const override
{
- // DEBUG
- fprintf (
- stderr,
- "called clone_expr_without_block_impl() on arithmeticorlogicalexpr\n");
-
return new ArithmeticOrLogicalExpr (*this);
}
};
@@ -666,25 +476,19 @@ public:
// Note: overloading trait specified in comments
ExprType expr_type;
- // Expr* right_expr;
- ::std::unique_ptr<Expr> right_expr;
+ std::unique_ptr<Expr> right_expr;
public:
- /*~ComparisonExpr() {
- delete right_expr;
- }*/
-
- ::std::string as_string () const;
+ std::string as_string () const override;
- inline ExprType get_expr_type () const { return expr_type; }
+ ExprType get_expr_type () const { return expr_type; }
// Constructor requires pointers for polymorphism
- ComparisonExpr (::std::unique_ptr<Expr> left_value,
- ::std::unique_ptr<Expr> right_value, ExprType comparison_kind,
+ ComparisonExpr (std::unique_ptr<Expr> left_value,
+ std::unique_ptr<Expr> right_value, ExprType comparison_kind,
Location locus)
- : OperatorExpr (::std::move (left_value), ::std::vector<Attribute> (),
- locus),
- expr_type (comparison_kind), right_expr (::std::move (right_value))
+ : OperatorExpr (std::move (left_value), std::vector<Attribute> (), locus),
+ expr_type (comparison_kind), right_expr (std::move (right_value))
{}
// outer attributes not allowed
@@ -694,8 +498,6 @@ public:
right_expr (other.right_expr->clone_expr ())
{}
- // Destructor - define here if required
-
// Overload assignment operator to deep copy
ComparisonExpr &operator= (ComparisonExpr const &other)
{
@@ -712,28 +514,24 @@ public:
ComparisonExpr (ComparisonExpr &&other) = default;
ComparisonExpr &operator= (ComparisonExpr &&other) = default;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
Expr *get_lhs () { return main_or_left_expr.get (); }
- // TODO: implement via a function call to std::cmp::PartialEq::eq(&op1, &op2)
- // maybe?
+ /* TODO: implement via a function call to std::cmp::PartialEq::eq(&op1, &op2)
+ * maybe? */
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual ComparisonExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ ComparisonExpr *clone_expr_impl () const override
{
return new ComparisonExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual ComparisonExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ ComparisonExpr *clone_expr_without_block_impl () const override
{
- // DEBUG
- fprintf (stderr,
- "called clone_expr_without_block_impl() on comparisonexpr\n");
-
return new ComparisonExpr (*this);
}
};
@@ -750,21 +548,16 @@ public:
ExprType expr_type;
- // Expr* right_expr;
- ::std::unique_ptr<Expr> right_expr;
+ std::unique_ptr<Expr> right_expr;
public:
- /*~LazyBooleanExpr() {
- delete right_expr;
- }*/
-
// Constructor calls OperatorExpr's protected constructor
- LazyBooleanExpr (::std::unique_ptr<Expr> left_bool_expr,
- ::std::unique_ptr<Expr> right_bool_expr, ExprType expr_kind,
+ LazyBooleanExpr (std::unique_ptr<Expr> left_bool_expr,
+ std::unique_ptr<Expr> right_bool_expr, ExprType expr_kind,
Location locus)
- : OperatorExpr (::std::move (left_bool_expr), ::std::vector<Attribute> (),
+ : OperatorExpr (std::move (left_bool_expr), std::vector<Attribute> (),
locus),
- expr_type (expr_kind), right_expr (::std::move (right_bool_expr))
+ expr_type (expr_kind), right_expr (std::move (right_bool_expr))
{}
// outer attributes not allowed
@@ -774,8 +567,6 @@ public:
right_expr (other.right_expr->clone_expr ())
{}
- // Destructor - define here if required
-
// Overload assignment operator to deep copy
LazyBooleanExpr &operator= (LazyBooleanExpr const &other)
{
@@ -791,30 +582,26 @@ public:
LazyBooleanExpr (LazyBooleanExpr &&other) = default;
LazyBooleanExpr &operator= (LazyBooleanExpr &&other) = default;
- ::std::string as_string () const;
+ std::string as_string () const override;
- inline ExprType get_expr_type () const { return expr_type; }
+ ExprType get_expr_type () const { return expr_type; }
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
Expr *get_lhs () { return main_or_left_expr.get (); }
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual LazyBooleanExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ LazyBooleanExpr *clone_expr_impl () const override
{
return new LazyBooleanExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual LazyBooleanExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ LazyBooleanExpr *clone_expr_without_block_impl () const override
{
- // DEBUG
- fprintf (stderr,
- "called clone_expr_without_block_impl() on lazybooleanexpr\n");
-
return new LazyBooleanExpr (*this);
}
};
@@ -822,19 +609,17 @@ protected:
// Binary infix "as" cast expression.
class TypeCastExpr : public OperatorExpr
{
- // TypeNoBounds type_to_convert_to;
- ::std::unique_ptr<TypeNoBounds> type_to_convert_to;
+ std::unique_ptr<TypeNoBounds> type_to_convert_to;
// Note: only certain type casts allowed, outlined in reference
public:
- ::std::string as_string () const;
+ std::string as_string () const override;
// Constructor requires calling protected constructor of OperatorExpr
- TypeCastExpr (::std::unique_ptr<Expr> expr_to_cast,
- ::std::unique_ptr<TypeNoBounds> type_to_cast_to, Location locus)
- : OperatorExpr (::std::move (expr_to_cast), ::std::vector<Attribute> (),
- locus),
- type_to_convert_to (::std::move (type_to_cast_to))
+ TypeCastExpr (std::unique_ptr<Expr> expr_to_cast,
+ std::unique_ptr<TypeNoBounds> type_to_cast_to, Location locus)
+ : OperatorExpr (std::move (expr_to_cast), std::vector<Attribute> (), locus),
+ type_to_convert_to (std::move (type_to_cast_to))
{}
// outer attributes not allowed
@@ -844,8 +629,6 @@ public:
type_to_convert_to (other.type_to_convert_to->clone_type_no_bounds ())
{}
- // Destructor - define here if required
-
// Overload assignment operator to deep copy
TypeCastExpr &operator= (TypeCastExpr const &other)
{
@@ -860,24 +643,20 @@ public:
TypeCastExpr (TypeCastExpr &&other) = default;
TypeCastExpr &operator= (TypeCastExpr &&other) = default;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual TypeCastExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ TypeCastExpr *clone_expr_impl () const override
{
return new TypeCastExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual TypeCastExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ TypeCastExpr *clone_expr_without_block_impl () const override
{
- // DEBUG
- fprintf (stderr,
- "called clone_expr_without_block_impl() on typecastexpr\n");
-
return new TypeCastExpr (*this);
}
};
@@ -886,48 +665,23 @@ protected:
class AssignmentExpr : public OperatorExpr
{
public:
- // Expr* right_expr;
- ::std::unique_ptr<Expr> right_expr;
+ std::unique_ptr<Expr> right_expr;
- /*~AssignmentExpr() {
- delete right_expr;
- }*/
-
- ::std::string as_string () const;
+ std::string as_string () const override;
// Call OperatorExpr constructor to initialise left_expr
- AssignmentExpr (::std::unique_ptr<Expr> value_to_assign_to,
- ::std::unique_ptr<Expr> value_to_assign, Location locus)
- : OperatorExpr (::std::move (value_to_assign_to),
- ::std::vector<Attribute> (), locus),
- right_expr (::std::move (value_to_assign))
+ AssignmentExpr (std::unique_ptr<Expr> value_to_assign_to,
+ std::unique_ptr<Expr> value_to_assign, Location locus)
+ : OperatorExpr (std::move (value_to_assign_to), std::vector<Attribute> (),
+ locus),
+ right_expr (std::move (value_to_assign))
{}
// outer attributes not allowed
// Call OperatorExpr constructor in copy constructor, as well as clone
AssignmentExpr (AssignmentExpr const &other)
- : OperatorExpr (other) /*, right_expr(other.right_expr->clone_expr())*/
- {
- // DEBUG: moved cloning right expr into body
- fprintf (stderr, "assignment expr copy constructor successfully cloned "
- "base operator expr\n");
- if (other.right_expr == NULL)
- {
- fprintf (stderr, "other expr's right expr (in assignment) is null!!!");
- }
- fprintf (stderr, "test other's right expr as string: %s\n",
- other.right_expr->as_string ().c_str ());
- // apparently, despite not being null, cloning still fails
- right_expr = other.right_expr->clone_expr ();
- fprintf (
- stderr,
- "assignment expr copy constructor successfully cloned right expr\n");
-
- // DEBUG
- fprintf (stderr, "assignment expr copy constructor called successfully\n");
- }
-
- // Destructor - define here if required
+ : OperatorExpr (other), right_expr (other.right_expr->clone_expr ())
+ {}
// Overload assignment operator to clone unique_ptr right_expr
AssignmentExpr &operator= (AssignmentExpr const &other)
@@ -944,36 +698,31 @@ public:
AssignmentExpr (AssignmentExpr &&other) = default;
AssignmentExpr &operator= (AssignmentExpr &&other) = default;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
void visit_lhs (ASTVisitor &vis) { main_or_left_expr->accept_vis (vis); }
-
void visit_rhs (ASTVisitor &vis) { right_expr->accept_vis (vis); }
Expr *get_lhs () { return main_or_left_expr.get (); }
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual AssignmentExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ AssignmentExpr *clone_expr_impl () const override
{
return new AssignmentExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual AssignmentExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ AssignmentExpr *clone_expr_without_block_impl () const override
{
- // DEBUG
- fprintf (stderr,
- "called clone_expr_without_block_impl() on assignmentexpr\n");
-
return new AssignmentExpr (*this);
}
};
-// Binary infix compound assignment (arithmetic or logic then assignment)
-// expressions.
+/* Binary infix compound assignment (arithmetic or logic then assignment)
+ * expressions. */
class CompoundAssignmentExpr : public OperatorExpr
{
public:
@@ -994,26 +743,20 @@ public:
private:
// Note: overloading trait specified in comments
ExprType expr_type;
-
- // Expr* right_expr;
- ::std::unique_ptr<Expr> right_expr;
+ std::unique_ptr<Expr> right_expr;
public:
- /*~CompoundAssignmentExpr() {
- delete right_expr;
- }*/
+ std::string as_string () const override;
- ::std::string as_string () const;
-
- inline ExprType get_expr_type () const { return expr_type; }
+ ExprType get_expr_type () const { return expr_type; }
// Use pointers in constructor to enable polymorphism
- CompoundAssignmentExpr (::std::unique_ptr<Expr> value_to_assign_to,
- ::std::unique_ptr<Expr> value_to_assign,
+ CompoundAssignmentExpr (std::unique_ptr<Expr> value_to_assign_to,
+ std::unique_ptr<Expr> value_to_assign,
ExprType expr_kind, Location locus)
- : OperatorExpr (::std::move (value_to_assign_to),
- ::std::vector<Attribute> (), locus),
- expr_type (expr_kind), right_expr (::std::move (value_to_assign))
+ : OperatorExpr (std::move (value_to_assign_to), std::vector<Attribute> (),
+ locus),
+ expr_type (expr_kind), right_expr (std::move (value_to_assign))
{}
// outer attributes not allowed
@@ -1023,8 +766,6 @@ public:
right_expr (other.right_expr->clone_expr ())
{}
- // Destructor - define here if required
-
// Overload assignment operator to clone
CompoundAssignmentExpr &operator= (CompoundAssignmentExpr const &other)
{
@@ -1041,26 +782,20 @@ public:
CompoundAssignmentExpr (CompoundAssignmentExpr &&other) = default;
CompoundAssignmentExpr &operator= (CompoundAssignmentExpr &&other) = default;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual CompoundAssignmentExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ CompoundAssignmentExpr *clone_expr_impl () const override
{
return new CompoundAssignmentExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual CompoundAssignmentExpr *
- clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ CompoundAssignmentExpr *clone_expr_without_block_impl () const override
{
- // DEBUG
- fprintf (
- stderr,
- "called clone_expr_without_block_impl() on compoundassignmentexpr\n");
-
return new CompoundAssignmentExpr (*this);
}
};
@@ -1068,30 +803,22 @@ protected:
// Expression in parentheses (i.e. like literally just any 3 + (2 * 6))
class GroupedExpr : public ExprWithoutBlock
{
- ::std::vector<Attribute> inner_attrs;
- // Expr* expr_in_parens;
- ::std::unique_ptr<Expr> expr_in_parens;
+ std::vector<Attribute> inner_attrs;
+ std::unique_ptr<Expr> expr_in_parens;
Location locus;
public:
- /*~GroupedExpr() {
- delete expr_in_parens;
- }*/
+ std::string as_string () const override;
- ::std::string as_string () const;
-
- inline ::std::vector<Attribute> get_inner_attrs () const
- {
- return inner_attrs;
- }
+ std::vector<Attribute> get_inner_attrs () const { return inner_attrs; }
- GroupedExpr (::std::unique_ptr<Expr> parenthesised_expr,
- ::std::vector<Attribute> inner_attribs,
- ::std::vector<Attribute> outer_attribs, Location locus)
- : ExprWithoutBlock (::std::move (outer_attribs)),
- inner_attrs (::std::move (inner_attribs)),
- expr_in_parens (::std::move (parenthesised_expr)), locus (locus)
+ GroupedExpr (std::unique_ptr<Expr> parenthesised_expr,
+ std::vector<Attribute> inner_attribs,
+ std::vector<Attribute> outer_attribs, Location locus)
+ : ExprWithoutBlock (std::move (outer_attribs)),
+ inner_attrs (std::move (inner_attribs)),
+ expr_in_parens (std::move (parenthesised_expr)), locus (locus)
{}
// Copy constructor includes clone for expr_in_parens
@@ -1100,8 +827,6 @@ public:
expr_in_parens (other.expr_in_parens->clone_expr ()), locus (other.locus)
{}
- // Destructor - define here if required
-
// Overloaded assignment operator to clone expr_in_parens
GroupedExpr &operator= (GroupedExpr const &other)
{
@@ -1119,22 +844,21 @@ public:
GroupedExpr &operator= (GroupedExpr &&other) = default;
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual GroupedExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ GroupedExpr *clone_expr_impl () const override
{
return new GroupedExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual GroupedExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ GroupedExpr *clone_expr_without_block_impl () const override
{
return new GroupedExpr (*this);
}
@@ -1148,12 +872,12 @@ public:
virtual ~ArrayElems () {}
// Unique pointer custom clone ArrayElems function
- ::std::unique_ptr<ArrayElems> clone_array_elems () const
+ std::unique_ptr<ArrayElems> clone_array_elems () const
{
- return ::std::unique_ptr<ArrayElems> (clone_array_elems_impl ());
+ return std::unique_ptr<ArrayElems> (clone_array_elems_impl ());
}
- virtual ::std::string as_string () const = 0;
+ virtual std::string as_string () const = 0;
virtual void accept_vis (ASTVisitor &vis) = 0;
@@ -1165,44 +889,29 @@ protected:
// Value array elements
class ArrayElemsValues : public ArrayElems
{
- //::std::vector<Expr> values;
- ::std::vector< ::std::unique_ptr<Expr> > values;
+ std::vector<std::unique_ptr<Expr>> values;
// TODO: should this store location data?
public:
- /*inline ::std::vector< ::std::unique_ptr<Expr> > get_values() const {
- return values;
- }*/
-
- ArrayElemsValues (::std::vector< ::std::unique_ptr<Expr> > elems)
- : values (::std::move (elems))
+ ArrayElemsValues (std::vector<std::unique_ptr<Expr>> elems)
+ : values (std::move (elems))
{}
// copy constructor with vector clone
ArrayElemsValues (ArrayElemsValues const &other)
{
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
values.reserve (other.values.size ());
-
for (const auto &e : other.values)
- {
- values.push_back (e->clone_expr ());
- }
+ values.push_back (e->clone_expr ());
}
// overloaded assignment operator with vector clone
ArrayElemsValues &operator= (ArrayElemsValues const &other)
{
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
values.reserve (other.values.size ());
-
for (const auto &e : other.values)
- {
- values.push_back (e->clone_expr ());
- }
+ values.push_back (e->clone_expr ());
return *this;
}
@@ -1211,12 +920,12 @@ public:
ArrayElemsValues (ArrayElemsValues &&other) = default;
ArrayElemsValues &operator= (ArrayElemsValues &&other) = default;
- ::std::string as_string () const;
+ std::string as_string () const override;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- virtual ArrayElemsValues *clone_array_elems_impl () const OVERRIDE
+ ArrayElemsValues *clone_array_elems_impl () const override
{
return new ArrayElemsValues (*this);
}
@@ -1225,24 +934,17 @@ protected:
// Copied array element and number of copies
class ArrayElemsCopied : public ArrayElems
{
- // Expr* elem_to_copy;
- ::std::unique_ptr<Expr> elem_to_copy;
- // Expr* num_copies;
- ::std::unique_ptr<Expr> num_copies;
+ std::unique_ptr<Expr> elem_to_copy;
+ std::unique_ptr<Expr> num_copies;
// TODO: should this store location data?
public:
- /*~ArrayElemsCopied() {
- delete num_copies;
- delete elem_to_copy;
- }*/
-
// 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)),
- num_copies (::std::move (copy_amount))
+ ArrayElemsCopied (std::unique_ptr<Expr> copied_elem,
+ std::unique_ptr<Expr> copy_amount)
+ : elem_to_copy (std::move (copied_elem)),
+ num_copies (std::move (copy_amount))
{}
// Copy constructor required due to unique_ptr - uses custom clone
@@ -1251,8 +953,6 @@ public:
num_copies (other.num_copies->clone_expr ())
{}
- // Destructor - define here if required
-
// Overloaded assignment operator for deep copying
ArrayElemsCopied &operator= (ArrayElemsCopied const &other)
{
@@ -1266,12 +966,12 @@ public:
ArrayElemsCopied (ArrayElemsCopied &&other) = default;
ArrayElemsCopied &operator= (ArrayElemsCopied &&other) = default;
- ::std::string as_string () const;
+ std::string as_string () const override;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- virtual ArrayElemsCopied *clone_array_elems_impl () const OVERRIDE
+ ArrayElemsCopied *clone_array_elems_impl () const override
{
return new ArrayElemsCopied (*this);
}
@@ -1280,30 +980,26 @@ protected:
// Array definition-ish expression
class ArrayExpr : public ExprWithoutBlock
{
- ::std::vector<Attribute> inner_attrs;
- // ArrayElems internal_elements;
- ::std::unique_ptr<ArrayElems> internal_elements;
+ std::vector<Attribute> inner_attrs;
+ std::unique_ptr<ArrayElems> internal_elements;
Location locus;
public:
- ::std::string as_string () const;
+ std::string as_string () const override;
- inline ::std::vector<Attribute> get_inner_attrs () const
- {
- return inner_attrs;
- }
+ std::vector<Attribute> get_inner_attrs () const { return inner_attrs; }
// Returns whether array expr has array elems or if it is just empty.
- inline bool has_array_elems () const { return internal_elements != NULL; }
+ bool has_array_elems () const { return internal_elements != nullptr; }
// Constructor requires ArrayElems pointer
- ArrayExpr (::std::unique_ptr<ArrayElems> array_elems,
- ::std::vector<Attribute> inner_attribs,
- ::std::vector<Attribute> outer_attribs, Location locus)
- : ExprWithoutBlock (::std::move (outer_attribs)),
- inner_attrs (::std::move (inner_attribs)),
- internal_elements (::std::move (array_elems)), locus (locus)
+ ArrayExpr (std::unique_ptr<ArrayElems> array_elems,
+ std::vector<Attribute> inner_attribs,
+ std::vector<Attribute> outer_attribs, Location locus)
+ : ExprWithoutBlock (std::move (outer_attribs)),
+ inner_attrs (std::move (inner_attribs)),
+ internal_elements (std::move (array_elems)), locus (locus)
{}
// Copy constructor requires cloning ArrayElems for polymorphism to hold
@@ -1312,22 +1008,16 @@ public:
locus (other.locus)
{
if (other.has_array_elems ())
- {
- internal_elements = other.internal_elements->clone_array_elems ();
- }
+ internal_elements = other.internal_elements->clone_array_elems ();
}
- // Destructor - define here if required
-
// Overload assignment operator to clone internal_elements
ArrayExpr &operator= (ArrayExpr const &other)
{
ExprWithoutBlock::operator= (other);
inner_attrs = other.inner_attrs;
if (other.has_array_elems ())
- {
- internal_elements = other.internal_elements->clone_array_elems ();
- }
+ internal_elements = other.internal_elements->clone_array_elems ();
locus = other.locus;
// outer_attrs = other.outer_attrs;
@@ -1339,55 +1029,44 @@ public:
ArrayExpr &operator= (ArrayExpr &&other) = default;
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual ArrayExpr *clone_expr_impl () const OVERRIDE
- {
- return new ArrayExpr (*this);
- }
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ ArrayExpr *clone_expr_impl () const override { return new ArrayExpr (*this); }
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual ArrayExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ ArrayExpr *clone_expr_without_block_impl () const override
{
return new ArrayExpr (*this);
}
};
// Aka IndexExpr (also applies to slices)
-// Apparently a[b] is equivalent to *std::ops::Index::index(&a, b) or
-// *std::ops::Index::index_mut(&mut a, b)
-// Also apparently deref operations on a will be repeatedly applied to find an
-// implementation
+/* Apparently a[b] is equivalent to *std::ops::Index::index(&a, b) or
+ * *std::ops::Index::index_mut(&mut a, b) */
+/* Also apparently deref operations on a will be repeatedly applied to find an
+ * implementation */
class ArrayIndexExpr : public ExprWithoutBlock
{
- /*Expr* array_expr;
- Expr* index_expr;*/
- ::std::unique_ptr<Expr> array_expr;
- ::std::unique_ptr<Expr> index_expr;
+ std::unique_ptr<Expr> array_expr;
+ std::unique_ptr<Expr> index_expr;
Location locus;
public:
- /*~ArrayIndexExpr() {
- delete index_expr;
- delete array_expr;
- }*/
-
- ::std::string as_string () const;
-
- ArrayIndexExpr (::std::unique_ptr<Expr> array_expr,
- ::std::unique_ptr<Expr> array_index_expr,
- ::std::vector<Attribute> outer_attribs, Location locus)
- : ExprWithoutBlock (::std::move (outer_attribs)),
- array_expr (::std::move (array_expr)),
- index_expr (::std::move (array_index_expr)), locus (locus)
+ std::string as_string () const override;
+
+ ArrayIndexExpr (std::unique_ptr<Expr> array_expr,
+ std::unique_ptr<Expr> array_index_expr,
+ std::vector<Attribute> outer_attribs, Location locus)
+ : ExprWithoutBlock (std::move (outer_attribs)),
+ array_expr (std::move (array_expr)),
+ index_expr (std::move (array_index_expr)), locus (locus)
{}
// Copy constructor requires special cloning due to unique_ptr
@@ -1396,8 +1075,6 @@ public:
index_expr (other.index_expr->clone_expr ()), locus (other.locus)
{}
- // Destructor - define here if required
-
// Overload assignment operator to clone unique_ptrs
ArrayIndexExpr &operator= (ArrayIndexExpr const &other)
{
@@ -1415,22 +1092,21 @@ public:
ArrayIndexExpr &operator= (ArrayIndexExpr &&other) = default;
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual ArrayIndexExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ ArrayIndexExpr *clone_expr_impl () const override
{
return new ArrayIndexExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual ArrayIndexExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ ArrayIndexExpr *clone_expr_without_block_impl () const override
{
return new ArrayIndexExpr (*this);
}
@@ -1439,28 +1115,24 @@ protected:
// AST representation of a tuple
class TupleExpr : public ExprWithoutBlock
{
- ::std::vector<Attribute> inner_attrs;
+ std::vector<Attribute> inner_attrs;
- //::std::vector<Expr> tuple_elems;
- ::std::vector< ::std::unique_ptr<Expr> > tuple_elems;
+ std::vector<std::unique_ptr<Expr>> tuple_elems;
// replaces (inlined version of) TupleElements
Location locus;
public:
- ::std::string as_string () const;
+ std::string as_string () const override;
- inline ::std::vector<Attribute> get_inner_attrs () const
- {
- return inner_attrs;
- }
+ std::vector<Attribute> get_inner_attrs () const { return inner_attrs; }
- TupleExpr (::std::vector< ::std::unique_ptr<Expr> > tuple_elements,
- ::std::vector<Attribute> inner_attribs,
- ::std::vector<Attribute> outer_attribs, Location locus)
- : ExprWithoutBlock (::std::move (outer_attribs)),
- inner_attrs (::std::move (inner_attribs)),
- tuple_elems (::std::move (tuple_elements)), locus (locus)
+ TupleExpr (std::vector<std::unique_ptr<Expr>> tuple_elements,
+ std::vector<Attribute> inner_attribs,
+ std::vector<Attribute> outer_attribs, Location locus)
+ : ExprWithoutBlock (std::move (outer_attribs)),
+ inner_attrs (std::move (inner_attribs)),
+ tuple_elems (std::move (tuple_elements)), locus (locus)
{}
// copy constructor with vector clone
@@ -1468,14 +1140,9 @@ public:
: ExprWithoutBlock (other), inner_attrs (other.inner_attrs),
locus (other.locus)
{
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
tuple_elems.reserve (other.tuple_elems.size ());
-
for (const auto &e : other.tuple_elems)
- {
- tuple_elems.push_back (e->clone_expr ());
- }
+ tuple_elems.push_back (e->clone_expr ());
}
// overloaded assignment operator to vector clone
@@ -1485,14 +1152,9 @@ public:
inner_attrs = other.inner_attrs;
locus = other.locus;
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
tuple_elems.reserve (other.tuple_elems.size ());
-
for (const auto &e : other.tuple_elems)
- {
- tuple_elems.push_back (e->clone_expr ());
- }
+ tuple_elems.push_back (e->clone_expr ());
return *this;
}
@@ -1501,26 +1163,22 @@ public:
TupleExpr (TupleExpr &&other) = default;
TupleExpr &operator= (TupleExpr &&other) = default;
- // Note: syntactically, can disambiguate single-element tuple from parens with
- // comma, i.e. (0,) rather than (0)
+ /* Note: syntactically, can disambiguate single-element tuple from parens with
+ * comma, i.e. (0,) rather than (0) */
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual TupleExpr *clone_expr_impl () const OVERRIDE
- {
- return new TupleExpr (*this);
- }
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ TupleExpr *clone_expr_impl () const override { return new TupleExpr (*this); }
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual TupleExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ TupleExpr *clone_expr_without_block_impl () const override
{
return new TupleExpr (*this);
}
@@ -1530,8 +1188,7 @@ protected:
// AST representation of a tuple indexing expression
class TupleIndexExpr : public ExprWithoutBlock
{
- // Expr* tuple_expr;
- ::std::unique_ptr<Expr> tuple_expr;
+ std::unique_ptr<Expr> tuple_expr;
// TupleIndex is a decimal int literal with no underscores or suffix
TupleIndex tuple_index;
@@ -1540,18 +1197,14 @@ class TupleIndexExpr : public ExprWithoutBlock
// i.e. pair.0
public:
- /*~TupleIndexExpr() {
- delete tuple_expr;
- }*/
+ std::string as_string () const override;
- ::std::string as_string () const;
+ TupleIndex get_tuple_index () const { return tuple_index; }
- inline TupleIndex get_tuple_index () const { return tuple_index; }
-
- TupleIndexExpr (::std::unique_ptr<Expr> tuple_expr, TupleIndex index,
- ::std::vector<Attribute> outer_attribs, Location locus)
- : ExprWithoutBlock (::std::move (outer_attribs)),
- tuple_expr (::std::move (tuple_expr)), tuple_index (index), locus (locus)
+ TupleIndexExpr (std::unique_ptr<Expr> tuple_expr, TupleIndex index,
+ std::vector<Attribute> outer_attribs, Location locus)
+ : ExprWithoutBlock (std::move (outer_attribs)),
+ tuple_expr (std::move (tuple_expr)), tuple_index (index), locus (locus)
{}
// Copy constructor requires a clone for tuple_expr
@@ -1560,8 +1213,6 @@ public:
tuple_index (other.tuple_index), locus (other.locus)
{}
- // Destructor - define here if required
-
// Overload assignment operator in order to clone
TupleIndexExpr &operator= (TupleIndexExpr const &other)
{
@@ -1579,22 +1230,21 @@ public:
TupleIndexExpr &operator= (TupleIndexExpr &&other) = default;
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual TupleIndexExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ TupleIndexExpr *clone_expr_impl () const override
{
return new TupleIndexExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual TupleIndexExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ TupleIndexExpr *clone_expr_without_block_impl () const override
{
return new TupleIndexExpr (*this);
}
@@ -1608,90 +1258,77 @@ class StructExpr : public ExprWithoutBlock
protected:
// Protected constructor to allow initialising struct_name
StructExpr (PathInExpression struct_path,
- ::std::vector<Attribute> outer_attribs)
- : ExprWithoutBlock (::std::move (outer_attribs)),
- struct_name (::std::move (struct_path))
+ std::vector<Attribute> outer_attribs)
+ : ExprWithoutBlock (std::move (outer_attribs)),
+ struct_name (std::move (struct_path))
{}
public:
- inline const PathInExpression &get_struct_name () const
- {
- return struct_name;
- }
+ const PathInExpression &get_struct_name () const { return struct_name; }
- virtual ::std::string as_string () const;
+ std::string as_string () const override;
};
// Actual AST node of the struct creator (with no fields). Not abstract!
class StructExprStruct : public StructExpr
{
- ::std::vector<Attribute> inner_attrs;
+ std::vector<Attribute> inner_attrs;
Location locus;
public:
- ::std::string as_string () const;
+ std::string as_string () const override;
- inline ::std::vector<Attribute> get_inner_attrs () const
- {
- return inner_attrs;
- }
+ std::vector<Attribute> get_inner_attrs () const { return inner_attrs; }
// Constructor has to call protected constructor of base class
StructExprStruct (PathInExpression struct_path,
- ::std::vector<Attribute> inner_attribs,
- ::std::vector<Attribute> outer_attribs, Location locus)
- : StructExpr (::std::move (struct_path), ::std::move (outer_attribs)),
- inner_attrs (::std::move (inner_attribs)), locus (locus)
+ std::vector<Attribute> inner_attribs,
+ std::vector<Attribute> outer_attribs, Location locus)
+ : StructExpr (std::move (struct_path), std::move (outer_attribs)),
+ inner_attrs (std::move (inner_attribs)), locus (locus)
{}
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual StructExprStruct *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ StructExprStruct *clone_expr_impl () const override
{
return new StructExprStruct (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual StructExprStruct *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ StructExprStruct *clone_expr_without_block_impl () const override
{
return new StructExprStruct (*this);
}
};
-// AST node representing expression used to fill a struct's fields from another
-// struct
+/* AST node representing expression used to fill a struct's fields from another
+ * struct */
struct StructBase
{
public:
- // Expr* base_struct;
- ::std::unique_ptr<Expr> base_struct;
+ std::unique_ptr<Expr> base_struct;
// TODO: should this store location data?
- StructBase (::std::unique_ptr<Expr> base_struct_ptr)
- : base_struct (::std::move (base_struct_ptr))
+ StructBase (std::unique_ptr<Expr> base_struct_ptr)
+ : base_struct (std::move (base_struct_ptr))
{}
// Copy constructor requires clone
StructBase (StructBase const &other)
{
- // HACK: gets around base_struct pointer being null (e.g. if no struct base
- // exists)
- if (other.base_struct != NULL)
- {
- other.base_struct->clone_expr ();
- }
-
- // DEBUG:
- fprintf (stderr, "struct base copy constructor called successfully\n");
+ /* HACK: gets around base_struct pointer being null (e.g. if no struct base
+ * exists) */
+ if (other.base_struct != nullptr)
+ other.base_struct->clone_expr ();
}
// Destructor
@@ -1709,33 +1346,29 @@ public:
StructBase (StructBase &&other) = default;
StructBase &operator= (StructBase &&other) = default;
- /*~StructBase() {
- delete base_struct;
- }*/
-
// Returns a null expr-ed StructBase - error state
- static StructBase error () { return StructBase (NULL); }
+ static StructBase error () { return StructBase (nullptr); }
// Returns whether StructBase is in error state
- inline bool is_invalid () const { return base_struct == NULL; }
+ bool is_invalid () const { return base_struct == nullptr; }
- ::std::string as_string () const;
+ std::string as_string () const;
};
-// Base AST node for a single struct expression field (in struct instance
-// creation) - abstract
+/* Base AST node for a single struct expression field (in struct instance
+ * creation) - abstract */
class StructExprField
{
public:
virtual ~StructExprField () {}
// Unique pointer custom clone function
- ::std::unique_ptr<StructExprField> clone_struct_expr_field () const
+ std::unique_ptr<StructExprField> clone_struct_expr_field () const
{
- return ::std::unique_ptr<StructExprField> (clone_struct_expr_field_impl ());
+ return std::unique_ptr<StructExprField> (clone_struct_expr_field_impl ());
}
- virtual ::std::string as_string () const = 0;
+ virtual std::string as_string () const = 0;
virtual void accept_vis (ASTVisitor &vis) = 0;
@@ -1753,34 +1386,32 @@ public:
// TODO: should this store location data?
StructExprFieldIdentifier (Identifier field_identifier)
- : field_name (::std::move (field_identifier))
+ : field_name (std::move (field_identifier))
{}
- ::std::string as_string () const { return field_name; }
+ std::string as_string () const override { return field_name; }
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this rather than
- // base
- virtual StructExprFieldIdentifier *
- clone_struct_expr_field_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ StructExprFieldIdentifier *clone_struct_expr_field_impl () const override
{
return new StructExprFieldIdentifier (*this);
}
};
-// Base AST node for a single struct expression field with an assigned value -
-// abstract
+/* Base AST node for a single struct expression field with an assigned value -
+ * abstract */
class StructExprFieldWithVal : public StructExprField
{
public:
- // Expr* value;
- ::std::unique_ptr<Expr> value;
+ std::unique_ptr<Expr> value;
protected:
- StructExprFieldWithVal (::std::unique_ptr<Expr> field_value)
- : value (::std::move (field_value))
+ StructExprFieldWithVal (std::unique_ptr<Expr> field_value)
+ : value (std::move (field_value))
{}
// Copy constructor requires clone
@@ -1788,8 +1419,6 @@ protected:
: value (other.value->clone_expr ())
{}
- // Destructor - define here if required
-
// Overload assignment operator to clone unique_ptr
StructExprFieldWithVal &operator= (StructExprFieldWithVal const &other)
{
@@ -1803,11 +1432,7 @@ protected:
StructExprFieldWithVal &operator= (StructExprFieldWithVal &&other) = default;
public:
- /*~StructExprFieldWithVal() {
- delete value;
- }*/
-
- ::std::string as_string () const;
+ std::string as_string () const override;
};
// Identifier and value variant of StructExprField AST node
@@ -1819,23 +1444,19 @@ public:
// TODO: should this store location data?
StructExprFieldIdentifierValue (Identifier field_identifier,
- ::std::unique_ptr<Expr> field_value)
- : StructExprFieldWithVal (::std::move (field_value)),
- field_name (::std::move (field_identifier))
+ std::unique_ptr<Expr> field_value)
+ : StructExprFieldWithVal (std::move (field_value)),
+ field_name (std::move (field_identifier))
{}
- // copy constructor, destructor, and overloaded assignment operator should
- // carry through
-
- ::std::string as_string () const;
+ std::string as_string () const override;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this rather than
- // base
- virtual StructExprFieldIdentifierValue *
- clone_struct_expr_field_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ StructExprFieldIdentifierValue *clone_struct_expr_field_impl () const override
{
return new StructExprFieldIdentifierValue (*this);
}
@@ -1850,22 +1471,18 @@ public:
// TODO: should this store location data?
StructExprFieldIndexValue (TupleIndex tuple_index,
- ::std::unique_ptr<Expr> field_value)
- : StructExprFieldWithVal (::std::move (field_value)), index (tuple_index)
+ std::unique_ptr<Expr> field_value)
+ : StructExprFieldWithVal (std::move (field_value)), index (tuple_index)
{}
- // copy constructor, destructor, and overloaded assignment operator should
- // carry through
+ std::string as_string () const override;
- ::std::string as_string () const;
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this rather than
- // base
- virtual StructExprFieldIndexValue *
- clone_struct_expr_field_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ StructExprFieldIndexValue *clone_struct_expr_field_impl () const override
{
return new StructExprFieldIndexValue (*this);
}
@@ -1875,17 +1492,17 @@ protected:
class StructExprStructFields : public StructExprStruct
{
public:
- //::std::vector<StructExprField> fields;
- ::std::vector< ::std::unique_ptr<StructExprField> > fields;
+ // std::vector<StructExprField> fields;
+ std::vector<std::unique_ptr<StructExprField>> fields;
// bool has_struct_base;
StructBase struct_base;
- ::std::string as_string () const;
+ std::string as_string () const override;
- inline bool has_struct_base () const { return !struct_base.is_invalid (); }
+ bool has_struct_base () const { return !struct_base.is_invalid (); }
- /*inline ::std::vector< ::std::unique_ptr<StructExprField> > get_fields()
+ /*inline std::vector<std::unique_ptr<StructExprField>> get_fields()
const { return fields;
}*/
@@ -1896,44 +1513,22 @@ public:
// Constructor for StructExprStructFields when no struct base is used
StructExprStructFields (
PathInExpression struct_path,
- ::std::vector< ::std::unique_ptr<StructExprField> > expr_fields,
- Location locus, StructBase base_struct = StructBase::error (),
- ::std::vector<Attribute> inner_attribs = ::std::vector<Attribute> (),
- ::std::vector<Attribute> outer_attribs = ::std::vector<Attribute> ())
- : StructExprStruct (::std::move (struct_path), ::std::move (inner_attribs),
- ::std::move (outer_attribs), locus),
- fields (::std::move (expr_fields)),
- struct_base (::std::move (base_struct))
+ std::vector<std::unique_ptr<StructExprField>> expr_fields, Location locus,
+ StructBase base_struct = StructBase::error (),
+ std::vector<Attribute> inner_attribs = std::vector<Attribute> (),
+ std::vector<Attribute> outer_attribs = std::vector<Attribute> ())
+ : StructExprStruct (std::move (struct_path), std::move (inner_attribs),
+ std::move (outer_attribs), locus),
+ fields (std::move (expr_fields)), struct_base (std::move (base_struct))
{}
// copy constructor with vector clone
StructExprStructFields (StructExprStructFields const &other)
: StructExprStruct (other), struct_base (other.struct_base)
{
- // DEBUG
- fprintf (stderr,
- "got past the initialisation list part of copy constructor\n");
-
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
fields.reserve (other.fields.size ());
-
- // DEBUG
- fprintf (stderr, "reserved space in fields\n");
-
for (const auto &e : other.fields)
- {
- // DEBUG
- fprintf (stderr, "about to clone a field\n");
-
- fields.push_back (e->clone_struct_expr_field ());
-
- // DEBUG
- fprintf (stderr, "cloned a field successfully\n");
- }
-
- // DEBUG
- fprintf (stderr, "finished cloning fields\n");
+ fields.push_back (e->clone_struct_expr_field ());
}
// overloaded assignment operator with vector clone
@@ -1942,14 +1537,9 @@ public:
StructExprStruct::operator= (other);
struct_base = other.struct_base;
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
fields.reserve (other.fields.size ());
-
for (const auto &e : other.fields)
- {
- fields.push_back (e->clone_struct_expr_field ());
- }
+ fields.push_back (e->clone_struct_expr_field ());
return *this;
}
@@ -1958,44 +1548,20 @@ public:
StructExprStructFields (StructExprStructFields &&other) = default;
StructExprStructFields &operator= (StructExprStructFields &&other) = default;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual StructExprStructFields *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ StructExprStructFields *clone_expr_impl () const override
{
return new StructExprStructFields (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual StructExprStructFields *
- clone_expr_without_block_impl () const OVERRIDE
- {
- // DEBUG
- fprintf (
- stderr,
- "called structexprstructfields clone expr without block impl - about "
- "to return new structexprstructfields\n");
-
- // DEBUG - test creation of a base from this
- fprintf (stderr, "about to try to create and allocate structexprstruct \n");
- StructExprStruct *test_DELETE = new StructExprStruct (*this);
- delete test_DELETE;
- fprintf (stderr, "managed to create and allocate structexprstruct \n");
- // very weird: can create and allocate structexpstruct but not
- // structexprstructfields
-
- // DEBUG - test creation of a non-returned class from this
- fprintf (stderr, "about to try to create and allocate "
- "structexprstructfields (but not return)\n");
- StructExprStructFields *test_DELETE2 = new StructExprStructFields (*this);
- delete test_DELETE2;
- fprintf (stderr, "managed to create and allocate structexprstructfields "
- "(if not returned) \n");
- // ok this fails. fair enough.
-
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ StructExprStructFields *clone_expr_without_block_impl () const override
+ {
return new StructExprStructFields (*this);
}
};
@@ -2006,33 +1572,33 @@ class StructExprStructBase : public StructExprStruct
StructBase struct_base;
public:
- ::std::string as_string () const;
+ std::string as_string () const override;
/*inline StructBase get_struct_base() const {
return struct_base;
}*/
StructExprStructBase (PathInExpression struct_path, StructBase base_struct,
- ::std::vector<Attribute> inner_attribs,
- ::std::vector<Attribute> outer_attribs, Location locus)
- : StructExprStruct (::std::move (struct_path), ::std::move (inner_attribs),
- ::std::move (outer_attribs), locus),
- struct_base (::std::move (base_struct))
+ std::vector<Attribute> inner_attribs,
+ std::vector<Attribute> outer_attribs, Location locus)
+ : StructExprStruct (std::move (struct_path), std::move (inner_attribs),
+ std::move (outer_attribs), locus),
+ struct_base (std::move (base_struct))
{}
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual StructExprStructBase *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ StructExprStructBase *clone_expr_impl () const override
{
return new StructExprStructBase (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual StructExprStructBase *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ StructExprStructBase *clone_expr_without_block_impl () const override
{
return new StructExprStructBase (*this);
}
@@ -2041,45 +1607,36 @@ protected:
// AST node of a tuple struct creator
class StructExprTuple : public StructExpr
{
- ::std::vector<Attribute> inner_attrs;
- //::std::vector<Expr> exprs;
- ::std::vector< ::std::unique_ptr<Expr> > exprs;
+ std::vector<Attribute> inner_attrs;
+ std::vector<std::unique_ptr<Expr>> exprs;
Location locus;
public:
- ::std::string as_string () const;
+ std::string as_string () const override;
- inline const ::std::vector<Attribute> &get_inner_attrs () const
- {
- return inner_attrs;
- }
+ const std::vector<Attribute> &get_inner_attrs () const { return inner_attrs; }
- /*inline ::std::vector< ::std::unique_ptr<Expr> > get_exprs() const {
+ /*inline std::vector<std::unique_ptr<Expr>> get_exprs() const {
return exprs;
}*/
StructExprTuple (PathInExpression struct_path,
- ::std::vector< ::std::unique_ptr<Expr> > tuple_exprs,
- ::std::vector<Attribute> inner_attribs,
- ::std::vector<Attribute> outer_attribs, Location locus)
- : StructExpr (::std::move (struct_path), ::std::move (outer_attribs)),
- inner_attrs (::std::move (inner_attribs)),
- exprs (::std::move (tuple_exprs)), locus (locus)
+ std::vector<std::unique_ptr<Expr>> tuple_exprs,
+ std::vector<Attribute> inner_attribs,
+ std::vector<Attribute> outer_attribs, Location locus)
+ : StructExpr (std::move (struct_path), std::move (outer_attribs)),
+ inner_attrs (std::move (inner_attribs)), exprs (std::move (tuple_exprs)),
+ locus (locus)
{}
// copy constructor with vector clone
StructExprTuple (StructExprTuple const &other)
: StructExpr (other), inner_attrs (other.inner_attrs), locus (other.locus)
{
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
exprs.reserve (other.exprs.size ());
-
for (const auto &e : other.exprs)
- {
- exprs.push_back (e->clone_expr ());
- }
+ exprs.push_back (e->clone_expr ());
}
// overloaded assignment operator with vector clone
@@ -2089,14 +1646,9 @@ public:
inner_attrs = other.inner_attrs;
locus = other.locus;
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
exprs.reserve (other.exprs.size ());
-
for (const auto &e : other.exprs)
- {
- exprs.push_back (e->clone_expr ());
- }
+ exprs.push_back (e->clone_expr ());
return *this;
}
@@ -2106,22 +1658,21 @@ public:
StructExprTuple &operator= (StructExprTuple &&other) = default;
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual StructExprTuple *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ StructExprTuple *clone_expr_impl () const override
{
return new StructExprTuple (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual StructExprTuple *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ StructExprTuple *clone_expr_without_block_impl () const override
{
return new StructExprTuple (*this);
}
@@ -2133,35 +1684,34 @@ class StructExprUnit : public StructExpr
Location locus;
public:
- ::std::string as_string () const
+ std::string as_string () const override
{
return get_struct_name ().as_string ();
// return struct_name.as_string();
}
StructExprUnit (PathInExpression struct_path,
- ::std::vector<Attribute> outer_attribs, Location locus)
- : StructExpr (::std::move (struct_path), ::std::move (outer_attribs)),
+ std::vector<Attribute> outer_attribs, Location locus)
+ : StructExpr (std::move (struct_path), std::move (outer_attribs)),
locus (locus)
{}
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual StructExprUnit *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ StructExprUnit *clone_expr_impl () const override
{
return new StructExprUnit (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual StructExprUnit *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ StructExprUnit *clone_expr_without_block_impl () const override
{
return new StructExprUnit (*this);
}
@@ -2176,30 +1726,27 @@ class EnumVariantExpr : public ExprWithoutBlock
protected:
// Protected constructor for initialising enum_variant_path
EnumVariantExpr (PathInExpression path_to_enum_variant,
- ::std::vector<Attribute> outer_attribs)
- : ExprWithoutBlock (::std::move (outer_attribs)),
- enum_variant_path (::std::move (path_to_enum_variant))
+ std::vector<Attribute> outer_attribs)
+ : ExprWithoutBlock (std::move (outer_attribs)),
+ enum_variant_path (std::move (path_to_enum_variant))
{}
public:
// TODO: maybe remove and have string version gotten here directly
- inline PathInExpression get_enum_variant_path () const
- {
- return enum_variant_path;
- }
+ PathInExpression get_enum_variant_path () const { return enum_variant_path; }
};
-// Base AST node for a single enum expression field (in enum instance creation)
-// - abstract
+/* 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
+ std::unique_ptr<EnumExprField> clone_enum_expr_field () const
{
- return ::std::unique_ptr<EnumExprField> (clone_enum_expr_field_impl ());
+ return std::unique_ptr<EnumExprField> (clone_enum_expr_field_impl ());
}
virtual void accept_vis (ASTVisitor &vis) = 0;
@@ -2218,32 +1765,31 @@ class EnumExprFieldIdentifier : public EnumExprField
public:
EnumExprFieldIdentifier (Identifier field_identifier)
- : field_name (::std::move (field_identifier))
+ : field_name (std::move (field_identifier))
{}
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual EnumExprFieldIdentifier *clone_enum_expr_field_impl () const OVERRIDE
+ /* 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
+/* Base AST node for a single enum expression field with an assigned value -
+ * abstract */
class EnumExprFieldWithVal : public EnumExprField
{
- // Expr* value;
- ::std::unique_ptr<Expr> value;
+ std::unique_ptr<Expr> value;
// TODO: should this store location data?
protected:
- EnumExprFieldWithVal (::std::unique_ptr<Expr> field_value)
- : value (::std::move (field_value))
+ EnumExprFieldWithVal (std::unique_ptr<Expr> field_value)
+ : value (std::move (field_value))
{}
// Copy constructor must clone unique_ptr value
@@ -2251,8 +1797,6 @@ protected:
: value (other.value->clone_expr ())
{}
- // Destructor - define here if required
-
// Overload assignment operator to clone
EnumExprFieldWithVal &operator= (EnumExprFieldWithVal const &other)
{
@@ -2275,21 +1819,20 @@ class EnumExprFieldIdentifierValue : public EnumExprFieldWithVal
public:
EnumExprFieldIdentifierValue (Identifier field_name,
- ::std::unique_ptr<Expr> field_value)
- : EnumExprFieldWithVal (::std::move (field_value)),
- field_name (::std::move (field_name))
+ std::unique_ptr<Expr> field_value)
+ : EnumExprFieldWithVal (std::move (field_value)),
+ field_name (std::move (field_name))
{}
// copy constructor, destructor, and assignment operator should not need
// defining
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual EnumExprFieldIdentifierValue *
- clone_enum_expr_field_impl () const OVERRIDE
+ /* 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);
}
@@ -2305,19 +1848,16 @@ class EnumExprFieldIndexValue : public EnumExprFieldWithVal
public:
EnumExprFieldIndexValue (TupleIndex field_index,
- ::std::unique_ptr<Expr> field_value)
- : EnumExprFieldWithVal (::std::move (field_value)), index (field_index)
+ std::unique_ptr<Expr> field_value)
+ : EnumExprFieldWithVal (std::move (field_value)), index (field_index)
{}
- // copy constructor, destructor, and assignment operator should not need
- // defining
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual EnumExprFieldIndexValue *clone_enum_expr_field_impl () const OVERRIDE
+ /* 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);
}
@@ -2326,39 +1866,33 @@ protected:
// Struct-like syntax enum variant instance creation AST node
class EnumExprStruct : public EnumVariantExpr
{
- //::std::vector<EnumExprField> fields;
- ::std::vector< ::std::unique_ptr<EnumExprField> > fields;
+ // std::vector<EnumExprField> fields;
+ std::vector<std::unique_ptr<EnumExprField>> fields;
Location locus;
public:
- ::std::string as_string () const;
+ std::string as_string () const override;
- /*inline ::std::vector< ::std::unique_ptr<EnumExprField> > get_fields() const
+ /*inline std::vector<std::unique_ptr<EnumExprField>> get_fields() const
{ return fields;
}*/
- 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)
+ 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)
{
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
fields.reserve (other.fields.size ());
-
for (const auto &e : other.fields)
- {
- fields.push_back (e->clone_enum_expr_field ());
- }
+ fields.push_back (e->clone_enum_expr_field ());
}
// overloaded assignment operator with vector clone
@@ -2367,14 +1901,9 @@ public:
EnumVariantExpr::operator= (other);
locus = other.locus;
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
fields.reserve (other.fields.size ());
-
for (const auto &e : other.fields)
- {
- fields.push_back (e->clone_enum_expr_field ());
- }
+ fields.push_back (e->clone_enum_expr_field ());
return *this;
}
@@ -2384,22 +1913,21 @@ public:
EnumExprStruct &operator= (EnumExprStruct &&other) = default;
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual EnumExprStruct *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ EnumExprStruct *clone_expr_impl () const override
{
return new EnumExprStruct (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual EnumExprStruct *clone_expr_without_block_impl () const OVERRIDE
+ /* 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);
}
@@ -2408,38 +1936,32 @@ protected:
// Tuple-like syntax enum variant instance creation AST node
class EnumExprTuple : public EnumVariantExpr
{
- //::std::vector<Expr> values;
- ::std::vector< ::std::unique_ptr<Expr> > values;
+ std::vector<std::unique_ptr<Expr>> values;
Location locus;
public:
- ::std::string as_string () const;
+ std::string as_string () const override;
- /*inline ::std::vector< ::std::unique_ptr<Expr> > get_values() const {
+ /*inline std::vector<std::unique_ptr<Expr>> get_values() const {
return values;
}*/
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)
+ 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)
{
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
values.reserve (other.values.size ());
-
for (const auto &e : other.values)
- {
- values.push_back (e->clone_expr ());
- }
+ values.push_back (e->clone_expr ());
}
// overloaded assignment operator with vector clone
@@ -2448,14 +1970,9 @@ public:
EnumVariantExpr::operator= (other);
locus = other.locus;
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
values.reserve (other.values.size ());
-
for (const auto &e : other.values)
- {
- values.push_back (e->clone_expr ());
- }
+ values.push_back (e->clone_expr ());
return *this;
}
@@ -2465,22 +1982,21 @@ public:
EnumExprTuple &operator= (EnumExprTuple &&other) = default;
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual EnumExprTuple *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ EnumExprTuple *clone_expr_impl () const override
{
return new EnumExprTuple (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual EnumExprTuple *clone_expr_without_block_impl () const OVERRIDE
+ /* 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);
}
@@ -2492,73 +2008,67 @@ class EnumExprFieldless : public EnumVariantExpr
Location locus;
public:
- ::std::string as_string () const
+ 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)),
+ std::vector<Attribute> outer_attribs, Location locus)
+ : EnumVariantExpr (std::move (enum_variant_path),
+ std::move (outer_attribs)),
locus (locus)
{}
- // copy constructor, destructor, and assignment operator should not need
- // defining
-
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual EnumExprFieldless *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ EnumExprFieldless *clone_expr_impl () const override
{
return new EnumExprFieldless (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual EnumExprFieldless *clone_expr_without_block_impl () const OVERRIDE
+ /* 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;
+
// Function call expression AST node
class CallExpr : public ExprWithoutBlock
{
public:
- // Expr* function;
- ::std::unique_ptr<Expr> function;
- //::std::vector<Expr> params; // inlined form of CallParams
- ::std::vector< ::std::unique_ptr<Expr> > params;
+ std::unique_ptr<Expr> function;
+ // inlined form of CallParams
+ std::vector<std::unique_ptr<Expr>> params;
Location locus;
Function *fndeclRef;
- /*~CallExpr() {
- delete function;
- }*/
-
- ::std::string as_string () const;
+ std::string as_string () const override;
- /*inline ::std::vector< ::std::unique_ptr<Expr> > get_params() const {
+ /*inline std::vector<std::unique_ptr<Expr>> get_params() const {
return params;
}*/
- CallExpr (::std::unique_ptr<Expr> function_expr,
- ::std::vector< ::std::unique_ptr<Expr> > function_params,
- ::std::vector<Attribute> outer_attribs, Location locus)
- : ExprWithoutBlock (::std::move (outer_attribs)),
- function (::std::move (function_expr)),
- params (::std::move (function_params)), locus (locus)
+ CallExpr (std::unique_ptr<Expr> function_expr,
+ std::vector<std::unique_ptr<Expr>> function_params,
+ std::vector<Attribute> outer_attribs, Location locus)
+ : ExprWithoutBlock (std::move (outer_attribs)),
+ function (std::move (function_expr)),
+ params (std::move (function_params)), locus (locus)
{}
// copy constructor requires clone
@@ -2566,18 +2076,11 @@ public:
: ExprWithoutBlock (other), function (other.function->clone_expr ()),
locus (other.locus)
/*, params(other.params),*/ {
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
params.reserve (other.params.size ());
-
for (const auto &e : other.params)
- {
- params.push_back (e->clone_expr ());
- }
+ params.push_back (e->clone_expr ());
}
- // Destructor - define here if required
-
// Overload assignment operator to clone
CallExpr &operator= (CallExpr const &other)
{
@@ -2587,14 +2090,9 @@ public:
// params = other.params;
// outer_attrs = other.outer_attrs;
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
params.reserve (other.params.size ());
-
for (const auto &e : other.params)
- {
- params.push_back (e->clone_expr ());
- }
+ params.push_back (e->clone_expr ());
return *this;
}
@@ -2604,25 +2102,21 @@ public:
CallExpr &operator= (CallExpr &&other) = default;
// Returns whether function call has parameters.
- inline bool has_params () const { return !params.empty (); }
+ bool has_params () const { return !params.empty (); }
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual CallExpr *clone_expr_impl () const OVERRIDE
- {
- return new CallExpr (*this);
- }
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ CallExpr *clone_expr_impl () const override { return new CallExpr (*this); }
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual CallExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ CallExpr *clone_expr_without_block_impl () const override
{
return new CallExpr (*this);
}
@@ -2631,33 +2125,28 @@ protected:
// Method call expression AST node
class MethodCallExpr : public ExprWithoutBlock
{
- // Expr* receiver;
- ::std::unique_ptr<Expr> receiver;
+ std::unique_ptr<Expr> receiver;
PathExprSegment method_name;
- //::std::vector<Expr> params; // inlined form of CallParams
- ::std::vector< ::std::unique_ptr<Expr> > params;
+ // inlined form of CallParams
+ std::vector<std::unique_ptr<Expr>> params;
Location locus;
public:
- /*~MethodCallExpr() {
- delete receiver;
- }*/
-
- ::std::string as_string () const;
+ std::string as_string () const override;
- /*inline ::std::vector< ::std::unique_ptr<Expr> > get_params() const {
+ /*inline std::vector<std::unique_ptr<Expr>> get_params() const {
return params;
}*/
- MethodCallExpr (::std::unique_ptr<Expr> call_receiver,
+ MethodCallExpr (std::unique_ptr<Expr> call_receiver,
PathExprSegment method_path,
- ::std::vector< ::std::unique_ptr<Expr> > method_params,
- ::std::vector<Attribute> outer_attribs, Location locus)
- : ExprWithoutBlock (::std::move (outer_attribs)),
- receiver (::std::move (call_receiver)),
- method_name (::std::move (method_path)),
- params (::std::move (method_params)), locus (locus)
+ std::vector<std::unique_ptr<Expr>> method_params,
+ std::vector<Attribute> outer_attribs, Location locus)
+ : ExprWithoutBlock (std::move (outer_attribs)),
+ receiver (std::move (call_receiver)),
+ method_name (std::move (method_path)), params (std::move (method_params)),
+ locus (locus)
{}
// copy constructor required due to cloning
@@ -2665,18 +2154,11 @@ public:
: ExprWithoutBlock (other), receiver (other.receiver->clone_expr ()),
method_name (other.method_name), locus (other.locus)
/*, params(other.params),*/ {
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
params.reserve (other.params.size ());
-
for (const auto &e : other.params)
- {
- params.push_back (e->clone_expr ());
- }
+ params.push_back (e->clone_expr ());
}
- // Destructor - define here if required
-
// Overload assignment operator to clone receiver object
MethodCallExpr &operator= (MethodCallExpr const &other)
{
@@ -2687,14 +2169,9 @@ public:
// params = other.params;
// outer_attrs = other.outer_attrs;
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
params.reserve (other.params.size ());
-
for (const auto &e : other.params)
- {
- params.push_back (e->clone_expr ());
- }
+ params.push_back (e->clone_expr ());
return *this;
}
@@ -2704,22 +2181,21 @@ public:
MethodCallExpr &operator= (MethodCallExpr &&other) = default;
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual MethodCallExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ MethodCallExpr *clone_expr_impl () const override
{
return new MethodCallExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual MethodCallExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ MethodCallExpr *clone_expr_without_block_impl () const override
{
return new MethodCallExpr (*this);
}
@@ -2729,25 +2205,20 @@ protected:
// Struct or union field access expression AST node
class FieldAccessExpr : public ExprWithoutBlock
{
- // Expr* receiver;
- ::std::unique_ptr<Expr> receiver;
+ std::unique_ptr<Expr> receiver;
Identifier field;
Location locus;
public:
- /*~FieldAccessExpr() {
- delete receiver;
- }*/
+ std::string as_string () const override;
- ::std::string as_string () const;
-
- FieldAccessExpr (::std::unique_ptr<Expr> field_access_receiver,
- Identifier field_name,
- ::std::vector<Attribute> outer_attribs, Location locus)
- : ExprWithoutBlock (::std::move (outer_attribs)),
- receiver (::std::move (field_access_receiver)),
- field (::std::move (field_name)), locus (locus)
+ FieldAccessExpr (std::unique_ptr<Expr> field_access_receiver,
+ Identifier field_name, std::vector<Attribute> outer_attribs,
+ Location locus)
+ : ExprWithoutBlock (std::move (outer_attribs)),
+ receiver (std::move (field_access_receiver)),
+ field (std::move (field_name)), locus (locus)
{}
// Copy constructor required due to unique_ptr cloning
@@ -2756,8 +2227,6 @@ public:
field (other.field), locus (other.locus)
{}
- // Destructor - define here if required
-
// Overload assignment operator to clone unique_ptr
FieldAccessExpr &operator= (FieldAccessExpr const &other)
{
@@ -2775,22 +2244,21 @@ public:
FieldAccessExpr &operator= (FieldAccessExpr &&other) = default;
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual FieldAccessExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ FieldAccessExpr *clone_expr_impl () const override
{
return new FieldAccessExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual FieldAccessExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ FieldAccessExpr *clone_expr_without_block_impl () const override
{
return new FieldAccessExpr (*this);
}
@@ -2800,23 +2268,21 @@ protected:
struct ClosureParam
{
private:
- // Pattern pattern;
- ::std::unique_ptr<Pattern> pattern;
+ std::unique_ptr<Pattern> pattern;
// bool has_type_given;
- // Type type;
- ::std::unique_ptr<Type> type;
+ std::unique_ptr<Type> type;
// TODO: should this store location data?
public:
// Returns whether the type of the parameter has been given.
- inline bool has_type_given () const { return type != NULL; }
+ bool has_type_given () const { return type != nullptr; }
// Constructor for closure parameter
- ClosureParam (::std::unique_ptr<Pattern> param_pattern,
- ::std::unique_ptr<Type> param_type = NULL)
- : pattern (::std::move (param_pattern)), type (::std::move (param_type))
+ ClosureParam (std::unique_ptr<Pattern> param_pattern,
+ std::unique_ptr<Type> param_type = nullptr)
+ : pattern (std::move (param_pattern)), type (std::move (param_type))
{}
// Copy constructor required due to cloning as a result of unique_ptrs
@@ -2824,10 +2290,8 @@ public:
: pattern (other.pattern->clone_pattern ())
{
// guard to protect from null pointer dereference
- if (other.type != NULL)
- {
- type = other.type->clone_type ();
- }
+ if (other.type != nullptr)
+ type = other.type->clone_type ();
}
~ClosureParam () = default;
@@ -2846,72 +2310,61 @@ public:
ClosureParam &operator= (ClosureParam &&other) = default;
// Returns whether closure parameter is in an error state.
- inline bool is_error () const { return pattern == NULL; }
+ bool is_error () const { return pattern == nullptr; }
// Creates an error state closure parameter.
- static ClosureParam create_error () { return ClosureParam (NULL); }
+ static ClosureParam create_error () { return ClosureParam (nullptr); }
- ::std::string as_string () const;
+ std::string as_string () const;
};
// Base closure definition expression AST node - abstract
class ClosureExpr : public ExprWithoutBlock
{
bool has_move;
- ::std::vector<ClosureParam> params; // may be empty
- // also note a double pipe "||" can be used for empty params - does not need a
- // space
+ std::vector<ClosureParam> params; // may be empty
+ /* also note a double pipe "||" can be used for empty params - does not need a
+ * space */
Location locus;
protected:
- ClosureExpr (::std::vector<ClosureParam> closure_params, bool has_move,
- ::std::vector<Attribute> outer_attribs, Location locus)
- : ExprWithoutBlock (::std::move (outer_attribs)), has_move (has_move),
- params (::std::move (closure_params)), locus (locus)
+ ClosureExpr (std::vector<ClosureParam> closure_params, bool has_move,
+ std::vector<Attribute> outer_attribs, Location locus)
+ : ExprWithoutBlock (std::move (outer_attribs)), has_move (has_move),
+ params (std::move (closure_params)), locus (locus)
{}
- // Copy constructor, destructor, and assignment operator override should not
- // be needed
public:
- virtual ::std::string as_string () const;
+ std::string as_string () const override;
Location get_locus () const { return locus; }
-
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
+ Location get_locus_slow () const override { return get_locus (); }
};
// Represents a non-type-specified closure expression AST node
class ClosureExprInner : public ClosureExpr
{
- // Expr* closure_inner;
- ::std::unique_ptr<Expr> closure_inner;
+ std::unique_ptr<Expr> closure_inner;
public:
- /*~ClosureExprInner() {
- delete closure_inner;
- }*/
-
- ::std::string as_string () const;
+ std::string as_string () const override;
// Constructor for a ClosureExprInner
- ClosureExprInner (::std::unique_ptr<Expr> closure_inner_expr,
- ::std::vector<ClosureParam> closure_params, Location locus,
+ ClosureExprInner (std::unique_ptr<Expr> closure_inner_expr,
+ std::vector<ClosureParam> closure_params, Location locus,
bool is_move = false,
- ::std::vector<Attribute> outer_attribs
- = ::std::vector<Attribute> ())
- : ClosureExpr (::std::move (closure_params), is_move,
- ::std::move (outer_attribs), locus),
- closure_inner (::std::move (closure_inner_expr))
+ std::vector<Attribute> outer_attribs
+ = std::vector<Attribute> ())
+ : ClosureExpr (std::move (closure_params), is_move,
+ std::move (outer_attribs), locus),
+ closure_inner (std::move (closure_inner_expr))
{}
// Copy constructor must be defined to allow copying via cloning of unique_ptr
ClosureExprInner (ClosureExprInner const &other)
: ClosureExpr (other), closure_inner (other.closure_inner->clone_expr ())
{}
- // TODO: ensure that this actually constructs properly
-
- // Destructor - define here if required
// Overload assignment operator to clone closure_inner
ClosureExprInner &operator= (ClosureExprInner const &other)
@@ -2929,59 +2382,53 @@ public:
ClosureExprInner (ClosureExprInner &&other) = default;
ClosureExprInner &operator= (ClosureExprInner &&other) = default;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual ClosureExprInner *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ ClosureExprInner *clone_expr_impl () const override
{
return new ClosureExprInner (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual ClosureExprInner *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ ClosureExprInner *clone_expr_without_block_impl () const override
{
return new ClosureExprInner (*this);
}
};
-// Forward decl BlockExpr for ClosureExprInnerTyped
-// class BlockExpr;
-
// A block AST node
class BlockExpr : public ExprWithBlock
{
public:
- ::std::vector<Attribute> inner_attrs;
-
- /*bool has_statements;
- Statements statements;*/
+ std::vector<Attribute> inner_attrs;
// bool has_statements;
- ::std::vector< ::std::unique_ptr<Stmt> > statements;
+ std::vector<std::unique_ptr<Stmt>> statements;
// bool has_expr;
- ::std::unique_ptr<ExprWithoutBlock> expr; // inlined from Statements
+ std::unique_ptr<ExprWithoutBlock> expr; // inlined from Statements
Location locus;
- ::std::string as_string () const;
+ std::string as_string () const override;
// Returns whether the block contains statements.
- inline bool has_statements () const { return !statements.empty (); }
+ bool has_statements () const { return !statements.empty (); }
// Returns whether the block contains an expression
- inline bool has_expr () const { return expr != NULL; }
-
- BlockExpr (::std::vector< ::std::unique_ptr<Stmt> > block_statements,
- ::std::unique_ptr<ExprWithoutBlock> block_expr,
- ::std::vector<Attribute> inner_attribs,
- ::std::vector<Attribute> outer_attribs, Location locus)
- : ExprWithBlock (::std::move (outer_attribs)),
- inner_attrs (::std::move (inner_attribs)),
- statements (::std::move (block_statements)),
- expr (::std::move (block_expr)), locus (locus)
+ bool has_expr () const { return expr != nullptr; }
+
+ BlockExpr (std::vector<std::unique_ptr<Stmt>> block_statements,
+ std::unique_ptr<ExprWithoutBlock> block_expr,
+ std::vector<Attribute> inner_attribs,
+ std::vector<Attribute> outer_attribs, Location locus)
+ : ExprWithBlock (std::move (outer_attribs)),
+ inner_attrs (std::move (inner_attribs)),
+ statements (std::move (block_statements)), expr (std::move (block_expr)),
+ locus (locus)
{}
// Copy constructor with clone
@@ -2990,23 +2437,14 @@ public:
inner_attrs (other.inner_attrs), locus (other.locus)
{
// guard to protect from null pointer dereference
- if (other.expr != NULL)
- {
- expr = other.expr->clone_expr_without_block ();
- }
+ if (other.expr != nullptr)
+ expr = other.expr->clone_expr_without_block ();
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
statements.reserve (other.statements.size ());
-
for (const auto &e : other.statements)
- {
- statements.push_back (e->clone_stmt ());
- }
+ statements.push_back (e->clone_stmt ());
}
- // Destructor - define here if required
-
// Overloaded assignment operator to clone pointer
BlockExpr &operator= (BlockExpr const &other)
{
@@ -3017,14 +2455,9 @@ public:
locus = other.locus;
// outer_attrs = other.outer_attrs;
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
statements.reserve (other.statements.size ());
-
for (const auto &e : other.statements)
- {
- statements.push_back (e->clone_stmt ());
- }
+ statements.push_back (e->clone_stmt ());
return *this;
}
@@ -3034,30 +2467,29 @@ public:
BlockExpr &operator= (BlockExpr &&other) = default;
// Unique pointer custom clone function
- ::std::unique_ptr<BlockExpr> clone_block_expr () const
+ std::unique_ptr<BlockExpr> clone_block_expr () const
{
- return ::std::unique_ptr<BlockExpr> (clone_block_expr_impl ());
+ return std::unique_ptr<BlockExpr> (clone_block_expr_impl ());
}
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual BlockExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ BlockExpr *clone_expr_impl () const override
{
- return new BlockExpr (*this);
+ return clone_block_expr_impl ();
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual BlockExpr *clone_expr_with_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ BlockExpr *clone_expr_with_block_impl () const override
{
- return new BlockExpr (*this);
+ return clone_block_expr_impl ();
}
/* This is the base method as not an abstract class - not virtual but could be
@@ -3071,30 +2503,24 @@ protected:
// Represents a type-specified closure expression AST node
class ClosureExprInnerTyped : public ClosureExpr
{
- // Type return_type;
- ::std::unique_ptr<Type> return_type;
- // BlockExpr* expr;
- ::std::unique_ptr<BlockExpr>
+ std::unique_ptr<Type> return_type;
+ std::unique_ptr<BlockExpr>
expr; // only used because may be polymorphic in future
public:
- /*~ClosureExprInnerTyped() {
- delete expr;
- }*/
-
- ::std::string as_string () const;
+ std::string as_string () const override;
// Constructor potentially with a move
- ClosureExprInnerTyped (::std::unique_ptr<Type> closure_return_type,
- ::std::unique_ptr<BlockExpr> closure_expr,
- ::std::vector<ClosureParam> closure_params,
+ ClosureExprInnerTyped (std::unique_ptr<Type> closure_return_type,
+ std::unique_ptr<BlockExpr> closure_expr,
+ std::vector<ClosureParam> closure_params,
Location locus, bool is_move = false,
- ::std::vector<Attribute> outer_attribs
- = ::std::vector<Attribute> ())
- : ClosureExpr (::std::move (closure_params), is_move,
- ::std::move (outer_attribs), locus),
- return_type (::std::move (closure_return_type)),
- expr (::std::move (closure_expr))
+ std::vector<Attribute> outer_attribs
+ = std::vector<Attribute> ())
+ : ClosureExpr (std::move (closure_params), is_move,
+ std::move (outer_attribs), locus),
+ return_type (std::move (closure_return_type)),
+ expr (std::move (closure_expr))
{}
// Copy constructor requires cloning
@@ -3103,8 +2529,6 @@ public:
expr (other.expr->clone_block_expr ())
{}
- // Destructor - define here if required
-
// Overload assignment operator to clone unique_ptrs
ClosureExprInnerTyped &operator= (ClosureExprInnerTyped const &other)
{
@@ -3122,19 +2546,19 @@ public:
ClosureExprInnerTyped (ClosureExprInnerTyped &&other) = default;
ClosureExprInnerTyped &operator= (ClosureExprInnerTyped &&other) = default;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual ClosureExprInnerTyped *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ ClosureExprInnerTyped *clone_expr_impl () const override
{
return new ClosureExprInnerTyped (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual ClosureExprInnerTyped *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ ClosureExprInnerTyped *clone_expr_without_block_impl () const override
{
return new ClosureExprInnerTyped (*this);
}
@@ -3145,43 +2569,38 @@ class ContinueExpr : public ExprWithoutBlock
{
// bool has_label;
Lifetime label;
-
Location locus;
public:
- ::std::string as_string () const;
+ std::string as_string () const override;
// Returns true if the continue expr has a label.
- inline bool has_label () const { return !label.is_error (); }
+ bool has_label () const { return !label.is_error (); }
// Constructor for a ContinueExpr with a label.
ContinueExpr (Location locus, Lifetime label = Lifetime::error (),
- ::std::vector<Attribute> outer_attribs
- = ::std::vector<Attribute> ())
- : ExprWithoutBlock (::std::move (outer_attribs)),
- label (::std::move (label)), locus (locus)
+ std::vector<Attribute> outer_attribs
+ = std::vector<Attribute> ())
+ : ExprWithoutBlock (std::move (outer_attribs)), label (std::move (label)),
+ locus (locus)
{}
- // copy constructor, destructor, and assignment operator should not need
- // defining
-
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual ContinueExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ ContinueExpr *clone_expr_impl () const override
{
return new ContinueExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual ContinueExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ ContinueExpr *clone_expr_without_block_impl () const override
{
return new ContinueExpr (*this);
}
@@ -3195,35 +2614,27 @@ class BreakExpr : public ExprWithoutBlock
Lifetime label;
// bool has_break_expr;
- // Expr* break_expr; // may be uninitialised
- ::std::unique_ptr<Expr> break_expr;
+ std::unique_ptr<Expr> break_expr;
Location locus;
public:
- /*~BreakExpr() {
- if (has_break_expr) {
- delete break_expr;
- }
- }*/
-
- ::std::string as_string () const;
+ std::string as_string () const override;
// Returns whether the break expression has a label or not.
- inline bool has_label () const { return !label.is_error (); }
+ bool has_label () const { return !label.is_error (); }
- // Returns whether the break expression has an expression used in the break or
- // not.
- inline bool has_break_expr () const { return break_expr != NULL; }
+ /* Returns whether the break expression has an expression used in the break or
+ * not. */
+ bool has_break_expr () const { return break_expr != nullptr; }
// Constructor for a break expression
BreakExpr (Location locus, Lifetime break_label = Lifetime::error (),
- ::std::unique_ptr<Expr> expr_in_break = NULL,
- ::std::vector<Attribute> outer_attribs
- = ::std::vector<Attribute> ())
- : ExprWithoutBlock (::std::move (outer_attribs)),
- label (::std::move (break_label)),
- break_expr (::std::move (expr_in_break)), locus (locus)
+ std::unique_ptr<Expr> expr_in_break = nullptr,
+ std::vector<Attribute> outer_attribs = std::vector<Attribute> ())
+ : ExprWithoutBlock (std::move (outer_attribs)),
+ label (std::move (break_label)), break_expr (std::move (expr_in_break)),
+ locus (locus)
{}
// Copy constructor defined to use clone for unique pointer
@@ -3231,14 +2642,10 @@ public:
: ExprWithoutBlock (other), label (other.label), locus (other.locus)
{
// guard to protect from null pointer dereference
- if (other.break_expr != NULL)
- {
- break_expr = other.break_expr->clone_expr ();
- }
+ if (other.break_expr != nullptr)
+ break_expr = other.break_expr->clone_expr ();
}
- // Destructor - define here if required
-
// Overload assignment operator to clone unique pointer
BreakExpr &operator= (BreakExpr const &other)
{
@@ -3256,22 +2663,18 @@ public:
BreakExpr &operator= (BreakExpr &&other) = default;
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual BreakExpr *clone_expr_impl () const OVERRIDE
- {
- return new BreakExpr (*this);
- }
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ BreakExpr *clone_expr_impl () const override { return new BreakExpr (*this); }
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual BreakExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ BreakExpr *clone_expr_without_block_impl () const override
{
return new BreakExpr (*this);
}
@@ -3285,36 +2688,28 @@ class RangeExpr : public ExprWithoutBlock
protected:
// outer attributes not allowed before range expressions
RangeExpr (Location locus)
- : ExprWithoutBlock (::std::vector<Attribute> ()), locus (locus)
+ : ExprWithoutBlock (std::vector<Attribute> ()), locus (locus)
{}
public:
Location get_locus () const { return locus; }
-
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
+ Location get_locus_slow () const override { return get_locus (); }
};
// Range from (inclusive) and to (exclusive) expression AST node object
// aka RangeExpr; constructs a std::ops::Range object
class RangeFromToExpr : public RangeExpr
{
- /*Expr* from;
- Expr* to;*/
- ::std::unique_ptr<Expr> from;
- ::std::unique_ptr<Expr> to;
+ std::unique_ptr<Expr> from;
+ std::unique_ptr<Expr> to;
public:
- /*~RangeFromToExpr() {
- delete from;
- delete to;
- }*/
-
- ::std::string as_string () const;
+ std::string as_string () const override;
- RangeFromToExpr (::std::unique_ptr<Expr> range_from,
- ::std::unique_ptr<Expr> range_to, Location locus)
- : RangeExpr (locus), from (::std::move (range_from)),
- to (::std::move (range_to))
+ RangeFromToExpr (std::unique_ptr<Expr> range_from,
+ std::unique_ptr<Expr> range_to, Location locus)
+ : RangeExpr (locus), from (std::move (range_from)),
+ to (std::move (range_to))
{}
// Copy constructor with cloning
@@ -3323,8 +2718,6 @@ public:
to (other.to->clone_expr ())
{}
- // Destructor - define here if required
-
// Overload assignment operator to clone unique pointers
RangeFromToExpr &operator= (RangeFromToExpr const &other)
{
@@ -3339,19 +2732,19 @@ public:
RangeFromToExpr (RangeFromToExpr &&other) = default;
RangeFromToExpr &operator= (RangeFromToExpr &&other) = default;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual RangeFromToExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ RangeFromToExpr *clone_expr_impl () const override
{
return new RangeFromToExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual RangeFromToExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ RangeFromToExpr *clone_expr_without_block_impl () const override
{
return new RangeFromToExpr (*this);
}
@@ -3361,18 +2754,13 @@ protected:
// constructs a std::ops::RangeFrom object
class RangeFromExpr : public RangeExpr
{
- // Expr* from;
- ::std::unique_ptr<Expr> from;
+ std::unique_ptr<Expr> from;
public:
- /*~RangeFromExpr() {
- delete from;
- }*/
-
- ::std::string as_string () const;
+ std::string as_string () const override;
- RangeFromExpr (::std::unique_ptr<Expr> range_from, Location locus)
- : RangeExpr (locus), from (::std::move (range_from))
+ RangeFromExpr (std::unique_ptr<Expr> range_from, Location locus)
+ : RangeExpr (locus), from (std::move (range_from))
{}
// Copy constructor with clone
@@ -3380,8 +2768,6 @@ public:
: RangeExpr (other), from (other.from->clone_expr ())
{}
- // Destructor - define here if required
-
// Overload assignment operator to clone unique_ptr
RangeFromExpr &operator= (RangeFromExpr const &other)
{
@@ -3395,19 +2781,19 @@ public:
RangeFromExpr (RangeFromExpr &&other) = default;
RangeFromExpr &operator= (RangeFromExpr &&other) = default;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual RangeFromExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ RangeFromExpr *clone_expr_impl () const override
{
return new RangeFromExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual RangeFromExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ RangeFromExpr *clone_expr_without_block_impl () const override
{
return new RangeFromExpr (*this);
}
@@ -3417,19 +2803,14 @@ protected:
// constructs a std::ops::RangeTo object
class RangeToExpr : public RangeExpr
{
- // Expr* to;
- ::std::unique_ptr<Expr> to;
+ std::unique_ptr<Expr> to;
public:
- /*~RangeToExpr() {
- delete to;
- }*/
-
- ::std::string as_string () const;
+ std::string as_string () const override;
// outer attributes not allowed
- RangeToExpr (::std::unique_ptr<Expr> range_to, Location locus)
- : RangeExpr (locus), to (::std::move (range_to))
+ RangeToExpr (std::unique_ptr<Expr> range_to, Location locus)
+ : RangeExpr (locus), to (std::move (range_to))
{}
// Copy constructor with clone
@@ -3437,8 +2818,6 @@ public:
: RangeExpr (other), to (other.to->clone_expr ())
{}
- // Destructor - define here if required
-
// Overload assignment operator to clone unique_ptr
RangeToExpr &operator= (RangeToExpr const &other)
{
@@ -3452,19 +2831,19 @@ public:
RangeToExpr (RangeToExpr &&other) = default;
RangeToExpr &operator= (RangeToExpr &&other) = default;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual RangeToExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ RangeToExpr *clone_expr_impl () const override
{
return new RangeToExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual RangeToExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ RangeToExpr *clone_expr_without_block_impl () const override
{
return new RangeToExpr (*this);
}
@@ -3475,24 +2854,24 @@ protected:
class RangeFullExpr : public RangeExpr
{
public:
- ::std::string as_string () const;
+ std::string as_string () const override;
RangeFullExpr (Location locus) : RangeExpr (locus) {}
// outer attributes not allowed
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual RangeFullExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ RangeFullExpr *clone_expr_impl () const override
{
return new RangeFullExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual RangeFullExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ RangeFullExpr *clone_expr_without_block_impl () const override
{
return new RangeFullExpr (*this);
}
@@ -3502,23 +2881,16 @@ protected:
// aka RangeInclusiveExpr; constructs a std::ops::RangeInclusive object
class RangeFromToInclExpr : public RangeExpr
{
- /*Expr* from;
- Expr* to;*/
- ::std::unique_ptr<Expr> from;
- ::std::unique_ptr<Expr> to;
+ std::unique_ptr<Expr> from;
+ std::unique_ptr<Expr> to;
public:
- /*~RangeFromToInclExpr() {
- delete from;
- delete to;
- }*/
+ std::string as_string () const override;
- ::std::string as_string () const;
-
- RangeFromToInclExpr (::std::unique_ptr<Expr> range_from,
- ::std::unique_ptr<Expr> range_to, Location locus)
- : RangeExpr (locus), from (::std::move (range_from)),
- to (::std::move (range_to))
+ RangeFromToInclExpr (std::unique_ptr<Expr> range_from,
+ std::unique_ptr<Expr> range_to, Location locus)
+ : RangeExpr (locus), from (std::move (range_from)),
+ to (std::move (range_to))
{}
// outer attributes not allowed
@@ -3528,8 +2900,6 @@ public:
to (other.to->clone_expr ())
{}
- // Destructor - define here if required
-
// Overload assignment operator to use clone
RangeFromToInclExpr &operator= (RangeFromToInclExpr const &other)
{
@@ -3544,19 +2914,19 @@ public:
RangeFromToInclExpr (RangeFromToInclExpr &&other) = default;
RangeFromToInclExpr &operator= (RangeFromToInclExpr &&other) = default;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual RangeFromToInclExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ RangeFromToInclExpr *clone_expr_impl () const override
{
return new RangeFromToInclExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual RangeFromToInclExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ RangeFromToInclExpr *clone_expr_without_block_impl () const override
{
return new RangeFromToInclExpr (*this);
}
@@ -3566,18 +2936,13 @@ protected:
// aka RangeToInclusiveExpr; constructs a std::ops::RangeToInclusive object
class RangeToInclExpr : public RangeExpr
{
- // Expr* to;
- ::std::unique_ptr<Expr> to;
+ std::unique_ptr<Expr> to;
public:
- /*~RangeToInclExpr() {
- delete to;
- }*/
-
- ::std::string as_string () const;
+ std::string as_string () const override;
- RangeToInclExpr (::std::unique_ptr<Expr> range_to, Location locus)
- : RangeExpr (locus), to (::std::move (range_to))
+ RangeToInclExpr (std::unique_ptr<Expr> range_to, Location locus)
+ : RangeExpr (locus), to (std::move (range_to))
{}
// outer attributes not allowed
@@ -3586,8 +2951,6 @@ public:
: RangeExpr (other), to (other.to->clone_expr ())
{}
- // Define destructor here if required
-
// Overload assignment operator to clone pointer
RangeToInclExpr &operator= (RangeToInclExpr const &other)
{
@@ -3601,19 +2964,19 @@ public:
RangeToInclExpr (RangeToInclExpr &&other) = default;
RangeToInclExpr &operator= (RangeToInclExpr &&other) = default;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual RangeToInclExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ RangeToInclExpr *clone_expr_impl () const override
{
return new RangeToInclExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual RangeToInclExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ RangeToInclExpr *clone_expr_without_block_impl () const override
{
return new RangeToInclExpr (*this);
}
@@ -3623,30 +2986,21 @@ protected:
class ReturnExpr : public ExprWithoutBlock
{
public:
- // bool has_return_expr;
- // Expr* return_expr;
- ::std::unique_ptr<Expr> return_expr;
+ std::unique_ptr<Expr> return_expr;
Location locus;
- /*~ReturnExpr() {
- if (has_return_expr) {
- delete return_expr;
- }
- }*/
-
- ::std::string as_string () const;
+ std::string as_string () const override;
- // Returns whether the object has an expression returned (i.e. not void return
- // type).
- inline bool has_return_expr () const { return return_expr != NULL; }
+ /* Returns whether the object has an expression returned (i.e. not void return
+ * type). */
+ bool has_return_expr () const { return return_expr != nullptr; }
// Constructor for ReturnExpr.
- ReturnExpr (Location locus, ::std::unique_ptr<Expr> returned_expr = NULL,
- ::std::vector<Attribute> outer_attribs
- = ::std::vector<Attribute> ())
- : ExprWithoutBlock (::std::move (outer_attribs)),
- return_expr (::std::move (returned_expr)), locus (locus)
+ ReturnExpr (Location locus, std::unique_ptr<Expr> returned_expr = nullptr,
+ std::vector<Attribute> outer_attribs = std::vector<Attribute> ())
+ : ExprWithoutBlock (std::move (outer_attribs)),
+ return_expr (std::move (returned_expr)), locus (locus)
{}
// Copy constructor with clone
@@ -3654,14 +3008,10 @@ public:
: ExprWithoutBlock (other), locus (other.locus)
{
// guard to protect from null pointer dereference
- if (other.return_expr != NULL)
- {
- return_expr = other.return_expr->clone_expr ();
- }
+ if (other.return_expr != nullptr)
+ return_expr = other.return_expr->clone_expr ();
}
- // Destructor - define here if required
-
// Overloaded assignment operator to clone return_expr pointer
ReturnExpr &operator= (ReturnExpr const &other)
{
@@ -3678,22 +3028,21 @@ public:
ReturnExpr &operator= (ReturnExpr &&other) = default;
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual ReturnExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ ReturnExpr *clone_expr_impl () const override
{
return new ReturnExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual ReturnExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ ReturnExpr *clone_expr_without_block_impl () const override
{
return new ReturnExpr (*this);
}
@@ -3701,31 +3050,22 @@ protected:
// Forward decl - defined in rust-macro.h
class MacroInvocation;
-/*class MacroInvocation : public ExprWithoutBlock {
- public:
- ::std::string as_string() const;
-};*/
// An unsafe block AST node
class UnsafeBlockExpr : public ExprWithBlock
{
// Or just have it extend BlockExpr
- // BlockExpr* expr;
- ::std::unique_ptr<BlockExpr> expr;
+ std::unique_ptr<BlockExpr> expr;
Location locus;
public:
- /*~UnsafeBlockExpr() {
- delete expr;
- }*/
+ std::string as_string () const override;
- ::std::string as_string () const;
-
- UnsafeBlockExpr (::std::unique_ptr<BlockExpr> block_expr,
- ::std::vector<Attribute> outer_attribs, Location locus)
- : ExprWithBlock (::std::move (outer_attribs)),
- expr (::std::move (block_expr)), locus (locus)
+ UnsafeBlockExpr (std::unique_ptr<BlockExpr> block_expr,
+ std::vector<Attribute> outer_attribs, Location locus)
+ : ExprWithBlock (std::move (outer_attribs)), expr (std::move (block_expr)),
+ locus (locus)
{}
// Copy constructor with clone
@@ -3734,8 +3074,6 @@ public:
locus (other.locus)
{}
- // Destructor - define here if required
-
// Overloaded assignment operator to clone
UnsafeBlockExpr &operator= (UnsafeBlockExpr const &other)
{
@@ -3752,22 +3090,21 @@ public:
UnsafeBlockExpr &operator= (UnsafeBlockExpr &&other) = default;
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual UnsafeBlockExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ UnsafeBlockExpr *clone_expr_impl () const override
{
return new UnsafeBlockExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual UnsafeBlockExpr *clone_expr_with_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ UnsafeBlockExpr *clone_expr_with_block_impl () const override
{
return new UnsafeBlockExpr (*this);
}
@@ -3782,14 +3119,14 @@ class LoopLabel /*: public Node*/
Location locus;
public:
- ::std::string as_string () const;
+ std::string as_string () const;
LoopLabel (Lifetime loop_label, Location locus = Location ())
- : label (::std::move (loop_label)), locus (locus)
+ : label (std::move (loop_label)), locus (locus)
{}
// Returns whether the LoopLabel is in an error state.
- inline bool is_error () const { return label.is_error (); }
+ bool is_error () const { return label.is_error (); }
// Creates an error state LoopLabel.
static LoopLabel error () { return LoopLabel (Lifetime::error ()); }
@@ -3805,21 +3142,20 @@ protected:
// bool has_loop_label;
LoopLabel loop_label;
- // BlockExpr* loop_block;
- ::std::unique_ptr<BlockExpr> loop_block;
+ std::unique_ptr<BlockExpr> loop_block;
private:
Location locus;
protected:
// Constructor for BaseLoopExpr
- BaseLoopExpr (::std::unique_ptr<BlockExpr> loop_block, Location locus,
+ BaseLoopExpr (std::unique_ptr<BlockExpr> loop_block, Location locus,
LoopLabel loop_label = LoopLabel::error (),
- ::std::vector<Attribute> outer_attribs
- = ::std::vector<Attribute> ())
- : ExprWithBlock (::std::move (outer_attribs)),
- loop_label (::std::move (loop_label)),
- loop_block (::std::move (loop_block)), locus (locus)
+ std::vector<Attribute> outer_attribs
+ = std::vector<Attribute> ())
+ : ExprWithBlock (std::move (outer_attribs)),
+ loop_label (std::move (loop_label)), loop_block (std::move (loop_block)),
+ locus (locus)
{}
// Copy constructor for BaseLoopExpr with clone
@@ -3828,8 +3164,6 @@ protected:
loop_block (other.loop_block->clone_block_expr ()), locus (other.locus)
{}
- // Destructor - define here if required
-
// Overloaded assignment operator to clone
BaseLoopExpr &operator= (BaseLoopExpr const &other)
{
@@ -3847,48 +3181,36 @@ protected:
BaseLoopExpr &operator= (BaseLoopExpr &&other) = default;
public:
- /*~BaseLoopExpr() {
- delete loop_block;
- }*/
-
- inline bool has_loop_label () const { return !loop_label.is_error (); }
+ bool has_loop_label () const { return !loop_label.is_error (); }
Location get_locus () const { return locus; }
-
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
+ Location get_locus_slow () const override { return get_locus (); }
};
// 'Loop' expression (i.e. the infinite loop) AST node
class LoopExpr : public BaseLoopExpr
{
public:
- ::std::string as_string () const;
+ std::string as_string () const override;
// Constructor for LoopExpr
- LoopExpr (::std::unique_ptr<BlockExpr> loop_block, Location locus,
+ LoopExpr (std::unique_ptr<BlockExpr> loop_block, Location locus,
LoopLabel loop_label = LoopLabel::error (),
- ::std::vector<Attribute> outer_attribs
- = ::std::vector<Attribute> ())
- : BaseLoopExpr (::std::move (loop_block), locus, ::std::move (loop_label),
- ::std::move (outer_attribs))
+ std::vector<Attribute> outer_attribs = std::vector<Attribute> ())
+ : BaseLoopExpr (std::move (loop_block), locus, std::move (loop_label),
+ std::move (outer_attribs))
{}
- // copy constructor, destructor, and assignment operator should not need
- // modification
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual LoopExpr *clone_expr_impl () const OVERRIDE
- {
- return new LoopExpr (*this);
- }
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ LoopExpr *clone_expr_impl () const override { return new LoopExpr (*this); }
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual LoopExpr *clone_expr_with_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ LoopExpr *clone_expr_with_block_impl () const override
{
return new LoopExpr (*this);
}
@@ -3897,25 +3219,20 @@ protected:
// While loop expression AST node (predicate loop)
class WhileLoopExpr : public BaseLoopExpr
{
- // Expr* condition;
- ::std::unique_ptr<Expr> condition;
+ std::unique_ptr<Expr> condition;
public:
- /*~WhileLoopExpr() {
- delete condition;
- }*/
-
- ::std::string as_string () const;
+ std::string as_string () const override;
// Constructor for while loop with loop label
- WhileLoopExpr (::std::unique_ptr<Expr> loop_condition,
- ::std::unique_ptr<BlockExpr> loop_block, Location locus,
+ WhileLoopExpr (std::unique_ptr<Expr> loop_condition,
+ std::unique_ptr<BlockExpr> loop_block, Location locus,
LoopLabel loop_label = LoopLabel::error (),
- ::std::vector<Attribute> outer_attribs
- = ::std::vector<Attribute> ())
- : BaseLoopExpr (::std::move (loop_block), locus, ::std::move (loop_label),
- ::std::move (outer_attribs)),
- condition (::std::move (loop_condition))
+ std::vector<Attribute> outer_attribs
+ = std::vector<Attribute> ())
+ : BaseLoopExpr (std::move (loop_block), locus, std::move (loop_label),
+ std::move (outer_attribs)),
+ condition (std::move (loop_condition))
{}
// Copy constructor with clone
@@ -3923,8 +3240,6 @@ public:
: BaseLoopExpr (other), condition (other.condition->clone_expr ())
{}
- // Destructor - define here if required
-
// Overloaded assignment operator to clone
WhileLoopExpr &operator= (WhileLoopExpr const &other)
{
@@ -3941,52 +3256,45 @@ public:
WhileLoopExpr (WhileLoopExpr &&other) = default;
WhileLoopExpr &operator= (WhileLoopExpr &&other) = default;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual WhileLoopExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ WhileLoopExpr *clone_expr_impl () const override
{
return new WhileLoopExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual WhileLoopExpr *clone_expr_with_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ WhileLoopExpr *clone_expr_with_block_impl () const override
{
return new WhileLoopExpr (*this);
}
};
-// Forward decl MatchArmPatterns
-// struct MatchArmPatterns;
-
// While let loop expression AST node (predicate pattern loop)
class WhileLetLoopExpr : public BaseLoopExpr
{
// MatchArmPatterns patterns;
- ::std::vector< ::std::unique_ptr<Pattern> > match_arm_patterns; // inlined
- // Expr* condition;
- ::std::unique_ptr<Expr> condition;
+ std::vector<std::unique_ptr<Pattern>> match_arm_patterns; // inlined
+ std::unique_ptr<Expr> condition;
public:
- /*~WhileLetLoopExpr() {
- delete condition;
- }*/
-
- ::std::string as_string () const;
+ std::string as_string () const override;
// Constructor with a loop label
- WhileLetLoopExpr (
- ::std::vector< ::std::unique_ptr<Pattern> > match_arm_patterns,
- ::std::unique_ptr<Expr> condition, ::std::unique_ptr<BlockExpr> loop_block,
- Location locus, LoopLabel loop_label = LoopLabel::error (),
- ::std::vector<Attribute> outer_attribs = ::std::vector<Attribute> ())
- : BaseLoopExpr (::std::move (loop_block), locus, ::std::move (loop_label),
- ::std::move (outer_attribs)),
- match_arm_patterns (::std::move (match_arm_patterns)),
- condition (::std::move (condition))
+ WhileLetLoopExpr (std::vector<std::unique_ptr<Pattern>> match_arm_patterns,
+ std::unique_ptr<Expr> condition,
+ std::unique_ptr<BlockExpr> loop_block, Location locus,
+ LoopLabel loop_label = LoopLabel::error (),
+ std::vector<Attribute> outer_attribs
+ = std::vector<Attribute> ())
+ : BaseLoopExpr (std::move (loop_block), locus, std::move (loop_label),
+ std::move (outer_attribs)),
+ match_arm_patterns (std::move (match_arm_patterns)),
+ condition (std::move (condition))
{}
// Copy constructor with clone
@@ -3995,18 +3303,11 @@ public:
/*match_arm_patterns(other.match_arm_patterns),*/ condition (
other.condition->clone_expr ())
{
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
match_arm_patterns.reserve (other.match_arm_patterns.size ());
-
for (const auto &e : other.match_arm_patterns)
- {
- match_arm_patterns.push_back (e->clone_pattern ());
- }
+ match_arm_patterns.push_back (e->clone_pattern ());
}
- // Destructor - define here if required
-
// Overloaded assignment operator to clone pointers
WhileLetLoopExpr &operator= (WhileLetLoopExpr const &other)
{
@@ -4017,14 +3318,9 @@ public:
// loop_label = other.loop_label;
// outer_attrs = other.outer_attrs;
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
match_arm_patterns.reserve (other.match_arm_patterns.size ());
-
for (const auto &e : other.match_arm_patterns)
- {
- match_arm_patterns.push_back (e->clone_pattern ());
- }
+ match_arm_patterns.push_back (e->clone_pattern ());
return *this;
}
@@ -4033,19 +3329,19 @@ public:
WhileLetLoopExpr (WhileLetLoopExpr &&other) = default;
WhileLetLoopExpr &operator= (WhileLetLoopExpr &&other) = default;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual WhileLetLoopExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ WhileLetLoopExpr *clone_expr_impl () const override
{
return new WhileLetLoopExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual WhileLetLoopExpr *clone_expr_with_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ WhileLetLoopExpr *clone_expr_with_block_impl () const override
{
return new WhileLetLoopExpr (*this);
}
@@ -4054,29 +3350,22 @@ protected:
// For loop expression AST node (iterator loop)
class ForLoopExpr : public BaseLoopExpr
{
- // Pattern pattern;
- ::std::unique_ptr<Pattern> pattern;
- // Expr* iterator_expr;
- ::std::unique_ptr<Expr> iterator_expr;
+ std::unique_ptr<Pattern> pattern;
+ std::unique_ptr<Expr> iterator_expr;
public:
- /*~ForLoopExpr() {
- delete iterator_expr;
- }*/
-
- ::std::string as_string () const;
+ std::string as_string () const override;
// Constructor with loop label
- ForLoopExpr (::std::unique_ptr<Pattern> loop_pattern,
- ::std::unique_ptr<Expr> iterator_expr,
- ::std::unique_ptr<BlockExpr> loop_body, Location locus,
+ ForLoopExpr (std::unique_ptr<Pattern> loop_pattern,
+ std::unique_ptr<Expr> iterator_expr,
+ std::unique_ptr<BlockExpr> loop_body, Location locus,
LoopLabel loop_label = LoopLabel::error (),
- ::std::vector<Attribute> outer_attribs
- = ::std::vector<Attribute> ())
- : BaseLoopExpr (::std::move (loop_body), locus, ::std::move (loop_label),
- ::std::move (outer_attribs)),
- pattern (::std::move (loop_pattern)),
- iterator_expr (::std::move (iterator_expr))
+ std::vector<Attribute> outer_attribs = std::vector<Attribute> ())
+ : BaseLoopExpr (std::move (loop_body), locus, std::move (loop_label),
+ std::move (outer_attribs)),
+ pattern (std::move (loop_pattern)),
+ iterator_expr (std::move (iterator_expr))
{}
// Copy constructor with clone
@@ -4085,8 +3374,6 @@ public:
iterator_expr (other.iterator_expr->clone_expr ())
{}
- // Destructor - define here if required
-
// Overloaded assignment operator to clone
ForLoopExpr &operator= (ForLoopExpr const &other)
{
@@ -4104,19 +3391,19 @@ public:
ForLoopExpr (ForLoopExpr &&other) = default;
ForLoopExpr &operator= (ForLoopExpr &&other) = default;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual ForLoopExpr *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ ForLoopExpr *clone_expr_impl () const override
{
return new ForLoopExpr (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual ForLoopExpr *clone_expr_with_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ ForLoopExpr *clone_expr_with_block_impl () const override
{
return new ForLoopExpr (*this);
}
@@ -4128,30 +3415,18 @@ class IfLetExpr;
// Base if expression with no "else" or "if let" AST node
class IfExpr : public ExprWithBlock
{
- /*Expr* condition;
- BlockExpr* if_block;*/
- ::std::unique_ptr<Expr> condition;
- ::std::unique_ptr<BlockExpr> if_block;
- /*union {
- BlockExpr else_block;
- IfExpr* if_expr;
- IfLetExpr if_let_expr;
- } consequent_block;*/
+ std::unique_ptr<Expr> condition;
+ std::unique_ptr<BlockExpr> if_block;
Location locus;
public:
- /*virtual ~IfExpr() {
- delete condition;
- delete if_block;
- }*/
+ std::string as_string () const override;
- ::std::string as_string () const;
-
- IfExpr (::std::unique_ptr<Expr> condition,
- ::std::unique_ptr<BlockExpr> if_block, Location locus)
- : ExprWithBlock (::std::vector<Attribute> ()),
- condition (::std::move (condition)), if_block (::std::move (if_block)),
+ IfExpr (std::unique_ptr<Expr> condition, std::unique_ptr<BlockExpr> if_block,
+ Location locus)
+ : ExprWithBlock (std::vector<Attribute> ()),
+ condition (std::move (condition)), if_block (std::move (if_block)),
locus (locus)
{}
// outer attributes are never allowed on IfExprs
@@ -4162,8 +3437,6 @@ public:
if_block (other.if_block->clone_block_expr ()), locus (other.locus)
{}
- // Destructor - define here if required
-
// Overloaded assignment operator to clone expressions
IfExpr &operator= (IfExpr const &other)
{
@@ -4180,9 +3453,9 @@ public:
IfExpr &operator= (IfExpr &&other) = default;
// Unique pointer custom clone function
- ::std::unique_ptr<IfExpr> clone_if_expr () const
+ std::unique_ptr<IfExpr> clone_if_expr () const
{
- return ::std::unique_ptr<IfExpr> (clone_if_expr_impl ());
+ return std::unique_ptr<IfExpr> (clone_if_expr_impl ());
}
/* Note that multiple "else if"s are handled via nested ASTs rather than a
@@ -4190,33 +3463,27 @@ public:
* better approach? or does it not parse correctly and have downsides? */
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
void vis_if_condition (ASTVisitor &vis) { condition->accept_vis (vis); }
-
void vis_if_block (ASTVisitor &vis) { if_block->accept_vis (vis); }
Expr *get_if_condition () { return condition.get (); }
-
BlockExpr *get_if_block () { return if_block.get (); }
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual IfExpr *clone_expr_impl () const OVERRIDE
- {
- return new IfExpr (*this);
- }
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ IfExpr *clone_expr_impl () const override { return new IfExpr (*this); }
// Base clone function but still concrete as concrete base class
virtual IfExpr *clone_if_expr_impl () const { return new IfExpr (*this); }
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual IfExpr *clone_expr_with_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ IfExpr *clone_expr_with_block_impl () const override
{
return new IfExpr (*this);
}
@@ -4225,21 +3492,16 @@ protected:
// If expression with an ending "else" expression AST node (trailing)
class IfExprConseqElse : public IfExpr
{
- // BlockExpr* else_block;
- ::std::unique_ptr<BlockExpr> else_block;
+ std::unique_ptr<BlockExpr> else_block;
public:
- /*~IfExprConseqElse() {
- delete else_block;
- }*/
-
- ::std::string as_string () const;
+ std::string as_string () const override;
- IfExprConseqElse (::std::unique_ptr<Expr> condition,
- ::std::unique_ptr<BlockExpr> if_block,
- ::std::unique_ptr<BlockExpr> else_block, Location locus)
- : IfExpr (::std::move (condition), ::std::move (if_block), locus),
- else_block (::std::move (else_block))
+ IfExprConseqElse (std::unique_ptr<Expr> condition,
+ std::unique_ptr<BlockExpr> if_block,
+ std::unique_ptr<BlockExpr> else_block, Location locus)
+ : IfExpr (std::move (condition), std::move (if_block), locus),
+ else_block (std::move (else_block))
{}
// again, outer attributes not allowed
@@ -4248,8 +3510,6 @@ public:
: IfExpr (other), else_block (other.else_block->clone_block_expr ())
{}
- // Destructor - define here if required
-
// Overloaded assignment operator with cloning
IfExprConseqElse &operator= (IfExprConseqElse const &other)
{
@@ -4265,28 +3525,28 @@ public:
IfExprConseqElse (IfExprConseqElse &&other) = default;
IfExprConseqElse &operator= (IfExprConseqElse &&other) = default;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
void vis_else_block (ASTVisitor &vis) { else_block->accept_vis (vis); }
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual IfExprConseqElse *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ IfExprConseqElse *clone_expr_impl () const override
{
return new IfExprConseqElse (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual IfExprConseqElse *clone_expr_with_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ IfExprConseqElse *clone_expr_with_block_impl () const override
{
return new IfExprConseqElse (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual IfExprConseqElse *clone_if_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ IfExprConseqElse *clone_if_expr_impl () const override
{
return new IfExprConseqElse (*this);
}
@@ -4295,21 +3555,16 @@ protected:
// If expression with an ending "else if" expression AST node
class IfExprConseqIf : public IfExpr
{
- // IfExpr* if_expr;
- ::std::unique_ptr<IfExpr> conseq_if_expr;
+ std::unique_ptr<IfExpr> conseq_if_expr;
public:
- /*~IfExprConseqIf() {
- delete if_expr;
- }*/
+ std::string as_string () const override;
- ::std::string as_string () const;
-
- IfExprConseqIf (::std::unique_ptr<Expr> condition,
- ::std::unique_ptr<BlockExpr> if_block,
- ::std::unique_ptr<IfExpr> conseq_if_expr, Location locus)
- : IfExpr (::std::move (condition), ::std::move (if_block), locus),
- conseq_if_expr (::std::move (conseq_if_expr))
+ IfExprConseqIf (std::unique_ptr<Expr> condition,
+ std::unique_ptr<BlockExpr> if_block,
+ std::unique_ptr<IfExpr> conseq_if_expr, Location locus)
+ : IfExpr (std::move (condition), std::move (if_block), locus),
+ conseq_if_expr (std::move (conseq_if_expr))
{}
// outer attributes not allowed
@@ -4318,8 +3573,6 @@ public:
: IfExpr (other), conseq_if_expr (other.conseq_if_expr->clone_if_expr ())
{}
- // Destructor - define here if required
-
// Overloaded assignment operator to use clone
IfExprConseqIf &operator= (IfExprConseqIf const &other)
{
@@ -4335,7 +3588,7 @@ public:
IfExprConseqIf (IfExprConseqIf &&other) = default;
IfExprConseqIf &operator= (IfExprConseqIf &&other) = default;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
void vis_conseq_if_expr (ASTVisitor &vis)
{
@@ -4343,23 +3596,23 @@ public:
}
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual IfExprConseqIf *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ IfExprConseqIf *clone_expr_impl () const override
{
return new IfExprConseqIf (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual IfExprConseqIf *clone_expr_with_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ IfExprConseqIf *clone_expr_with_block_impl () const override
{
return new IfExprConseqIf (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual IfExprConseqIf *clone_if_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ IfExprConseqIf *clone_if_expr_impl () const override
{
return new IfExprConseqIf (*this);
}
@@ -4369,29 +3622,21 @@ protected:
class IfLetExpr : public ExprWithBlock
{
// MatchArmPatterns patterns;
- ::std::vector< ::std::unique_ptr<Pattern> > match_arm_patterns; // inlined
- /*Expr* value;
- BlockExpr* if_block;*/
- ::std::unique_ptr<Expr> value;
- ::std::unique_ptr<BlockExpr> if_block;
- /*union {
- BlockExpr else_block;
- IfExpr if_expr;
- IfLetExpr* if_let_expr;
- } consequent_block;*/
+ std::vector<std::unique_ptr<Pattern>> match_arm_patterns; // inlined
+ std::unique_ptr<Expr> value;
+ std::unique_ptr<BlockExpr> if_block;
Location locus;
public:
- ::std::string as_string () const;
-
- IfLetExpr (::std::vector< ::std::unique_ptr<Pattern> > match_arm_patterns,
- ::std::unique_ptr<Expr> value,
- ::std::unique_ptr<BlockExpr> if_block, Location locus)
- : ExprWithBlock (::std::vector<Attribute> ()),
- match_arm_patterns (::std::move (match_arm_patterns)),
- value (::std::move (value)), if_block (::std::move (if_block)),
- locus (locus)
+ std::string as_string () const override;
+
+ IfLetExpr (std::vector<std::unique_ptr<Pattern>> match_arm_patterns,
+ std::unique_ptr<Expr> value, std::unique_ptr<BlockExpr> if_block,
+ Location locus)
+ : ExprWithBlock (std::vector<Attribute> ()),
+ match_arm_patterns (std::move (match_arm_patterns)),
+ value (std::move (value)), if_block (std::move (if_block)), locus (locus)
{}
// outer attributes not allowed on if let exprs either
@@ -4402,18 +3647,11 @@ public:
other.value->clone_expr ()),
if_block (other.if_block->clone_block_expr ()), locus (other.locus)
{
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
match_arm_patterns.reserve (other.match_arm_patterns.size ());
-
for (const auto &e : other.match_arm_patterns)
- {
- match_arm_patterns.push_back (e->clone_pattern ());
- }
+ match_arm_patterns.push_back (e->clone_pattern ());
}
- // destructor - define here if required
-
// overload assignment operator to clone
IfLetExpr &operator= (IfLetExpr const &other)
{
@@ -4423,14 +3661,9 @@ public:
if_block = other.if_block->clone_block_expr ();
locus = other.locus;
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
match_arm_patterns.reserve (other.match_arm_patterns.size ());
-
for (const auto &e : other.match_arm_patterns)
- {
- match_arm_patterns.push_back (e->clone_pattern ());
- }
+ match_arm_patterns.push_back (e->clone_pattern ());
return *this;
}
@@ -4440,28 +3673,24 @@ public:
IfLetExpr &operator= (IfLetExpr &&other) = default;
// Unique pointer custom clone function
- ::std::unique_ptr<IfLetExpr> clone_if_let_expr () const
+ std::unique_ptr<IfLetExpr> clone_if_let_expr () const
{
- return ::std::unique_ptr<IfLetExpr> (clone_if_let_expr_impl ());
+ return std::unique_ptr<IfLetExpr> (clone_if_let_expr_impl ());
}
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual IfLetExpr *clone_expr_impl () const OVERRIDE
- {
- return new IfLetExpr (*this);
- }
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ IfLetExpr *clone_expr_impl () const override { return new IfLetExpr (*this); }
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual IfLetExpr *clone_expr_with_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ IfLetExpr *clone_expr_with_block_impl () const override
{
return new IfLetExpr (*this);
}
@@ -4476,22 +3705,17 @@ protected:
// If expression with an ending "else if let" expression AST node
class IfExprConseqIfLet : public IfExpr
{
- // IfLetExpr* if_let_expr;
- ::std::unique_ptr<IfLetExpr> if_let_expr;
+ std::unique_ptr<IfLetExpr> if_let_expr;
public:
- /*~IfExprIfConseqIfLet() {
- delete if_let_expr;
- }*/
+ std::string as_string () const override;
- ::std::string as_string () const;
-
- IfExprConseqIfLet (::std::unique_ptr<Expr> condition,
- ::std::unique_ptr<BlockExpr> if_block,
- ::std::unique_ptr<IfLetExpr> conseq_if_let_expr,
+ IfExprConseqIfLet (std::unique_ptr<Expr> condition,
+ std::unique_ptr<BlockExpr> if_block,
+ std::unique_ptr<IfLetExpr> conseq_if_let_expr,
Location locus)
- : IfExpr (::std::move (condition), ::std::move (if_block), locus),
- if_let_expr (::std::move (conseq_if_let_expr))
+ : IfExpr (std::move (condition), std::move (if_block), locus),
+ if_let_expr (std::move (conseq_if_let_expr))
{}
// outer attributes not allowed
@@ -4500,8 +3724,6 @@ public:
: IfExpr (other), if_let_expr (other.if_let_expr->clone_if_let_expr ())
{}
- // Destructor - define here if required
-
// Overloaded assignment operator to use clone
IfExprConseqIfLet &operator= (IfExprConseqIfLet const &other)
{
@@ -4517,52 +3739,47 @@ public:
IfExprConseqIfLet (IfExprConseqIfLet &&other) = default;
IfExprConseqIfLet &operator= (IfExprConseqIfLet &&other) = default;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual IfExprConseqIfLet *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ IfExprConseqIfLet *clone_expr_impl () const override
{
return new IfExprConseqIfLet (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual IfExprConseqIfLet *clone_expr_with_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ IfExprConseqIfLet *clone_expr_with_block_impl () const override
{
return new IfExprConseqIfLet (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual IfExprConseqIfLet *clone_if_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ IfExprConseqIfLet *clone_if_expr_impl () const override
{
return new IfExprConseqIfLet (*this);
}
};
-// AST node representing "if let" expression with an "else" expression at the
-// end
+/* AST node representing "if let" expression with an "else" expression at the
+ * end */
class IfLetExprConseqElse : public IfLetExpr
{
- // BlockExpr* else_block;
- ::std::unique_ptr<BlockExpr> else_block;
+ std::unique_ptr<BlockExpr> else_block;
public:
- /*~IfLetExprConseqElse() {
- delete else_block;
- }*/
-
- ::std::string as_string () const;
+ std::string as_string () const override;
IfLetExprConseqElse (
- ::std::vector< ::std::unique_ptr<Pattern> > match_arm_patterns,
- ::std::unique_ptr<Expr> value, ::std::unique_ptr<BlockExpr> if_block,
- ::std::unique_ptr<BlockExpr> else_block, Location locus)
- : IfLetExpr (::std::move (match_arm_patterns), ::std::move (value),
- ::std::move (if_block), locus),
- else_block (::std::move (else_block))
+ std::vector<std::unique_ptr<Pattern>> match_arm_patterns,
+ std::unique_ptr<Expr> value, std::unique_ptr<BlockExpr> if_block,
+ std::unique_ptr<BlockExpr> else_block, Location locus)
+ : IfLetExpr (std::move (match_arm_patterns), std::move (value),
+ std::move (if_block), locus),
+ else_block (std::move (else_block))
{}
// outer attributes not allowed
@@ -4571,8 +3788,6 @@ public:
: IfLetExpr (other), else_block (other.else_block->clone_block_expr ())
{}
- // destructor - define here if required
-
// overload assignment operator to clone
IfLetExprConseqElse &operator= (IfLetExprConseqElse const &other)
{
@@ -4590,52 +3805,47 @@ public:
IfLetExprConseqElse (IfLetExprConseqElse &&other) = default;
IfLetExprConseqElse &operator= (IfLetExprConseqElse &&other) = default;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual IfLetExprConseqElse *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ IfLetExprConseqElse *clone_expr_impl () const override
{
return new IfLetExprConseqElse (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual IfLetExprConseqElse *clone_expr_with_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ IfLetExprConseqElse *clone_expr_with_block_impl () const override
{
return new IfLetExprConseqElse (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual IfLetExprConseqElse *clone_if_let_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ IfLetExprConseqElse *clone_if_let_expr_impl () const override
{
return new IfLetExprConseqElse (*this);
}
};
-// AST node representing "if let" expression with an "else if" expression at the
-// end
+/* AST node representing "if let" expression with an "else if" expression at the
+ * end */
class IfLetExprConseqIf : public IfLetExpr
{
- // IfExpr* if_expr;
- ::std::unique_ptr<IfExpr> if_expr;
+ std::unique_ptr<IfExpr> if_expr;
public:
- /*~IfLetExprConseqIf() {
- delete if_expr;
- }*/
-
- ::std::string as_string () const;
-
- IfLetExprConseqIf (
- ::std::vector< ::std::unique_ptr<Pattern> > match_arm_patterns,
- ::std::unique_ptr<Expr> value, ::std::unique_ptr<BlockExpr> if_block,
- ::std::unique_ptr<IfExpr> if_expr, Location locus)
- : IfLetExpr (::std::move (match_arm_patterns), ::std::move (value),
- ::std::move (if_block), locus),
- if_expr (::std::move (if_expr))
+ std::string as_string () const override;
+
+ IfLetExprConseqIf (std::vector<std::unique_ptr<Pattern>> match_arm_patterns,
+ std::unique_ptr<Expr> value,
+ std::unique_ptr<BlockExpr> if_block,
+ std::unique_ptr<IfExpr> if_expr, Location locus)
+ : IfLetExpr (std::move (match_arm_patterns), std::move (value),
+ std::move (if_block), locus),
+ if_expr (std::move (if_expr))
{}
// again, outer attributes not allowed
@@ -4644,8 +3854,6 @@ public:
: IfLetExpr (other), if_expr (other.if_expr->clone_if_expr ())
{}
- // destructor - define here if required
-
// overload assignment operator to clone
IfLetExprConseqIf &operator= (IfLetExprConseqIf const &other)
{
@@ -4662,52 +3870,47 @@ public:
IfLetExprConseqIf (IfLetExprConseqIf &&other) = default;
IfLetExprConseqIf &operator= (IfLetExprConseqIf &&other) = default;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual IfLetExprConseqIf *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ IfLetExprConseqIf *clone_expr_impl () const override
{
return new IfLetExprConseqIf (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual IfLetExprConseqIf *clone_expr_with_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ IfLetExprConseqIf *clone_expr_with_block_impl () const override
{
return new IfLetExprConseqIf (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual IfLetExprConseqIf *clone_if_let_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ IfLetExprConseqIf *clone_if_let_expr_impl () const override
{
return new IfLetExprConseqIf (*this);
}
};
-// AST node representing "if let" expression with an "else if let" expression at
-// the end
+/* AST node representing "if let" expression with an "else if let" expression at
+ * the end */
class IfLetExprConseqIfLet : public IfLetExpr
{
- // IfLetExpr* if_let_expr;
- ::std::unique_ptr<IfLetExpr> if_let_expr;
+ std::unique_ptr<IfLetExpr> if_let_expr;
public:
- /*~IfLetExprConseqIfLet() {
- delete if_let_expr;
- }*/
-
- ::std::string as_string () const;
+ std::string as_string () const override;
IfLetExprConseqIfLet (
- ::std::vector< ::std::unique_ptr<Pattern> > match_arm_patterns,
- ::std::unique_ptr<Expr> value, ::std::unique_ptr<BlockExpr> if_block,
- ::std::unique_ptr<IfLetExpr> if_let_expr, Location locus)
- : IfLetExpr (::std::move (match_arm_patterns), ::std::move (value),
- ::std::move (if_block), locus),
- if_let_expr (::std::move (if_let_expr))
+ std::vector<std::unique_ptr<Pattern>> match_arm_patterns,
+ std::unique_ptr<Expr> value, std::unique_ptr<BlockExpr> if_block,
+ std::unique_ptr<IfLetExpr> if_let_expr, Location locus)
+ : IfLetExpr (std::move (match_arm_patterns), std::move (value),
+ std::move (if_block), locus),
+ if_let_expr (std::move (if_let_expr))
{}
// outer attributes not allowed
@@ -4716,8 +3919,6 @@ public:
: IfLetExpr (other), if_let_expr (other.if_let_expr->clone_if_let_expr ())
{}
- // destructor - define here if required
-
// overload assignment operator to clone
IfLetExprConseqIfLet &operator= (IfLetExprConseqIfLet const &other)
{
@@ -4734,26 +3935,26 @@ public:
IfLetExprConseqIfLet (IfLetExprConseqIfLet &&other) = default;
IfLetExprConseqIfLet &operator= (IfLetExprConseqIfLet &&other) = default;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual IfLetExprConseqIfLet *clone_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ IfLetExprConseqIfLet *clone_expr_impl () const override
{
return new IfLetExprConseqIfLet (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual IfLetExprConseqIfLet *clone_expr_with_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ IfLetExprConseqIfLet *clone_expr_with_block_impl () const override
{
return new IfLetExprConseqIfLet (*this);
}
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual IfLetExprConseqIfLet *clone_if_let_expr_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ IfLetExprConseqIfLet *clone_if_let_expr_impl () const override
{
return new IfLetExprConseqIfLet (*this);
}
@@ -4763,33 +3964,27 @@ protected:
struct MatchArm
{
private:
- ::std::vector<Attribute> outer_attrs;
+ std::vector<Attribute> outer_attrs;
// MatchArmPatterns patterns;
- ::std::vector< ::std::unique_ptr<Pattern> > match_arm_patterns; // inlined
+ std::vector<std::unique_ptr<Pattern>> match_arm_patterns; // inlined
// bool has_match_arm_guard;
- // Expr* match_arm_guard; // inlined from MatchArmGuard
- ::std::unique_ptr<Expr> guard_expr;
+ // inlined from MatchArmGuard
+ std::unique_ptr<Expr> guard_expr;
// TODO: should this store location data?
public:
- /*~MatchArm() {
- if (has_match_arm_guard) {
- delete match_arm_guard;
- }
- }*/
-
// Returns whether the MatchArm has a match arm guard expression
- inline bool has_match_arm_guard () const { return guard_expr != NULL; }
+ bool has_match_arm_guard () const { return guard_expr != nullptr; }
// Constructor for match arm with a guard expression
- MatchArm (::std::vector< ::std::unique_ptr<Pattern> > match_arm_patterns,
- ::std::unique_ptr<Expr> guard_expr = NULL,
- ::std::vector<Attribute> outer_attrs = ::std::vector<Attribute> ())
- : outer_attrs (::std::move (outer_attrs)),
- match_arm_patterns (::std::move (match_arm_patterns)),
- guard_expr (::std::move (guard_expr))
+ MatchArm (std::vector<std::unique_ptr<Pattern>> match_arm_patterns,
+ std::unique_ptr<Expr> guard_expr = nullptr,
+ std::vector<Attribute> outer_attrs = std::vector<Attribute> ())
+ : outer_attrs (std::move (outer_attrs)),
+ match_arm_patterns (std::move (match_arm_patterns)),
+ guard_expr (std::move (guard_expr))
{}
// Copy constructor with clone
@@ -4798,30 +3993,12 @@ public:
other.outer_attrs)
{
// guard to protect from null pointer dereference
- if (other.guard_expr != NULL)
- {
- guard_expr = other.guard_expr->clone_expr ();
- }
-
- // DEBUG
- fprintf (
- stderr,
- "started copy-constructing match arm (outer attrs, guard expr done)\n");
-
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
- match_arm_patterns.reserve (other.match_arm_patterns.size ());
+ if (other.guard_expr != nullptr)
+ guard_expr = other.guard_expr->clone_expr ();
+ match_arm_patterns.reserve (other.match_arm_patterns.size ());
for (const auto &e : other.match_arm_patterns)
- {
- match_arm_patterns.push_back (e->clone_pattern ());
-
- // DEBUG
- fprintf (stderr, "successfully pushed back a match arm pattern\n");
- }
-
- // DEBUG
- fprintf (stderr, "successfully copy-constructed match arm\n");
+ match_arm_patterns.push_back (e->clone_pattern ());
}
~MatchArm () = default;
@@ -4833,14 +4010,9 @@ public:
outer_attrs = other.outer_attrs;
guard_expr = other.guard_expr->clone_expr ();
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
match_arm_patterns.reserve (other.match_arm_patterns.size ());
-
for (const auto &e : other.match_arm_patterns)
- {
- match_arm_patterns.push_back (e->clone_pattern ());
- }
+ match_arm_patterns.push_back (e->clone_pattern ());
return *this;
}
@@ -4850,15 +4022,15 @@ public:
MatchArm &operator= (MatchArm &&other) = default;
// Returns whether match arm is in an error state.
- inline bool is_error () const { return match_arm_patterns.empty (); }
+ bool is_error () const { return match_arm_patterns.empty (); }
// Creates a match arm in an error state.
static MatchArm create_error ()
{
- return MatchArm (::std::vector< ::std::unique_ptr<Pattern> > ());
+ return MatchArm (std::vector<std::unique_ptr<Pattern>> ());
}
- ::std::string as_string () const;
+ std::string as_string () const;
};
// Base "match case" for a match expression - abstract
@@ -4867,7 +4039,7 @@ class MatchCase
MatchArm arm;
protected:
- MatchCase (MatchArm arm) : arm (::std::move (arm)) {}
+ MatchCase (MatchArm arm) : arm (std::move (arm)) {}
// Should not require copy constructor or assignment operator overloading
@@ -4878,15 +4050,12 @@ public:
virtual ~MatchCase () {}
// Unique pointer custom clone function
- ::std::unique_ptr<MatchCase> clone_match_case () const
+ std::unique_ptr<MatchCase> clone_match_case () const
{
- // DEBUG
- fprintf (stderr, "about to call clone match case impl\n");
-
- return ::std::unique_ptr<MatchCase> (clone_match_case_impl ());
+ return std::unique_ptr<MatchCase> (clone_match_case_impl ());
}
- virtual ::std::string as_string () const;
+ virtual std::string as_string () const;
virtual void accept_vis (ASTVisitor &vis) = 0;
};
@@ -4894,29 +4063,19 @@ public:
// Block expression match case
class MatchCaseBlockExpr : public MatchCase
{
- // BlockExpr* block_expr;
- ::std::unique_ptr<BlockExpr> block_expr;
+ std::unique_ptr<BlockExpr> block_expr;
// TODO: should this store location data?
public:
- /*~MatchCaseBlockExpr() {
- delete block_expr;
- }*/
-
- MatchCaseBlockExpr (MatchArm arm, ::std::unique_ptr<BlockExpr> block_expr)
- : MatchCase (::std::move (arm)), block_expr (::std::move (block_expr))
+ MatchCaseBlockExpr (MatchArm arm, std::unique_ptr<BlockExpr> block_expr)
+ : MatchCase (std::move (arm)), block_expr (std::move (block_expr))
{}
// Copy constructor requires clone
MatchCaseBlockExpr (MatchCaseBlockExpr const &other)
: MatchCase (other), block_expr (other.block_expr->clone_block_expr ())
- {
- // DEBUG
- fprintf (stderr, "successfully copy constructed match case expr\n");
- }
-
- // Destructor - define here if required
+ {}
// Overload assignment operator to have clone
MatchCaseBlockExpr &operator= (MatchCaseBlockExpr const &other)
@@ -4932,18 +4091,15 @@ public:
MatchCaseBlockExpr (MatchCaseBlockExpr &&other) = default;
MatchCaseBlockExpr &operator= (MatchCaseBlockExpr &&other) = default;
- ::std::string as_string () const;
+ std::string as_string () const override;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual MatchCaseBlockExpr *clone_match_case_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ MatchCaseBlockExpr *clone_match_case_impl () const override
{
- // DEBUG
- fprintf (stderr, "about to copy construct match case block expr\n");
-
return new MatchCaseBlockExpr (*this);
}
};
@@ -4951,29 +4107,19 @@ protected:
// Expression (except block expression) match case
class MatchCaseExpr : public MatchCase
{
- // Expr* expr;
- ::std::unique_ptr<Expr> expr;
+ std::unique_ptr<Expr> expr;
// TODO: should this store location data?
public:
- /*~MatchCaseExpr() {
- delete expr;
- }*/
-
- MatchCaseExpr (MatchArm arm, ::std::unique_ptr<Expr> expr)
- : MatchCase (::std::move (arm)), expr (::std::move (expr))
+ MatchCaseExpr (MatchArm arm, std::unique_ptr<Expr> expr)
+ : MatchCase (std::move (arm)), expr (std::move (expr))
{}
// Copy constructor requires clone
MatchCaseExpr (MatchCaseExpr const &other)
: MatchCase (other), expr (other.expr->clone_expr ())
- {
- // DEBUG
- fprintf (stderr, "successfully copy constructed match case expr\n");
- }
-
- // Destructor - define here if required
+ {}
// Overload assignment operator to have clone
MatchCaseExpr &operator= (MatchCaseExpr const &other)
@@ -4989,24 +4135,15 @@ public:
MatchCaseExpr (MatchCaseExpr &&other) = default;
MatchCaseExpr &operator= (MatchCaseExpr &&other) = default;
- ::std::string as_string () const;
+ std::string as_string () const override;
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual MatchCaseExpr *clone_match_case_impl () const OVERRIDE
- {
- // DEBUG
- fprintf (stderr, "about to copy construct match case expr\n");
- if (expr == NULL)
- {
- fprintf (
- stderr,
- "warning: match case expr to be copy constructed has null expr!\n");
- }
-
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ MatchCaseExpr *clone_match_case_impl () const override
+ {
return new MatchCaseExpr (*this);
}
};
@@ -5014,35 +4151,29 @@ protected:
// Match expression AST node
class MatchExpr : public ExprWithBlock
{
- // Expr* branch_value;
- ::std::unique_ptr<Expr> branch_value;
- ::std::vector<Attribute> inner_attrs;
+ std::unique_ptr<Expr> branch_value;
+ std::vector<Attribute> inner_attrs;
// bool has_match_arms;
// MatchArms match_arms;
- ::std::vector< ::std::unique_ptr<MatchCase> >
- match_arms; // inlined from MatchArms
+ std::vector<std::unique_ptr<MatchCase>> match_arms; // inlined from MatchArms
Location locus;
public:
- /*~MatchExpr() {
- delete branch_value;
- }*/
-
- ::std::string as_string () const;
+ std::string as_string () const override;
// Returns whether the match expression has any match arms.
- inline bool has_match_arms () const { return !match_arms.empty (); }
-
- MatchExpr (::std::unique_ptr<Expr> branch_value,
- ::std::vector< ::std::unique_ptr<MatchCase> > match_arms,
- ::std::vector<Attribute> inner_attrs,
- ::std::vector<Attribute> outer_attrs, Location locus)
- : ExprWithBlock (::std::move (outer_attrs)),
- branch_value (::std::move (branch_value)),
- inner_attrs (::std::move (inner_attrs)),
- match_arms (::std::move (match_arms)), locus (locus)
+ bool has_match_arms () const { return !match_arms.empty (); }
+
+ MatchExpr (std::unique_ptr<Expr> branch_value,
+ std::vector<std::unique_ptr<MatchCase>> match_arms,
+ std::vector<Attribute> inner_attrs,
+ std::vector<Attribute> outer_attrs, Location locus)
+ : ExprWithBlock (std::move (outer_attrs)),
+ branch_value (std::move (branch_value)),
+ inner_attrs (std::move (inner_attrs)),
+ match_arms (std::move (match_arms)), locus (locus)
{}
// Copy constructor requires clone due to unique_ptr
@@ -5052,27 +4183,11 @@ public:
other.branch_value->clone_expr ()), /*match_arms(other.match_arms),*/
inner_attrs (other.inner_attrs), locus (other.locus)
{
- fprintf (stderr,
- "copy constructor for matchexpr called - only match arm vector "
- "copying after this\n");
-
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
match_arms.reserve (other.match_arms.size ());
-
- fprintf (stderr, "match expr: successfully reserved size\n");
-
for (const auto &e : other.match_arms)
- {
- match_arms.push_back (e->clone_match_case ());
- fprintf (stderr, "match expr: successfully pushed back a match case\n");
- }
-
- fprintf (stderr, "match expr: successfully pushed back all match cases\n");
+ match_arms.push_back (e->clone_match_case ());
}
- // Destructor - define here if required
-
// Overloaded assignment operator to clone due to unique_ptr
MatchExpr &operator= (MatchExpr const &other)
{
@@ -5083,14 +4198,9 @@ public:
// outer_attrs = other.outer_attrs;
locus = other.locus;
- // crappy vector unique pointer clone - TODO is there a better way of doing
- // this?
match_arms.reserve (other.match_arms.size ());
-
for (const auto &e : other.match_arms)
- {
- match_arms.push_back (e->clone_match_case ());
- }
+ match_arms.push_back (e->clone_match_case ());
return *this;
}
@@ -5100,22 +4210,18 @@ public:
MatchExpr &operator= (MatchExpr &&other) = default;
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual MatchExpr *clone_expr_impl () const OVERRIDE
- {
- return new MatchExpr (*this);
- }
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ MatchExpr *clone_expr_impl () const override { return new MatchExpr (*this); }
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual MatchExpr *clone_expr_with_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ MatchExpr *clone_expr_with_block_impl () const override
{
return new MatchExpr (*this);
}
@@ -5124,16 +4230,16 @@ protected:
// Await expression AST node (pseudo-member variable access)
class AwaitExpr : public ExprWithoutBlock
{
- ::std::unique_ptr<Expr> awaited_expr;
+ std::unique_ptr<Expr> awaited_expr;
Location locus;
public:
// TODO: ensure outer attributes are actually allowed
- AwaitExpr (::std::unique_ptr<Expr> awaited_expr,
- ::std::vector<Attribute> outer_attrs, Location locus)
- : ExprWithoutBlock (::std::move (outer_attrs)),
- awaited_expr (::std::move (awaited_expr)), locus (locus)
+ AwaitExpr (std::unique_ptr<Expr> awaited_expr,
+ std::vector<Attribute> outer_attrs, Location locus)
+ : ExprWithoutBlock (std::move (outer_attrs)),
+ awaited_expr (std::move (awaited_expr)), locus (locus)
{}
// copy constructor with clone
@@ -5142,8 +4248,6 @@ public:
awaited_expr (other.awaited_expr->clone_expr ()), locus (other.locus)
{}
- // destructor - define here if required
-
// overloaded assignment operator with clone
AwaitExpr &operator= (AwaitExpr const &other)
{
@@ -5158,18 +4262,17 @@ public:
AwaitExpr (AwaitExpr &&other) = default;
AwaitExpr &operator= (AwaitExpr &&other) = default;
- ::std::string as_string () const;
+ std::string as_string () const override;
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual AwaitExpr *clone_expr_without_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ AwaitExpr *clone_expr_without_block_impl () const override
{
return new AwaitExpr (*this);
}
@@ -5180,15 +4283,15 @@ class AsyncBlockExpr : public ExprWithBlock
{
// TODO: should this extend BlockExpr rather than be a composite of it?
bool has_move;
- ::std::unique_ptr<BlockExpr> block_expr;
+ std::unique_ptr<BlockExpr> block_expr;
Location locus;
public:
- AsyncBlockExpr (::std::unique_ptr<BlockExpr> block_expr, bool has_move,
- ::std::vector<Attribute> outer_attrs, Location locus)
- : ExprWithBlock (::std::move (outer_attrs)), has_move (has_move),
- block_expr (::std::move (block_expr)), locus (locus)
+ AsyncBlockExpr (std::unique_ptr<BlockExpr> block_expr, bool has_move,
+ std::vector<Attribute> outer_attrs, Location locus)
+ : ExprWithBlock (std::move (outer_attrs)), has_move (has_move),
+ block_expr (std::move (block_expr)), locus (locus)
{}
// copy constructor with clone
@@ -5197,8 +4300,6 @@ public:
block_expr (other.block_expr->clone_block_expr ()), locus (other.locus)
{}
- // destructor - define if required
-
// overloaded assignment operator to clone
AsyncBlockExpr &operator= (AsyncBlockExpr const &other)
{
@@ -5214,18 +4315,17 @@ public:
AsyncBlockExpr (AsyncBlockExpr &&other) = default;
AsyncBlockExpr &operator= (AsyncBlockExpr &&other) = default;
- ::std::string as_string () const;
+ std::string as_string () const override;
Location get_locus () const { return locus; }
+ Location get_locus_slow () const override { return get_locus (); }
- Location get_locus_slow () const OVERRIDE { return get_locus (); }
-
- virtual void accept_vis (ASTVisitor &vis) OVERRIDE;
+ void accept_vis (ASTVisitor &vis) override;
protected:
- // Use covariance to implement clone function as returning this object rather
- // than base
- virtual AsyncBlockExpr *clone_expr_with_block_impl () const OVERRIDE
+ /* Use covariance to implement clone function as returning this object rather
+ * than base */
+ AsyncBlockExpr *clone_expr_with_block_impl () const override
{
return new AsyncBlockExpr (*this);
}