Changes in / [41b24c8:e61207e7]


Ignore:
Files:
2 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/coroutine.hfa

    r41b24c8 re61207e7  
    4949
    5050forall(dtype T | is_coroutine(T))
    51 static inline T & resume(T & cor);
     51static inline void resume(T & cor);
    5252
    5353forall(dtype T | is_coroutine(T))
  • src/AST/Convert.cpp

    r41b24c8 re61207e7  
    135135                decl->parent = parent;
    136136                decl->body   = old->body;
    137                 decl->params = params;
     137                decl->parameters = params;
    138138                decl->members    = members;
    139139                decl->extension  = old->extension;
     
    592592
    593593        }
    594 
    595         virtual void visit( AttrExpr * ) override final {
    596 
    597                 assert( 0 );
    598         }
    599594};
    600595
  • src/AST/Decl.hpp

    r41b24c8 re61207e7  
    3030#include "Parser/ParseNode.h"  // for DeclarationNode::Aggregate
    3131
    32 // Must be included in *all* AST classes; should be #undef'd at the end of the file
    33 #define MUTATE_FRIEND template<typename node_t> friend node_t * mutate(const node_t * node);
    34 
    3532namespace ast {
    3633
     
    5855private:
    5956        Decl * clone() const override = 0;
    60         MUTATE_FRIEND
    6157};
    6258
     
    9187private:
    9288        DeclWithType * clone() const override = 0;
    93         MUTATE_FRIEND
    9489};
    9590
     
    113108private:
    114109        ObjectDecl * clone() const override { return new ObjectDecl{ *this }; }
    115         MUTATE_FRIEND
     110
     111        /// Must be copied in ALL derived classes
     112        template<typename node_t>
     113        friend node_t * mutate(const node_t * node);
    116114};
    117115
     
    137135private:
    138136        FunctionDecl * clone() const override { return new FunctionDecl( *this ); }
    139         MUTATE_FRIEND
     137
     138        /// Must be copied in ALL derived classes
     139        template<typename node_t>
     140        friend node_t * mutate(const node_t * node);
    140141};
    141142
     
    156157private:
    157158        NamedTypeDecl* clone() const override = 0;
    158         MUTATE_FRIEND
    159159};
    160160
     
    198198private:
    199199        TypeDecl * clone() const override { return new TypeDecl{ *this }; }
    200         MUTATE_FRIEND
     200
     201        /// Must be copied in ALL derived classes
     202        template<typename node_t>
     203        friend node_t * mutate(const node_t * node);
    201204};
    202205
     
    213216private:
    214217        TypedefDecl * clone() const override { return new TypedefDecl{ *this }; }
    215         MUTATE_FRIEND
     218
     219        /// Must be copied in ALL derived classes
     220        template<typename node_t>
     221        friend node_t * mutate(const node_t * node);
    216222};
    217223
     
    232238        AggregateDecl* set_body( bool b ) { body = b; return this; }
    233239
    234 private:
    235         AggregateDecl * clone() const override = 0;
    236         MUTATE_FRIEND
    237 
    238240protected:
    239241        /// Produces a name for the kind of aggregate
     
    258260private:
    259261        StructDecl * clone() const override { return new StructDecl{ *this }; }
    260         MUTATE_FRIEND
     262
     263        /// Must be copied in ALL derived classes
     264        template<typename node_t>
     265        friend node_t * mutate(const node_t * node);
    261266
    262267        std::string typeString() const override { return "struct"; }
     
    273278private:
    274279        UnionDecl * clone() const override { return new UnionDecl{ *this }; }
    275         MUTATE_FRIEND
     280
     281        /// Must be copied in ALL derived classes
     282        template<typename node_t>
     283        friend node_t * mutate(const node_t * node);
    276284
    277285        std::string typeString() const override { return "union"; }
     
    291299private:
    292300        EnumDecl * clone() const override { return new EnumDecl{ *this }; }
    293         MUTATE_FRIEND
     301
     302        /// Must be copied in ALL derived classes
     303        template<typename node_t>
     304        friend node_t * mutate(const node_t * node);
    294305
    295306        std::string typeString() const override { return "enum"; }
     
    309320private:
    310321        TraitDecl * clone() const override { return new TraitDecl{ *this }; }
    311         MUTATE_FRIEND
     322
     323        /// Must be copied in ALL derived classes
     324        template<typename node_t>
     325        friend node_t * mutate(const node_t * node);
    312326
    313327        std::string typeString() const override { return "trait"; }
     
    324338private:
    325339        AsmDecl *clone() const override { return new AsmDecl( *this ); }
    326         MUTATE_FRIEND
     340
     341        /// Must be copied in ALL derived classes
     342        template<typename node_t>
     343        friend node_t * mutate(const node_t * node);
    327344};
    328345
     
    338355private:
    339356        StaticAssertDecl * clone() const override { return new StaticAssertDecl( *this ); }
    340         MUTATE_FRIEND
     357
     358        /// Must be copied in ALL derived classes
     359        template<typename node_t>
     360        friend node_t * mutate(const node_t * node);
    341361};
    342362
    343363}
    344 
    345 #undef MUTATE_FRIEND
    346364
    347365// Local Variables: //
  • src/AST/Expr.hpp

    r41b24c8 re61207e7  
    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
    133129};
    134130
     
    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
     
    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
     
    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
     
    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
     
    495470
    496471}
    497 
    498 #undef MUTATE_FRIEND
    499472
    500473// Local Variables: //
  • src/AST/Init.hpp

    r41b24c8 re61207e7  
    2323#include "Visitor.hpp"
    2424
    25 // Must be included in *all* AST classes; should be #undef'd at the end of the file
    26 #define MUTATE_FRIEND template<typename node_t> friend node_t * mutate(const node_t * node);
    27 
    2825namespace ast {
    2926
     
    4340private:
    4441        Designation* clone() const override { return new Designation{ *this }; }
    45         MUTATE_FRIEND
    4642};
    4743
     
    5955private:
    6056        Init * clone() const override = 0;
    61         MUTATE_FRIEND
    6257};
    6358
     
    7469private:
    7570        SingleInit * clone() const override { return new SingleInit{ *this }; }
    76         MUTATE_FRIEND
     71
     72        /// Must be copied in ALL derived classes
     73        template<typename node_t>
     74        friend node_t * mutate(const node_t * node);
    7775};
    7876
     
    9997private:
    10098        ListInit * clone() const override { return new ListInit{ *this }; }
    101         MUTATE_FRIEND
     99
     100        /// Must be copied in ALL derived classes
     101        template<typename node_t>
     102        friend node_t * mutate(const node_t * node);
    102103};
    103104
     
    119120private:
    120121        ConstructorInit * clone() const override { return new ConstructorInit{ *this }; }
    121         MUTATE_FRIEND
     122
     123        /// Must be copied in ALL derived classes
     124        template<typename node_t>
     125        friend node_t * mutate(const node_t * node);
    122126};
    123127
    124128}
    125 
    126 #undef MUTATE_FRIEND
    127129
    128130// Local Variables: //
  • src/AST/Pass.impl.hpp

    r41b24c8 re61207e7  
    1919#include <type_traits>
    2020#include <unordered_map>
    21 
    22 #include "AST/TypeSubstitution.hpp"
    2321
    2422#define VISIT_START( node ) \
  • src/AST/Stmt.hpp

    r41b24c8 re61207e7  
    2626#include "Common/CodeLocation.h"
    2727
    28 // Must be included in *all* AST classes; should be #undef'd at the end of the file
    29 #define MUTATE_FRIEND template<typename node_t> friend auto mutate(const node_t * node);
    30 
    3128namespace ast {
    3229
     
    3835        std::vector<Label> labels;
    3936
    40         Stmt( const CodeLocation & loc, std::vector<Label> && labels = {} )
     37        Stmt( const CodeLocation& loc, std::vector<Label>&& labels = {} )
    4138        : ParseNode(loc), labels(std::move(labels)) {}
    4239
    4340        Stmt(const Stmt& o) : ParseNode(o), labels(o.labels) {}
    4441
    45         const Stmt * accept( Visitor & v ) const override = 0;
    46 private:
    47         Stmt * clone() const override = 0;
    48         MUTATE_FRIEND
     42        const Stmt* accept( Visitor& v ) const override = 0;
     43private:
     44        Stmt* clone() const override = 0;
    4945};
    5046
     
    5450        std::list<ptr<Stmt>> kids;
    5551
    56         CompoundStmt(const CodeLocation & loc, std::list<ptr<Stmt>> && ks = {} )
     52        CompoundStmt(const CodeLocation& loc, std::list<ptr<Stmt>>&& ks = {} )
    5753        : Stmt(loc), kids(std::move(ks)) {}
    5854
     
    6056        CompoundStmt( CompoundStmt&& o ) = default;
    6157
    62         void push_back( Stmt * s ) { kids.emplace_back( s ); }
    63         void push_front( Stmt * s ) { kids.emplace_front( s ); }
    64 
    65         const CompoundStmt * accept( Visitor & v ) const override { return v.visit( this ); }
    66 private:
    67         CompoundStmt * clone() const override { return new CompoundStmt{ *this }; }
    68         MUTATE_FRIEND
     58        void push_back( Stmt* s ) { kids.emplace_back( s ); }
     59        void push_front( Stmt* s ) { kids.emplace_front( s ); }
     60
     61        const CompoundStmt* accept( Visitor& v ) const override { return v.visit( this ); }
     62private:
     63        CompoundStmt* clone() const override { return new CompoundStmt{ *this }; }
     64
     65        /// Must be copied in ALL derived classes
     66        template<typename node_t>
     67        friend node_t * mutate(const node_t * node);
    6968};
    7069
     
    7271class NullStmt final : public Stmt {
    7372public:
    74         NullStmt( const CodeLocation & loc, std::vector<Label> && labels = {} )
     73        NullStmt( const CodeLocation& loc, std::vector<Label>&& labels = {} )
    7574        : Stmt(loc, std::move(labels)) {}
    7675
    77         const NullStmt * accept( Visitor & v ) const override { return v.visit( this ); }
    78 private:
    79         NullStmt * clone() const override { return new NullStmt{ *this }; }
    80         MUTATE_FRIEND
     76        const NullStmt* accept( Visitor& v ) const override { return v.visit( this ); }
     77private:
     78        NullStmt* clone() const override { return new NullStmt{ *this }; }
     79
     80        /// Must be copied in ALL derived classes
     81        template<typename node_t>
     82        friend node_t * mutate(const node_t * node);
    8183};
    8284
     
    8890        ExprStmt( const CodeLocation & loc, const Expr * e ) : Stmt(loc), expr(e) {}
    8991
    90         const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
     92        const Stmt * accept( Visitor& v ) const override { return v.visit( this ); }
    9193private:
    9294        ExprStmt * clone() const override { return new ExprStmt{ *this }; }
    93         MUTATE_FRIEND
     95
     96        /// Must be copied in ALL derived classes
     97        template<typename node_t>
     98        friend node_t * mutate(const node_t * node);
    9499};
    95100
     
    102107        std::vector<Label> gotoLabels;
    103108
    104         AsmStmt( const CodeLocation & loc, bool isVolatile, const Expr * instruction,
    105                 std::vector<ptr<Expr>> && output, std::vector<ptr<Expr>> && input,
    106                 std::vector<ptr<ConstantExpr>> && clobber, std::vector<Label> && gotoLabels,
    107                 std::vector<Label> && labels = {})
     109        AsmStmt( const CodeLocation& loc, bool isVolatile, const Expr * instruction,
     110                std::vector<ptr<Expr>>&& output, std::vector<ptr<Expr>>&& input,
     111                std::vector<ptr<ConstantExpr>>&& clobber, std::vector<Label>&& gotoLabels,
     112                std::vector<Label>&& labels = {})
    108113        : Stmt(loc, std::move(labels)), isVolatile(isVolatile), instruction(instruction),
    109114          output(std::move(output)), input(std::move(input)), clobber(std::move(clobber)),
    110115          gotoLabels(std::move(gotoLabels)) {}
    111116
    112         const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
    113 private:
    114         AsmStmt * clone() const override { return new AsmStmt{ *this }; }
    115         MUTATE_FRIEND
     117        const Stmt* accept( Visitor& v ) const override { return v.visit( this ); }
     118private:
     119        AsmStmt* clone() const override { return new AsmStmt{ *this }; }
     120
     121        /// Must be copied in ALL derived classes
     122        template<typename node_t>
     123        friend node_t * mutate(const node_t * node);
    116124};
    117125
     
    120128        std::string directive;
    121129
    122         DirectiveStmt( const CodeLocation & loc, const std::string & directive,
    123                 std::vector<Label> && labels = {} )
     130        DirectiveStmt( const CodeLocation& loc, const std::string & directive,
     131                std::vector<Label>&& labels = {} )
    124132        : Stmt(loc, std::move(labels)), directive(directive) {}
    125133
    126         const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
    127 private:
    128         DirectiveStmt * clone() const override { return new DirectiveStmt{ *this }; }
    129         MUTATE_FRIEND
     134        const Stmt* accept( Visitor& v ) const override { return v.visit( this ); }
     135private:
     136        DirectiveStmt* clone() const override { return new DirectiveStmt{ *this }; }
     137
     138        /// Must be copied in ALL derived classes
     139        template<typename node_t>
     140        friend node_t * mutate(const node_t * node);
    130141};
    131142
     
    137148        std::vector<ptr<Stmt>> inits;
    138149
    139         IfStmt( const CodeLocation & loc, const Expr * cond, const Stmt * thenPart,
    140                 Stmt * const elsePart, std::vector<ptr<Stmt>> && inits,
    141                 std::vector<Label> && labels = {} )
     150        IfStmt( const CodeLocation& loc, const Expr* cond, const Stmt* thenPart,
     151                Stmt * const elsePart, std::vector<ptr<Stmt>>&& inits,
     152                std::vector<Label>&& labels = {} )
    142153        : Stmt(loc, std::move(labels)), cond(cond), thenPart(thenPart), elsePart(elsePart),
    143154          inits(std::move(inits)) {}
    144155
    145         const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
    146 private:
    147         IfStmt * clone() const override { return new IfStmt{ *this }; }
    148         MUTATE_FRIEND
     156        const Stmt* accept( Visitor& v ) const override { return v.visit( this ); }
     157private:
     158        IfStmt* clone() const override { return new IfStmt{ *this }; }
     159
     160        /// Must be copied in ALL derived classes
     161        template<typename node_t>
     162        friend node_t * mutate(const node_t * node);
    149163};
    150164
     
    154168        std::vector<ptr<Stmt>> stmts;
    155169
    156         SwitchStmt( const CodeLocation & loc, const Expr * cond, std::vector<ptr<Stmt>> && stmts,
    157                 std::vector<Label> && labels = {} )
     170        SwitchStmt( const CodeLocation& loc, const Expr* cond, std::vector<ptr<Stmt>>&& stmts,
     171                std::vector<Label>&& labels = {} )
    158172        : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {}
    159173
    160         const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
    161 private:
    162         SwitchStmt * clone() const override { return new SwitchStmt{ *this }; }
    163         MUTATE_FRIEND
     174        const Stmt* accept( Visitor& v ) const override { return v.visit( this ); }
     175private:
     176        SwitchStmt* clone() const override { return new SwitchStmt{ *this }; }
     177
     178        /// Must be copied in ALL derived classes
     179        template<typename node_t>
     180        friend node_t * mutate(const node_t * node);
    164181};
    165182
     
    169186        std::vector<ptr<Stmt>> stmts;
    170187
    171         CaseStmt( const CodeLocation & loc, const Expr * cond, std::vector<ptr<Stmt>> && stmts,
    172                 std::vector<Label> && labels = {} )
    173         : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {}
     188    CaseStmt( const CodeLocation& loc, const Expr* cond, std::vector<ptr<Stmt>>&& stmts,
     189        std::vector<Label>&& labels = {} )
     190    : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {}
    174191
    175192        bool isDefault() { return !cond; }
    176193
    177         const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
    178 private:
    179         CaseStmt * clone() const override { return new CaseStmt{ *this }; }
    180         MUTATE_FRIEND
     194        const Stmt* accept( Visitor& v ) const override { return v.visit( this ); }
     195private:
     196        CaseStmt* clone() const override { return new CaseStmt{ *this }; }
     197
     198        /// Must be copied in ALL derived classes
     199        template<typename node_t>
     200        friend node_t * mutate(const node_t * node);
    181201};
    182202
     
    188208        bool isDoWhile;
    189209
    190         WhileStmt( const CodeLocation & loc, const Expr * cond, const Stmt * body,
    191                 std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, std::vector<Label> && labels = {} )
     210        WhileStmt( const CodeLocation& loc, const Expr* cond, const Stmt* body,
     211                std::vector<ptr<Stmt>>&& inits, bool isDoWhile = false, std::vector<Label>&& labels = {} )
    192212        : Stmt(loc, std::move(labels)), cond(cond), body(body), inits(std::move(inits)),
    193213          isDoWhile(isDoWhile) {}
    194214
    195         const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
    196 private:
    197         WhileStmt * clone() const override { return new WhileStmt{ *this }; }
    198         MUTATE_FRIEND
     215        const Stmt* accept( Visitor& v ) const override { return v.visit( this ); }
     216private:
     217        WhileStmt* clone() const override { return new WhileStmt{ *this }; }
     218
     219        /// Must be copied in ALL derived classes
     220        template<typename node_t>
     221        friend node_t * mutate(const node_t * node);
    199222};
    200223
     
    206229        ptr<Stmt> body;
    207230
    208         ForStmt( const CodeLocation & loc, std::vector<ptr<Stmt>> && inits, const Expr * cond,
    209                 const Expr * inc, const Stmt * body, std::vector<Label> && labels = {} )
     231        ForStmt( const CodeLocation& loc, std::vector<ptr<Stmt>>&& inits, const Expr* cond,
     232                const Expr* inc, const Stmt* body, std::vector<Label>&& labels = {} )
    210233        : Stmt(loc, std::move(labels)), inits(std::move(inits)), cond(cond), inc(inc),
    211234          body(body) {}
    212235
    213         const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
    214 private:
    215         ForStmt * clone() const override { return new ForStmt{ *this }; }
    216         MUTATE_FRIEND
     236        const Stmt* accept( Visitor& v ) const override { return v.visit( this ); }
     237private:
     238        ForStmt* clone() const override { return new ForStmt{ *this }; }
     239
     240        /// Must be copied in ALL derived classes
     241        template<typename node_t>
     242        friend node_t * mutate(const node_t * node);
    217243};
    218244
     
    227253        Kind kind;
    228254
    229         BranchStmt( const CodeLocation & loc, Kind kind, Label target,
    230                 std::vector<Label> && labels = {} );
    231         BranchStmt( const CodeLocation & loc, const Expr * computedTarget,
    232                 std::vector<Label> && labels = {} )
     255        BranchStmt( const CodeLocation& loc, Kind kind, Label target,
     256                std::vector<Label>&& labels = {} );
     257        BranchStmt( const CodeLocation& loc, const Expr* computedTarget,
     258                std::vector<Label>&& labels = {} )
    233259        : Stmt(loc, std::move(labels)), originalTarget(loc), target(loc),
    234260          computedTarget(computedTarget), kind(Goto) {}
     
    236262        const char * kindName() { return kindNames[kind]; }
    237263
    238         const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
    239 private:
    240         BranchStmt * clone() const override { return new BranchStmt{ *this }; }
    241         MUTATE_FRIEND
     264        const Stmt* accept( Visitor& v ) const override { return v.visit( this ); }
     265private:
     266        BranchStmt* clone() const override { return new BranchStmt{ *this }; }
     267
     268        /// Must be copied in ALL derived classes
     269        template<typename node_t>
     270        friend node_t * mutate(const node_t * node);
    242271
    243272        static const char * kindNames[kindEnd];
     
    248277        ptr<Expr> expr;
    249278
    250         ReturnStmt( const CodeLocation & loc, const Expr * expr, std::vector<Label> && labels = {} )
     279        ReturnStmt( const CodeLocation& loc, const Expr* expr, std::vector<Label>&& labels = {} )
    251280        : Stmt(loc, std::move(labels)), expr(expr) {}
    252281
    253         const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
    254 private:
    255         ReturnStmt * clone() const override { return new ReturnStmt{ *this }; }
    256         MUTATE_FRIEND
     282        const Stmt* accept( Visitor& v ) const override { return v.visit( this ); }
     283private:
     284        ReturnStmt* clone() const override { return new ReturnStmt{ *this }; }
     285
     286        /// Must be copied in ALL derived classes
     287        template<typename node_t>
     288        friend node_t * mutate(const node_t * node);
    257289};
    258290
     
    265297        Kind kind;
    266298
    267         ThrowStmt( const CodeLocation & loc, Kind kind, const Expr * expr, const Expr * target,
    268                 std::vector<Label> && labels = {} )
     299        ThrowStmt( const CodeLocation& loc, Kind kind, const Expr* expr, const Expr* target,
     300                std::vector<Label>&& labels = {} )
    269301        : Stmt(loc, std::move(labels)), expr(expr), target(target), kind(kind) {}
    270302
    271         const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
    272 private:
    273         ThrowStmt * clone() const override { return new ThrowStmt{ *this }; }
    274         MUTATE_FRIEND
     303        const Stmt* accept( Visitor& v ) const override { return v.visit( this ); }
     304private:
     305        ThrowStmt* clone() const override { return new ThrowStmt{ *this }; }
     306
     307        /// Must be copied in ALL derived classes
     308        template<typename node_t>
     309        friend node_t * mutate(const node_t * node);
    275310};
    276311
     
    281316        ptr<FinallyStmt> finally;
    282317
    283         TryStmt( const CodeLocation & loc, const CompoundStmt * body,
    284                 std::vector<ptr<CatchStmt>> && handlers, const FinallyStmt * finally,
    285                 std::vector<Label> && labels = {} )
     318        TryStmt( const CodeLocation& loc, const CompoundStmt* body,
     319                std::vector<ptr<CatchStmt>>&& handlers, const FinallyStmt* finally,
     320                std::vector<Label>&& labels = {} )
    286321        : Stmt(loc, std::move(labels)), body(body), handlers(std::move(handlers)), finally(finally) {}
    287322
    288         const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
    289 private:
    290         TryStmt * clone() const override { return new TryStmt{ *this }; }
    291         MUTATE_FRIEND
     323        const Stmt* accept( Visitor& v ) const override { return v.visit( this ); }
     324private:
     325        TryStmt* clone() const override { return new TryStmt{ *this }; }
     326
     327        /// Must be copied in ALL derived classes
     328        template<typename node_t>
     329        friend node_t * mutate(const node_t * node);
    292330};
    293331
     
    301339        Kind kind;
    302340
    303         CatchStmt( const CodeLocation & loc, Kind kind, const Decl * decl, const Expr * cond,
    304                 const Stmt * body, std::vector<Label> && labels = {} )
     341        CatchStmt( const CodeLocation& loc, Kind kind, const Decl* decl, const Expr* cond,
     342                const Stmt* body, std::vector<Label>&& labels = {} )
    305343        : Stmt(loc, std::move(labels)), decl(decl), cond(cond), body(body), kind(kind) {}
    306344
    307         const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
    308 private:
    309         CatchStmt * clone() const override { return new CatchStmt{ *this }; }
    310         MUTATE_FRIEND
     345        const Stmt* accept( Visitor& v ) const override { return v.visit( this ); }
     346private:
     347        CatchStmt* clone() const override { return new CatchStmt{ *this }; }
     348
     349        /// Must be copied in ALL derived classes
     350        template<typename node_t>
     351        friend node_t * mutate(const node_t * node);
    311352};
    312353
     
    315356        ptr<CompoundStmt> body;
    316357
    317         FinallyStmt( const CodeLocation & loc, const CompoundStmt * body,
    318                 std::vector<Label> && labels = {} )
     358        FinallyStmt( const CodeLocation& loc, const CompoundStmt* body,
     359                std::vector<Label>&& labels = {} )
    319360        : Stmt(loc, std::move(labels)), body(body) {}
    320361
    321         const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
    322 private:
    323         FinallyStmt * clone() const override { return new FinallyStmt{ *this }; }
    324         MUTATE_FRIEND
     362        const Stmt* accept( Visitor& v ) const override { return v.visit( this ); }
     363private:
     364        FinallyStmt* clone() const override { return new FinallyStmt{ *this }; }
     365
     366        /// Must be copied in ALL derived classes
     367        template<typename node_t>
     368        friend node_t * mutate(const node_t * node);
    325369};
    326370
     
    353397        OrElse orElse;
    354398
    355         WaitForStmt( const CodeLocation & loc, std::vector<Label> && labels = {} )
     399        WaitForStmt( const CodeLocation& loc, std::vector<Label>&& labels = {} )
    356400        : Stmt(loc, std::move(labels)) {}
    357401
    358         const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
    359 private:
    360         WaitForStmt * clone() const override { return new WaitForStmt{ *this }; }
    361         MUTATE_FRIEND
     402        const Stmt* accept( Visitor& v ) const override { return v.visit( this ); }
     403private:
     404        WaitForStmt* clone() const override { return new WaitForStmt{ *this }; }
     405
     406        /// Must be copied in ALL derived classes
     407        template<typename node_t>
     408        friend node_t * mutate(const node_t * node);
    362409};
    363410
     
    367414        ptr<Stmt> stmt;
    368415
    369         WithStmt( const CodeLocation & loc, std::vector<ptr<Expr>> && exprs, const Stmt * stmt,
    370                 std::vector<Label> && labels = {} )
     416        WithStmt( const CodeLocation& loc, std::vector<ptr<Expr>>&& exprs, const Stmt* stmt,
     417                std::vector<Label>&& labels = {} )
    371418        : Stmt(loc, std::move(labels)), exprs(std::move(exprs)), stmt(stmt) {}
    372419
    373         const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
    374 private:
    375         WithStmt * clone() const override { return new WithStmt{ *this }; }
    376         MUTATE_FRIEND
     420        const Stmt* accept( Visitor& v ) const override { return v.visit( this ); }
     421private:
     422        WithStmt* clone() const override { return new WithStmt{ *this }; }
     423
     424        /// Must be copied in ALL derived classes
     425        template<typename node_t>
     426        friend node_t * mutate(const node_t * node);
    377427};
    378428
     
    381431        ptr<Decl> decl;
    382432
    383         DeclStmt( const CodeLocation & loc, const Decl * decl, std::vector<Label> && labels = {} )
     433        DeclStmt( const CodeLocation& loc, const Decl* decl, std::vector<Label>&& labels = {} )
    384434        : Stmt(loc, std::move(labels)), decl(decl) {}
    385435
    386         const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
    387 private:
    388         DeclStmt * clone() const override { return new DeclStmt{ *this }; }
    389         MUTATE_FRIEND
     436        const Stmt* accept( Visitor& v ) const override { return v.visit( this ); }
     437private:
     438        DeclStmt* clone() const override { return new DeclStmt{ *this }; }
     439
     440        /// Must be copied in ALL derived classes
     441        template<typename node_t>
     442        friend node_t * mutate(const node_t * node);
    390443};
    391444
     
    394447        readonly<Stmt> callStmt;
    395448
    396         ImplicitCtorDtorStmt( const CodeLocation & loc, const Stmt * callStmt,
    397                 std::vector<Label> && labels = {} )
     449        ImplicitCtorDtorStmt( const CodeLocation& loc, const Stmt* callStmt,
     450                std::vector<Label>&& labels = {} )
    398451        : Stmt(loc, std::move(labels)), callStmt(callStmt) {}
    399452
    400         const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
    401 private:
    402         ImplicitCtorDtorStmt * clone() const override { return new ImplicitCtorDtorStmt{ *this }; }
    403         MUTATE_FRIEND
     453        const Stmt* accept( Visitor& v ) const override { return v.visit( this ); }
     454private:
     455        ImplicitCtorDtorStmt* clone() const override { return new ImplicitCtorDtorStmt{ *this }; }
     456
     457        /// Must be copied in ALL derived classes
     458        template<typename node_t>
     459        friend node_t * mutate(const node_t * node);
    404460};
    405461
    406462}
    407 
    408 #undef MUTATE_FRIEND
    409463
    410464// Local Variables: //
  • src/AST/Type.hpp

    r41b24c8 re61207e7  
    2929#include "Visitor.hpp"
    3030
    31 // Must be included in *all* AST classes; should be #undef'd at the end of the file
    32 #define MUTATE_FRIEND template<typename node_t> friend auto mutate(const node_t * node);
    33 
    3431namespace ast {
    3532
     
    7370private:
    7471        virtual Type * clone() const override = 0;
    75         MUTATE_FRIEND
    7672};
    7773
     
    8884private:
    8985        VoidType * clone() const override { return new VoidType{ *this }; }
    90         MUTATE_FRIEND
    9186};
    9287
     
    151146private:
    152147        BasicType * clone() const override { return new BasicType{ *this }; }
    153         MUTATE_FRIEND
    154148};
    155149
     
    182176private:
    183177        PointerType * clone() const override { return new PointerType{ *this }; }
    184         MUTATE_FRIEND
    185178};
    186179
     
    204197private:
    205198        ArrayType * clone() const override { return new ArrayType{ *this }; }
    206         MUTATE_FRIEND
    207199};
    208200
     
    224216private:
    225217        ReferenceType * clone() const override { return new ReferenceType{ *this }; }
    226         MUTATE_FRIEND
    227218};
    228219
     
    239230private:
    240231        QualifiedType * clone() const override { return new QualifiedType{ *this }; }
    241         MUTATE_FRIEND
    242232};
    243233
     
    255245private:
    256246        virtual ParameterizedType * clone() const override = 0;
    257         MUTATE_FRIEND
    258247};
    259248
     
    285274private:
    286275        FunctionType * clone() const override { return new FunctionType{ *this }; }
    287         MUTATE_FRIEND
    288276};
    289277
     
    307295private:
    308296        virtual ReferenceToType * clone() const override = 0;
    309         MUTATE_FRIEND
    310297
    311298protected:
     
    332319private:
    333320        StructInstType * clone() const override { return new StructInstType{ *this }; }
    334         MUTATE_FRIEND
    335321
    336322        std::string typeString() const override { return "struct"; }
     
    355341private:
    356342        UnionInstType * clone() const override { return new UnionInstType{ *this }; }
    357         MUTATE_FRIEND
    358343
    359344        std::string typeString() const override { return "union"; }
     
    378363private:
    379364        EnumInstType * clone() const override { return new EnumInstType{ *this }; }
    380         MUTATE_FRIEND
    381365
    382366        std::string typeString() const override { return "enum"; }
     
    402386private:
    403387        TraitInstType * clone() const override { return new TraitInstType{ *this }; }
    404         MUTATE_FRIEND
    405388
    406389        std::string typeString() const override { return "trait"; }
     
    431414private:
    432415        TypeInstType * clone() const override { return new TypeInstType{ *this }; }
    433         MUTATE_FRIEND
    434416
    435417        std::string typeString() const override { return "type"; }
     
    460442private:
    461443        TupleType * clone() const override { return new TupleType{ *this }; }
    462         MUTATE_FRIEND
    463444};
    464445
     
    475456private:
    476457        TypeofType * clone() const override { return new TypeofType{ *this }; }
    477         MUTATE_FRIEND
    478458};
    479459
     
    486466private:
    487467        VarArgsType * clone() const override { return new VarArgsType{ *this }; }
    488         MUTATE_FRIEND
    489468};
    490469
     
    497476private:
    498477        ZeroType * clone() const override { return new ZeroType{ *this }; }
    499         MUTATE_FRIEND
    500478};
    501479
     
    508486private:
    509487        OneType * clone() const override { return new OneType{ *this }; }
    510         MUTATE_FRIEND
    511488};
    512489
     
    519496private:
    520497        GlobalScopeType * clone() const override { return new GlobalScopeType{ *this }; }
    521         MUTATE_FRIEND
    522498};
    523499
    524500}
    525 
    526 #undef MUTATE_FRIEND
    527501
    528502// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.