Changeset ab904dc


Ignore:
Timestamp:
Jun 1, 2017, 11:00:46 AM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
296b2be, 4a58895
Parents:
7b15d7a
Message:

Added mutator capabilities to the pass visitor

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Common/PassVisitor.h

    r7b15d7a rab904dc  
    11#pragma once
    22
     3#include "SynTree/Mutator.h"
    34#include "SynTree/Visitor.h"
    45
    5 //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    6 //Deep magic (a.k.a template meta programming) to make the templated visitor work
    7 //Basically the goal is to make 2 previsit_impl
     6#include "SynTree/Initializer.h"
     7#include "SynTree/Statement.h"
     8#include "SynTree/Type.h"
     9#include "SynTree/Declaration.h"
     10#include "SynTree/Expression.h"
     11#include "SynTree/Constant.h"
     12
     13//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     14// Deep magic (a.k.a template meta programming) to make the templated visitor work
     15// Basically the goal is to make 2 previsit_impl
    816// 1 - Use when a pass implements a valid previsit. This uses overloading which means the any overload of
    917//     'pass.previsit( node )' that compiles will be used for that node for that type
     
    1624//     The second implementation takes a long while the first takes an int. Since the caller always passes an literal 0
    1725//     the first implementation takes priority in regards to overloading.
    18 //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     26// Mutator functions work along the same principal
     27//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     28// Visit
    1929template<typename pass_type, typename node_type>
    2030static inline auto previsit_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) ->decltype( pass.previsit( node ), void() ) {
     
    2333
    2434template<typename pass_type, typename node_type>
    25 static inline void previsit_impl( __attribute__((unused)) pass_type& pass, node_type * node, __attribute__((unused)) long unused ) {
    26         //Do nothing
    27 }
     35static inline void previsit_impl( __attribute__((unused)) pass_type& pass, node_type * node, __attribute__((unused)) long unused ) {}
    2836
    2937
     
    3442
    3543template<typename pass_type, typename node_type>
    36 static inline auto postvisit_impl( __attribute__((unused)) pass_type& pass, node_type * node, __attribute__((unused)) long unused ) {
    37         //Do nothing
    38 }
     44static inline void postvisit_impl( __attribute__((unused)) pass_type& pass, node_type * node, __attribute__((unused)) long unused ) {}
     45
     46// Mutate
     47template<typename pass_type, typename node_type>
     48static inline auto premutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) ->decltype( pass.premutate( node ), void() ) {
     49        return pass.premutate( node );
     50}
     51
     52template<typename pass_type, typename node_type>
     53static inline void premutate_impl( __attribute__((unused)) pass_type& pass, node_type * node, __attribute__((unused)) long unused ) {}
     54
     55
     56template<typename return_type, typename pass_type, typename node_type>
     57static inline auto postmutate_impl( pass_type& pass, node_type * node, __attribute__((unused)) int unused ) ->decltype( pass.postmutate( node ) ) {
     58        return pass.postmutate( node );
     59}
     60
     61template<typename return_type, typename pass_type, typename node_type>
     62static inline return_type postmutate_impl( __attribute__((unused)) pass_type& pass, node_type * node, __attribute__((unused)) long unused ) { return node; }
    3963
    4064//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     
    4468//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    4569template< typename pass_type >
    46 class PassVisitor final : public Visitor {
     70class PassVisitor final : public Visitor, public Mutator {
    4771public:
    4872        PassVisitor() = default;
     
    145169        virtual void visit( Constant *constant ) override final;
    146170
     171        virtual DeclarationWithType* mutate( ObjectDecl *objectDecl ) override final;
     172        virtual DeclarationWithType* mutate( FunctionDecl *functionDecl ) override final;
     173        virtual Declaration* mutate( StructDecl *aggregateDecl ) override final;
     174        virtual Declaration* mutate( UnionDecl *aggregateDecl ) override final;
     175        virtual Declaration* mutate( EnumDecl *aggregateDecl ) override final;
     176        virtual Declaration* mutate( TraitDecl *aggregateDecl ) override final;
     177        virtual TypeDecl* mutate( TypeDecl *typeDecl ) override final;
     178        virtual Declaration* mutate( TypedefDecl *typeDecl ) override final;
     179        virtual AsmDecl* mutate( AsmDecl *asmDecl ) override final;
     180
     181        virtual CompoundStmt* mutate( CompoundStmt *compoundStmt ) override final;
     182        virtual Statement* mutate( ExprStmt *exprStmt ) override final;
     183        virtual Statement* mutate( AsmStmt *asmStmt ) override final;
     184        virtual Statement* mutate( IfStmt *ifStmt ) override final;
     185        virtual Statement* mutate( WhileStmt *whileStmt ) override final;
     186        virtual Statement* mutate( ForStmt *forStmt ) override final;
     187        virtual Statement* mutate( SwitchStmt *switchStmt ) override final;
     188        virtual Statement* mutate( CaseStmt *caseStmt ) override final;
     189        virtual Statement* mutate( BranchStmt *branchStmt ) override final;
     190        virtual Statement* mutate( ReturnStmt *returnStmt ) override final;
     191        virtual Statement* mutate( TryStmt *returnStmt ) override final;
     192        virtual Statement* mutate( CatchStmt *catchStmt ) override final;
     193        virtual Statement* mutate( FinallyStmt *catchStmt ) override final;
     194        virtual NullStmt* mutate( NullStmt *nullStmt ) override final;
     195        virtual Statement* mutate( DeclStmt *declStmt ) override final;
     196        virtual Statement* mutate( ImplicitCtorDtorStmt *impCtorDtorStmt ) override final;
     197
     198        virtual Expression* mutate( ApplicationExpr *applicationExpr ) override final;
     199        virtual Expression* mutate( UntypedExpr *untypedExpr ) override final;
     200        virtual Expression* mutate( NameExpr *nameExpr ) override final;
     201        virtual Expression* mutate( AddressExpr *castExpr ) override final;
     202        virtual Expression* mutate( LabelAddressExpr *labAddressExpr ) override final;
     203        virtual Expression* mutate( CastExpr *castExpr ) override final;
     204        virtual Expression* mutate( UntypedMemberExpr *memberExpr ) override final;
     205        virtual Expression* mutate( MemberExpr *memberExpr ) override final;
     206        virtual Expression* mutate( VariableExpr *variableExpr ) override final;
     207        virtual Expression* mutate( ConstantExpr *constantExpr ) override final;
     208        virtual Expression* mutate( SizeofExpr *sizeofExpr ) override final;
     209        virtual Expression* mutate( AlignofExpr *alignofExpr ) override final;
     210        virtual Expression* mutate( UntypedOffsetofExpr *offsetofExpr ) override final;
     211        virtual Expression* mutate( OffsetofExpr *offsetofExpr ) override final;
     212        virtual Expression* mutate( OffsetPackExpr *offsetPackExpr ) override final;
     213        virtual Expression* mutate( AttrExpr *attrExpr ) override final;
     214        virtual Expression* mutate( LogicalExpr *logicalExpr ) override final;
     215        virtual Expression* mutate( ConditionalExpr *conditionalExpr ) override final;
     216        virtual Expression* mutate( CommaExpr *commaExpr ) override final;
     217        virtual Expression* mutate( TypeExpr *typeExpr ) override final;
     218        virtual Expression* mutate( AsmExpr *asmExpr ) override final;
     219        virtual Expression* mutate( ImplicitCopyCtorExpr *impCpCtorExpr ) override final;
     220        virtual Expression* mutate( ConstructorExpr *ctorExpr ) override final;
     221        virtual Expression* mutate( CompoundLiteralExpr *compLitExpr ) override final;
     222        virtual Expression* mutate( UntypedValofExpr *valofExpr ) override final;
     223        virtual Expression* mutate( RangeExpr *rangeExpr ) override final;
     224        virtual Expression* mutate( UntypedTupleExpr *tupleExpr ) override final;
     225        virtual Expression* mutate( TupleExpr *tupleExpr ) override final;
     226        virtual Expression* mutate( TupleIndexExpr *tupleExpr ) override final;
     227        virtual Expression* mutate( MemberTupleExpr *tupleExpr ) override final;
     228        virtual Expression* mutate( TupleAssignExpr *assignExpr ) override final;
     229        virtual Expression* mutate( StmtExpr * stmtExpr ) override final;
     230        virtual Expression* mutate( UniqueExpr * uniqueExpr ) override final;
     231
     232        virtual Type* mutate( VoidType *basicType ) override final;
     233        virtual Type* mutate( BasicType *basicType ) override final;
     234        virtual Type* mutate( PointerType *pointerType ) override final;
     235        virtual Type* mutate( ArrayType *arrayType ) override final;
     236        virtual Type* mutate( FunctionType *functionType ) override final;
     237        virtual Type* mutate( StructInstType *aggregateUseType ) override final;
     238        virtual Type* mutate( UnionInstType *aggregateUseType ) override final;
     239        virtual Type* mutate( EnumInstType *aggregateUseType ) override final;
     240        virtual Type* mutate( TraitInstType *aggregateUseType ) override final;
     241        virtual Type* mutate( TypeInstType *aggregateUseType ) override final;
     242        virtual Type* mutate( TupleType *tupleType ) override final;
     243        virtual Type* mutate( TypeofType *typeofType ) override final;
     244        virtual Type* mutate( AttrType *attrType ) override final;
     245        virtual Type* mutate( VarArgsType *varArgsType ) override final;
     246        virtual Type* mutate( ZeroType *zeroType ) override final;
     247        virtual Type* mutate( OneType *oneType ) override final;
     248
     249        virtual Initializer* mutate( SingleInit *singleInit ) override final;
     250        virtual Initializer* mutate( ListInit *listInit ) override final;
     251        virtual Initializer* mutate( ConstructorInit *ctorInit ) override final;
     252
     253        virtual Subrange *mutate( Subrange *subrange ) override final;
     254
     255        virtual Constant *mutate( Constant *constant ) override final;
     256
    147257private:
    148258        template<typename node_type>
     
    159269                postvisit_impl( pass, node, 0 );
    160270        }
     271
     272        template<typename node_type>
     273        auto call_premutate ( node_type * node )
     274                -> decltype( premutate_impl( pass, node, 0 ), void() )
     275        {
     276                premutate_impl( pass, node, 0 );
     277        }
     278
     279        template<typename return_type, typename node_type>
     280        auto call_postmutate ( node_type * node )
     281                -> decltype( postmutate_impl<return_type>( pass, node, 0 ) )
     282        {
     283                return postmutate_impl<return_type>( pass, node, 0 );
     284        }
    161285};
    162286
  • src/Common/PassVisitor.impl.h

    r7b15d7a rab904dc  
    66        call_postvisit( node ); \
    77
    8 
    9 template< typename pass_type >
    10 void PassVisitor< pass_type>::visit( ObjectDecl * node ) {
    11         VISIT_BODY( node );
    12 }
    13 
    14 template< typename pass_type >
    15 void PassVisitor< pass_type>::visit( FunctionDecl * node ) {
    16         VISIT_BODY( node );
    17 }
    18 
    19 template< typename pass_type >
    20 void PassVisitor< pass_type>::visit( StructDecl * node ) {
    21         VISIT_BODY( node );
    22 }
    23 
    24 template< typename pass_type >
    25 void PassVisitor< pass_type>::visit( UnionDecl * node ) {
    26         VISIT_BODY( node );
    27 }
    28 
    29 template< typename pass_type >
    30 void PassVisitor< pass_type>::visit( EnumDecl * node ) {
    31         VISIT_BODY( node );
    32 }
    33 
    34 template< typename pass_type >
    35 void PassVisitor< pass_type>::visit( TraitDecl * node ) {
    36         VISIT_BODY( node );
    37 }
    38 
    39 template< typename pass_type >
    40 void PassVisitor< pass_type>::visit( TypeDecl * node ) {
    41         VISIT_BODY( node );
    42 }
    43 
    44 template< typename pass_type >
    45 void PassVisitor< pass_type>::visit( TypedefDecl * node ) {
    46         VISIT_BODY( node );
    47 }
    48 
    49 template< typename pass_type >
    50 void PassVisitor< pass_type>::visit( AsmDecl * node ) {
    51         VISIT_BODY( node );
    52 }
    53 
    54 template< typename pass_type >
    55 void PassVisitor< pass_type>::visit( CompoundStmt * node ) {
    56         VISIT_BODY( node );
    57 }
    58 
    59 template< typename pass_type >
    60 void PassVisitor< pass_type>::visit( ExprStmt * node ) {
    61         VISIT_BODY( node );
    62 }
    63 
    64 template< typename pass_type >
    65 void PassVisitor< pass_type>::visit( AsmStmt * node ) {
    66         VISIT_BODY( node );
    67 }
    68 
    69 template< typename pass_type >
    70 void PassVisitor< pass_type>::visit( IfStmt * node ) {
    71         VISIT_BODY( node );
    72 }
    73 
    74 template< typename pass_type >
    75 void PassVisitor< pass_type>::visit( WhileStmt * node ) {
    76         VISIT_BODY( node );
    77 }
    78 
    79 template< typename pass_type >
    80 void PassVisitor< pass_type>::visit( ForStmt * node ) {
    81         VISIT_BODY( node );
    82 }
    83 
    84 template< typename pass_type >
    85 void PassVisitor< pass_type>::visit( SwitchStmt * node ) {
    86         VISIT_BODY( node );
    87 }
    88 
    89 template< typename pass_type >
    90 void PassVisitor< pass_type>::visit( CaseStmt * node ) {
    91         VISIT_BODY( node );
    92 }
    93 
    94 template< typename pass_type >
    95 void PassVisitor< pass_type>::visit( BranchStmt * node ) {
    96         VISIT_BODY( node );
    97 }
    98 
    99 template< typename pass_type >
    100 void PassVisitor< pass_type>::visit( ReturnStmt * node ) {
    101         VISIT_BODY( node );
    102 }
    103 
    104 template< typename pass_type >
    105 void PassVisitor< pass_type>::visit( TryStmt * node ) {
    106         VISIT_BODY( node );
    107 }
    108 
    109 template< typename pass_type >
    110 void PassVisitor< pass_type>::visit( CatchStmt * node ) {
    111         VISIT_BODY( node );
    112 }
    113 
    114 template< typename pass_type >
    115 void PassVisitor< pass_type>::visit( FinallyStmt * node ) {
    116         VISIT_BODY( node );
    117 }
    118 
    119 template< typename pass_type >
    120 void PassVisitor< pass_type>::visit( NullStmt * node ) {
    121         VISIT_BODY( node );
    122 }
    123 
    124 template< typename pass_type >
    125 void PassVisitor< pass_type>::visit( DeclStmt * node ) {
    126         VISIT_BODY( node );
    127 }
    128 
    129 template< typename pass_type >
    130 void PassVisitor< pass_type>::visit( ImplicitCtorDtorStmt * node ) {
    131         VISIT_BODY( node );
    132 }
    133 
    134 template< typename pass_type >
    135 void PassVisitor< pass_type>::visit( ApplicationExpr * node ) {
    136         VISIT_BODY( node );
    137 }
    138 
    139 template< typename pass_type >
    140 void PassVisitor< pass_type>::visit( UntypedExpr * node ) {
    141         VISIT_BODY( node );
    142 }
    143 
    144 template< typename pass_type >
    145 void PassVisitor< pass_type>::visit( NameExpr * node ) {
    146         VISIT_BODY( node );
    147 }
    148 
    149 template< typename pass_type >
    150 void PassVisitor< pass_type>::visit( CastExpr * node ) {
    151         VISIT_BODY( node );
    152 }
    153 
    154 template< typename pass_type >
    155 void PassVisitor< pass_type>::visit( AddressExpr * node ) {
    156         VISIT_BODY( node );
    157 }
    158 
    159 template< typename pass_type >
    160 void PassVisitor< pass_type>::visit( LabelAddressExpr * node ) {
    161         VISIT_BODY( node );
    162 }
    163 
    164 template< typename pass_type >
    165 void PassVisitor< pass_type>::visit( UntypedMemberExpr * node ) {
    166         VISIT_BODY( node );
    167 }
    168 
    169 template< typename pass_type >
    170 void PassVisitor< pass_type>::visit( MemberExpr * node ) {
    171         VISIT_BODY( node );
    172 }
    173 
    174 template< typename pass_type >
    175 void PassVisitor< pass_type>::visit( VariableExpr * node ) {
    176         VISIT_BODY( node );
    177 }
    178 
    179 template< typename pass_type >
    180 void PassVisitor< pass_type>::visit( ConstantExpr * node ) {
    181         VISIT_BODY( node );
    182 }
    183 
    184 template< typename pass_type >
    185 void PassVisitor< pass_type>::visit( SizeofExpr * node ) {
    186         VISIT_BODY( node );
    187 }
    188 
    189 template< typename pass_type >
    190 void PassVisitor< pass_type>::visit( AlignofExpr * node ) {
    191         VISIT_BODY( node );
    192 }
    193 
    194 template< typename pass_type >
    195 void PassVisitor< pass_type>::visit( UntypedOffsetofExpr * node ) {
    196         VISIT_BODY( node );
    197 }
    198 
    199 template< typename pass_type >
    200 void PassVisitor< pass_type>::visit( OffsetofExpr * node ) {
    201         VISIT_BODY( node );
    202 }
    203 
    204 template< typename pass_type >
    205 void PassVisitor< pass_type>::visit( OffsetPackExpr * node ) {
    206         VISIT_BODY( node );
    207 }
    208 
    209 template< typename pass_type >
    210 void PassVisitor< pass_type>::visit( AttrExpr * node ) {
    211         VISIT_BODY( node );
    212 }
    213 
    214 template< typename pass_type >
    215 void PassVisitor< pass_type>::visit( LogicalExpr * node ) {
    216         VISIT_BODY( node );
    217 }
    218 
    219 template< typename pass_type >
    220 void PassVisitor< pass_type>::visit( ConditionalExpr * node ) {
    221         VISIT_BODY( node );
    222 }
    223 
    224 template< typename pass_type >
    225 void PassVisitor< pass_type>::visit( CommaExpr * node ) {
    226         VISIT_BODY( node );
    227 }
    228 
    229 template< typename pass_type >
    230 void PassVisitor< pass_type>::visit( TypeExpr * node ) {
    231         VISIT_BODY( node );
    232 }
    233 
    234 template< typename pass_type >
    235 void PassVisitor< pass_type>::visit( AsmExpr * node ) {
    236         VISIT_BODY( node );
    237 }
    238 
    239 template< typename pass_type >
    240 void PassVisitor< pass_type>::visit( ImplicitCopyCtorExpr * node ) {
    241         VISIT_BODY( node );
    242 }
    243 
    244 template< typename pass_type >
    245 void PassVisitor< pass_type>::visit( ConstructorExpr * node ) {
    246         VISIT_BODY( node );
    247 }
    248 
    249 template< typename pass_type >
    250 void PassVisitor< pass_type>::visit( CompoundLiteralExpr * node ) {
    251         VISIT_BODY( node );
    252 }
    253 
    254 template< typename pass_type >
    255 void PassVisitor< pass_type>::visit( UntypedValofExpr * node ) {
    256         VISIT_BODY( node );
    257 }
    258 
    259 template< typename pass_type >
    260 void PassVisitor< pass_type>::visit( RangeExpr * node ) {
    261         VISIT_BODY( node );
    262 }
    263 
    264 template< typename pass_type >
    265 void PassVisitor< pass_type>::visit( UntypedTupleExpr * node ) {
    266         VISIT_BODY( node );
    267 }
    268 
    269 template< typename pass_type >
    270 void PassVisitor< pass_type>::visit( TupleExpr * node ) {
    271         VISIT_BODY( node );
    272 }
    273 
    274 template< typename pass_type >
    275 void PassVisitor< pass_type>::visit( TupleIndexExpr * node ) {
    276         VISIT_BODY( node );
    277 }
    278 
    279 template< typename pass_type >
    280 void PassVisitor< pass_type>::visit( MemberTupleExpr * node ) {
    281         VISIT_BODY( node );
    282 }
    283 
    284 template< typename pass_type >
    285 void PassVisitor< pass_type>::visit( TupleAssignExpr * node ) {
    286         VISIT_BODY( node );
    287 }
    288 
    289 template< typename pass_type >
    290 void PassVisitor< pass_type>::visit( StmtExpr * node ) {
    291         VISIT_BODY( node );
    292 }
    293 
    294 template< typename pass_type >
    295 void PassVisitor< pass_type>::visit( UniqueExpr * node ) {
    296         VISIT_BODY( node );
    297 }
    298 
    299 template< typename pass_type >
    300 void PassVisitor< pass_type>::visit( VoidType * node ) {
    301         VISIT_BODY( node );
    302 }
    303 
    304 template< typename pass_type >
    305 void PassVisitor< pass_type>::visit( BasicType * node ) {
    306         VISIT_BODY( node );
    307 }
    308 
    309 template< typename pass_type >
    310 void PassVisitor< pass_type>::visit( PointerType * node ) {
    311         VISIT_BODY( node );
    312 }
    313 
    314 template< typename pass_type >
    315 void PassVisitor< pass_type>::visit( ArrayType * node ) {
    316         VISIT_BODY( node );
    317 }
    318 
    319 template< typename pass_type >
    320 void PassVisitor< pass_type>::visit( FunctionType * node ) {
    321         VISIT_BODY( node );
    322 }
    323 
    324 template< typename pass_type >
    325 void PassVisitor< pass_type>::visit( StructInstType * node ) {
    326         VISIT_BODY( node );
    327 }
    328 
    329 template< typename pass_type >
    330 void PassVisitor< pass_type>::visit( UnionInstType * node ) {
    331         VISIT_BODY( node );
    332 }
    333 
    334 template< typename pass_type >
    335 void PassVisitor< pass_type>::visit( EnumInstType * node ) {
    336         VISIT_BODY( node );
    337 }
    338 
    339 template< typename pass_type >
    340 void PassVisitor< pass_type>::visit( TraitInstType * node ) {
    341         VISIT_BODY( node );
    342 }
    343 
    344 template< typename pass_type >
    345 void PassVisitor< pass_type>::visit( TypeInstType * node ) {
    346         VISIT_BODY( node );
    347 }
    348 
    349 template< typename pass_type >
    350 void PassVisitor< pass_type>::visit( TupleType * node ) {
    351         VISIT_BODY( node );
    352 }
    353 
    354 template< typename pass_type >
    355 void PassVisitor< pass_type>::visit( TypeofType * node ) {
    356         VISIT_BODY( node );
    357 }
    358 
    359 template< typename pass_type >
    360 void PassVisitor< pass_type>::visit( AttrType * node ) {
    361         VISIT_BODY( node );
    362 }
    363 
    364 template< typename pass_type >
    365 void PassVisitor< pass_type>::visit( VarArgsType * node ) {
    366         VISIT_BODY( node );
    367 }
    368 
    369 template< typename pass_type >
    370 void PassVisitor< pass_type>::visit( ZeroType * node ) {
    371         VISIT_BODY( node );
    372 }
    373 
    374 template< typename pass_type >
    375 void PassVisitor< pass_type>::visit( OneType * node ) {
    376         VISIT_BODY( node );
    377 }
    378 
    379 template< typename pass_type >
    380 void PassVisitor< pass_type>::visit( SingleInit * node ) {
    381         VISIT_BODY( node );
    382 }
    383 
    384 template< typename pass_type >
    385 void PassVisitor< pass_type>::visit( ListInit * node ) {
    386         VISIT_BODY( node );
    387 }
    388 
    389 template< typename pass_type >
    390 void PassVisitor< pass_type>::visit( ConstructorInit * node ) {
    391         VISIT_BODY( node );
    392 }
    393 
    394 template< typename pass_type >
    395 void PassVisitor< pass_type>::visit( Subrange * node ) {
    396         VISIT_BODY( node );
    397 }
    398 
    399 template< typename pass_type >
    400 void PassVisitor< pass_type>::visit( Constant * node ) {
    401         VISIT_BODY( node );
    402 }
     8#define MUTATE_BODY( type, node )                   \
     9        call_premutate( node );                       \
     10        Mutator::mutate( node );                      \
     11        auto ret = call_postmutate< type * >( node ); \
     12        return ret;                                   \
     13
     14
     15
     16
     17template< typename pass_type >
     18void PassVisitor< pass_type >::visit( ObjectDecl * node ) {
     19        VISIT_BODY( node );
     20}
     21
     22template< typename pass_type >
     23void PassVisitor< pass_type >::visit( FunctionDecl * node ) {
     24        VISIT_BODY( node );
     25}
     26
     27template< typename pass_type >
     28void PassVisitor< pass_type >::visit( StructDecl * node ) {
     29        VISIT_BODY( node );
     30}
     31
     32template< typename pass_type >
     33void PassVisitor< pass_type >::visit( UnionDecl * node ) {
     34        VISIT_BODY( node );
     35}
     36
     37template< typename pass_type >
     38void PassVisitor< pass_type >::visit( EnumDecl * node ) {
     39        VISIT_BODY( node );
     40}
     41
     42template< typename pass_type >
     43void PassVisitor< pass_type >::visit( TraitDecl * node ) {
     44        VISIT_BODY( node );
     45}
     46
     47template< typename pass_type >
     48void PassVisitor< pass_type >::visit( TypeDecl * node ) {
     49        VISIT_BODY( node );
     50}
     51
     52template< typename pass_type >
     53void PassVisitor< pass_type >::visit( TypedefDecl * node ) {
     54        VISIT_BODY( node );
     55}
     56
     57template< typename pass_type >
     58void PassVisitor< pass_type >::visit( AsmDecl * node ) {
     59        VISIT_BODY( node );
     60}
     61
     62template< typename pass_type >
     63void PassVisitor< pass_type >::visit( CompoundStmt * node ) {
     64        VISIT_BODY( node );
     65}
     66
     67template< typename pass_type >
     68void PassVisitor< pass_type >::visit( ExprStmt * node ) {
     69        VISIT_BODY( node );
     70}
     71
     72template< typename pass_type >
     73void PassVisitor< pass_type >::visit( AsmStmt * node ) {
     74        VISIT_BODY( node );
     75}
     76
     77template< typename pass_type >
     78void PassVisitor< pass_type >::visit( IfStmt * node ) {
     79        VISIT_BODY( node );
     80}
     81
     82template< typename pass_type >
     83void PassVisitor< pass_type >::visit( WhileStmt * node ) {
     84        VISIT_BODY( node );
     85}
     86
     87template< typename pass_type >
     88void PassVisitor< pass_type >::visit( ForStmt * node ) {
     89        VISIT_BODY( node );
     90}
     91
     92template< typename pass_type >
     93void PassVisitor< pass_type >::visit( SwitchStmt * node ) {
     94        VISIT_BODY( node );
     95}
     96
     97template< typename pass_type >
     98void PassVisitor< pass_type >::visit( CaseStmt * node ) {
     99        VISIT_BODY( node );
     100}
     101
     102template< typename pass_type >
     103void PassVisitor< pass_type >::visit( BranchStmt * node ) {
     104        VISIT_BODY( node );
     105}
     106
     107template< typename pass_type >
     108void PassVisitor< pass_type >::visit( ReturnStmt * node ) {
     109        VISIT_BODY( node );
     110}
     111
     112template< typename pass_type >
     113void PassVisitor< pass_type >::visit( TryStmt * node ) {
     114        VISIT_BODY( node );
     115}
     116
     117template< typename pass_type >
     118void PassVisitor< pass_type >::visit( CatchStmt * node ) {
     119        VISIT_BODY( node );
     120}
     121
     122template< typename pass_type >
     123void PassVisitor< pass_type >::visit( FinallyStmt * node ) {
     124        VISIT_BODY( node );
     125}
     126
     127template< typename pass_type >
     128void PassVisitor< pass_type >::visit( NullStmt * node ) {
     129        VISIT_BODY( node );
     130}
     131
     132template< typename pass_type >
     133void PassVisitor< pass_type >::visit( DeclStmt * node ) {
     134        VISIT_BODY( node );
     135}
     136
     137template< typename pass_type >
     138void PassVisitor< pass_type >::visit( ImplicitCtorDtorStmt * node ) {
     139        VISIT_BODY( node );
     140}
     141
     142template< typename pass_type >
     143void PassVisitor< pass_type >::visit( ApplicationExpr * node ) {
     144        VISIT_BODY( node );
     145}
     146
     147template< typename pass_type >
     148void PassVisitor< pass_type >::visit( UntypedExpr * node ) {
     149        VISIT_BODY( node );
     150}
     151
     152template< typename pass_type >
     153void PassVisitor< pass_type >::visit( NameExpr * node ) {
     154        VISIT_BODY( node );
     155}
     156
     157template< typename pass_type >
     158void PassVisitor< pass_type >::visit( CastExpr * node ) {
     159        VISIT_BODY( node );
     160}
     161
     162template< typename pass_type >
     163void PassVisitor< pass_type >::visit( AddressExpr * node ) {
     164        VISIT_BODY( node );
     165}
     166
     167template< typename pass_type >
     168void PassVisitor< pass_type >::visit( LabelAddressExpr * node ) {
     169        VISIT_BODY( node );
     170}
     171
     172template< typename pass_type >
     173void PassVisitor< pass_type >::visit( UntypedMemberExpr * node ) {
     174        VISIT_BODY( node );
     175}
     176
     177template< typename pass_type >
     178void PassVisitor< pass_type >::visit( MemberExpr * node ) {
     179        VISIT_BODY( node );
     180}
     181
     182template< typename pass_type >
     183void PassVisitor< pass_type >::visit( VariableExpr * node ) {
     184        VISIT_BODY( node );
     185}
     186
     187template< typename pass_type >
     188void PassVisitor< pass_type >::visit( ConstantExpr * node ) {
     189        VISIT_BODY( node );
     190}
     191
     192template< typename pass_type >
     193void PassVisitor< pass_type >::visit( SizeofExpr * node ) {
     194        VISIT_BODY( node );
     195}
     196
     197template< typename pass_type >
     198void PassVisitor< pass_type >::visit( AlignofExpr * node ) {
     199        VISIT_BODY( node );
     200}
     201
     202template< typename pass_type >
     203void PassVisitor< pass_type >::visit( UntypedOffsetofExpr * node ) {
     204        VISIT_BODY( node );
     205}
     206
     207template< typename pass_type >
     208void PassVisitor< pass_type >::visit( OffsetofExpr * node ) {
     209        VISIT_BODY( node );
     210}
     211
     212template< typename pass_type >
     213void PassVisitor< pass_type >::visit( OffsetPackExpr * node ) {
     214        VISIT_BODY( node );
     215}
     216
     217template< typename pass_type >
     218void PassVisitor< pass_type >::visit( AttrExpr * node ) {
     219        VISIT_BODY( node );
     220}
     221
     222template< typename pass_type >
     223void PassVisitor< pass_type >::visit( LogicalExpr * node ) {
     224        VISIT_BODY( node );
     225}
     226
     227template< typename pass_type >
     228void PassVisitor< pass_type >::visit( ConditionalExpr * node ) {
     229        VISIT_BODY( node );
     230}
     231
     232template< typename pass_type >
     233void PassVisitor< pass_type >::visit( CommaExpr * node ) {
     234        VISIT_BODY( node );
     235}
     236
     237template< typename pass_type >
     238void PassVisitor< pass_type >::visit( TypeExpr * node ) {
     239        VISIT_BODY( node );
     240}
     241
     242template< typename pass_type >
     243void PassVisitor< pass_type >::visit( AsmExpr * node ) {
     244        VISIT_BODY( node );
     245}
     246
     247template< typename pass_type >
     248void PassVisitor< pass_type >::visit( ImplicitCopyCtorExpr * node ) {
     249        VISIT_BODY( node );
     250}
     251
     252template< typename pass_type >
     253void PassVisitor< pass_type >::visit( ConstructorExpr * node ) {
     254        VISIT_BODY( node );
     255}
     256
     257template< typename pass_type >
     258void PassVisitor< pass_type >::visit( CompoundLiteralExpr * node ) {
     259        VISIT_BODY( node );
     260}
     261
     262template< typename pass_type >
     263void PassVisitor< pass_type >::visit( UntypedValofExpr * node ) {
     264        VISIT_BODY( node );
     265}
     266
     267template< typename pass_type >
     268void PassVisitor< pass_type >::visit( RangeExpr * node ) {
     269        VISIT_BODY( node );
     270}
     271
     272template< typename pass_type >
     273void PassVisitor< pass_type >::visit( UntypedTupleExpr * node ) {
     274        VISIT_BODY( node );
     275}
     276
     277template< typename pass_type >
     278void PassVisitor< pass_type >::visit( TupleExpr * node ) {
     279        VISIT_BODY( node );
     280}
     281
     282template< typename pass_type >
     283void PassVisitor< pass_type >::visit( TupleIndexExpr * node ) {
     284        VISIT_BODY( node );
     285}
     286
     287template< typename pass_type >
     288void PassVisitor< pass_type >::visit( MemberTupleExpr * node ) {
     289        VISIT_BODY( node );
     290}
     291
     292template< typename pass_type >
     293void PassVisitor< pass_type >::visit( TupleAssignExpr * node ) {
     294        VISIT_BODY( node );
     295}
     296
     297template< typename pass_type >
     298void PassVisitor< pass_type >::visit( StmtExpr * node ) {
     299        VISIT_BODY( node );
     300}
     301
     302template< typename pass_type >
     303void PassVisitor< pass_type >::visit( UniqueExpr * node ) {
     304        VISIT_BODY( node );
     305}
     306
     307template< typename pass_type >
     308void PassVisitor< pass_type >::visit( VoidType * node ) {
     309        VISIT_BODY( node );
     310}
     311
     312template< typename pass_type >
     313void PassVisitor< pass_type >::visit( BasicType * node ) {
     314        VISIT_BODY( node );
     315}
     316
     317template< typename pass_type >
     318void PassVisitor< pass_type >::visit( PointerType * node ) {
     319        VISIT_BODY( node );
     320}
     321
     322template< typename pass_type >
     323void PassVisitor< pass_type >::visit( ArrayType * node ) {
     324        VISIT_BODY( node );
     325}
     326
     327template< typename pass_type >
     328void PassVisitor< pass_type >::visit( FunctionType * node ) {
     329        VISIT_BODY( node );
     330}
     331
     332template< typename pass_type >
     333void PassVisitor< pass_type >::visit( StructInstType * node ) {
     334        VISIT_BODY( node );
     335}
     336
     337template< typename pass_type >
     338void PassVisitor< pass_type >::visit( UnionInstType * node ) {
     339        VISIT_BODY( node );
     340}
     341
     342template< typename pass_type >
     343void PassVisitor< pass_type >::visit( EnumInstType * node ) {
     344        VISIT_BODY( node );
     345}
     346
     347template< typename pass_type >
     348void PassVisitor< pass_type >::visit( TraitInstType * node ) {
     349        VISIT_BODY( node );
     350}
     351
     352template< typename pass_type >
     353void PassVisitor< pass_type >::visit( TypeInstType * node ) {
     354        VISIT_BODY( node );
     355}
     356
     357template< typename pass_type >
     358void PassVisitor< pass_type >::visit( TupleType * node ) {
     359        VISIT_BODY( node );
     360}
     361
     362template< typename pass_type >
     363void PassVisitor< pass_type >::visit( TypeofType * node ) {
     364        VISIT_BODY( node );
     365}
     366
     367template< typename pass_type >
     368void PassVisitor< pass_type >::visit( AttrType * node ) {
     369        VISIT_BODY( node );
     370}
     371
     372template< typename pass_type >
     373void PassVisitor< pass_type >::visit( VarArgsType * node ) {
     374        VISIT_BODY( node );
     375}
     376
     377template< typename pass_type >
     378void PassVisitor< pass_type >::visit( ZeroType * node ) {
     379        VISIT_BODY( node );
     380}
     381
     382template< typename pass_type >
     383void PassVisitor< pass_type >::visit( OneType * node ) {
     384        VISIT_BODY( node );
     385}
     386
     387template< typename pass_type >
     388void PassVisitor< pass_type >::visit( SingleInit * node ) {
     389        VISIT_BODY( node );
     390}
     391
     392template< typename pass_type >
     393void PassVisitor< pass_type >::visit( ListInit * node ) {
     394        VISIT_BODY( node );
     395}
     396
     397template< typename pass_type >
     398void PassVisitor< pass_type >::visit( ConstructorInit * node ) {
     399        VISIT_BODY( node );
     400}
     401
     402template< typename pass_type >
     403void PassVisitor< pass_type >::visit( Subrange * node ) {
     404        VISIT_BODY( node );
     405}
     406
     407template< typename pass_type >
     408void PassVisitor< pass_type >::visit( Constant * node ) {
     409        VISIT_BODY( node );
     410}
     411
     412//---------------------------------------------------------------------------------------------------------------
     413
     414template< typename pass_type >
     415DeclarationWithType * PassVisitor< pass_type >::mutate( ObjectDecl * node ) {
     416        MUTATE_BODY( DeclarationWithType, node );
     417}
     418
     419template< typename pass_type >
     420DeclarationWithType * PassVisitor< pass_type >::mutate( FunctionDecl * node ) {
     421        MUTATE_BODY( DeclarationWithType, node );
     422}
     423
     424template< typename pass_type >
     425Declaration * PassVisitor< pass_type >::mutate( StructDecl * node ) {
     426        MUTATE_BODY( Declaration, node );
     427}
     428
     429template< typename pass_type >
     430Declaration * PassVisitor< pass_type >::mutate( UnionDecl * node ) {
     431        MUTATE_BODY( Declaration, node );
     432}
     433
     434template< typename pass_type >
     435Declaration * PassVisitor< pass_type >::mutate( EnumDecl * node ) {
     436        MUTATE_BODY( Declaration, node );
     437}
     438
     439template< typename pass_type >
     440Declaration * PassVisitor< pass_type >::mutate( TraitDecl * node ) {
     441        MUTATE_BODY( Declaration, node );
     442}
     443
     444template< typename pass_type >
     445TypeDecl * PassVisitor< pass_type >::mutate( TypeDecl * node ) {
     446        MUTATE_BODY( TypeDecl, node );
     447}
     448
     449template< typename pass_type >
     450Declaration * PassVisitor< pass_type >::mutate( TypedefDecl * node ) {
     451        MUTATE_BODY( Declaration, node );
     452}
     453
     454template< typename pass_type >
     455AsmDecl * PassVisitor< pass_type >::mutate( AsmDecl * node ) {
     456        MUTATE_BODY( AsmDecl, node );
     457}
     458
     459template< typename pass_type >
     460CompoundStmt * PassVisitor< pass_type >::mutate( CompoundStmt * node ) {
     461        MUTATE_BODY( CompoundStmt, node );
     462}
     463
     464template< typename pass_type >
     465Statement * PassVisitor< pass_type >::mutate( ExprStmt * node ) {
     466        MUTATE_BODY( Statement, node );
     467}
     468
     469template< typename pass_type >
     470Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) {
     471        MUTATE_BODY( Statement, node );
     472}
     473
     474template< typename pass_type >
     475Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) {
     476        MUTATE_BODY( Statement, node );
     477}
     478
     479template< typename pass_type >
     480Statement * PassVisitor< pass_type >::mutate( WhileStmt * node ) {
     481        MUTATE_BODY( Statement, node );
     482}
     483
     484template< typename pass_type >
     485Statement * PassVisitor< pass_type >::mutate( ForStmt * node ) {
     486        MUTATE_BODY( Statement, node );
     487}
     488
     489template< typename pass_type >
     490Statement * PassVisitor< pass_type >::mutate( SwitchStmt * node ) {
     491        MUTATE_BODY( Statement, node );
     492}
     493
     494template< typename pass_type >
     495Statement * PassVisitor< pass_type >::mutate( CaseStmt * node ) {
     496        MUTATE_BODY( Statement, node );
     497}
     498
     499template< typename pass_type >
     500Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) {
     501        MUTATE_BODY( Statement, node );
     502}
     503
     504template< typename pass_type >
     505Statement * PassVisitor< pass_type >::mutate( ReturnStmt * node ) {
     506        MUTATE_BODY( Statement, node );
     507}
     508
     509template< typename pass_type >
     510Statement * PassVisitor< pass_type >::mutate( TryStmt * node ) {
     511        MUTATE_BODY( Statement, node );
     512}
     513
     514template< typename pass_type >
     515Statement * PassVisitor< pass_type >::mutate( CatchStmt * node ) {
     516        MUTATE_BODY( Statement, node );
     517}
     518
     519template< typename pass_type >
     520Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) {
     521        MUTATE_BODY( Statement, node );
     522}
     523
     524template< typename pass_type >
     525NullStmt * PassVisitor< pass_type >::mutate( NullStmt * node ) {
     526        MUTATE_BODY( NullStmt, node );
     527}
     528
     529template< typename pass_type >
     530Statement * PassVisitor< pass_type >::mutate( DeclStmt * node ) {
     531        MUTATE_BODY( Statement, node );
     532}
     533
     534template< typename pass_type >
     535Statement * PassVisitor< pass_type >::mutate( ImplicitCtorDtorStmt * node ) {
     536        MUTATE_BODY( Statement, node );
     537}
     538
     539template< typename pass_type >
     540Expression * PassVisitor< pass_type >::mutate( ApplicationExpr * node ) {
     541        MUTATE_BODY( Expression, node );
     542}
     543
     544template< typename pass_type >
     545Expression * PassVisitor< pass_type >::mutate( UntypedExpr * node ) {
     546        MUTATE_BODY( Expression, node );
     547}
     548
     549template< typename pass_type >
     550Expression * PassVisitor< pass_type >::mutate( NameExpr * node ) {
     551        MUTATE_BODY( Expression, node );
     552}
     553
     554template< typename pass_type >
     555Expression * PassVisitor< pass_type >::mutate( AddressExpr * node ) {
     556        MUTATE_BODY( Expression, node );
     557}
     558
     559template< typename pass_type >
     560Expression * PassVisitor< pass_type >::mutate( LabelAddressExpr * node ) {
     561        MUTATE_BODY( Expression, node );
     562}
     563
     564template< typename pass_type >
     565Expression * PassVisitor< pass_type >::mutate( CastExpr * node ) {
     566        MUTATE_BODY( Expression, node );
     567}
     568
     569template< typename pass_type >
     570Expression * PassVisitor< pass_type >::mutate( UntypedMemberExpr * node ) {
     571        MUTATE_BODY( Expression, node );
     572}
     573
     574template< typename pass_type >
     575Expression * PassVisitor< pass_type >::mutate( MemberExpr * node ) {
     576        MUTATE_BODY( Expression, node );
     577}
     578
     579template< typename pass_type >
     580Expression * PassVisitor< pass_type >::mutate( VariableExpr * node ) {
     581        MUTATE_BODY( Expression, node );
     582}
     583
     584template< typename pass_type >
     585Expression * PassVisitor< pass_type >::mutate( ConstantExpr * node ) {
     586        MUTATE_BODY( Expression, node );
     587}
     588
     589template< typename pass_type >
     590Expression * PassVisitor< pass_type >::mutate( SizeofExpr * node ) {
     591        MUTATE_BODY( Expression, node );
     592}
     593
     594template< typename pass_type >
     595Expression * PassVisitor< pass_type >::mutate( AlignofExpr * node ) {
     596        MUTATE_BODY( Expression, node );
     597}
     598
     599template< typename pass_type >
     600Expression * PassVisitor< pass_type >::mutate( UntypedOffsetofExpr * node ) {
     601        MUTATE_BODY( Expression, node );
     602}
     603
     604template< typename pass_type >
     605Expression * PassVisitor< pass_type >::mutate( OffsetofExpr * node ) {
     606        MUTATE_BODY( Expression, node );
     607}
     608
     609template< typename pass_type >
     610Expression * PassVisitor< pass_type >::mutate( OffsetPackExpr * node ) {
     611        MUTATE_BODY( Expression, node );
     612}
     613
     614template< typename pass_type >
     615Expression * PassVisitor< pass_type >::mutate( AttrExpr * node ) {
     616        MUTATE_BODY( Expression, node );
     617}
     618
     619template< typename pass_type >
     620Expression * PassVisitor< pass_type >::mutate( LogicalExpr * node ) {
     621        MUTATE_BODY( Expression, node );
     622}
     623
     624template< typename pass_type >
     625Expression * PassVisitor< pass_type >::mutate( ConditionalExpr * node ) {
     626        MUTATE_BODY( Expression, node );
     627}
     628
     629template< typename pass_type >
     630Expression * PassVisitor< pass_type >::mutate( CommaExpr * node ) {
     631        MUTATE_BODY( Expression, node );
     632}
     633
     634template< typename pass_type >
     635Expression * PassVisitor< pass_type >::mutate( TypeExpr * node ) {
     636        MUTATE_BODY( Expression, node );
     637}
     638
     639template< typename pass_type >
     640Expression * PassVisitor< pass_type >::mutate( AsmExpr * node ) {
     641        MUTATE_BODY( Expression, node );
     642}
     643
     644template< typename pass_type >
     645Expression * PassVisitor< pass_type >::mutate( ImplicitCopyCtorExpr * node ) {
     646        MUTATE_BODY( Expression, node );
     647}
     648
     649template< typename pass_type >
     650Expression * PassVisitor< pass_type >::mutate( ConstructorExpr * node ) {
     651        MUTATE_BODY( Expression, node );
     652}
     653
     654template< typename pass_type >
     655Expression * PassVisitor< pass_type >::mutate( CompoundLiteralExpr * node ) {
     656        MUTATE_BODY( Expression, node );
     657}
     658
     659template< typename pass_type >
     660Expression * PassVisitor< pass_type >::mutate( UntypedValofExpr * node ) {
     661        MUTATE_BODY( Expression, node );
     662}
     663
     664template< typename pass_type >
     665Expression * PassVisitor< pass_type >::mutate( RangeExpr * node ) {
     666        MUTATE_BODY( Expression, node );
     667}
     668
     669template< typename pass_type >
     670Expression * PassVisitor< pass_type >::mutate( UntypedTupleExpr * node ) {
     671        MUTATE_BODY( Expression, node );
     672}
     673
     674template< typename pass_type >
     675Expression * PassVisitor< pass_type >::mutate( TupleExpr * node ) {
     676        MUTATE_BODY( Expression, node );
     677}
     678
     679template< typename pass_type >
     680Expression * PassVisitor< pass_type >::mutate( TupleIndexExpr * node ) {
     681        MUTATE_BODY( Expression, node );
     682}
     683
     684template< typename pass_type >
     685Expression * PassVisitor< pass_type >::mutate( MemberTupleExpr * node ) {
     686        MUTATE_BODY( Expression, node );
     687}
     688
     689template< typename pass_type >
     690Expression * PassVisitor< pass_type >::mutate( TupleAssignExpr * node ) {
     691        MUTATE_BODY( Expression, node );
     692}
     693
     694template< typename pass_type >
     695Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) {
     696        MUTATE_BODY( Expression, node );
     697}
     698
     699template< typename pass_type >
     700Expression * PassVisitor< pass_type >::mutate( UniqueExpr * node ) {
     701        MUTATE_BODY( Expression, node );
     702}
     703
     704template< typename pass_type >
     705Type * PassVisitor< pass_type >::mutate( VoidType * node ) {
     706        MUTATE_BODY( Type, node );
     707}
     708
     709template< typename pass_type >
     710Type * PassVisitor< pass_type >::mutate( BasicType * node ) {
     711        MUTATE_BODY( Type, node );
     712}
     713
     714template< typename pass_type >
     715Type * PassVisitor< pass_type >::mutate( PointerType * node ) {
     716        MUTATE_BODY( Type, node );
     717}
     718
     719template< typename pass_type >
     720Type * PassVisitor< pass_type >::mutate( ArrayType * node ) {
     721        MUTATE_BODY( Type, node );
     722}
     723
     724template< typename pass_type >
     725Type * PassVisitor< pass_type >::mutate( FunctionType * node ) {
     726        MUTATE_BODY( Type, node );
     727}
     728
     729template< typename pass_type >
     730Type * PassVisitor< pass_type >::mutate( StructInstType * node ) {
     731        MUTATE_BODY( Type, node );
     732}
     733
     734template< typename pass_type >
     735Type * PassVisitor< pass_type >::mutate( UnionInstType * node ) {
     736        MUTATE_BODY( Type, node );
     737}
     738
     739template< typename pass_type >
     740Type * PassVisitor< pass_type >::mutate( EnumInstType * node ) {
     741        MUTATE_BODY( Type, node );
     742}
     743
     744template< typename pass_type >
     745Type * PassVisitor< pass_type >::mutate( TraitInstType * node ) {
     746        MUTATE_BODY( Type, node );
     747}
     748
     749template< typename pass_type >
     750Type * PassVisitor< pass_type >::mutate( TypeInstType * node ) {
     751        MUTATE_BODY( Type, node );
     752}
     753
     754template< typename pass_type >
     755Type * PassVisitor< pass_type >::mutate( TupleType * node ) {
     756        MUTATE_BODY( Type, node );
     757}
     758
     759template< typename pass_type >
     760Type * PassVisitor< pass_type >::mutate( TypeofType * node ) {
     761        MUTATE_BODY( Type, node );
     762}
     763
     764template< typename pass_type >
     765Type * PassVisitor< pass_type >::mutate( AttrType * node ) {
     766        MUTATE_BODY( Type, node );
     767}
     768
     769template< typename pass_type >
     770Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) {
     771        MUTATE_BODY( Type, node );
     772}
     773
     774template< typename pass_type >
     775Type * PassVisitor< pass_type >::mutate( ZeroType * node ) {
     776        MUTATE_BODY( Type, node );
     777}
     778
     779template< typename pass_type >
     780Type * PassVisitor< pass_type >::mutate( OneType * node ) {
     781        MUTATE_BODY( Type, node );
     782}
     783
     784template< typename pass_type >
     785Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) {
     786        MUTATE_BODY( Initializer, node );
     787}
     788
     789template< typename pass_type >
     790Initializer * PassVisitor< pass_type >::mutate( ListInit * node ) {
     791        MUTATE_BODY( Initializer, node );
     792}
     793
     794template< typename pass_type >
     795Initializer * PassVisitor< pass_type >::mutate( ConstructorInit * node ) {
     796        MUTATE_BODY( Initializer, node );
     797}
     798
     799template< typename pass_type >
     800Subrange * PassVisitor< pass_type >::mutate( Subrange * node  )  {
     801        MUTATE_BODY( Subrange, node );
     802}
     803
     804template< typename pass_type >
     805Constant * PassVisitor< pass_type >::mutate( Constant * node  )  {
     806        MUTATE_BODY( Constant, node );
     807}
  • src/Tuples/TupleExpansion.cc

    r7b15d7a rab904dc  
    1818#include <cassert>
    1919#include "Tuples.h"
     20#include "Common/PassVisitor.h"
     21#include "Common/ScopedMap.h"
    2022#include "GenPoly/DeclMutator.h"
     23#include "InitTweak/GenInit.h"
     24#include "InitTweak/InitTweak.h"
     25#include "ResolvExpr/typeops.h"
     26#include "SymTab/Mangler.h"
     27#include "SynTree/Declaration.h"
     28#include "SynTree/Expression.h"
     29#include "SynTree/Initializer.h"
    2130#include "SynTree/Mutator.h"
    2231#include "SynTree/Statement.h"
    23 #include "SynTree/Declaration.h"
    2432#include "SynTree/Type.h"
    25 #include "SynTree/Expression.h"
    26 #include "SynTree/Initializer.h"
    27 #include "SymTab/Mangler.h"
    28 #include "Common/ScopedMap.h"
    29 #include "ResolvExpr/typeops.h"
    30 #include "InitTweak/GenInit.h"
    31 #include "InitTweak/InitTweak.h"
    3233
    3334namespace Tuples {
     
    8283                };
    8384
    84                 class TupleIndexExpander final : public Mutator {
    85                 public:
    86                         typedef Mutator Parent;
    87                         using Parent::mutate;
    88 
    89                         virtual Expression * mutate( TupleIndexExpr * tupleExpr ) override;
     85                class TupleIndexExpander {
     86                public:
     87                        Expression * postmutate( TupleIndexExpr * tupleExpr );
    9088                };
    9189
     
    116114                replacer.mutateDeclarationList( translationUnit );
    117115
    118                 TupleIndexExpander idxExpander;
     116                PassVisitor<TupleIndexExpander> idxExpander;
    119117                mutateAll( translationUnit, idxExpander );
    120118
     
    250248        }
    251249
    252         Expression * TupleIndexExpander::mutate( TupleIndexExpr * tupleExpr ) {
    253                 Expression * tuple = maybeMutate( tupleExpr->get_tuple(), *this );
     250        Expression * TupleIndexExpander::postmutate( TupleIndexExpr * tupleExpr ) {
     251                Expression * tuple = tupleExpr->get_tuple();
    254252                assert( tuple );
    255253                tupleExpr->set_tuple( nullptr );
Note: See TracChangeset for help on using the changeset viewer.