Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Expr.hpp

    rf3cc5b6 r87701b6  
    2727#include "Visitor.hpp"
    2828
    29 // 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 auto mutate(const node_t * node);
    31 
    3229namespace ast {
    3330
     
    130127private:
    131128        Expr * clone() const override = 0;
    132         MUTATE_FRIEND
    133 };
    134 
    135 /// The application of a function to a set of parameters.
     129};
     130
     131/// The application of a function to a set of parameters.
    136132/// Post-resolver form of `UntypedExpr`
    137133class ApplicationExpr final : public Expr {
     
    145141private:
    146142        ApplicationExpr * clone() const override { return new ApplicationExpr{ *this }; }
    147         MUTATE_FRIEND
    148143};
    149144
     
    165160private:
    166161        UntypedExpr * clone() const override { return new UntypedExpr{ *this }; }
    167         MUTATE_FRIEND
    168162};
    169163
     
    179173private:
    180174        NameExpr * clone() const override { return new NameExpr{ *this }; }
    181         MUTATE_FRIEND
    182175};
    183176
     
    192185private:
    193186        AddressExpr * clone() const override { return new AddressExpr{ *this }; }
    194         MUTATE_FRIEND
    195187};
    196188
     
    206198private:
    207199        LabelAddressExpr * clone() const override { return new LabelAddressExpr{ *this }; }
    208         MUTATE_FRIEND
    209200};
    210201
     
    218209        GeneratedFlag isGenerated;
    219210
    220         CastExpr( const CodeLocation & loc, const Expr * a, const Type * to, 
     211        CastExpr( const CodeLocation & loc, const Expr * a, const Type * to,
    221212                GeneratedFlag g = GeneratedCast ) : Expr( loc, to ), arg( a ), isGenerated( g ) {}
    222213        /// Cast-to-void
     
    226217private:
    227218        CastExpr * clone() const override { return new CastExpr{ *this }; }
    228         MUTATE_FRIEND
    229219};
    230220
     
    244234private:
    245235        KeywordCastExpr * clone() const override { return new KeywordCastExpr{ *this }; }
    246         MUTATE_FRIEND
    247236};
    248237
     
    258247private:
    259248        VirtualCastExpr * clone() const override { return new VirtualCastExpr{ *this }; }
    260         MUTATE_FRIEND
    261249};
    262250
     
    273261private:
    274262        UntypedMemberExpr * clone() const override { return new UntypedMemberExpr{ *this }; }
    275         MUTATE_FRIEND
    276263};
    277264
     
    287274private:
    288275        MemberExpr * clone() const override { return new MemberExpr{ *this }; }
    289         MUTATE_FRIEND
    290276};
    291277
     
    303289private:
    304290        VariableExpr * clone() const override { return new VariableExpr{ *this }; }
    305         MUTATE_FRIEND
    306291};
    307292
     
    311296                unsigned long long ival;
    312297                double dval;
    313                
     298
    314299                Val( unsigned long long i ) : ival( i ) {}
    315300                Val( double d ) : dval( d ) {}
     
    318303        std::string rep;
    319304
    320         ConstantExpr( 
     305        ConstantExpr(
    321306                const CodeLocation & loc, const Type * ty, const std::string & r, unsigned long long v )
    322307        : Expr( loc, ty ), val( v ), rep( r ) {}
    323308        ConstantExpr( const CodeLocation & loc, const Type * ty, const std::string & r, double v )
    324309        : Expr( loc, ty ), val( v ), rep( r ) {}
    325        
     310
    326311        /// Gets the value of this constant as an integer
    327312        long long int intValue() const;
     
    347332private:
    348333        ConstantExpr * clone() const override { return new ConstantExpr{ *this }; }
    349         MUTATE_FRIEND
    350334};
    351335
     
    363347private:
    364348        SizeofExpr * clone() const override { return new SizeofExpr{ *this }; }
    365         MUTATE_FRIEND
    366349};
    367350
     
    379362private:
    380363        AlignofExpr * clone() const override { return new AlignofExpr{ *this }; }
    381         MUTATE_FRIEND
    382364};
    383365
     
    394376private:
    395377        UntypedOffsetofExpr * clone() const override { return new UntypedOffsetofExpr{ *this }; }
    396         MUTATE_FRIEND
    397378};
    398379
     
    408389private:
    409390        OffsetofExpr * clone() const override { return new OffsetofExpr{ *this }; }
    410         MUTATE_FRIEND
    411391};
    412392
     
    421401private:
    422402        OffsetPackExpr * clone() const override { return new OffsetPackExpr{ *this }; }
    423         MUTATE_FRIEND
    424403};
    425404
     
    439418private:
    440419        LogicalExpr * clone() const override { return new LogicalExpr{ *this }; }
    441         MUTATE_FRIEND
    442420};
    443421
     
    455433private:
    456434        ConditionalExpr * clone() const override { return new ConditionalExpr{ *this }; }
    457         MUTATE_FRIEND
    458435};
    459436
     
    464441        ptr<Expr> arg2;
    465442
    466         CommaExpr( const CodeLocation & loc, const Expr * a1, const Expr * a2 ) 
     443        CommaExpr( const CodeLocation & loc, const Expr * a1, const Expr * a2 )
    467444        : Expr( loc ), arg1( a1 ), arg2( a2 ) {}
    468445
     
    470447private:
    471448        CommaExpr * clone() const override { return new CommaExpr{ *this }; }
    472         MUTATE_FRIEND
    473449};
    474450
     
    483459private:
    484460        TypeExpr * clone() const override { return new TypeExpr{ *this }; }
    485         MUTATE_FRIEND
    486461};
    487462
     
    491466public:
    492467        ptr<Expr> inout;
    493         ptr<Expr> constraint;
    494 };
    495 
    496 //=================================================================================================
    497 /// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency
    498 /// remove only if there is a better solution
    499 /// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with
    500 /// forward declarations
    501 inline void increment( const class Expr * node, Node::ref_type ref ) { node->increment(ref); }
    502 inline void decrement( const class Expr * node, Node::ref_type ref ) { node->decrement(ref); }
    503 inline void increment( const class ApplicationExpr * node, Node::ref_type ref ) { node->increment(ref); }
    504 inline void decrement( const class ApplicationExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    505 inline void increment( const class UntypedExpr * node, Node::ref_type ref ) { node->increment(ref); }
    506 inline void decrement( const class UntypedExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    507 inline void increment( const class NameExpr * node, Node::ref_type ref ) { node->increment(ref); }
    508 inline void decrement( const class NameExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    509 inline void increment( const class AddressExpr * node, Node::ref_type ref ) { node->increment(ref); }
    510 inline void decrement( const class AddressExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    511 inline void increment( const class LabelAddressExpr * node, Node::ref_type ref ) { node->increment(ref); }
    512 inline void decrement( const class LabelAddressExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    513 inline void increment( const class CastExpr * node, Node::ref_type ref ) { node->increment(ref); }
    514 inline void decrement( const class CastExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    515 inline void increment( const class KeywordCastExpr * node, Node::ref_type ref ) { node->increment(ref); }
    516 inline void decrement( const class KeywordCastExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    517 inline void increment( const class VirtualCastExpr * node, Node::ref_type ref ) { node->increment(ref); }
    518 inline void decrement( const class VirtualCastExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    519 inline void increment( const class MemberExpr * node, Node::ref_type ref ) { node->increment(ref); }
    520 inline void decrement( const class MemberExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    521 inline void increment( const class UntypedMemberExpr * node, Node::ref_type ref ) { node->increment(ref); }
    522 inline void decrement( const class UntypedMemberExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    523 inline void increment( const class VariableExpr * node, Node::ref_type ref ) { node->increment(ref); }
    524 inline void decrement( const class VariableExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    525 inline void increment( const class ConstantExpr * node, Node::ref_type ref ) { node->increment(ref); }
    526 inline void decrement( const class ConstantExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    527 inline void increment( const class SizeofExpr * node, Node::ref_type ref ) { node->increment(ref); }
    528 inline void decrement( const class SizeofExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    529 inline void increment( const class AlignofExpr * node, Node::ref_type ref ) { node->increment(ref); }
    530 inline void decrement( const class AlignofExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    531 inline void increment( const class UntypedOffsetofExpr * node, Node::ref_type ref ) { node->increment(ref); }
    532 inline void decrement( const class UntypedOffsetofExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    533 inline void increment( const class OffsetofExpr * node, Node::ref_type ref ) { node->increment(ref); }
    534 inline void decrement( const class OffsetofExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    535 inline void increment( const class OffsetPackExpr * node, Node::ref_type ref ) { node->increment(ref); }
    536 inline void decrement( const class OffsetPackExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    537 inline void increment( const class LogicalExpr * node, Node::ref_type ref ) { node->increment(ref); }
    538 inline void decrement( const class LogicalExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    539 inline void increment( const class ConditionalExpr * node, Node::ref_type ref ) { node->increment(ref); }
    540 inline void decrement( const class ConditionalExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    541 inline void increment( const class CommaExpr * node, Node::ref_type ref ) { node->increment(ref); }
    542 inline void decrement( const class CommaExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    543 inline void increment( const class TypeExpr * node, Node::ref_type ref ) { node->increment(ref); }
    544 inline void decrement( const class TypeExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    545 inline void increment( const class AsmExpr * node, Node::ref_type ref ) { node->increment(ref); }
    546 inline void decrement( const class AsmExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    547 // inline void increment( const class ImplicitCopyCtorExpr * node, Node::ref_type ref ) { node->increment(ref); }
    548 // inline void decrement( const class ImplicitCopyCtorExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    549 // inline void increment( const class ConstructorExpr * node, Node::ref_type ref ) { node->increment(ref); }
    550 // inline void decrement( const class ConstructorExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    551 // inline void increment( const class CompoundLiteralExpr * node, Node::ref_type ref ) { node->increment(ref); }
    552 // inline void decrement( const class CompoundLiteralExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    553 // inline void increment( const class UntypedValofExpr * node, Node::ref_type ref ) { node->increment(ref); }
    554 // inline void decrement( const class UntypedValofExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    555 // inline void increment( const class RangeExpr * node, Node::ref_type ref ) { node->increment(ref); }
    556 // inline void decrement( const class RangeExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    557 // inline void increment( const class UntypedTupleExpr * node, Node::ref_type ref ) { node->increment(ref); }
    558 // inline void decrement( const class UntypedTupleExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    559 // inline void increment( const class TupleExpr * node, Node::ref_type ref ) { node->increment(ref); }
    560 // inline void decrement( const class TupleExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    561 // inline void increment( const class TupleIndexExpr * node, Node::ref_type ref ) { node->increment(ref); }
    562 // inline void decrement( const class TupleIndexExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    563 // inline void increment( const class TupleAssignExpr * node, Node::ref_type ref ) { node->increment(ref); }
    564 // inline void decrement( const class TupleAssignExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    565 // inline void increment( const class StmtExpr * node, Node::ref_type ref ) { node->increment(ref); }
    566 // inline void decrement( const class StmtExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    567 // inline void increment( const class UniqueExpr * node, Node::ref_type ref ) { node->increment(ref); }
    568 // inline void decrement( const class UniqueExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    569 // inline void increment( const class UntypedInitExpr * node, Node::ref_type ref ) { node->increment(ref); }
    570 // inline void decrement( const class UntypedInitExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    571 // inline void increment( const class InitExpr * node, Node::ref_type ref ) { node->increment(ref); }
    572 // inline void decrement( const class InitExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    573 // inline void increment( const class DeletedExpr * node, Node::ref_type ref ) { node->increment(ref); }
    574 // inline void decrement( const class DeletedExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    575 // inline void increment( const class DefaultArgExpr * node, Node::ref_type ref ) { node->increment(ref); }
    576 // inline void decrement( const class DefaultArgExpr * node, Node::ref_type ref ) { node->decrement(ref); }
    577 // inline void increment( const class GenericExpr * node, Node::ref_type ref ) { node->increment(ref); }
    578 // inline void decrement( const class GenericExpr * node, Node::ref_type ref ) { node->decrement(ref); }
     468        ptr<Expr> constraint;
     469};
     470
    579471}
    580 
    581 #undef MUTATE_FRIEND
    582472
    583473// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.