Ignore:
File:
1 edited

Legend:

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

    r447c356 rb11d8e2  
    22// IWYU pragma: private, include "PassVisitor.h"
    33
    4 #define VISIT_START( node )                                     \
    5         __attribute__((unused))                                   \
    6         ChildrenGuard children_guard( get_visit_children_ptr() ); \
    7         __attribute__((unused))                                   \
     4#define VISIT_START( node )                     \
     5        __attribute__((unused))                   \
    86        guard_value_impl guard( at_cleanup_impl(pass, 0) );       \
    9         call_previsit( node );                                    \
     7        bool visit_children = true;               \
     8        set_visit_children( visit_children );   \
     9        call_previsit( node );                    \
     10        if( visit_children ) {                    \
    1011
    1112#define VISIT_END( node )                       \
     13        }                                         \
    1214        call_postvisit( node );                   \
    1315
    14 #define MUTATE_START( node )                                    \
    15         __attribute__((unused))                                   \
    16         ChildrenGuard children_guard( get_visit_children_ptr() ); \
    17         __attribute__((unused))                                   \
     16#define MUTATE_START( node )                    \
     17        __attribute__((unused))                   \
    1818        guard_value_impl guard( at_cleanup_impl(pass, 0) );       \
    19         call_premutate( node );                                   \
     19        bool visit_children = true;               \
     20        set_visit_children( visit_children );   \
     21        call_premutate( node );                   \
     22        if( visit_children ) {                    \
    2023
    2124#define MUTATE_END( type, node )                \
     25        }                                         \
    2226        return call_postmutate< type * >( node ); \
    2327
    2428
    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 );      \
     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 );   \
    3939
    4040
     
    6363template< typename pass_type >
    6464static inline void acceptAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& visitor ) {
     65
    6566        DeclList_t* beforeDecls = visitor.get_beforeDecls();
    6667        DeclList_t* afterDecls  = visitor.get_afterDecls();
     
    7576                try {
    7677                        // run visitor on declaration
    77                         maybeAccept_impl( *i, visitor );
     78                        maybeAccept( *i, visitor );
    7879                } catch( SemanticError &e ) {
    7980                        e.set_location( (*i)->location );
     
    9192template< typename pass_type >
    9293static inline void mutateAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& mutator ) {
     94
    9395        DeclList_t* beforeDecls = mutator.get_beforeDecls();
    9496        DeclList_t* afterDecls  = mutator.get_afterDecls();
     
    102104                try {
    103105                        // run mutator on declaration
    104                         maybeMutate_impl( *i, mutator );
     106                        *i = maybeMutate( *i, mutator );
    105107                } catch( SemanticError &e ) {
    106108                        e.set_location( (*i)->location );
     
    116118}
    117119
    118 template< typename TreeType, typename pass_type >
    119 inline 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 
    126 template< typename Container, typename pass_type >
    127 inline void maybeAccept_impl( Container & container, PassVisitor< pass_type > & visitor ) {
    128         if ( ! visitor.get_visit_children() ) return;
     120template< typename Container, typename VisitorType >
     121inline void maybeAccept( Container &container, VisitorType &visitor ) {
    129122        SemanticError errors;
    130123        for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
     
    143136}
    144137
    145 template< typename TreeType, typename pass_type >
    146 inline 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 
    154 template< typename Container, typename pass_type >
    155 inline void maybeMutate_impl( Container & container, PassVisitor< pass_type > & mutator ) {
    156         if ( ! mutator.get_visit_children() ) return;
     138template< typename Container, typename MutatorType >
     139inline void maybeMutateRef( Container &container, MutatorType &mutator ) {
    157140        SemanticError errors;
    158141        for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {
    159142                try {
    160143                        if ( *i ) {
     144///                 *i = (*i)->acceptMutator( mutator );
    161145                                *i = dynamic_cast< typename Container::value_type >( (*i)->acceptMutator( mutator ) );
    162146                                assert( *i );
     
    175159template< typename func_t >
    176160void PassVisitor< pass_type >::handleStatementList( std::list< Statement * > & statements, func_t func ) {
    177         if ( ! get_visit_children() ) return;
    178161        SemanticError errors;
    179162
     
    216199void PassVisitor< pass_type >::visitStatementList( std::list< Statement * > & statements ) {
    217200        handleStatementList( statements, [this]( Statement * stmt) {
    218                 maybeAccept_impl( stmt, *this );
     201                stmt->accept( *this );
    219202        });
    220203}
     
    223206void PassVisitor< pass_type >::mutateStatementList( std::list< Statement * > & statements ) {
    224207        handleStatementList( statements, [this]( Statement *& stmt) {
    225                 maybeMutate_impl( stmt, *this );
     208                stmt = stmt->acceptMutator( *this );
    226209        });
    227210}
     
    231214template< typename func_t >
    232215Statement * PassVisitor< pass_type >::handleStatement( Statement * stmt, func_t func ) {
    233         if ( ! get_visit_children() ) return stmt;
    234 
    235216        // don't want statements from outer CompoundStmts to be added to this CompoundStmt
    236217        ValueGuardPtr< TypeSubstitution * >  oldEnv        ( get_env_ptr    () );
     
    263244Statement * PassVisitor< pass_type >::visitStatement( Statement * stmt ) {
    264245        return handleStatement( stmt, [this]( Statement * stmt ) {
    265                 maybeAccept_impl( stmt, *this );
     246                maybeAccept( stmt, *this );
    266247                return stmt;
    267248        });
     
    271252Statement * PassVisitor< pass_type >::mutateStatement( Statement * stmt ) {
    272253        return handleStatement( stmt, [this]( Statement * stmt ) {
    273                 maybeMutate_impl( stmt, *this );
    274                 return stmt;
     254                return maybeMutate( stmt, *this );
    275255        });
    276256}
     
    279259template< typename func_t >
    280260Expression * PassVisitor< pass_type >::handleExpression( Expression * expr, func_t func ) {
    281         if ( ! get_visit_children() ) return expr;
    282261        if( !expr ) return nullptr;
    283262
     
    287266        }
    288267
    289         // should env be moved onto the result of the mutate?
     268        // should env be cloned (or moved) onto the result of the mutate?
    290269        return func( expr );
    291270}
     
    294273Expression * PassVisitor< pass_type >::visitExpression( Expression * expr ) {
    295274        return handleExpression(expr, [this]( Expression * expr ) {
    296                 maybeAccept_impl( expr, *this );
     275                expr->accept( *this );
    297276                return expr;
    298277        });
     
    302281Expression * PassVisitor< pass_type >::mutateExpression( Expression * expr ) {
    303282        return handleExpression(expr, [this]( Expression * expr ) {
    304                 maybeMutate_impl( expr, *this );
    305                 return expr;
     283                return expr->acceptMutator( *this );
    306284        });
    307 }
    308 
    309 template< typename TreeType, typename VisitorType >
    310 inline 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 
    319 template< typename TreeType, typename MutatorType >
    320 inline 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 );
    327285}
    328286
     
    361319
    362320        indexerScopedAccept( node->type         , *this );
    363         maybeAccept_impl   ( node->init         , *this );
    364         maybeAccept_impl   ( node->bitfieldWidth, *this );
    365         maybeAccept_impl   ( node->attributes   , *this );
     321        maybeAccept        ( node->init         , *this );
     322        maybeAccept        ( node->bitfieldWidth, *this );
    366323
    367324        if ( node->name != "" ) {
     
    377334
    378335        indexerScopedMutate( node->type         , *this );
    379         maybeMutate_impl   ( node->init         , *this );
    380         maybeMutate_impl   ( node->bitfieldWidth, *this );
    381         maybeMutate_impl   ( node->attributes   , *this );
     336        maybeMutateRef     ( node->init         , *this );
     337        maybeMutateRef     ( node->bitfieldWidth, *this );
    382338
    383339        if ( node->name != "" ) {
     
    400356        {
    401357                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    402                 maybeAccept_impl( node->type, *this );
    403                 maybeAccept_impl( node->statements, *this );
    404                 maybeAccept_impl( node->attributes, *this );
     358                maybeAccept( node->type, *this );
     359                maybeAccept( node->statements, *this );
    405360        }
    406361
     
    418373        {
    419374                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    420                 maybeMutate_impl( node->type, *this );
    421                 maybeMutate_impl( node->statements, *this );
    422                 maybeMutate_impl( node->attributes, *this );
     375                maybeMutateRef( node->type, *this );
     376                maybeMutateRef( node->statements, *this );
    423377        }
    424378
     
    438392        {
    439393                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    440                 maybeAccept_impl( node->parameters, *this );
    441                 maybeAccept_impl( node->members   , *this );
     394                maybeAccept( node->parameters, *this );
     395                maybeAccept( node->members   , *this );
    442396        }
    443397
     
    458412        {
    459413                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    460                 maybeMutate_impl( node->parameters, *this );
    461                 maybeMutate_impl( node->members   , *this );
     414                maybeMutateRef( node->parameters, *this );
     415                maybeMutateRef( node->members   , *this );
    462416        }
    463417
     
    479433        {
    480434                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    481                 maybeAccept_impl( node->parameters, *this );
    482                 maybeAccept_impl( node->members   , *this );
     435                maybeAccept( node->parameters, *this );
     436                maybeAccept( node->members   , *this );
    483437        }
    484438
     
    497451        {
    498452                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    499                 maybeMutate_impl( node->parameters, *this );
    500                 maybeMutate_impl( node->members   , *this );
     453                maybeMutateRef( node->parameters, *this );
     454                maybeMutateRef( node->members   , *this );
    501455        }
    502456
     
    515469
    516470        // unlike structs, traits, and unions, enums inject their members into the global scope
    517         maybeAccept_impl( node->parameters, *this );
    518         maybeAccept_impl( node->members   , *this );
     471        maybeAccept( node->parameters, *this );
     472        maybeAccept( node->members   , *this );
    519473
    520474        VISIT_END( node );
     
    528482
    529483        // unlike structs, traits, and unions, enums inject their members into the global scope
    530         maybeMutate_impl( node->parameters, *this );
    531         maybeMutate_impl( node->members   , *this );
     484        maybeMutateRef( node->parameters, *this );
     485        maybeMutateRef( node->members   , *this );
    532486
    533487        MUTATE_END( Declaration, node );
     
    542496        {
    543497                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    544                 maybeAccept_impl( node->parameters, *this );
    545                 maybeAccept_impl( node->members   , *this );
     498                maybeAccept( node->parameters, *this );
     499                maybeAccept( node->members   , *this );
    546500        }
    547501
     
    557511        {
    558512                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    559                 maybeMutate_impl( node->parameters, *this );
    560                 maybeMutate_impl( node->members   , *this );
     513                maybeMutateRef( node->parameters, *this );
     514                maybeMutateRef( node->members   , *this );
    561515        }
    562516
     
    574528        {
    575529                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    576                 maybeAccept_impl( node->parameters, *this );
    577                 maybeAccept_impl( node->base      , *this );
     530                maybeAccept( node->parameters, *this );
     531                maybeAccept( node->base      , *this );
    578532        }
    579533
     
    583537        indexerAddType( node );
    584538
    585         maybeAccept_impl( node->assertions, *this );
     539        maybeAccept( node->assertions, *this );
    586540
    587541        indexerScopedAccept( node->init, *this );
     
    596550        {
    597551                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    598                 maybeMutate_impl( node->parameters, *this );
    599                 maybeMutate_impl( node->base      , *this );
     552                maybeMutateRef( node->parameters, *this );
     553                maybeMutateRef( node->base      , *this );
    600554        }
    601555
     
    605559        indexerAddType( node );
    606560
    607         maybeMutate_impl( node->assertions, *this );
     561        maybeMutateRef( node->assertions, *this );
    608562
    609563        indexerScopedMutate( node->init, *this );
     
    620574        {
    621575                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    622                 maybeAccept_impl( node->parameters, *this );
    623                 maybeAccept_impl( node->base      , *this );
     576                maybeAccept( node->parameters, *this );
     577                maybeAccept( node->base      , *this );
    624578        }
    625579
    626580        indexerAddType( node );
    627581
    628         maybeAccept_impl( node->assertions, *this );
     582        maybeAccept( node->assertions, *this );
    629583
    630584        VISIT_END( node );
     
    637591        {
    638592                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    639                 maybeMutate_impl( node->parameters, *this );
    640                 maybeMutate_impl( node->base      , *this );
     593                maybeMutateRef     ( node->parameters, *this );
     594                maybeMutateRef( node->base      , *this );
    641595        }
    642596
    643597        indexerAddType( node );
    644598
    645         maybeMutate_impl( node->assertions, *this );
     599        maybeMutateRef( node->assertions, *this );
    646600
    647601        MUTATE_END( Declaration, node );
     
    654608        VISIT_START( node );
    655609
    656         maybeAccept_impl( node->stmt, *this );
     610        maybeAccept( node->stmt, *this );
    657611
    658612        VISIT_END( node );
     
    663617        MUTATE_START( node );
    664618
    665         maybeMutate_impl( node->stmt, *this );
     619        maybeMutateRef( node->stmt, *this );
    666620
    667621        MUTATE_END( AsmDecl, node );
     
    732686                // if statements introduce a level of scope (for the initialization)
    733687                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    734                 maybeAccept_impl( node->get_initialization(), *this );
    735                 visitExpression ( node->condition );
     688                acceptAll( node->get_initialization(), *this );
     689                visitExpression( node->condition );
    736690                node->thenPart = visitStatement( node->thenPart );
    737691                node->elsePart = visitStatement( node->elsePart );
     
    746700                // if statements introduce a level of scope (for the initialization)
    747701                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    748                 maybeMutate_impl( node->get_initialization(), *this );
     702                maybeMutateRef( node->get_initialization(), *this );
    749703                node->condition = mutateExpression( node->condition );
    750704                node->thenPart  = mutateStatement ( node->thenPart  );
     
    784738                // for statements introduce a level of scope (for the initialization)
    785739                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    786                 maybeAccept_impl( node->initialization, *this );
     740                maybeAccept( node->initialization, *this );
    787741                visitExpression( node->condition );
    788742                visitExpression( node->increment );
     
    798752                // for statements introduce a level of scope (for the initialization)
    799753                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    800                 maybeMutate_impl( node->initialization, *this );
     754                maybeMutateRef( node->initialization, *this );
    801755                node->condition = mutateExpression( node->condition );
    802756                node->increment = mutateExpression( node->increment );
     
    901855        VISIT_START( node );
    902856
    903         maybeAccept_impl( node->block       , *this );
    904         maybeAccept_impl( node->handlers    , *this );
    905         maybeAccept_impl( node->finallyBlock, *this );
     857        maybeAccept( node->block       , *this );
     858        maybeAccept( node->handlers    , *this );
     859        maybeAccept( node->finallyBlock, *this );
    906860
    907861        VISIT_END( node );
     
    912866        MUTATE_START( node );
    913867
    914         maybeMutate_impl( node->block       , *this );
    915         maybeMutate_impl( node->handlers    , *this );
    916         maybeMutate_impl( node->finallyBlock, *this );
     868        maybeMutateRef( node->block       , *this );
     869        maybeMutateRef( node->handlers    , *this );
     870        maybeMutateRef( node->finallyBlock, *this );
    917871
    918872        MUTATE_END( Statement, node );
     
    927881                // catch statements introduce a level of scope (for the caught exception)
    928882                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    929                 maybeAccept_impl( node->decl, *this );
     883                maybeAccept( node->decl, *this );
    930884                node->cond = visitExpression( node->cond );
    931885                node->body = visitStatement ( node->body );
     
    940894                // catch statements introduce a level of scope (for the caught exception)
    941895                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    942                 maybeMutate_impl( node->decl, *this );
     896                maybeMutateRef( node->decl, *this );
    943897                node->cond = mutateExpression( node->cond );
    944898                node->body = mutateStatement ( node->body );
     
    1014968
    1015969        indexerScopedAccept( node->result  , *this );
    1016         maybeAccept_impl        ( node->function, *this );
    1017         maybeAccept_impl        ( node->args    , *this );
     970        maybeAccept        ( node->function, *this );
     971        maybeAccept        ( node->args    , *this );
    1018972
    1019973        VISIT_END( node );
     
    1026980        indexerScopedMutate( node->env     , *this );
    1027981        indexerScopedMutate( node->result  , *this );
    1028         maybeMutate_impl   ( node->function, *this );
    1029         maybeMutate_impl   ( node->args    , *this );
     982        maybeMutateRef     ( node->function, *this );
     983        maybeMutateRef     ( node->args    , *this );
    1030984
    1031985        MUTATE_END( Expression, node );
     
    1038992        VISIT_START( node );
    1039993
    1040         // maybeAccept_impl( node->get_env(), *this );
     994        // maybeAccept( node->get_env(), *this );
    1041995        indexerScopedAccept( node->result, *this );
    1042996
     
    10901044
    10911045        indexerScopedAccept( node->result, *this );
    1092         maybeAccept_impl        ( node->arg   , *this );
     1046        maybeAccept        ( node->arg   , *this );
    10931047
    10941048        VISIT_END( node );
     
    11011055        indexerScopedMutate( node->env   , *this );
    11021056        indexerScopedMutate( node->result, *this );
    1103         maybeMutate_impl   ( node->arg   , *this );
     1057        maybeMutateRef     ( node->arg   , *this );
    11041058
    11051059        MUTATE_END( Expression, node );
     
    11131067
    11141068        indexerScopedAccept( node->result, *this );
    1115         maybeAccept_impl( node->arg, *this );
     1069        maybeAccept( node->arg, *this );
    11161070
    11171071        VISIT_END( node );
     
    11241078        indexerScopedMutate( node->env   , *this );
    11251079        indexerScopedMutate( node->result, *this );
    1126         maybeMutate_impl   ( node->arg   , *this );
     1080        maybeMutateRef     ( node->arg   , *this );
    11271081
    11281082        MUTATE_END( Expression, node );
     
    11361090
    11371091        indexerScopedAccept( node->result, *this );
    1138         maybeAccept_impl   ( node->arg   , *this );
     1092        maybeAccept        ( node->arg   , *this );
    11391093
    11401094        VISIT_END( node );
     
    11471101        indexerScopedMutate( node->env   , *this );
    11481102        indexerScopedMutate( node->result, *this );
    1149         maybeMutate_impl   ( node->arg   , *this );
     1103        maybeMutateRef     ( node->arg   , *this );
    11501104
    11511105        MUTATE_END( Expression, node );
     
    11801134
    11811135        indexerScopedAccept( node->result   , *this );
    1182         maybeAccept_impl   ( node->aggregate, *this );
    1183         maybeAccept_impl   ( node->member   , *this );
     1136        maybeAccept        ( node->aggregate, *this );
     1137        maybeAccept        ( node->member   , *this );
    11841138
    11851139        VISIT_END( node );
     
    11921146        indexerScopedMutate( node->env      , *this );
    11931147        indexerScopedMutate( node->result   , *this );
    1194         maybeMutate_impl   ( node->aggregate, *this );
    1195         maybeMutate_impl   ( node->member   , *this );
     1148        maybeMutateRef     ( node->aggregate, *this );
     1149        maybeMutateRef     ( node->member   , *this );
    11961150
    11971151        MUTATE_END( Expression, node );
     
    12051159
    12061160        indexerScopedAccept( node->result   , *this );
    1207         maybeAccept_impl   ( node->aggregate, *this );
     1161        maybeAccept        ( node->aggregate, *this );
    12081162
    12091163        VISIT_END( node );
     
    12161170        indexerScopedMutate( node->env      , *this );
    12171171        indexerScopedMutate( node->result   , *this );
    1218         maybeMutate_impl   ( node->aggregate, *this );
     1172        maybeMutateRef     ( node->aggregate, *this );
    12191173
    12201174        MUTATE_END( Expression, node );
     
    12491203
    12501204        indexerScopedAccept( node->result   , *this );
    1251         maybeAccept_impl   ( &node->constant, *this );
     1205        maybeAccept        ( &node->constant, *this );
    12521206
    12531207        VISIT_END( node );
     
    12601214        indexerScopedMutate( node->env   , *this );
    12611215        indexerScopedMutate( node->result, *this );
    1262         Constant * ptr = &node->constant;
    1263         maybeMutate_impl( ptr, *this );
    1264         node->constant = *ptr;
     1216        node->constant = *maybeMutate( &node->constant, *this );
    12651217
    12661218        MUTATE_END( Expression, node );
     
    12751227        indexerScopedAccept( node->result, *this );
    12761228        if ( node->get_isType() ) {
    1277                 maybeAccept_impl( node->type, *this );
     1229                maybeAccept( node->type, *this );
    12781230        } else {
    1279                 maybeAccept_impl( node->expr, *this );
     1231                maybeAccept( node->expr, *this );
    12801232        }
    12811233
     
    12901242        indexerScopedMutate( node->result, *this );
    12911243        if ( node->get_isType() ) {
    1292                 maybeMutate_impl( node->type, *this );
     1244                maybeMutateRef( node->type, *this );
    12931245        } else {
    1294                 maybeMutate_impl( node->expr, *this );
     1246                maybeMutateRef( node->expr, *this );
    12951247        }
    12961248
     
    13061258        indexerScopedAccept( node->result, *this );
    13071259        if ( node->get_isType() ) {
    1308                 maybeAccept_impl( node->type, *this );
     1260                maybeAccept( node->type, *this );
    13091261        } else {
    1310                 maybeAccept_impl( node->expr, *this );
     1262                maybeAccept( node->expr, *this );
    13111263        }
    13121264
     
    13211273        indexerScopedMutate( node->result, *this );
    13221274        if ( node->get_isType() ) {
    1323                 maybeMutate_impl( node->type, *this );
     1275                maybeMutateRef( node->type, *this );
    13241276        } else {
    1325                 maybeMutate_impl( node->expr, *this );
     1277                maybeMutateRef( node->expr, *this );
    13261278        }
    13271279
     
    13361288
    13371289        indexerScopedAccept( node->result, *this );
    1338         maybeAccept_impl   ( node->type  , *this );
     1290        maybeAccept        ( node->type  , *this );
    13391291
    13401292        VISIT_END( node );
     
    13471299        indexerScopedMutate( node->env   , *this );
    13481300        indexerScopedMutate( node->result, *this );
    1349         maybeMutate_impl   ( node->type  , *this );
     1301        maybeMutateRef     ( node->type  , *this );
    13501302
    13511303        MUTATE_END( Expression, node );
     
    13591311
    13601312        indexerScopedAccept( node->result, *this );
    1361         maybeAccept_impl   ( node->type  , *this );
    1362         maybeAccept_impl   ( node->member, *this );
     1313        maybeAccept        ( node->type  , *this );
     1314        maybeAccept        ( node->member, *this );
    13631315
    13641316        VISIT_END( node );
     
    13711323        indexerScopedMutate( node->env   , *this );
    13721324        indexerScopedMutate( node->result, *this );
    1373         maybeMutate_impl   ( node->type  , *this );
    1374         maybeMutate_impl   ( node->member, *this );
     1325        maybeMutateRef     ( node->type  , *this );
     1326        maybeMutateRef     ( node->member, *this );
    13751327
    13761328        MUTATE_END( Expression, node );
     
    13841336
    13851337        indexerScopedAccept( node->result, *this );
    1386         maybeAccept_impl   ( node->type  , *this );
     1338        maybeAccept        ( node->type  , *this );
    13871339
    13881340        VISIT_END( node );
     
    13951347        indexerScopedMutate( node->env   , *this );
    13961348        indexerScopedMutate( node->result, *this );
    1397         maybeMutate_impl   ( node->type  , *this );
     1349        maybeMutateRef     ( node->type  , *this );
    13981350
    13991351        MUTATE_END( Expression, node );
     
    14081360        indexerScopedAccept( node->result, *this );
    14091361        if ( node->get_isType() ) {
    1410                 maybeAccept_impl( node->type, *this );
     1362                maybeAccept( node->type, *this );
    14111363        } else {
    1412                 maybeAccept_impl( node->expr, *this );
     1364                maybeAccept( node->expr, *this );
    14131365        }
    14141366
     
    14231375        indexerScopedMutate( node->result, *this );
    14241376        if ( node->get_isType() ) {
    1425                 maybeMutate_impl( node->type, *this );
     1377                maybeMutateRef( node->type, *this );
    14261378        } else {
    1427                 maybeMutate_impl( node->expr, *this );
     1379                maybeMutateRef( node->expr, *this );
    14281380        }
    14291381
     
    14381390
    14391391        indexerScopedAccept( node->result, *this );
    1440         maybeAccept_impl   ( node->arg1  , *this );
    1441         maybeAccept_impl   ( node->arg2  , *this );
     1392        maybeAccept        ( node->arg1  , *this );
     1393        maybeAccept        ( node->arg2  , *this );
    14421394
    14431395        VISIT_END( node );
     
    14501402        indexerScopedMutate( node->env   , *this );
    14511403        indexerScopedMutate( node->result, *this );
    1452         maybeMutate_impl   ( node->arg1  , *this );
    1453         maybeMutate_impl   ( node->arg2  , *this );
     1404        maybeMutateRef     ( node->arg1  , *this );
     1405        maybeMutateRef     ( node->arg2  , *this );
    14541406
    14551407        MUTATE_END( Expression, node );
     
    14631415
    14641416        indexerScopedAccept( node->result, *this );
    1465         maybeAccept_impl        ( node->arg1  , *this );
    1466         maybeAccept_impl        ( node->arg2  , *this );
    1467         maybeAccept_impl        ( node->arg3  , *this );
     1417        maybeAccept        ( node->arg1  , *this );
     1418        maybeAccept        ( node->arg2  , *this );
     1419        maybeAccept        ( node->arg3  , *this );
    14681420
    14691421        VISIT_END( node );
     
    14761428        indexerScopedMutate( node->env   , *this );
    14771429        indexerScopedMutate( node->result, *this );
    1478         maybeMutate_impl   ( node->arg1  , *this );
    1479         maybeMutate_impl   ( node->arg2  , *this );
    1480         maybeMutate_impl   ( node->arg3  , *this );
     1430        maybeMutateRef     ( node->arg1  , *this );
     1431        maybeMutateRef     ( node->arg2  , *this );
     1432        maybeMutateRef     ( node->arg3  , *this );
    14811433
    14821434        MUTATE_END( Expression, node );
     
    14901442
    14911443        indexerScopedAccept( node->result, *this );
    1492         maybeAccept_impl   ( node->arg1  , *this );
    1493         maybeAccept_impl   ( node->arg2  , *this );
     1444        maybeAccept        ( node->arg1  , *this );
     1445        maybeAccept        ( node->arg2  , *this );
    14941446
    14951447        VISIT_END( node );
     
    15021454        indexerScopedMutate( node->env   , *this );
    15031455        indexerScopedMutate( node->result, *this );
    1504         maybeMutate_impl   ( node->arg1  , *this );
    1505         maybeMutate_impl   ( node->arg2  , *this );
     1456        maybeMutateRef     ( node->arg1  , *this );
     1457        maybeMutateRef     ( node->arg2  , *this );
    15061458
    15071459        MUTATE_END( Expression, node );
     
    15151467
    15161468        indexerScopedAccept( node->result, *this );
    1517         maybeAccept_impl   ( node->type, *this );
     1469        maybeAccept        ( node->type, *this );
    15181470
    15191471        VISIT_END( node );
     
    15261478        indexerScopedMutate( node->env   , *this );
    15271479        indexerScopedMutate( node->result, *this );
    1528         maybeMutate_impl   ( node->type  , *this );
     1480        maybeMutateRef     ( node->type  , *this );
    15291481
    15301482        MUTATE_END( Expression, node );
     
    15381490
    15391491        indexerScopedAccept( node->result    , *this );
    1540         maybeAccept_impl   ( node->inout     , *this );
    1541         maybeAccept_impl   ( node->constraint, *this );
    1542         maybeAccept_impl   ( node->operand   , *this );
     1492        maybeAccept        ( node->inout     , *this );
     1493        maybeAccept        ( node->constraint, *this );
     1494        maybeAccept        ( node->operand   , *this );
    15431495
    15441496        VISIT_END( node );
     
    15511503        indexerScopedMutate( node->env       , *this );
    15521504        indexerScopedMutate( node->result    , *this );
    1553         maybeMutate_impl   ( node->inout     , *this );
    1554         maybeMutate_impl   ( node->constraint, *this );
    1555         maybeMutate_impl   ( node->operand   , *this );
     1505        maybeMutateRef     ( node->inout     , *this );
     1506        maybeMutateRef     ( node->constraint, *this );
     1507        maybeMutateRef     ( node->operand   , *this );
    15561508
    15571509        MUTATE_END( Expression, node );
     
    15651517
    15661518        indexerScopedAccept( node->result     , *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 );
     1519        maybeAccept        ( node->callExpr   , *this );
     1520        maybeAccept        ( node->tempDecls  , *this );
     1521        maybeAccept        ( node->returnDecls, *this );
     1522        maybeAccept        ( node->dtors      , *this );
    15711523
    15721524        VISIT_END( node );
     
    15791531        indexerScopedMutate( node->env        , *this );
    15801532        indexerScopedMutate( node->result     , *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 );
     1533        maybeMutateRef     ( node->callExpr   , *this );
     1534        maybeMutateRef     ( node->tempDecls  , *this );
     1535        maybeMutateRef     ( node->returnDecls, *this );
     1536        maybeMutateRef     ( node->dtors      , *this );
    15851537
    15861538        MUTATE_END( Expression, node );
     
    15941546
    15951547        indexerScopedAccept( node->result  , *this );
    1596         maybeAccept_impl   ( node->callExpr, *this );
     1548        maybeAccept        ( node->callExpr, *this );
    15971549
    15981550        VISIT_END( node );
     
    16051557        indexerScopedMutate( node->env     , *this );
    16061558        indexerScopedMutate( node->result  , *this );
    1607         maybeMutate_impl   ( node->callExpr, *this );
     1559        maybeMutateRef     ( node->callExpr, *this );
    16081560
    16091561        MUTATE_END( Expression, node );
     
    16171569
    16181570        indexerScopedAccept( node->result     , *this );
    1619         maybeAccept_impl   ( node->initializer, *this );
     1571        maybeAccept        ( node->initializer, *this );
    16201572
    16211573        VISIT_END( node );
     
    16281580        indexerScopedMutate( node->env        , *this );
    16291581        indexerScopedMutate( node->result     , *this );
    1630         maybeMutate_impl     ( node->initializer, *this );
     1582        maybeMutateRef     ( node->initializer, *this );
    16311583
    16321584        MUTATE_END( Expression, node );
     
    16401592
    16411593        indexerScopedAccept( node->result, *this );
    1642         maybeAccept_impl   ( node->low   , *this );
    1643         maybeAccept_impl   ( node->high  , *this );
     1594        maybeAccept        ( node->low   , *this );
     1595        maybeAccept        ( node->high  , *this );
    16441596
    16451597        VISIT_END( node );
     
    16521604        indexerScopedMutate( node->env   , *this );
    16531605        indexerScopedMutate( node->result, *this );
    1654         maybeMutate_impl   ( node->low   , *this );
    1655         maybeMutate_impl   ( node->high  , *this );
     1606        maybeMutateRef     ( node->low   , *this );
     1607        maybeMutateRef     ( node->high  , *this );
    16561608
    16571609        MUTATE_END( Expression, node );
     
    16651617
    16661618        indexerScopedAccept( node->result, *this );
    1667         maybeAccept_impl   ( node->exprs , *this );
     1619        maybeAccept        ( node->exprs , *this );
    16681620
    16691621        VISIT_END( node );
     
    16761628        indexerScopedMutate( node->env   , *this );
    16771629        indexerScopedMutate( node->result, *this );
    1678         maybeMutate_impl   ( node->exprs , *this );
     1630        maybeMutateRef     ( node->exprs , *this );
    16791631
    16801632        MUTATE_END( Expression, node );
     
    16881640
    16891641        indexerScopedAccept( node->result, *this );
    1690         maybeAccept_impl   ( node->exprs , *this );
     1642        maybeAccept          ( node->exprs , *this );
    16911643
    16921644        VISIT_END( node );
     
    16991651        indexerScopedMutate( node->env   , *this );
    17001652        indexerScopedMutate( node->result, *this );
    1701         maybeMutate_impl   ( node->exprs , *this );
     1653        maybeMutateRef     ( node->exprs , *this );
    17021654
    17031655        MUTATE_END( Expression, node );
     
    17111663
    17121664        indexerScopedAccept( node->result, *this );
    1713         maybeAccept_impl   ( node->tuple , *this );
     1665        maybeAccept        ( node->tuple , *this );
    17141666
    17151667        VISIT_END( node );
     
    17221674        indexerScopedMutate( node->env   , *this );
    17231675        indexerScopedMutate( node->result, *this );
    1724         maybeMutate_impl   ( node->tuple , *this );
     1676        maybeMutateRef     ( node->tuple , *this );
    17251677
    17261678        MUTATE_END( Expression, node );
     
    17341686
    17351687        indexerScopedAccept( node->result  , *this );
    1736         maybeAccept_impl   ( node->stmtExpr, *this );
     1688        maybeAccept        ( node->stmtExpr, *this );
    17371689
    17381690        VISIT_END( node );
     
    17451697        indexerScopedMutate( node->env     , *this );
    17461698        indexerScopedMutate( node->result  , *this );
    1747         maybeMutate_impl   ( node->stmtExpr, *this );
     1699        maybeMutateRef     ( node->stmtExpr, *this );
    17481700
    17491701        MUTATE_END( Expression, node );
     
    17621714
    17631715        indexerScopedAccept( node->result     , *this );
    1764         maybeAccept_impl   ( node->statements , *this );
    1765         maybeAccept_impl   ( node->returnDecls, *this );
    1766         maybeAccept_impl   ( node->dtors      , *this );
     1716        maybeAccept        ( node->statements , *this );
     1717        maybeAccept        ( node->returnDecls, *this );
     1718        maybeAccept        ( node->dtors      , *this );
    17671719
    17681720        VISIT_END( node );
     
    17791731
    17801732        indexerScopedMutate( node->result     , *this );
    1781         maybeMutate_impl   ( node->statements , *this );
    1782         maybeMutate_impl   ( node->returnDecls, *this );
    1783         maybeMutate_impl   ( node->dtors      , *this );
     1733        maybeMutateRef     ( node->statements , *this );
     1734        maybeMutateRef     ( node->returnDecls, *this );
     1735        maybeMutateRef     ( node->dtors      , *this );
    17841736
    17851737        MUTATE_END( Expression, node );
     
    17931745
    17941746        indexerScopedAccept( node->result, *this );
    1795         maybeAccept_impl   ( node->expr  , *this );
     1747        maybeAccept        ( node->expr  , *this );
    17961748
    17971749        VISIT_END( node );
     
    18041756        indexerScopedMutate( node->env   , *this );
    18051757        indexerScopedMutate( node->result, *this );
    1806         maybeMutate_impl   ( node->expr  , *this );
     1758        maybeMutateRef     ( node->expr  , *this );
    18071759
    18081760        MUTATE_END( Expression, node );
     
    18491801        {
    18501802                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    1851                 maybeAccept_impl( node->forall    , *this );
    1852                 maybeAccept_impl( node->parameters, *this );
     1803                maybeAccept( node->forall    , *this );
     1804                maybeAccept( node->parameters, *this );
    18531805        }
    18541806
     
    18641816        {
    18651817                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    1866                 maybeMutate_impl( node->forall    , *this );
    1867                 maybeMutate_impl( node->parameters, *this );
     1818                maybeMutateRef( node->forall    , *this );
     1819                maybeMutateRef( node->parameters, *this );
    18681820        }
    18691821
     
    18811833        {
    18821834                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    1883                 maybeAccept_impl( node->forall    , *this );
    1884                 maybeAccept_impl( node->parameters, *this );
     1835                maybeAccept( node->forall    , *this );
     1836                maybeAccept( node->parameters, *this );
    18851837        }
    18861838
     
    18961848        {
    18971849                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    1898                 maybeMutate_impl( node->forall    , *this );
    1899                 maybeMutate_impl( node->parameters, *this );
     1850                maybeMutateRef( node->forall    , *this );
     1851                maybeMutateRef( node->parameters, *this );
    19001852        }
    19011853
     
    19211873        VISIT_START( node );
    19221874
    1923         maybeAccept_impl( node->forall    , *this );
    1924         maybeAccept_impl( node->parameters, *this );
     1875        maybeAccept( node->forall    , *this );
     1876        maybeAccept( node->parameters, *this );
    19251877
    19261878        VISIT_END( node );
     
    19311883        MUTATE_START( node );
    19321884
    1933         maybeMutate_impl( node->forall    , *this );
    1934         maybeMutate_impl( node->parameters, *this );
     1885        maybeMutateRef( node->forall    , *this );
     1886        maybeMutateRef( node->parameters, *this );
    19351887
    19361888        MUTATE_END( Type, node );
     
    19781930        VISIT_START( node );
    19791931
    1980         maybeAccept_impl( node->get_designators(), *this );
     1932        maybeAccept( node->get_designators(), *this );
    19811933
    19821934        VISIT_END( node );
     
    19871939        MUTATE_START( node );
    19881940
    1989         maybeMutate_impl( node->get_designators(), *this );
     1941        maybeMutateRef( node->get_designators(), *this );
    19901942
    19911943        MUTATE_END( Designation, node );
     
    20291981template< typename pass_type >
    20301982void PassVisitor< pass_type >::visit( Constant * node ) {
    2031         VISIT_BODY( node );
    2032 }
    2033 
    2034 template< typename pass_type >
    2035 void PassVisitor< pass_type >::visit( Attribute * node ) {
    20361983        VISIT_BODY( node );
    20371984}
     
    21222069        MUTATE_BODY( Constant, node );
    21232070}
    2124 
    2125 template< typename pass_type >
    2126 Attribute * PassVisitor< pass_type >::mutate( Attribute * node  )  {
    2127         MUTATE_BODY( Attribute, node );
    2128 }
    2129 
    2130 template< typename pass_type >
    2131 TypeSubstitution * 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.