Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/PassVisitor.impl.h

    rb11d8e2 r447c356  
    22// IWYU pragma: private, include "PassVisitor.h"
    33
    4 #define VISIT_START( node )                     \
    5         __attribute__((unused))                   \
     4#define VISIT_START( node )                                     \
     5        __attribute__((unused))                                   \
     6        ChildrenGuard children_guard( get_visit_children_ptr() ); \
     7        __attribute__((unused))                                   \
    68        guard_value_impl guard( at_cleanup_impl(pass, 0) );       \
    7         bool visit_children = true;               \
    8         set_visit_children( visit_children );   \
    9         call_previsit( node );                    \
    10         if( visit_children ) {                    \
     9        call_previsit( node );                                    \
    1110
    1211#define VISIT_END( node )                       \
    13         }                                         \
    1412        call_postvisit( node );                   \
    1513
    16 #define MUTATE_START( node )                    \
    17         __attribute__((unused))                   \
     14#define MUTATE_START( node )                                    \
     15        __attribute__((unused))                                   \
     16        ChildrenGuard children_guard( get_visit_children_ptr() ); \
     17        __attribute__((unused))                                   \
    1818        guard_value_impl guard( at_cleanup_impl(pass, 0) );       \
    19         bool visit_children = true;               \
    20         set_visit_children( visit_children );   \
    21         call_premutate( node );                   \
    22         if( visit_children ) {                    \
     19        call_premutate( node );                                   \
    2320
    2421#define MUTATE_END( type, node )                \
    25         }                                         \
    2622        return call_postmutate< type * >( node ); \
    2723
    2824
    29 #define VISIT_BODY( node )        \
    30         VISIT_START( node );        \
    31         Visitor::visit( node );     \
    32         VISIT_END( node );          \
    33 
    34 
    35 #define MUTATE_BODY( type, node ) \
    36         MUTATE_START( node );       \
    37         Mutator::mutate( node );    \
    38         MUTATE_END( type, node );   \
     25#define VISIT_BODY( node )          \
     26        VISIT_START( node );          \
     27        if( children_guard ) {        \
     28                Visitor::visit( node ); \
     29        }                             \
     30        VISIT_END( node );            \
     31
     32
     33#define MUTATE_BODY( type, node )    \
     34        MUTATE_START( node );          \
     35        if( children_guard ) {         \
     36                Mutator::mutate( node ); \
     37        }                              \
     38        MUTATE_END( type, node );      \
    3939
    4040
     
    6363template< typename pass_type >
    6464static inline void acceptAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& visitor ) {
    65 
    6665        DeclList_t* beforeDecls = visitor.get_beforeDecls();
    6766        DeclList_t* afterDecls  = visitor.get_afterDecls();
     
    7675                try {
    7776                        // run visitor on declaration
    78                         maybeAccept( *i, visitor );
     77                        maybeAccept_impl( *i, visitor );
    7978                } catch( SemanticError &e ) {
    8079                        e.set_location( (*i)->location );
     
    9291template< typename pass_type >
    9392static inline void mutateAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& mutator ) {
    94 
    9593        DeclList_t* beforeDecls = mutator.get_beforeDecls();
    9694        DeclList_t* afterDecls  = mutator.get_afterDecls();
     
    104102                try {
    105103                        // run mutator on declaration
    106                         *i = maybeMutate( *i, mutator );
     104                        maybeMutate_impl( *i, mutator );
    107105                } catch( SemanticError &e ) {
    108106                        e.set_location( (*i)->location );
     
    118116}
    119117
    120 template< typename Container, typename VisitorType >
    121 inline void maybeAccept( Container &container, VisitorType &visitor ) {
     118template< typename TreeType, typename pass_type >
     119inline void maybeAccept_impl( TreeType * tree, PassVisitor< pass_type > & visitor ) {
     120        if ( ! visitor.get_visit_children() ) return;
     121        if ( tree ) {
     122                tree->accept( visitor );
     123        }
     124}
     125
     126template< typename Container, typename pass_type >
     127inline void maybeAccept_impl( Container & container, PassVisitor< pass_type > & visitor ) {
     128        if ( ! visitor.get_visit_children() ) return;
    122129        SemanticError errors;
    123130        for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
     
    136143}
    137144
    138 template< typename Container, typename MutatorType >
    139 inline void maybeMutateRef( Container &container, MutatorType &mutator ) {
     145template< typename TreeType, typename pass_type >
     146inline void maybeMutate_impl( TreeType *& tree, PassVisitor< pass_type > & mutator ) {
     147        if ( ! mutator.get_visit_children() ) return;
     148
     149        if ( tree ) {
     150                tree = strict_dynamic_cast< TreeType * >( tree->acceptMutator( mutator ) );
     151        }
     152}
     153
     154template< typename Container, typename pass_type >
     155inline void maybeMutate_impl( Container & container, PassVisitor< pass_type > & mutator ) {
     156        if ( ! mutator.get_visit_children() ) return;
    140157        SemanticError errors;
    141158        for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
    142159                try {
    143160                        if ( *i ) {
    144 ///                 *i = (*i)->acceptMutator( mutator );
    145161                                *i = dynamic_cast< typename Container::value_type >( (*i)->acceptMutator( mutator ) );
    146162                                assert( *i );
     
    159175template< typename func_t >
    160176void PassVisitor< pass_type >::handleStatementList( std::list< Statement * > & statements, func_t func ) {
     177        if ( ! get_visit_children() ) return;
    161178        SemanticError errors;
    162179
     
    199216void PassVisitor< pass_type >::visitStatementList( std::list< Statement * > & statements ) {
    200217        handleStatementList( statements, [this]( Statement * stmt) {
    201                 stmt->accept( *this );
     218                maybeAccept_impl( stmt, *this );
    202219        });
    203220}
     
    206223void PassVisitor< pass_type >::mutateStatementList( std::list< Statement * > & statements ) {
    207224        handleStatementList( statements, [this]( Statement *& stmt) {
    208                 stmt = stmt->acceptMutator( *this );
     225                maybeMutate_impl( stmt, *this );
    209226        });
    210227}
     
    214231template< typename func_t >
    215232Statement * PassVisitor< pass_type >::handleStatement( Statement * stmt, func_t func ) {
     233        if ( ! get_visit_children() ) return stmt;
     234
    216235        // don't want statements from outer CompoundStmts to be added to this CompoundStmt
    217236        ValueGuardPtr< TypeSubstitution * >  oldEnv        ( get_env_ptr    () );
     
    244263Statement * PassVisitor< pass_type >::visitStatement( Statement * stmt ) {
    245264        return handleStatement( stmt, [this]( Statement * stmt ) {
    246                 maybeAccept( stmt, *this );
     265                maybeAccept_impl( stmt, *this );
    247266                return stmt;
    248267        });
     
    252271Statement * PassVisitor< pass_type >::mutateStatement( Statement * stmt ) {
    253272        return handleStatement( stmt, [this]( Statement * stmt ) {
    254                 return maybeMutate( stmt, *this );
     273                maybeMutate_impl( stmt, *this );
     274                return stmt;
    255275        });
    256276}
     
    259279template< typename func_t >
    260280Expression * PassVisitor< pass_type >::handleExpression( Expression * expr, func_t func ) {
     281        if ( ! get_visit_children() ) return expr;
    261282        if( !expr ) return nullptr;
    262283
     
    266287        }
    267288
    268         // should env be cloned (or moved) onto the result of the mutate?
     289        // should env be moved onto the result of the mutate?
    269290        return func( expr );
    270291}
     
    273294Expression * PassVisitor< pass_type >::visitExpression( Expression * expr ) {
    274295        return handleExpression(expr, [this]( Expression * expr ) {
    275                 expr->accept( *this );
     296                maybeAccept_impl( expr, *this );
    276297                return expr;
    277298        });
     
    281302Expression * PassVisitor< pass_type >::mutateExpression( Expression * expr ) {
    282303        return handleExpression(expr, [this]( Expression * expr ) {
    283                 return expr->acceptMutator( *this );
     304                maybeMutate_impl( expr, *this );
     305                return expr;
    284306        });
     307}
     308
     309template< typename TreeType, typename VisitorType >
     310inline void indexerScopedAccept( TreeType * tree, VisitorType & visitor ) {
     311        if ( ! visitor.get_visit_children() ) return;
     312        auto guard = makeFuncGuard(
     313                [&visitor]() { visitor.indexerScopeEnter(); },
     314                [&visitor]() { visitor.indexerScopeLeave(); }
     315        );
     316        maybeAccept_impl( tree, visitor );
     317}
     318
     319template< typename TreeType, typename MutatorType >
     320inline void indexerScopedMutate( TreeType *& tree, MutatorType & mutator ) {
     321        if ( ! mutator.get_visit_children() ) return;
     322        auto guard = makeFuncGuard(
     323                [&mutator]() { mutator.indexerScopeEnter(); },
     324                [&mutator]() { mutator.indexerScopeLeave(); }
     325        );
     326        maybeMutate_impl( tree, mutator );
    285327}
    286328
     
    319361
    320362        indexerScopedAccept( node->type         , *this );
    321         maybeAccept        ( node->init         , *this );
    322         maybeAccept        ( node->bitfieldWidth, *this );
     363        maybeAccept_impl   ( node->init         , *this );
     364        maybeAccept_impl   ( node->bitfieldWidth, *this );
     365        maybeAccept_impl   ( node->attributes   , *this );
    323366
    324367        if ( node->name != "" ) {
     
    334377
    335378        indexerScopedMutate( node->type         , *this );
    336         maybeMutateRef     ( node->init         , *this );
    337         maybeMutateRef     ( node->bitfieldWidth, *this );
     379        maybeMutate_impl   ( node->init         , *this );
     380        maybeMutate_impl   ( node->bitfieldWidth, *this );
     381        maybeMutate_impl   ( node->attributes   , *this );
    338382
    339383        if ( node->name != "" ) {
     
    356400        {
    357401                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    358                 maybeAccept( node->type, *this );
    359                 maybeAccept( node->statements, *this );
     402                maybeAccept_impl( node->type, *this );
     403                maybeAccept_impl( node->statements, *this );
     404                maybeAccept_impl( node->attributes, *this );
    360405        }
    361406
     
    373418        {
    374419                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    375                 maybeMutateRef( node->type, *this );
    376                 maybeMutateRef( node->statements, *this );
     420                maybeMutate_impl( node->type, *this );
     421                maybeMutate_impl( node->statements, *this );
     422                maybeMutate_impl( node->attributes, *this );
    377423        }
    378424
     
    392438        {
    393439                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    394                 maybeAccept( node->parameters, *this );
    395                 maybeAccept( node->members   , *this );
     440                maybeAccept_impl( node->parameters, *this );
     441                maybeAccept_impl( node->members   , *this );
    396442        }
    397443
     
    412458        {
    413459                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    414                 maybeMutateRef( node->parameters, *this );
    415                 maybeMutateRef( node->members   , *this );
     460                maybeMutate_impl( node->parameters, *this );
     461                maybeMutate_impl( node->members   , *this );
    416462        }
    417463
     
    433479        {
    434480                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    435                 maybeAccept( node->parameters, *this );
    436                 maybeAccept( node->members   , *this );
     481                maybeAccept_impl( node->parameters, *this );
     482                maybeAccept_impl( node->members   , *this );
    437483        }
    438484
     
    451497        {
    452498                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    453                 maybeMutateRef( node->parameters, *this );
    454                 maybeMutateRef( node->members   , *this );
     499                maybeMutate_impl( node->parameters, *this );
     500                maybeMutate_impl( node->members   , *this );
    455501        }
    456502
     
    469515
    470516        // unlike structs, traits, and unions, enums inject their members into the global scope
    471         maybeAccept( node->parameters, *this );
    472         maybeAccept( node->members   , *this );
     517        maybeAccept_impl( node->parameters, *this );
     518        maybeAccept_impl( node->members   , *this );
    473519
    474520        VISIT_END( node );
     
    482528
    483529        // unlike structs, traits, and unions, enums inject their members into the global scope
    484         maybeMutateRef( node->parameters, *this );
    485         maybeMutateRef( node->members   , *this );
     530        maybeMutate_impl( node->parameters, *this );
     531        maybeMutate_impl( node->members   , *this );
    486532
    487533        MUTATE_END( Declaration, node );
     
    496542        {
    497543                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    498                 maybeAccept( node->parameters, *this );
    499                 maybeAccept( node->members   , *this );
     544                maybeAccept_impl( node->parameters, *this );
     545                maybeAccept_impl( node->members   , *this );
    500546        }
    501547
     
    511557        {
    512558                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    513                 maybeMutateRef( node->parameters, *this );
    514                 maybeMutateRef( node->members   , *this );
     559                maybeMutate_impl( node->parameters, *this );
     560                maybeMutate_impl( node->members   , *this );
    515561        }
    516562
     
    528574        {
    529575                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    530                 maybeAccept( node->parameters, *this );
    531                 maybeAccept( node->base      , *this );
     576                maybeAccept_impl( node->parameters, *this );
     577                maybeAccept_impl( node->base      , *this );
    532578        }
    533579
     
    537583        indexerAddType( node );
    538584
    539         maybeAccept( node->assertions, *this );
     585        maybeAccept_impl( node->assertions, *this );
    540586
    541587        indexerScopedAccept( node->init, *this );
     
    550596        {
    551597                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    552                 maybeMutateRef( node->parameters, *this );
    553                 maybeMutateRef( node->base      , *this );
     598                maybeMutate_impl( node->parameters, *this );
     599                maybeMutate_impl( node->base      , *this );
    554600        }
    555601
     
    559605        indexerAddType( node );
    560606
    561         maybeMutateRef( node->assertions, *this );
     607        maybeMutate_impl( node->assertions, *this );
    562608
    563609        indexerScopedMutate( node->init, *this );
     
    574620        {
    575621                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    576                 maybeAccept( node->parameters, *this );
    577                 maybeAccept( node->base      , *this );
     622                maybeAccept_impl( node->parameters, *this );
     623                maybeAccept_impl( node->base      , *this );
    578624        }
    579625
    580626        indexerAddType( node );
    581627
    582         maybeAccept( node->assertions, *this );
     628        maybeAccept_impl( node->assertions, *this );
    583629
    584630        VISIT_END( node );
     
    591637        {
    592638                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    593                 maybeMutateRef     ( node->parameters, *this );
    594                 maybeMutateRef( node->base      , *this );
     639                maybeMutate_impl( node->parameters, *this );
     640                maybeMutate_impl( node->base      , *this );
    595641        }
    596642
    597643        indexerAddType( node );
    598644
    599         maybeMutateRef( node->assertions, *this );
     645        maybeMutate_impl( node->assertions, *this );
    600646
    601647        MUTATE_END( Declaration, node );
     
    608654        VISIT_START( node );
    609655
    610         maybeAccept( node->stmt, *this );
     656        maybeAccept_impl( node->stmt, *this );
    611657
    612658        VISIT_END( node );
     
    617663        MUTATE_START( node );
    618664
    619         maybeMutateRef( node->stmt, *this );
     665        maybeMutate_impl( node->stmt, *this );
    620666
    621667        MUTATE_END( AsmDecl, node );
     
    686732                // if statements introduce a level of scope (for the initialization)
    687733                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    688                 acceptAll( node->get_initialization(), *this );
    689                 visitExpression( node->condition );
     734                maybeAccept_impl( node->get_initialization(), *this );
     735                visitExpression ( node->condition );
    690736                node->thenPart = visitStatement( node->thenPart );
    691737                node->elsePart = visitStatement( node->elsePart );
     
    700746                // if statements introduce a level of scope (for the initialization)
    701747                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    702                 maybeMutateRef( node->get_initialization(), *this );
     748                maybeMutate_impl( node->get_initialization(), *this );
    703749                node->condition = mutateExpression( node->condition );
    704750                node->thenPart  = mutateStatement ( node->thenPart  );
     
    738784                // for statements introduce a level of scope (for the initialization)
    739785                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    740                 maybeAccept( node->initialization, *this );
     786                maybeAccept_impl( node->initialization, *this );
    741787                visitExpression( node->condition );
    742788                visitExpression( node->increment );
     
    752798                // for statements introduce a level of scope (for the initialization)
    753799                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    754                 maybeMutateRef( node->initialization, *this );
     800                maybeMutate_impl( node->initialization, *this );
    755801                node->condition = mutateExpression( node->condition );
    756802                node->increment = mutateExpression( node->increment );
     
    855901        VISIT_START( node );
    856902
    857         maybeAccept( node->block       , *this );
    858         maybeAccept( node->handlers    , *this );
    859         maybeAccept( node->finallyBlock, *this );
     903        maybeAccept_impl( node->block       , *this );
     904        maybeAccept_impl( node->handlers    , *this );
     905        maybeAccept_impl( node->finallyBlock, *this );
    860906
    861907        VISIT_END( node );
     
    866912        MUTATE_START( node );
    867913
    868         maybeMutateRef( node->block       , *this );
    869         maybeMutateRef( node->handlers    , *this );
    870         maybeMutateRef( node->finallyBlock, *this );
     914        maybeMutate_impl( node->block       , *this );
     915        maybeMutate_impl( node->handlers    , *this );
     916        maybeMutate_impl( node->finallyBlock, *this );
    871917
    872918        MUTATE_END( Statement, node );
     
    881927                // catch statements introduce a level of scope (for the caught exception)
    882928                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    883                 maybeAccept( node->decl, *this );
     929                maybeAccept_impl( node->decl, *this );
    884930                node->cond = visitExpression( node->cond );
    885931                node->body = visitStatement ( node->body );
     
    894940                // catch statements introduce a level of scope (for the caught exception)
    895941                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    896                 maybeMutateRef( node->decl, *this );
     942                maybeMutate_impl( node->decl, *this );
    897943                node->cond = mutateExpression( node->cond );
    898944                node->body = mutateStatement ( node->body );
     
    9681014
    9691015        indexerScopedAccept( node->result  , *this );
    970         maybeAccept        ( node->function, *this );
    971         maybeAccept        ( node->args    , *this );
     1016        maybeAccept_impl        ( node->function, *this );
     1017        maybeAccept_impl        ( node->args    , *this );
    9721018
    9731019        VISIT_END( node );
     
    9801026        indexerScopedMutate( node->env     , *this );
    9811027        indexerScopedMutate( node->result  , *this );
    982         maybeMutateRef     ( node->function, *this );
    983         maybeMutateRef     ( node->args    , *this );
     1028        maybeMutate_impl   ( node->function, *this );
     1029        maybeMutate_impl   ( node->args    , *this );
    9841030
    9851031        MUTATE_END( Expression, node );
     
    9921038        VISIT_START( node );
    9931039
    994         // maybeAccept( node->get_env(), *this );
     1040        // maybeAccept_impl( node->get_env(), *this );
    9951041        indexerScopedAccept( node->result, *this );
    9961042
     
    10441090
    10451091        indexerScopedAccept( node->result, *this );
    1046         maybeAccept        ( node->arg   , *this );
     1092        maybeAccept_impl        ( node->arg   , *this );
    10471093
    10481094        VISIT_END( node );
     
    10551101        indexerScopedMutate( node->env   , *this );
    10561102        indexerScopedMutate( node->result, *this );
    1057         maybeMutateRef     ( node->arg   , *this );
     1103        maybeMutate_impl   ( node->arg   , *this );
    10581104
    10591105        MUTATE_END( Expression, node );
     
    10671113
    10681114        indexerScopedAccept( node->result, *this );
    1069         maybeAccept( node->arg, *this );
     1115        maybeAccept_impl( node->arg, *this );
    10701116
    10711117        VISIT_END( node );
     
    10781124        indexerScopedMutate( node->env   , *this );
    10791125        indexerScopedMutate( node->result, *this );
    1080         maybeMutateRef     ( node->arg   , *this );
     1126        maybeMutate_impl   ( node->arg   , *this );
    10811127
    10821128        MUTATE_END( Expression, node );
     
    10901136
    10911137        indexerScopedAccept( node->result, *this );
    1092         maybeAccept        ( node->arg   , *this );
     1138        maybeAccept_impl   ( node->arg   , *this );
    10931139
    10941140        VISIT_END( node );
     
    11011147        indexerScopedMutate( node->env   , *this );
    11021148        indexerScopedMutate( node->result, *this );
    1103         maybeMutateRef     ( node->arg   , *this );
     1149        maybeMutate_impl   ( node->arg   , *this );
    11041150
    11051151        MUTATE_END( Expression, node );
     
    11341180
    11351181        indexerScopedAccept( node->result   , *this );
    1136         maybeAccept        ( node->aggregate, *this );
    1137         maybeAccept        ( node->member   , *this );
     1182        maybeAccept_impl   ( node->aggregate, *this );
     1183        maybeAccept_impl   ( node->member   , *this );
    11381184
    11391185        VISIT_END( node );
     
    11461192        indexerScopedMutate( node->env      , *this );
    11471193        indexerScopedMutate( node->result   , *this );
    1148         maybeMutateRef     ( node->aggregate, *this );
    1149         maybeMutateRef     ( node->member   , *this );
     1194        maybeMutate_impl   ( node->aggregate, *this );
     1195        maybeMutate_impl   ( node->member   , *this );
    11501196
    11511197        MUTATE_END( Expression, node );
     
    11591205
    11601206        indexerScopedAccept( node->result   , *this );
    1161         maybeAccept        ( node->aggregate, *this );
     1207        maybeAccept_impl   ( node->aggregate, *this );
    11621208
    11631209        VISIT_END( node );
     
    11701216        indexerScopedMutate( node->env      , *this );
    11711217        indexerScopedMutate( node->result   , *this );
    1172         maybeMutateRef     ( node->aggregate, *this );
     1218        maybeMutate_impl   ( node->aggregate, *this );
    11731219
    11741220        MUTATE_END( Expression, node );
     
    12031249
    12041250        indexerScopedAccept( node->result   , *this );
    1205         maybeAccept        ( &node->constant, *this );
     1251        maybeAccept_impl   ( &node->constant, *this );
    12061252
    12071253        VISIT_END( node );
     
    12141260        indexerScopedMutate( node->env   , *this );
    12151261        indexerScopedMutate( node->result, *this );
    1216         node->constant = *maybeMutate( &node->constant, *this );
     1262        Constant * ptr = &node->constant;
     1263        maybeMutate_impl( ptr, *this );
     1264        node->constant = *ptr;
    12171265
    12181266        MUTATE_END( Expression, node );
     
    12271275        indexerScopedAccept( node->result, *this );
    12281276        if ( node->get_isType() ) {
    1229                 maybeAccept( node->type, *this );
     1277                maybeAccept_impl( node->type, *this );
    12301278        } else {
    1231                 maybeAccept( node->expr, *this );
     1279                maybeAccept_impl( node->expr, *this );
    12321280        }
    12331281
     
    12421290        indexerScopedMutate( node->result, *this );
    12431291        if ( node->get_isType() ) {
    1244                 maybeMutateRef( node->type, *this );
     1292                maybeMutate_impl( node->type, *this );
    12451293        } else {
    1246                 maybeMutateRef( node->expr, *this );
     1294                maybeMutate_impl( node->expr, *this );
    12471295        }
    12481296
     
    12581306        indexerScopedAccept( node->result, *this );
    12591307        if ( node->get_isType() ) {
    1260                 maybeAccept( node->type, *this );
     1308                maybeAccept_impl( node->type, *this );
    12611309        } else {
    1262                 maybeAccept( node->expr, *this );
     1310                maybeAccept_impl( node->expr, *this );
    12631311        }
    12641312
     
    12731321        indexerScopedMutate( node->result, *this );
    12741322        if ( node->get_isType() ) {
    1275                 maybeMutateRef( node->type, *this );
     1323                maybeMutate_impl( node->type, *this );
    12761324        } else {
    1277                 maybeMutateRef( node->expr, *this );
     1325                maybeMutate_impl( node->expr, *this );
    12781326        }
    12791327
     
    12881336
    12891337        indexerScopedAccept( node->result, *this );
    1290         maybeAccept        ( node->type  , *this );
     1338        maybeAccept_impl   ( node->type  , *this );
    12911339
    12921340        VISIT_END( node );
     
    12991347        indexerScopedMutate( node->env   , *this );
    13001348        indexerScopedMutate( node->result, *this );
    1301         maybeMutateRef     ( node->type  , *this );
     1349        maybeMutate_impl   ( node->type  , *this );
    13021350
    13031351        MUTATE_END( Expression, node );
     
    13111359
    13121360        indexerScopedAccept( node->result, *this );
    1313         maybeAccept        ( node->type  , *this );
    1314         maybeAccept        ( node->member, *this );
     1361        maybeAccept_impl   ( node->type  , *this );
     1362        maybeAccept_impl   ( node->member, *this );
    13151363
    13161364        VISIT_END( node );
     
    13231371        indexerScopedMutate( node->env   , *this );
    13241372        indexerScopedMutate( node->result, *this );
    1325         maybeMutateRef     ( node->type  , *this );
    1326         maybeMutateRef     ( node->member, *this );
     1373        maybeMutate_impl   ( node->type  , *this );
     1374        maybeMutate_impl   ( node->member, *this );
    13271375
    13281376        MUTATE_END( Expression, node );
     
    13361384
    13371385        indexerScopedAccept( node->result, *this );
    1338         maybeAccept        ( node->type  , *this );
     1386        maybeAccept_impl   ( node->type  , *this );
    13391387
    13401388        VISIT_END( node );
     
    13471395        indexerScopedMutate( node->env   , *this );
    13481396        indexerScopedMutate( node->result, *this );
    1349         maybeMutateRef     ( node->type  , *this );
     1397        maybeMutate_impl   ( node->type  , *this );
    13501398
    13511399        MUTATE_END( Expression, node );
     
    13601408        indexerScopedAccept( node->result, *this );
    13611409        if ( node->get_isType() ) {
    1362                 maybeAccept( node->type, *this );
     1410                maybeAccept_impl( node->type, *this );
    13631411        } else {
    1364                 maybeAccept( node->expr, *this );
     1412                maybeAccept_impl( node->expr, *this );
    13651413        }
    13661414
     
    13751423        indexerScopedMutate( node->result, *this );
    13761424        if ( node->get_isType() ) {
    1377                 maybeMutateRef( node->type, *this );
     1425                maybeMutate_impl( node->type, *this );
    13781426        } else {
    1379                 maybeMutateRef( node->expr, *this );
     1427                maybeMutate_impl( node->expr, *this );
    13801428        }
    13811429
     
    13901438
    13911439        indexerScopedAccept( node->result, *this );
    1392         maybeAccept        ( node->arg1  , *this );
    1393         maybeAccept        ( node->arg2  , *this );
     1440        maybeAccept_impl   ( node->arg1  , *this );
     1441        maybeAccept_impl   ( node->arg2  , *this );
    13941442
    13951443        VISIT_END( node );
     
    14021450        indexerScopedMutate( node->env   , *this );
    14031451        indexerScopedMutate( node->result, *this );
    1404         maybeMutateRef     ( node->arg1  , *this );
    1405         maybeMutateRef     ( node->arg2  , *this );
     1452        maybeMutate_impl   ( node->arg1  , *this );
     1453        maybeMutate_impl   ( node->arg2  , *this );
    14061454
    14071455        MUTATE_END( Expression, node );
     
    14151463
    14161464        indexerScopedAccept( node->result, *this );
    1417         maybeAccept        ( node->arg1  , *this );
    1418         maybeAccept        ( node->arg2  , *this );
    1419         maybeAccept        ( node->arg3  , *this );
     1465        maybeAccept_impl        ( node->arg1  , *this );
     1466        maybeAccept_impl        ( node->arg2  , *this );
     1467        maybeAccept_impl        ( node->arg3  , *this );
    14201468
    14211469        VISIT_END( node );
     
    14281476        indexerScopedMutate( node->env   , *this );
    14291477        indexerScopedMutate( node->result, *this );
    1430         maybeMutateRef     ( node->arg1  , *this );
    1431         maybeMutateRef     ( node->arg2  , *this );
    1432         maybeMutateRef     ( node->arg3  , *this );
     1478        maybeMutate_impl   ( node->arg1  , *this );
     1479        maybeMutate_impl   ( node->arg2  , *this );
     1480        maybeMutate_impl   ( node->arg3  , *this );
    14331481
    14341482        MUTATE_END( Expression, node );
     
    14421490
    14431491        indexerScopedAccept( node->result, *this );
    1444         maybeAccept        ( node->arg1  , *this );
    1445         maybeAccept        ( node->arg2  , *this );
     1492        maybeAccept_impl   ( node->arg1  , *this );
     1493        maybeAccept_impl   ( node->arg2  , *this );
    14461494
    14471495        VISIT_END( node );
     
    14541502        indexerScopedMutate( node->env   , *this );
    14551503        indexerScopedMutate( node->result, *this );
    1456         maybeMutateRef     ( node->arg1  , *this );
    1457         maybeMutateRef     ( node->arg2  , *this );
     1504        maybeMutate_impl   ( node->arg1  , *this );
     1505        maybeMutate_impl   ( node->arg2  , *this );
    14581506
    14591507        MUTATE_END( Expression, node );
     
    14671515
    14681516        indexerScopedAccept( node->result, *this );
    1469         maybeAccept        ( node->type, *this );
     1517        maybeAccept_impl   ( node->type, *this );
    14701518
    14711519        VISIT_END( node );
     
    14781526        indexerScopedMutate( node->env   , *this );
    14791527        indexerScopedMutate( node->result, *this );
    1480         maybeMutateRef     ( node->type  , *this );
     1528        maybeMutate_impl   ( node->type  , *this );
    14811529
    14821530        MUTATE_END( Expression, node );
     
    14901538
    14911539        indexerScopedAccept( node->result    , *this );
    1492         maybeAccept        ( node->inout     , *this );
    1493         maybeAccept        ( node->constraint, *this );
    1494         maybeAccept        ( node->operand   , *this );
     1540        maybeAccept_impl   ( node->inout     , *this );
     1541        maybeAccept_impl   ( node->constraint, *this );
     1542        maybeAccept_impl   ( node->operand   , *this );
    14951543
    14961544        VISIT_END( node );
     
    15031551        indexerScopedMutate( node->env       , *this );
    15041552        indexerScopedMutate( node->result    , *this );
    1505         maybeMutateRef     ( node->inout     , *this );
    1506         maybeMutateRef     ( node->constraint, *this );
    1507         maybeMutateRef     ( node->operand   , *this );
     1553        maybeMutate_impl   ( node->inout     , *this );
     1554        maybeMutate_impl   ( node->constraint, *this );
     1555        maybeMutate_impl   ( node->operand   , *this );
    15081556
    15091557        MUTATE_END( Expression, node );
     
    15171565
    15181566        indexerScopedAccept( node->result     , *this );
    1519         maybeAccept        ( node->callExpr   , *this );
    1520         maybeAccept        ( node->tempDecls  , *this );
    1521         maybeAccept        ( node->returnDecls, *this );
    1522         maybeAccept        ( node->dtors      , *this );
     1567        maybeAccept_impl   ( node->callExpr   , *this );
     1568        maybeAccept_impl   ( node->tempDecls  , *this );
     1569        maybeAccept_impl   ( node->returnDecls, *this );
     1570        maybeAccept_impl   ( node->dtors      , *this );
    15231571
    15241572        VISIT_END( node );
     
    15311579        indexerScopedMutate( node->env        , *this );
    15321580        indexerScopedMutate( node->result     , *this );
    1533         maybeMutateRef     ( node->callExpr   , *this );
    1534         maybeMutateRef     ( node->tempDecls  , *this );
    1535         maybeMutateRef     ( node->returnDecls, *this );
    1536         maybeMutateRef     ( node->dtors      , *this );
     1581        maybeMutate_impl   ( node->callExpr   , *this );
     1582        maybeMutate_impl   ( node->tempDecls  , *this );
     1583        maybeMutate_impl   ( node->returnDecls, *this );
     1584        maybeMutate_impl   ( node->dtors      , *this );
    15371585
    15381586        MUTATE_END( Expression, node );
     
    15461594
    15471595        indexerScopedAccept( node->result  , *this );
    1548         maybeAccept        ( node->callExpr, *this );
     1596        maybeAccept_impl   ( node->callExpr, *this );
    15491597
    15501598        VISIT_END( node );
     
    15571605        indexerScopedMutate( node->env     , *this );
    15581606        indexerScopedMutate( node->result  , *this );
    1559         maybeMutateRef     ( node->callExpr, *this );
     1607        maybeMutate_impl   ( node->callExpr, *this );
    15601608
    15611609        MUTATE_END( Expression, node );
     
    15691617
    15701618        indexerScopedAccept( node->result     , *this );
    1571         maybeAccept        ( node->initializer, *this );
     1619        maybeAccept_impl   ( node->initializer, *this );
    15721620
    15731621        VISIT_END( node );
     
    15801628        indexerScopedMutate( node->env        , *this );
    15811629        indexerScopedMutate( node->result     , *this );
    1582         maybeMutateRef     ( node->initializer, *this );
     1630        maybeMutate_impl     ( node->initializer, *this );
    15831631
    15841632        MUTATE_END( Expression, node );
     
    15921640
    15931641        indexerScopedAccept( node->result, *this );
    1594         maybeAccept        ( node->low   , *this );
    1595         maybeAccept        ( node->high  , *this );
     1642        maybeAccept_impl   ( node->low   , *this );
     1643        maybeAccept_impl   ( node->high  , *this );
    15961644
    15971645        VISIT_END( node );
     
    16041652        indexerScopedMutate( node->env   , *this );
    16051653        indexerScopedMutate( node->result, *this );
    1606         maybeMutateRef     ( node->low   , *this );
    1607         maybeMutateRef     ( node->high  , *this );
     1654        maybeMutate_impl   ( node->low   , *this );
     1655        maybeMutate_impl   ( node->high  , *this );
    16081656
    16091657        MUTATE_END( Expression, node );
     
    16171665
    16181666        indexerScopedAccept( node->result, *this );
    1619         maybeAccept        ( node->exprs , *this );
     1667        maybeAccept_impl   ( node->exprs , *this );
    16201668
    16211669        VISIT_END( node );
     
    16281676        indexerScopedMutate( node->env   , *this );
    16291677        indexerScopedMutate( node->result, *this );
    1630         maybeMutateRef     ( node->exprs , *this );
     1678        maybeMutate_impl   ( node->exprs , *this );
    16311679
    16321680        MUTATE_END( Expression, node );
     
    16401688
    16411689        indexerScopedAccept( node->result, *this );
    1642         maybeAccept          ( node->exprs , *this );
     1690        maybeAccept_impl   ( node->exprs , *this );
    16431691
    16441692        VISIT_END( node );
     
    16511699        indexerScopedMutate( node->env   , *this );
    16521700        indexerScopedMutate( node->result, *this );
    1653         maybeMutateRef     ( node->exprs , *this );
     1701        maybeMutate_impl   ( node->exprs , *this );
    16541702
    16551703        MUTATE_END( Expression, node );
     
    16631711
    16641712        indexerScopedAccept( node->result, *this );
    1665         maybeAccept        ( node->tuple , *this );
     1713        maybeAccept_impl   ( node->tuple , *this );
    16661714
    16671715        VISIT_END( node );
     
    16741722        indexerScopedMutate( node->env   , *this );
    16751723        indexerScopedMutate( node->result, *this );
    1676         maybeMutateRef     ( node->tuple , *this );
     1724        maybeMutate_impl   ( node->tuple , *this );
    16771725
    16781726        MUTATE_END( Expression, node );
     
    16861734
    16871735        indexerScopedAccept( node->result  , *this );
    1688         maybeAccept        ( node->stmtExpr, *this );
     1736        maybeAccept_impl   ( node->stmtExpr, *this );
    16891737
    16901738        VISIT_END( node );
     
    16971745        indexerScopedMutate( node->env     , *this );
    16981746        indexerScopedMutate( node->result  , *this );
    1699         maybeMutateRef     ( node->stmtExpr, *this );
     1747        maybeMutate_impl   ( node->stmtExpr, *this );
    17001748
    17011749        MUTATE_END( Expression, node );
     
    17141762
    17151763        indexerScopedAccept( node->result     , *this );
    1716         maybeAccept        ( node->statements , *this );
    1717         maybeAccept        ( node->returnDecls, *this );
    1718         maybeAccept        ( node->dtors      , *this );
     1764        maybeAccept_impl   ( node->statements , *this );
     1765        maybeAccept_impl   ( node->returnDecls, *this );
     1766        maybeAccept_impl   ( node->dtors      , *this );
    17191767
    17201768        VISIT_END( node );
     
    17311779
    17321780        indexerScopedMutate( node->result     , *this );
    1733         maybeMutateRef     ( node->statements , *this );
    1734         maybeMutateRef     ( node->returnDecls, *this );
    1735         maybeMutateRef     ( node->dtors      , *this );
     1781        maybeMutate_impl   ( node->statements , *this );
     1782        maybeMutate_impl   ( node->returnDecls, *this );
     1783        maybeMutate_impl   ( node->dtors      , *this );
    17361784
    17371785        MUTATE_END( Expression, node );
     
    17451793
    17461794        indexerScopedAccept( node->result, *this );
    1747         maybeAccept        ( node->expr  , *this );
     1795        maybeAccept_impl   ( node->expr  , *this );
    17481796
    17491797        VISIT_END( node );
     
    17561804        indexerScopedMutate( node->env   , *this );
    17571805        indexerScopedMutate( node->result, *this );
    1758         maybeMutateRef     ( node->expr  , *this );
     1806        maybeMutate_impl   ( node->expr  , *this );
    17591807
    17601808        MUTATE_END( Expression, node );
     
    18011849        {
    18021850                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    1803                 maybeAccept( node->forall    , *this );
    1804                 maybeAccept( node->parameters, *this );
     1851                maybeAccept_impl( node->forall    , *this );
     1852                maybeAccept_impl( node->parameters, *this );
    18051853        }
    18061854
     
    18161864        {
    18171865                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    1818                 maybeMutateRef( node->forall    , *this );
    1819                 maybeMutateRef( node->parameters, *this );
     1866                maybeMutate_impl( node->forall    , *this );
     1867                maybeMutate_impl( node->parameters, *this );
    18201868        }
    18211869
     
    18331881        {
    18341882                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    1835                 maybeAccept( node->forall    , *this );
    1836                 maybeAccept( node->parameters, *this );
     1883                maybeAccept_impl( node->forall    , *this );
     1884                maybeAccept_impl( node->parameters, *this );
    18371885        }
    18381886
     
    18481896        {
    18491897                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    1850                 maybeMutateRef( node->forall    , *this );
    1851                 maybeMutateRef( node->parameters, *this );
     1898                maybeMutate_impl( node->forall    , *this );
     1899                maybeMutate_impl( node->parameters, *this );
    18521900        }
    18531901
     
    18731921        VISIT_START( node );
    18741922
    1875         maybeAccept( node->forall    , *this );
    1876         maybeAccept( node->parameters, *this );
     1923        maybeAccept_impl( node->forall    , *this );
     1924        maybeAccept_impl( node->parameters, *this );
    18771925
    18781926        VISIT_END( node );
     
    18831931        MUTATE_START( node );
    18841932
    1885         maybeMutateRef( node->forall    , *this );
    1886         maybeMutateRef( node->parameters, *this );
     1933        maybeMutate_impl( node->forall    , *this );
     1934        maybeMutate_impl( node->parameters, *this );
    18871935
    18881936        MUTATE_END( Type, node );
     
    19301978        VISIT_START( node );
    19311979
    1932         maybeAccept( node->get_designators(), *this );
     1980        maybeAccept_impl( node->get_designators(), *this );
    19331981
    19341982        VISIT_END( node );
     
    19391987        MUTATE_START( node );
    19401988
    1941         maybeMutateRef( node->get_designators(), *this );
     1989        maybeMutate_impl( node->get_designators(), *this );
    19421990
    19431991        MUTATE_END( Designation, node );
     
    19812029template< typename pass_type >
    19822030void PassVisitor< pass_type >::visit( Constant * node ) {
     2031        VISIT_BODY( node );
     2032}
     2033
     2034template< typename pass_type >
     2035void PassVisitor< pass_type >::visit( Attribute * node ) {
    19832036        VISIT_BODY( node );
    19842037}
     
    20692122        MUTATE_BODY( Constant, node );
    20702123}
     2124
     2125template< typename pass_type >
     2126Attribute * PassVisitor< pass_type >::mutate( Attribute * node  )  {
     2127        MUTATE_BODY( Attribute, node );
     2128}
     2129
     2130template< typename pass_type >
     2131TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) {
     2132        MUTATE_START( node );
     2133
     2134        for ( auto & p : node->typeEnv ) {
     2135                indexerScopedMutate( p.second, *this );
     2136        }
     2137        for ( auto & p : node->varEnv ) {
     2138                indexerScopedMutate( p.second, *this );
     2139        }
     2140
     2141        MUTATE_END( TypeSubstitution, node );
     2142}
Note: See TracChangeset for help on using the changeset viewer.