Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Expr.hpp

    r17a0228a r9b4f329  
    2828
    2929// Must be included in *all* AST classes; should be #undef'd at the end of the file
    30 #define MUTATE_FRIEND template<typename node_t> friend node_t * mutate(const node_t * node);
     30#define MUTATE_FRIEND template<typename node_t> friend auto mutate(const node_t * node);
    3131
    3232namespace ast {
     
    133133};
    134134
    135 /// The application of a function to a set of parameters.
     135/// The application of a function to a set of parameters. 
    136136/// Post-resolver form of `UntypedExpr`
    137137class ApplicationExpr final : public Expr {
     
    218218        GeneratedFlag isGenerated;
    219219
    220         CastExpr( const CodeLocation & loc, const Expr * a, const Type * to,
     220        CastExpr( const CodeLocation & loc, const Expr * a, const Type * to, 
    221221                GeneratedFlag g = GeneratedCast ) : Expr( loc, to ), arg( a ), isGenerated( g ) {}
    222222        /// Cast-to-void
     
    311311                unsigned long long ival;
    312312                double dval;
    313 
     313               
    314314                Val( unsigned long long i ) : ival( i ) {}
    315315                Val( double d ) : dval( d ) {}
     
    318318        std::string rep;
    319319
    320         ConstantExpr(
     320        ConstantExpr( 
    321321                const CodeLocation & loc, const Type * ty, const std::string & r, unsigned long long v )
    322322        : Expr( loc, ty ), val( v ), rep( r ) {}
    323323        ConstantExpr( const CodeLocation & loc, const Type * ty, const std::string & r, double v )
    324324        : Expr( loc, ty ), val( v ), rep( r ) {}
    325 
     325       
    326326        /// Gets the value of this constant as an integer
    327327        long long int intValue() const;
     
    464464        ptr<Expr> arg2;
    465465
    466         CommaExpr( const CodeLocation & loc, const Expr * a1, const Expr * a2 )
     466        CommaExpr( const CodeLocation & loc, const Expr * a1, const Expr * a2 ) 
    467467        : Expr( loc ), arg1( a1 ), arg2( a2 ) {}
    468468
     
    503503};
    504504
    505 /// The application of a function to a set of parameters, along with a set of copy constructor
     505/// The application of a function to a set of parameters, along with a set of copy constructor 
    506506/// calls, one for each argument
    507507class ImplicitCopyCtorExpr final : public Expr {
     
    603603};
    604604
    605 /// A multiple- or mass-assignment operation, or a tuple ctor/dtor expression.
    606 /// multiple-assignment: both sides of the assignment have tuple type,
     605/// A multiple- or mass-assignment operation, or a tuple ctor/dtor expression. 
     606/// multiple-assignment: both sides of the assignment have tuple type, 
    607607///     e.g. `[a, b, c] = [d, e, f];`
    608608/// mass-assignment: left-hand side has tuple type and right-hand side does not:
     
    612612        ptr<StmtExpr> stmtExpr;
    613613
    614         TupleAssignExpr(
    615                 const CodeLocation & loc, std::vector<ptr<Expr>> && assigns,
     614        TupleAssignExpr( 
     615                const CodeLocation & loc, std::vector<ptr<Expr>> && assigns, 
    616616                std::vector<ptr<ObjectDecl>> && tempDecls );
    617 
     617       
    618618        const Expr * accept( Visitor & v ) const override { return v.visit( this ); }
    619619private:
     
    754754};
    755755
    756 
     756//=================================================================================================
     757/// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency
     758/// remove only if there is a better solution
     759/// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with
     760/// forward declarations
     761inline void increment( const class Expr * node, Node::ref_type ref ) { node->increment(ref); }
     762inline void decrement( const class Expr * node, Node::ref_type ref ) { node->decrement(ref); }
     763inline void increment( const class ApplicationExpr * node, Node::ref_type ref ) { node->increment(ref); }
     764inline void decrement( const class ApplicationExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     765inline void increment( const class UntypedExpr * node, Node::ref_type ref ) { node->increment(ref); }
     766inline void decrement( const class UntypedExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     767inline void increment( const class NameExpr * node, Node::ref_type ref ) { node->increment(ref); }
     768inline void decrement( const class NameExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     769inline void increment( const class AddressExpr * node, Node::ref_type ref ) { node->increment(ref); }
     770inline void decrement( const class AddressExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     771inline void increment( const class LabelAddressExpr * node, Node::ref_type ref ) { node->increment(ref); }
     772inline void decrement( const class LabelAddressExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     773inline void increment( const class CastExpr * node, Node::ref_type ref ) { node->increment(ref); }
     774inline void decrement( const class CastExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     775inline void increment( const class KeywordCastExpr * node, Node::ref_type ref ) { node->increment(ref); }
     776inline void decrement( const class KeywordCastExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     777inline void increment( const class VirtualCastExpr * node, Node::ref_type ref ) { node->increment(ref); }
     778inline void decrement( const class VirtualCastExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     779inline void increment( const class MemberExpr * node, Node::ref_type ref ) { node->increment(ref); }
     780inline void decrement( const class MemberExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     781inline void increment( const class UntypedMemberExpr * node, Node::ref_type ref ) { node->increment(ref); }
     782inline void decrement( const class UntypedMemberExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     783inline void increment( const class VariableExpr * node, Node::ref_type ref ) { node->increment(ref); }
     784inline void decrement( const class VariableExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     785inline void increment( const class ConstantExpr * node, Node::ref_type ref ) { node->increment(ref); }
     786inline void decrement( const class ConstantExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     787inline void increment( const class SizeofExpr * node, Node::ref_type ref ) { node->increment(ref); }
     788inline void decrement( const class SizeofExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     789inline void increment( const class AlignofExpr * node, Node::ref_type ref ) { node->increment(ref); }
     790inline void decrement( const class AlignofExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     791inline void increment( const class UntypedOffsetofExpr * node, Node::ref_type ref ) { node->increment(ref); }
     792inline void decrement( const class UntypedOffsetofExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     793inline void increment( const class OffsetofExpr * node, Node::ref_type ref ) { node->increment(ref); }
     794inline void decrement( const class OffsetofExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     795inline void increment( const class OffsetPackExpr * node, Node::ref_type ref ) { node->increment(ref); }
     796inline void decrement( const class OffsetPackExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     797inline void increment( const class LogicalExpr * node, Node::ref_type ref ) { node->increment(ref); }
     798inline void decrement( const class LogicalExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     799inline void increment( const class ConditionalExpr * node, Node::ref_type ref ) { node->increment(ref); }
     800inline void decrement( const class ConditionalExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     801inline void increment( const class CommaExpr * node, Node::ref_type ref ) { node->increment(ref); }
     802inline void decrement( const class CommaExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     803inline void increment( const class TypeExpr * node, Node::ref_type ref ) { node->increment(ref); }
     804inline void decrement( const class TypeExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     805inline void increment( const class AsmExpr * node, Node::ref_type ref ) { node->increment(ref); }
     806inline void decrement( const class AsmExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     807inline void increment( const class ImplicitCopyCtorExpr * node, Node::ref_type ref ) { node->increment(ref); }
     808inline void decrement( const class ImplicitCopyCtorExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     809inline void increment( const class ConstructorExpr * node, Node::ref_type ref ) { node->increment(ref); }
     810inline void decrement( const class ConstructorExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     811inline void increment( const class CompoundLiteralExpr * node, Node::ref_type ref ) { node->increment(ref); }
     812inline void decrement( const class CompoundLiteralExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     813inline void increment( const class RangeExpr * node, Node::ref_type ref ) { node->increment(ref); }
     814inline void decrement( const class RangeExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     815inline void increment( const class UntypedTupleExpr * node, Node::ref_type ref ) { node->increment(ref); }
     816inline void decrement( const class UntypedTupleExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     817inline void increment( const class TupleExpr * node, Node::ref_type ref ) { node->increment(ref); }
     818inline void decrement( const class TupleExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     819inline void increment( const class TupleIndexExpr * node, Node::ref_type ref ) { node->increment(ref); }
     820inline void decrement( const class TupleIndexExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     821inline void increment( const class TupleAssignExpr * node, Node::ref_type ref ) { node->increment(ref); }
     822inline void decrement( const class TupleAssignExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     823inline void increment( const class StmtExpr * node, Node::ref_type ref ) { node->increment(ref); }
     824inline void decrement( const class StmtExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     825inline void increment( const class UniqueExpr * node, Node::ref_type ref ) { node->increment(ref); }
     826inline void decrement( const class UniqueExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     827inline void increment( const class UntypedInitExpr * node, Node::ref_type ref ) { node->increment(ref); }
     828inline void decrement( const class UntypedInitExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     829inline void increment( const class InitExpr * node, Node::ref_type ref ) { node->increment(ref); }
     830inline void decrement( const class InitExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     831inline void increment( const class DeletedExpr * node, Node::ref_type ref ) { node->increment(ref); }
     832inline void decrement( const class DeletedExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     833inline void increment( const class DefaultArgExpr * node, Node::ref_type ref ) { node->increment(ref); }
     834inline void decrement( const class DefaultArgExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     835inline void increment( const class GenericExpr * node, Node::ref_type ref ) { node->increment(ref); }
     836inline void decrement( const class GenericExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    757837}
    758838
Note: See TracChangeset for help on using the changeset viewer.