Ignore:
File:
1 edited

Legend:

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

    re67991f r342146e1  
    8080
    8181template< typename pass_type >
    82 inline void acceptAll( const std::list< const Declaration * > & decls, PassVisitor< pass_type >& visitor ) {
    83         SemanticErrorException errors;
    84 
    85         pass_visitor_stats.depth++;
    86         pass_visitor_stats.max->push(pass_visitor_stats.depth);
    87         pass_visitor_stats.avg->push(pass_visitor_stats.depth);
    88         for ( const Declaration * decl : decls ) {
    89                 try {
    90                         // run visitor on declaration
    91                         maybeAccept_impl( decl, visitor );
    92                 }
    93                 catch( SemanticErrorException &e ) {
    94                         errors.append( e );
    95                 }
    96         }
    97         pass_visitor_stats.depth--;
    98         if ( ! errors.isEmpty() ) {
    99                 throw errors;
    100         }
    101 }
    102 
    103 template< typename pass_type >
    10482inline void mutateAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& mutator ) {
    10583        DeclList_t* beforeDecls = mutator.get_beforeDecls();
     
    139117}
    140118
    141 template< typename TreeType, typename pass_type >
    142 inline void maybeAccept_impl( const TreeType * tree, PassVisitor< pass_type > & visitor ) {
    143         if ( ! visitor.get_visit_children() ) return;
    144         if ( tree ) {
    145                 tree->accept( visitor );
    146         }
    147 }
    148 
    149119template< typename Container, typename pass_type >
    150120inline void maybeAccept_impl( Container & container, PassVisitor< pass_type > & visitor ) {
     
    159129                        if ( *i ) {
    160130                                (*i)->accept( visitor );
    161                         }
    162                 } catch( SemanticErrorException &e ) {
    163                         errors.append( e );
    164                 }
    165         }
    166         pass_visitor_stats.depth--;
    167         if ( ! errors.isEmpty() ) {
    168                 throw errors;
    169         }
    170 }
    171 
    172 template< typename Container, typename pass_type >
    173 inline void maybeAccept_impl( const Container & container, PassVisitor< pass_type > & visitor ) {
    174         if ( ! visitor.get_visit_children() ) return;
    175         SemanticErrorException errors;
    176 
    177         pass_visitor_stats.depth++;
    178         pass_visitor_stats.max->push(pass_visitor_stats.depth);
    179         pass_visitor_stats.avg->push(pass_visitor_stats.depth);
    180         for ( const auto & i : container ) {
    181                 try {
    182                         if ( i ) {
    183                                 i->accept( visitor );
    184131                        }
    185132                } catch( SemanticErrorException &e ) {
     
    280227
    281228template< typename pass_type >
    282 void PassVisitor< pass_type >::visitStatementList( const std::list< Statement * > & statements ) {
    283         if ( ! get_visit_children() ) return;
    284         SemanticErrorException errors;
    285 
    286         pass_visitor_stats.depth++;
    287         pass_visitor_stats.max->push(pass_visitor_stats.depth);
    288         pass_visitor_stats.avg->push(pass_visitor_stats.depth);
    289         for ( const Statement * i : statements ) {
    290                 try {
    291                         maybeAccept_impl( i, *this );
    292                 } catch ( SemanticErrorException &e ) {
    293                         errors.append( e );
    294                 }
    295         }
    296         pass_visitor_stats.depth--;
    297         if ( !errors.isEmpty() ) { throw errors; }
    298 }
    299 
    300 template< typename pass_type >
    301229void PassVisitor< pass_type >::mutateStatementList( std::list< Statement * > & statements ) {
    302230        handleStatementList( statements, [this]( Statement *& stmt) {
     
    347275
    348276template< typename pass_type >
    349 void PassVisitor< pass_type >::visitStatement( const Statement * stmt ) {
    350         if ( ! get_visit_children() ) return;
    351 
    352         // don't want statements from outer CompoundStmts to be added to this CompoundStmt
    353         ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type >  oldEnv( get_env_ptr() );
    354 
    355         maybeAccept_impl( stmt, *this );
    356 }
    357 
    358 template< typename pass_type >
    359277Statement * PassVisitor< pass_type >::mutateStatement( Statement * stmt ) {
    360278        return handleStatement( stmt, [this]( Statement * stmt ) {
     
    388306
    389307template< typename pass_type >
    390 void PassVisitor< pass_type >::visitExpression( const Expression * expr ) {
    391         if ( ! get_visit_children() ) return;
    392         if( !expr ) return;
    393 
    394         auto env_ptr = get_env_ptr();
    395         if ( env_ptr && expr->get_env() ) {
    396                 *env_ptr = expr->get_env();
    397         }
    398 
    399         maybeAccept_impl( expr, *this );
    400 }
    401 
    402 template< typename pass_type >
    403308Expression * PassVisitor< pass_type >::mutateExpression( Expression * expr ) {
    404309        return handleExpression(expr, [this]( Expression * expr ) {
     
    410315template< typename TreeType, typename VisitorType >
    411316inline void indexerScopedAccept( TreeType * tree, VisitorType & visitor ) {
    412         if ( ! visitor.get_visit_children() ) return;
    413         auto guard = makeFuncGuard(
    414                 [&visitor]() { visitor.indexerScopeEnter(); },
    415                 [&visitor]() { visitor.indexerScopeLeave(); }
    416         );
    417         maybeAccept_impl( tree, visitor );
    418 }
    419 
    420 template< typename TreeType, typename VisitorType >
    421 inline void indexerScopedAccept( const TreeType * tree, VisitorType & visitor ) {
    422317        if ( ! visitor.get_visit_children() ) return;
    423318        auto guard = makeFuncGuard(
     
    477372
    478373        indexerAddId( node );
    479 
    480         VISIT_END( node );
    481 }
    482 
    483 template< typename pass_type >
    484 void PassVisitor< pass_type >::visit( const ObjectDecl * node ) {
    485         VISIT_START( node );
    486 
    487         maybeAccept_impl( node->type         , *this );
    488         maybeAccept_impl( node->init         , *this );
    489         maybeAccept_impl( node->bitfieldWidth, *this );
    490         maybeAccept_impl( node->attributes   , *this );
    491374
    492375        VISIT_END( node );
     
    545428
    546429template< typename pass_type >
    547 void PassVisitor< pass_type >::visit( const FunctionDecl * node ) {
    548         VISIT_START( node );
    549 
    550         indexerAddId( node );
    551 
    552         maybeAccept_impl( node->withExprs, *this );
    553         {
    554                 // with clause introduces a level of scope (for the with expression members).
    555                 // with clause exprs are added to the indexer before parameters so that parameters
    556                 // shadow with exprs and not the other way around.
    557                 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    558                 indexerAddWith( node->withExprs, node );
    559                 {
    560                         auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    561                         // implicit add __func__ identifier as specified in the C manual 6.4.2.2
    562                         static ObjectDecl func(
    563                                 "__func__", noStorageClasses, LinkageSpec::C, nullptr,
    564                                 new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char ), nullptr, true, false ),
    565                                 nullptr
    566                         );
    567                         indexerAddId( &func );
    568                         maybeAccept_impl( node->type, *this );
    569                         // function body needs to have the same scope as parameters - CompoundStmt will not enter
    570                         // a new scope if inFunction is true
    571                         ValueGuard< bool > oldInFunction( inFunction );
    572                         inFunction = true;
    573                         maybeAccept_impl( node->statements, *this );
    574                         maybeAccept_impl( node->attributes, *this );
    575                 }
    576         }
    577 
    578         VISIT_END( node );
    579 }
    580 
    581 template< typename pass_type >
    582430DeclarationWithType * PassVisitor< pass_type >::mutate( FunctionDecl * node ) {
    583431        MUTATE_START( node );
     
    636484
    637485template< typename pass_type >
    638 void PassVisitor< pass_type >::visit( const StructDecl * node ) {
    639         VISIT_START( node );
     486Declaration * PassVisitor< pass_type >::mutate( StructDecl * node ) {
     487        MUTATE_START( node );
    640488
    641489        // make up a forward declaration and add it before processing the members
    642490        // needs to be on the heap because addStruct saves the pointer
    643491        indexerAddStructFwd( node );
     492
     493        {
     494                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
     495                maybeMutate_impl( node->parameters, *this );
     496                maybeMutate_impl( node->members   , *this );
     497        }
     498
     499        // this addition replaces the forward declaration
     500        indexerAddStruct( node );
     501
     502        MUTATE_END( Declaration, node );
     503}
     504
     505//--------------------------------------------------------------------------
     506// UnionDecl
     507template< typename pass_type >
     508void PassVisitor< pass_type >::visit( UnionDecl * node ) {
     509        VISIT_START( node );
     510
     511        // make up a forward declaration and add it before processing the members
     512        indexerAddUnionFwd( node );
    644513
    645514        {
     
    649518        }
    650519
    651         // this addition replaces the forward declaration
    652         indexerAddStruct( node );
    653 
    654         VISIT_END( node );
    655 }
    656 
    657 template< typename pass_type >
    658 Declaration * PassVisitor< pass_type >::mutate( StructDecl * node ) {
     520        indexerAddUnion( node );
     521
     522        VISIT_END( node );
     523}
     524
     525template< typename pass_type >
     526Declaration * PassVisitor< pass_type >::mutate( UnionDecl * node ) {
    659527        MUTATE_START( node );
    660528
    661529        // make up a forward declaration and add it before processing the members
    662         // needs to be on the heap because addStruct saves the pointer
    663         indexerAddStructFwd( node );
     530        indexerAddUnionFwd( node );
    664531
    665532        {
     
    669536        }
    670537
    671         // this addition replaces the forward declaration
    672         indexerAddStruct( node );
     538        indexerAddUnion( node );
    673539
    674540        MUTATE_END( Declaration, node );
     
    676542
    677543//--------------------------------------------------------------------------
    678 // UnionDecl
    679 template< typename pass_type >
    680 void PassVisitor< pass_type >::visit( UnionDecl * node ) {
    681         VISIT_START( node );
    682 
    683         // make up a forward declaration and add it before processing the members
    684         indexerAddUnionFwd( node );
     544// EnumDecl
     545template< typename pass_type >
     546void PassVisitor< pass_type >::visit( EnumDecl * node ) {
     547        VISIT_START( node );
     548
     549        indexerAddEnum( node );
     550
     551        // unlike structs, traits, and unions, enums inject their members into the global scope
     552        maybeAccept_impl( node->parameters, *this );
     553        maybeAccept_impl( node->members   , *this );
     554
     555        VISIT_END( node );
     556}
     557
     558template< typename pass_type >
     559Declaration * PassVisitor< pass_type >::mutate( EnumDecl * node ) {
     560        MUTATE_START( node );
     561
     562        indexerAddEnum( node );
     563
     564        // unlike structs, traits, and unions, enums inject their members into the global scope
     565        maybeMutate_impl( node->parameters, *this );
     566        maybeMutate_impl( node->members   , *this );
     567
     568        MUTATE_END( Declaration, node );
     569}
     570
     571//--------------------------------------------------------------------------
     572// TraitDecl
     573template< typename pass_type >
     574void PassVisitor< pass_type >::visit( TraitDecl * node ) {
     575        VISIT_START( node );
    685576
    686577        {
     
    690581        }
    691582
    692         indexerAddUnion( node );
    693 
    694         VISIT_END( node );
    695 }
    696 template< typename pass_type >
    697 void PassVisitor< pass_type >::visit( const UnionDecl * node ) {
    698         VISIT_START( node );
    699 
    700         // make up a forward declaration and add it before processing the members
    701         indexerAddUnionFwd( node );
    702 
    703         {
    704                 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    705                 maybeAccept_impl( node->parameters, *this );
    706                 maybeAccept_impl( node->members   , *this );
    707         }
    708 
    709         indexerAddUnion( node );
    710 
    711         VISIT_END( node );
    712 }
    713 
    714 template< typename pass_type >
    715 Declaration * PassVisitor< pass_type >::mutate( UnionDecl * node ) {
    716         MUTATE_START( node );
    717 
    718         // make up a forward declaration and add it before processing the members
    719         indexerAddUnionFwd( node );
     583        indexerAddTrait( node );
     584
     585        VISIT_END( node );
     586}
     587
     588template< typename pass_type >
     589Declaration * PassVisitor< pass_type >::mutate( TraitDecl * node ) {
     590        MUTATE_START( node );
    720591
    721592        {
     
    725596        }
    726597
    727         indexerAddUnion( node );
    728 
    729         MUTATE_END( Declaration, node );
    730 }
    731 
    732 //--------------------------------------------------------------------------
    733 // EnumDecl
    734 template< typename pass_type >
    735 void PassVisitor< pass_type >::visit( EnumDecl * node ) {
    736         VISIT_START( node );
    737 
    738         indexerAddEnum( node );
    739 
    740         // unlike structs, traits, and unions, enums inject their members into the global scope
    741         maybeAccept_impl( node->parameters, *this );
    742         maybeAccept_impl( node->members   , *this );
    743 
    744         VISIT_END( node );
    745 }
    746 
    747 template< typename pass_type >
    748 void PassVisitor< pass_type >::visit( const EnumDecl * node ) {
    749         VISIT_START( node );
    750 
    751         indexerAddEnum( node );
    752 
    753         // unlike structs, traits, and unions, enums inject their members into the global scope
    754         maybeAccept_impl( node->parameters, *this );
    755         maybeAccept_impl( node->members   , *this );
    756 
    757         VISIT_END( node );
    758 }
    759 
    760 template< typename pass_type >
    761 Declaration * PassVisitor< pass_type >::mutate( EnumDecl * node ) {
    762         MUTATE_START( node );
    763 
    764         indexerAddEnum( node );
    765 
    766         // unlike structs, traits, and unions, enums inject their members into the global scope
    767         maybeMutate_impl( node->parameters, *this );
    768         maybeMutate_impl( node->members   , *this );
    769 
    770         MUTATE_END( Declaration, node );
    771 }
    772 
    773 //--------------------------------------------------------------------------
    774 // TraitDecl
    775 template< typename pass_type >
    776 void PassVisitor< pass_type >::visit( TraitDecl * node ) {
    777         VISIT_START( node );
    778 
    779         {
    780                 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    781                 maybeAccept_impl( node->parameters, *this );
    782                 maybeAccept_impl( node->members   , *this );
    783         }
    784 
    785         indexerAddTrait( node );
    786 
    787         VISIT_END( node );
    788 }
    789 
    790 template< typename pass_type >
    791 void PassVisitor< pass_type >::visit( const TraitDecl * node ) {
    792         VISIT_START( node );
    793 
    794         {
    795                 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    796                 maybeAccept_impl( node->parameters, *this );
    797                 maybeAccept_impl( node->members   , *this );
    798         }
    799 
    800         indexerAddTrait( node );
    801 
    802         VISIT_END( node );
    803 }
    804 
    805 template< typename pass_type >
    806 Declaration * PassVisitor< pass_type >::mutate( TraitDecl * node ) {
    807         MUTATE_START( node );
    808 
    809         {
    810                 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    811                 maybeMutate_impl( node->parameters, *this );
    812                 maybeMutate_impl( node->members   , *this );
    813         }
    814 
    815598        indexerAddTrait( node );
    816599
     
    842625}
    843626
    844 
    845 template< typename pass_type >
    846 void PassVisitor< pass_type >::visit( const TypeDecl * node ) {
     627template< typename pass_type >
     628Declaration * PassVisitor< pass_type >::mutate( TypeDecl * node ) {
     629        MUTATE_START( node );
     630
     631        {
     632                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
     633                maybeMutate_impl( node->parameters, *this );
     634                maybeMutate_impl( node->base      , *this );
     635        }
     636
     637        // see A NOTE ON THE ORDER OF TRAVERSAL, above
     638        // note that assertions come after the type is added to the symtab, since they are not part of the type proper
     639        // and may depend on the type itself
     640        indexerAddType( node );
     641
     642        maybeMutate_impl( node->assertions, *this );
     643
     644        indexerScopedMutate( node->init, *this );
     645
     646        MUTATE_END( Declaration, node );
     647}
     648
     649//--------------------------------------------------------------------------
     650// TypedefDecl
     651template< typename pass_type >
     652void PassVisitor< pass_type >::visit( TypedefDecl * node ) {
    847653        VISIT_START( node );
    848654
     
    853659        }
    854660
    855         // see A NOTE ON THE ORDER OF TRAVERSAL, above
    856         // note that assertions come after the type is added to the symtab, since they are not part of the type proper
    857         // and may depend on the type itself
    858661        indexerAddType( node );
    859662
    860663        maybeAccept_impl( node->assertions, *this );
    861664
    862         indexerScopedAccept( node->init, *this );
    863 
    864         VISIT_END( node );
    865 }
    866 
    867 template< typename pass_type >
    868 Declaration * PassVisitor< pass_type >::mutate( TypeDecl * node ) {
     665        VISIT_END( node );
     666}
     667
     668template< typename pass_type >
     669Declaration * PassVisitor< pass_type >::mutate( TypedefDecl * node ) {
    869670        MUTATE_START( node );
    870671
     
    875676        }
    876677
    877         // see A NOTE ON THE ORDER OF TRAVERSAL, above
    878         // note that assertions come after the type is added to the symtab, since they are not part of the type proper
    879         // and may depend on the type itself
    880678        indexerAddType( node );
    881679
    882680        maybeMutate_impl( node->assertions, *this );
    883681
    884         indexerScopedMutate( node->init, *this );
    885 
    886682        MUTATE_END( Declaration, node );
    887683}
    888684
    889685//--------------------------------------------------------------------------
    890 // TypedefDecl
    891 template< typename pass_type >
    892 void PassVisitor< pass_type >::visit( TypedefDecl * node ) {
    893         VISIT_START( node );
    894 
    895         {
    896                 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    897                 maybeAccept_impl( node->parameters, *this );
    898                 maybeAccept_impl( node->base      , *this );
    899         }
    900 
    901         indexerAddType( node );
    902 
    903         maybeAccept_impl( node->assertions, *this );
    904 
    905         VISIT_END( node );
    906 }
    907 
    908 template< typename pass_type >
    909 void PassVisitor< pass_type >::visit( const TypedefDecl * node ) {
    910         VISIT_START( node );
    911 
    912         {
    913                 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    914                 maybeAccept_impl( node->parameters, *this );
    915                 maybeAccept_impl( node->base      , *this );
    916         }
    917 
    918         indexerAddType( node );
    919 
    920         maybeAccept_impl( node->assertions, *this );
    921 
    922         VISIT_END( node );
    923 }
    924 
    925 template< typename pass_type >
    926 Declaration * PassVisitor< pass_type >::mutate( TypedefDecl * node ) {
    927         MUTATE_START( node );
    928 
    929         {
    930                 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    931                 maybeMutate_impl( node->parameters, *this );
    932                 maybeMutate_impl( node->base      , *this );
    933         }
    934 
    935         indexerAddType( node );
    936 
    937         maybeMutate_impl( node->assertions, *this );
    938 
    939         MUTATE_END( Declaration, node );
    940 }
    941 
    942 //--------------------------------------------------------------------------
    943686// AsmDecl
    944687template< typename pass_type >
     
    952695
    953696template< typename pass_type >
    954 void PassVisitor< pass_type >::visit( const AsmDecl * node ) {
    955         VISIT_START( node );
    956 
    957         maybeAccept_impl( node->stmt, *this );
    958 
    959         VISIT_END( node );
    960 }
    961 
    962 template< typename pass_type >
    963697AsmDecl * PassVisitor< pass_type >::mutate( AsmDecl * node ) {
    964698        MUTATE_START( node );
     
    976710
    977711        node->condition = visitExpression( node->condition );
    978         maybeAccept_impl( node->message, *this );
    979 
    980         VISIT_END( node );
    981 }
    982 
    983 template< typename pass_type >
    984 void PassVisitor< pass_type >::visit( const StaticAssertDecl * node ) {
    985         VISIT_START( node );
    986 
    987         visitExpression( node->condition );
    988712        maybeAccept_impl( node->message, *this );
    989713
     
    1018742
    1019743template< typename pass_type >
    1020 void PassVisitor< pass_type >::visit( const CompoundStmt * node ) {
    1021         VISIT_START( node );
    1022         {
    1023                 // do not enter a new scope if inFunction is true - needs to check old state before the assignment
    1024                 ValueGuard< bool > oldInFunction( inFunction );
    1025                 auto guard1 = makeFuncGuard( [this, &oldInFunction]() { if ( ! oldInFunction.old ) indexerScopeEnter(); }, [this, &oldInFunction]() { if ( ! oldInFunction.old ) indexerScopeLeave(); } );
    1026                 auto guard2 = makeFuncGuard( [this]() { call_beginScope();   }, [this]() { call_endScope();     } );
    1027                 inFunction = false;
    1028                 visitStatementList( node->kids );
    1029         }
    1030         VISIT_END( node );
    1031 }
    1032 
    1033 template< typename pass_type >
    1034744CompoundStmt * PassVisitor< pass_type >::mutate( CompoundStmt * node ) {
    1035745        MUTATE_START( node );
     
    1057767
    1058768template< typename pass_type >
    1059 void PassVisitor< pass_type >::visit( const ExprStmt * node ) {
    1060         VISIT_START( node );
    1061 
    1062         visitExpression( node->expr );
    1063 
    1064         VISIT_END( node );
    1065 }
    1066 
    1067 template< typename pass_type >
    1068769Statement * PassVisitor< pass_type >::mutate( ExprStmt * node ) {
    1069770        MUTATE_START( node );
     
    1089790
    1090791template< typename pass_type >
    1091 void PassVisitor< pass_type >::visit( const AsmStmt * node ) {
    1092         VISIT_START( node )
    1093 
    1094         maybeAccept_impl( node->instruction, *this );
    1095         maybeAccept_impl( node->output, *this );
    1096         maybeAccept_impl( node->input, *this );
    1097         maybeAccept_impl( node->clobber, *this );
    1098 
    1099         VISIT_END( node );
    1100 }
    1101 
    1102 template< typename pass_type >
    1103792Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) {
    1104793        MUTATE_START( node );
     
    1122811
    1123812template< typename pass_type >
    1124 void PassVisitor< pass_type >::visit( const DirectiveStmt * node ) {
    1125         VISIT_START( node )
    1126 
    1127         VISIT_END( node );
    1128 }
    1129 
    1130 template< typename pass_type >
    1131813Statement * PassVisitor< pass_type >::mutate( DirectiveStmt * node ) {
    1132814        MUTATE_START( node );
     
    1143825                // if statements introduce a level of scope (for the initialization)
    1144826                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    1145                 maybeAccept_impl( node->initialization, *this );
     827                maybeAccept_impl( node->get_initialization(), *this );
    1146828                visitExpression ( node->condition );
    1147829                node->thenPart = visitStatement( node->thenPart );
     
    1152834
    1153835template< typename pass_type >
    1154 void PassVisitor< pass_type >::visit( const IfStmt * node ) {
    1155         VISIT_START( node );
     836Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) {
     837        MUTATE_START( node );
    1156838        {
    1157839                // if statements introduce a level of scope (for the initialization)
    1158840                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    1159                 maybeAccept_impl( node->initialization, *this );
    1160                 visitExpression ( node->condition );
    1161                 visitStatement  ( node->thenPart );
    1162                 visitStatement  ( node->elsePart );
    1163         }
    1164         VISIT_END( node );
    1165 }
    1166 
    1167 template< typename pass_type >
    1168 Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) {
    1169         MUTATE_START( node );
    1170         {
    1171                 // if statements introduce a level of scope (for the initialization)
    1172                 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    1173                 maybeMutate_impl( node->initialization, *this );
     841                maybeMutate_impl( node->get_initialization(), *this );
    1174842                node->condition = mutateExpression( node->condition );
    1175843                node->thenPart  = mutateStatement ( node->thenPart  );
     
    1191859                visitExpression ( node->condition );
    1192860                node->body = visitStatement( node->body );
    1193         }
    1194 
    1195         VISIT_END( node );
    1196 }
    1197 
    1198 template< typename pass_type >
    1199 void PassVisitor< pass_type >::visit( const WhileStmt * node ) {
    1200         VISIT_START( node );
    1201 
    1202         {
    1203                 // while statements introduce a level of scope (for the initialization)
    1204                 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    1205                 maybeAccept_impl( node->initialization, *this );
    1206                 visitExpression ( node->condition );
    1207                 visitStatement  ( node->body );
    1208861        }
    1209862
     
    1244897
    1245898template< typename pass_type >
    1246 void PassVisitor< pass_type >::visit( const ForStmt * node ) {
    1247         VISIT_START( node );
    1248         {
    1249                 // for statements introduce a level of scope (for the initialization)
    1250                 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    1251                 maybeAccept_impl( node->initialization, *this );
    1252                 visitExpression( node->condition );
    1253                 visitExpression( node->increment );
    1254                 visitStatement ( node->body );
    1255         }
    1256         VISIT_END( node );
    1257 }
    1258 
    1259 template< typename pass_type >
    1260899Statement * PassVisitor< pass_type >::mutate( ForStmt * node ) {
    1261900        MUTATE_START( node );
     
    1284923
    1285924template< typename pass_type >
    1286 void PassVisitor< pass_type >::visit( const SwitchStmt * node ) {
    1287         VISIT_START( node );
    1288 
    1289         visitExpression   ( node->condition  );
    1290         visitStatementList( node->statements );
    1291 
    1292         VISIT_END( node );
    1293 }
    1294 
    1295 template< typename pass_type >
    1296925Statement * PassVisitor< pass_type >::mutate( SwitchStmt * node ) {
    1297926        MUTATE_START( node );
     
    1316945
    1317946template< typename pass_type >
    1318 void PassVisitor< pass_type >::visit( const CaseStmt * node ) {
    1319         VISIT_START( node );
    1320 
    1321         visitExpression   ( node->condition );
    1322         visitStatementList( node->stmts     );
    1323 
    1324         VISIT_END( node );
    1325 }
    1326 
    1327 template< typename pass_type >
    1328947Statement * PassVisitor< pass_type >::mutate( CaseStmt * node ) {
    1329948        MUTATE_START( node );
     
    1344963
    1345964template< typename pass_type >
    1346 void PassVisitor< pass_type >::visit( const BranchStmt * node ) {
    1347         VISIT_START( node );
    1348         VISIT_END( node );
    1349 }
    1350 
    1351 template< typename pass_type >
    1352965Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) {
    1353966        MUTATE_START( node );
     
    1367980
    1368981template< typename pass_type >
    1369 void PassVisitor< pass_type >::visit( const ReturnStmt * node ) {
    1370         VISIT_START( node );
    1371 
    1372         visitExpression( node->expr );
    1373 
    1374         VISIT_END( node );
    1375 }
    1376 
    1377 template< typename pass_type >
    1378982Statement * PassVisitor< pass_type >::mutate( ReturnStmt * node ) {
    1379983        MUTATE_START( node );
     
    1386990//--------------------------------------------------------------------------
    1387991// ThrowStmt
     992
    1388993template< typename pass_type >
    1389994void PassVisitor< pass_type >::visit( ThrowStmt * node ) {
     
    13971002
    13981003template< typename pass_type >
    1399 void PassVisitor< pass_type >::visit( const ThrowStmt * node ) {
    1400         VISIT_START( node );
    1401 
    1402         maybeAccept_impl( node->expr, *this );
    1403         maybeAccept_impl( node->target, *this );
    1404 
    1405         VISIT_END( node );
    1406 }
    1407 
    1408 template< typename pass_type >
    14091004Statement * PassVisitor< pass_type >::mutate( ThrowStmt * node ) {
    14101005        MUTATE_START( node );
     
    14201015template< typename pass_type >
    14211016void PassVisitor< pass_type >::visit( TryStmt * node ) {
    1422         VISIT_START( node );
    1423 
    1424         maybeAccept_impl( node->block       , *this );
    1425         maybeAccept_impl( node->handlers    , *this );
    1426         maybeAccept_impl( node->finallyBlock, *this );
    1427 
    1428         VISIT_END( node );
    1429 }
    1430 
    1431 template< typename pass_type >
    1432 void PassVisitor< pass_type >::visit( const TryStmt * node ) {
    14331017        VISIT_START( node );
    14341018
     
    14671051
    14681052template< typename pass_type >
    1469 void PassVisitor< pass_type >::visit( const CatchStmt * node ) {
    1470         VISIT_START( node );
    1471         {
    1472                 // catch statements introduce a level of scope (for the caught exception)
    1473                 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    1474                 maybeAccept_impl( node->decl, *this );
    1475                 visitExpression ( node->cond );
    1476                 visitStatement  ( node->body );
    1477         }
    1478         VISIT_END( node );
    1479 }
    1480 
    1481 template< typename pass_type >
    14821053Statement * PassVisitor< pass_type >::mutate( CatchStmt * node ) {
    14831054        MUTATE_START( node );
     
    15041075
    15051076template< typename pass_type >
    1506 void PassVisitor< pass_type >::visit( const FinallyStmt * node ) {
    1507         VISIT_START( node );
    1508 
    1509         maybeAccept_impl( node->block, *this );
    1510 
    1511         VISIT_END( node );
    1512 }
    1513 
    1514 template< typename pass_type >
    15151077Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) {
    15161078        MUTATE_START( node );
     
    15451107
    15461108template< typename pass_type >
    1547 void PassVisitor< pass_type >::visit( const WaitForStmt * node ) {
    1548         VISIT_START( node );
    1549 
    1550         for( auto & clause : node->clauses ) {
    1551                 maybeAccept_impl( clause.target.function, *this );
    1552                 maybeAccept_impl( clause.target.arguments, *this );
    1553 
    1554                 maybeAccept_impl( clause.statement, *this );
    1555                 maybeAccept_impl( clause.condition, *this );
    1556         }
    1557 
    1558         maybeAccept_impl( node->timeout.time, *this );
    1559         maybeAccept_impl( node->timeout.statement, *this );
    1560         maybeAccept_impl( node->timeout.condition, *this );
    1561         maybeAccept_impl( node->orelse.statement, *this );
    1562         maybeAccept_impl( node->orelse.condition, *this );
    1563 
    1564         VISIT_END( node );
    1565 }
    1566 
    1567 template< typename pass_type >
    15681109Statement * PassVisitor< pass_type >::mutate( WaitForStmt * node ) {
    15691110        MUTATE_START( node );
     
    15891130
    15901131//--------------------------------------------------------------------------
    1591 // WithStmt
     1132// NullStmt
    15921133template< typename pass_type >
    15931134void PassVisitor< pass_type >::visit( WithStmt * node ) {
     
    16041145
    16051146template< typename pass_type >
    1606 void PassVisitor< pass_type >::visit( const WithStmt * node ) {
    1607         VISIT_START( node );
    1608         maybeAccept_impl( node->exprs, *this );
    1609         {
    1610                 // catch statements introduce a level of scope (for the caught exception)
    1611                 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    1612                 indexerAddWith( node->exprs, node );
    1613                 maybeAccept_impl( node->stmt, *this );
    1614         }
    1615         VISIT_END( node );
    1616 }
    1617 
    1618 template< typename pass_type >
    1619 Declaration * PassVisitor< pass_type >::mutate( WithStmt * node ) {
     1147Statement * PassVisitor< pass_type >::mutate( WithStmt * node ) {
    16201148        MUTATE_START( node );
    16211149        maybeMutate_impl( node->exprs, *this );
     
    16261154                maybeMutate_impl( node->stmt, *this );
    16271155        }
    1628         MUTATE_END( Declaration, node );
     1156        MUTATE_END( Statement, node );
    16291157}
    16301158
     
    16381166
    16391167template< typename pass_type >
    1640 void PassVisitor< pass_type >::visit( const NullStmt * node ) {
    1641         VISIT_START( node );
    1642         VISIT_END( node );
    1643 }
    1644 
    1645 template< typename pass_type >
    16461168NullStmt * PassVisitor< pass_type >::mutate( NullStmt * node ) {
    16471169        MUTATE_START( node );
     
    16611183
    16621184template< typename pass_type >
    1663 void PassVisitor< pass_type >::visit( const DeclStmt * node ) {
    1664         VISIT_START( node );
    1665 
    1666         maybeAccept_impl( node->decl, *this );
    1667 
    1668         VISIT_END( node );
    1669 }
    1670 
    1671 template< typename pass_type >
    16721185Statement * PassVisitor< pass_type >::mutate( DeclStmt * node ) {
    16731186        MUTATE_START( node );
     
    16901203
    16911204template< typename pass_type >
    1692 void PassVisitor< pass_type >::visit( const ImplicitCtorDtorStmt * node ) {
    1693         VISIT_START( node );
    1694 
    1695         maybeAccept_impl( node->callStmt, *this );
    1696 
    1697         VISIT_END( node );
    1698 }
    1699 
    1700 template< typename pass_type >
    17011205Statement * PassVisitor< pass_type >::mutate( ImplicitCtorDtorStmt * node ) {
    17021206        MUTATE_START( node );
     
    17141218
    17151219        indexerScopedAccept( node->result  , *this );
    1716         maybeAccept_impl   ( node->function, *this );
    1717         maybeAccept_impl   ( node->args    , *this );
    1718 
    1719         VISIT_END( node );
    1720 }
    1721 
    1722 template< typename pass_type >
    1723 void PassVisitor< pass_type >::visit( const ApplicationExpr * node ) {
    1724         VISIT_START( node );
    1725 
    1726         indexerScopedAccept( node->result  , *this );
    1727         maybeAccept_impl   ( node->function, *this );
    1728         maybeAccept_impl   ( node->args    , *this );
     1220        maybeAccept_impl        ( node->function, *this );
     1221        maybeAccept_impl        ( node->args    , *this );
    17291222
    17301223        VISIT_END( node );
     
    17601253
    17611254template< typename pass_type >
    1762 void PassVisitor< pass_type >::visit( const UntypedExpr * node ) {
    1763         VISIT_START( node );
    1764 
    1765         indexerScopedAccept( node->result, *this );
    1766 
    1767         for ( auto expr : node->args ) {
    1768                 visitExpression( expr );
    1769         }
    1770 
    1771         VISIT_END( node );
    1772 }
    1773 
    1774 template< typename pass_type >
    17751255Expression * PassVisitor< pass_type >::mutate( UntypedExpr * node ) {
    17761256        MUTATE_START( node );
     
    17981278
    17991279template< typename pass_type >
    1800 void PassVisitor< pass_type >::visit( const NameExpr * node ) {
     1280Expression * PassVisitor< pass_type >::mutate( NameExpr * node ) {
     1281        MUTATE_START( node );
     1282
     1283        indexerScopedMutate( node->env   , *this );
     1284        indexerScopedMutate( node->result, *this );
     1285
     1286        MUTATE_END( Expression, node );
     1287}
     1288
     1289//--------------------------------------------------------------------------
     1290// CastExpr
     1291template< typename pass_type >
     1292void PassVisitor< pass_type >::visit( CastExpr * node ) {
    18011293        VISIT_START( node );
    18021294
    18031295        indexerScopedAccept( node->result, *this );
    1804 
    1805         VISIT_END( node );
    1806 }
    1807 
    1808 template< typename pass_type >
    1809 Expression * PassVisitor< pass_type >::mutate( NameExpr * node ) {
     1296        maybeAccept_impl        ( node->arg   , *this );
     1297
     1298        VISIT_END( node );
     1299}
     1300
     1301template< typename pass_type >
     1302Expression * PassVisitor< pass_type >::mutate( CastExpr * node ) {
    18101303        MUTATE_START( node );
    18111304
    18121305        indexerScopedMutate( node->env   , *this );
    18131306        indexerScopedMutate( node->result, *this );
    1814 
    1815         MUTATE_END( Expression, node );
    1816 }
    1817 
    1818 //--------------------------------------------------------------------------
    1819 // CastExpr
    1820 template< typename pass_type >
    1821 void PassVisitor< pass_type >::visit( CastExpr * node ) {
     1307        maybeMutate_impl   ( node->arg   , *this );
     1308
     1309        MUTATE_END( Expression, node );
     1310}
     1311
     1312//--------------------------------------------------------------------------
     1313// KeywordCastExpr
     1314template< typename pass_type >
     1315void PassVisitor< pass_type >::visit( KeywordCastExpr * node ) {
     1316        VISIT_START( node );
     1317
     1318        indexerScopedAccept( node->result, *this );
     1319        maybeAccept_impl        ( node->arg   , *this );
     1320
     1321        VISIT_END( node );
     1322}
     1323
     1324template< typename pass_type >
     1325Expression * PassVisitor< pass_type >::mutate( KeywordCastExpr * node ) {
     1326        MUTATE_START( node );
     1327
     1328        indexerScopedMutate( node->env   , *this );
     1329        indexerScopedMutate( node->result, *this );
     1330        maybeMutate_impl   ( node->arg   , *this );
     1331
     1332        MUTATE_END( Expression, node );
     1333}
     1334
     1335//--------------------------------------------------------------------------
     1336// VirtualCastExpr
     1337template< typename pass_type >
     1338void PassVisitor< pass_type >::visit( VirtualCastExpr * node ) {
     1339        VISIT_START( node );
     1340
     1341        indexerScopedAccept( node->result, *this );
     1342        maybeAccept_impl( node->arg, *this );
     1343
     1344        VISIT_END( node );
     1345}
     1346
     1347template< typename pass_type >
     1348Expression * PassVisitor< pass_type >::mutate( VirtualCastExpr * node ) {
     1349        MUTATE_START( node );
     1350
     1351        indexerScopedMutate( node->env   , *this );
     1352        indexerScopedMutate( node->result, *this );
     1353        maybeMutate_impl   ( node->arg   , *this );
     1354
     1355        MUTATE_END( Expression, node );
     1356}
     1357
     1358//--------------------------------------------------------------------------
     1359// AddressExpr
     1360template< typename pass_type >
     1361void PassVisitor< pass_type >::visit( AddressExpr * node ) {
    18221362        VISIT_START( node );
    18231363
     
    18291369
    18301370template< typename pass_type >
    1831 void PassVisitor< pass_type >::visit( const CastExpr * node ) {
     1371Expression * PassVisitor< pass_type >::mutate( AddressExpr * node ) {
     1372        MUTATE_START( node );
     1373
     1374        indexerScopedMutate( node->env   , *this );
     1375        indexerScopedMutate( node->result, *this );
     1376        maybeMutate_impl   ( node->arg   , *this );
     1377
     1378        MUTATE_END( Expression, node );
     1379}
     1380
     1381//--------------------------------------------------------------------------
     1382// LabelAddressExpr
     1383template< typename pass_type >
     1384void PassVisitor< pass_type >::visit( LabelAddressExpr * node ) {
    18321385        VISIT_START( node );
    18331386
    18341387        indexerScopedAccept( node->result, *this );
    1835         maybeAccept_impl   ( node->arg   , *this );
    1836 
    1837         VISIT_END( node );
    1838 }
    1839 
    1840 template< typename pass_type >
    1841 Expression * PassVisitor< pass_type >::mutate( CastExpr * node ) {
     1388
     1389        VISIT_END( node );
     1390}
     1391
     1392template< typename pass_type >
     1393Expression * PassVisitor< pass_type >::mutate( LabelAddressExpr * node ) {
    18421394        MUTATE_START( node );
    18431395
    18441396        indexerScopedMutate( node->env   , *this );
    18451397        indexerScopedMutate( node->result, *this );
    1846         maybeMutate_impl   ( node->arg   , *this );
    1847 
    1848         MUTATE_END( Expression, node );
    1849 }
    1850 
    1851 //--------------------------------------------------------------------------
    1852 // KeywordCastExpr
    1853 template< typename pass_type >
    1854 void PassVisitor< pass_type >::visit( KeywordCastExpr * node ) {
    1855         VISIT_START( node );
    1856 
    1857         indexerScopedAccept( node->result, *this );
    1858         maybeAccept_impl        ( node->arg   , *this );
    1859 
    1860         VISIT_END( node );
    1861 }
    1862 
    1863 template< typename pass_type >
    1864 void PassVisitor< pass_type >::visit( const KeywordCastExpr * node ) {
    1865         VISIT_START( node );
    1866 
    1867         indexerScopedAccept( node->result, *this );
    1868         maybeAccept_impl   ( node->arg   , *this );
    1869 
    1870         VISIT_END( node );
    1871 }
    1872 
    1873 template< typename pass_type >
    1874 Expression * PassVisitor< pass_type >::mutate( KeywordCastExpr * node ) {
    1875         MUTATE_START( node );
    1876 
    1877         indexerScopedMutate( node->env   , *this );
    1878         indexerScopedMutate( node->result, *this );
    1879         maybeMutate_impl   ( node->arg   , *this );
    1880 
    1881         MUTATE_END( Expression, node );
    1882 }
    1883 
    1884 //--------------------------------------------------------------------------
    1885 // VirtualCastExpr
    1886 template< typename pass_type >
    1887 void PassVisitor< pass_type >::visit( VirtualCastExpr * node ) {
    1888         VISIT_START( node );
    1889 
    1890         indexerScopedAccept( node->result, *this );
    1891         maybeAccept_impl   ( node->arg, *this );
    1892 
    1893         VISIT_END( node );
    1894 }
    1895 
    1896 template< typename pass_type >
    1897 void PassVisitor< pass_type >::visit( const VirtualCastExpr * node ) {
    1898         VISIT_START( node );
    1899 
    1900         indexerScopedAccept( node->result, *this );
    1901         maybeAccept_impl   ( node->arg, *this );
    1902 
    1903         VISIT_END( node );
    1904 }
    1905 
    1906 template< typename pass_type >
    1907 Expression * PassVisitor< pass_type >::mutate( VirtualCastExpr * node ) {
    1908         MUTATE_START( node );
    1909 
    1910         indexerScopedMutate( node->env   , *this );
    1911         indexerScopedMutate( node->result, *this );
    1912         maybeMutate_impl   ( node->arg   , *this );
    1913 
    1914         MUTATE_END( Expression, node );
    1915 }
    1916 
    1917 //--------------------------------------------------------------------------
    1918 // AddressExpr
    1919 template< typename pass_type >
    1920 void PassVisitor< pass_type >::visit( AddressExpr * node ) {
    1921         VISIT_START( node );
    1922 
    1923         indexerScopedAccept( node->result, *this );
    1924         maybeAccept_impl   ( node->arg   , *this );
    1925 
    1926         VISIT_END( node );
    1927 }
    1928 
    1929 template< typename pass_type >
    1930 void PassVisitor< pass_type >::visit( const AddressExpr * node ) {
    1931         VISIT_START( node );
    1932 
    1933         indexerScopedAccept( node->result, *this );
    1934         maybeAccept_impl   ( node->arg   , *this );
    1935 
    1936         VISIT_END( node );
    1937 }
    1938 
    1939 template< typename pass_type >
    1940 Expression * PassVisitor< pass_type >::mutate( AddressExpr * node ) {
    1941         MUTATE_START( node );
    1942 
    1943         indexerScopedMutate( node->env   , *this );
    1944         indexerScopedMutate( node->result, *this );
    1945         maybeMutate_impl   ( node->arg   , *this );
    1946 
    1947         MUTATE_END( Expression, node );
    1948 }
    1949 
    1950 //--------------------------------------------------------------------------
    1951 // LabelAddressExpr
    1952 template< typename pass_type >
    1953 void PassVisitor< pass_type >::visit( LabelAddressExpr * node ) {
    1954         VISIT_START( node );
    1955 
    1956         indexerScopedAccept( node->result, *this );
    1957 
    1958         VISIT_END( node );
    1959 }
    1960 
    1961 template< typename pass_type >
    1962 void PassVisitor< pass_type >::visit( const LabelAddressExpr * node ) {
    1963         VISIT_START( node );
    1964 
    1965         indexerScopedAccept( node->result, *this );
    1966 
    1967         VISIT_END( node );
    1968 }
    1969 
    1970 template< typename pass_type >
    1971 Expression * PassVisitor< pass_type >::mutate( LabelAddressExpr * node ) {
    1972         MUTATE_START( node );
    1973 
    1974         indexerScopedMutate( node->env   , *this );
    1975         indexerScopedMutate( node->result, *this );
    19761398
    19771399        MUTATE_END( Expression, node );
     
    19821404template< typename pass_type >
    19831405void PassVisitor< pass_type >::visit( UntypedMemberExpr * node ) {
    1984         VISIT_START( node );
    1985 
    1986         indexerScopedAccept( node->result   , *this );
    1987         maybeAccept_impl   ( node->aggregate, *this );
    1988         maybeAccept_impl   ( node->member   , *this );
    1989 
    1990         VISIT_END( node );
    1991 }
    1992 
    1993 template< typename pass_type >
    1994 void PassVisitor< pass_type >::visit( const UntypedMemberExpr * node ) {
    19951406        VISIT_START( node );
    19961407
     
    20271438
    20281439template< typename pass_type >
    2029 void PassVisitor< pass_type >::visit( const MemberExpr * node ) {
    2030         VISIT_START( node );
    2031 
    2032         indexerScopedAccept( node->result   , *this );
    2033         maybeAccept_impl   ( node->aggregate, *this );
    2034 
    2035         VISIT_END( node );
    2036 }
    2037 
    2038 template< typename pass_type >
    20391440Expression * PassVisitor< pass_type >::mutate( MemberExpr * node ) {
    20401441        MUTATE_START( node );
     
    20591460
    20601461template< typename pass_type >
    2061 void PassVisitor< pass_type >::visit( const VariableExpr * node ) {
    2062         VISIT_START( node );
    2063 
    2064         indexerScopedAccept( node->result, *this );
    2065 
    2066         VISIT_END( node );
    2067 }
    2068 
    2069 template< typename pass_type >
    20701462Expression * PassVisitor< pass_type >::mutate( VariableExpr * node ) {
    20711463        MUTATE_START( node );
     
    20811473template< typename pass_type >
    20821474void PassVisitor< pass_type >::visit( ConstantExpr * node ) {
    2083         VISIT_START( node );
    2084 
    2085         indexerScopedAccept( node->result   , *this );
    2086         maybeAccept_impl   ( &node->constant, *this );
    2087 
    2088         VISIT_END( node );
    2089 }
    2090 
    2091 template< typename pass_type >
    2092 void PassVisitor< pass_type >::visit( const ConstantExpr * node ) {
    20931475        VISIT_START( node );
    20941476
     
    21291511
    21301512template< typename pass_type >
    2131 void PassVisitor< pass_type >::visit( const SizeofExpr * node ) {
     1513Expression * PassVisitor< pass_type >::mutate( SizeofExpr * node ) {
     1514        MUTATE_START( node );
     1515
     1516        indexerScopedMutate( node->env   , *this );
     1517        indexerScopedMutate( node->result, *this );
     1518        if ( node->get_isType() ) {
     1519                maybeMutate_impl( node->type, *this );
     1520        } else {
     1521                maybeMutate_impl( node->expr, *this );
     1522        }
     1523
     1524        MUTATE_END( Expression, node );
     1525}
     1526
     1527//--------------------------------------------------------------------------
     1528// AlignofExpr
     1529template< typename pass_type >
     1530void PassVisitor< pass_type >::visit( AlignofExpr * node ) {
    21321531        VISIT_START( node );
    21331532
     
    21431542
    21441543template< typename pass_type >
    2145 Expression * PassVisitor< pass_type >::mutate( SizeofExpr * node ) {
     1544Expression * PassVisitor< pass_type >::mutate( AlignofExpr * node ) {
    21461545        MUTATE_START( node );
    21471546
     
    21581557
    21591558//--------------------------------------------------------------------------
    2160 // AlignofExpr
    2161 template< typename pass_type >
    2162 void PassVisitor< pass_type >::visit( AlignofExpr * node ) {
     1559// UntypedOffsetofExpr
     1560template< typename pass_type >
     1561void PassVisitor< pass_type >::visit( UntypedOffsetofExpr * node ) {
     1562        VISIT_START( node );
     1563
     1564        indexerScopedAccept( node->result, *this );
     1565        maybeAccept_impl   ( node->type  , *this );
     1566
     1567        VISIT_END( node );
     1568}
     1569
     1570template< typename pass_type >
     1571Expression * PassVisitor< pass_type >::mutate( UntypedOffsetofExpr * node ) {
     1572        MUTATE_START( node );
     1573
     1574        indexerScopedMutate( node->env   , *this );
     1575        indexerScopedMutate( node->result, *this );
     1576        maybeMutate_impl   ( node->type  , *this );
     1577
     1578        MUTATE_END( Expression, node );
     1579}
     1580
     1581//--------------------------------------------------------------------------
     1582// OffsetofExpr
     1583template< typename pass_type >
     1584void PassVisitor< pass_type >::visit( OffsetofExpr * node ) {
     1585        VISIT_START( node );
     1586
     1587        indexerScopedAccept( node->result, *this );
     1588        maybeAccept_impl   ( node->type  , *this );
     1589
     1590        VISIT_END( node );
     1591}
     1592
     1593template< typename pass_type >
     1594Expression * PassVisitor< pass_type >::mutate( OffsetofExpr * node ) {
     1595        MUTATE_START( node );
     1596
     1597        indexerScopedMutate( node->env   , *this );
     1598        indexerScopedMutate( node->result, *this );
     1599        maybeMutate_impl   ( node->type  , *this );
     1600
     1601        MUTATE_END( Expression, node );
     1602}
     1603
     1604//--------------------------------------------------------------------------
     1605// OffsetPackExpr
     1606template< typename pass_type >
     1607void PassVisitor< pass_type >::visit( OffsetPackExpr * node ) {
     1608        VISIT_START( node );
     1609
     1610        indexerScopedAccept( node->result, *this );
     1611        maybeAccept_impl   ( node->type  , *this );
     1612
     1613        VISIT_END( node );
     1614}
     1615
     1616template< typename pass_type >
     1617Expression * PassVisitor< pass_type >::mutate( OffsetPackExpr * node ) {
     1618        MUTATE_START( node );
     1619
     1620        indexerScopedMutate( node->env   , *this );
     1621        indexerScopedMutate( node->result, *this );
     1622        maybeMutate_impl   ( node->type  , *this );
     1623
     1624        MUTATE_END( Expression, node );
     1625}
     1626
     1627//--------------------------------------------------------------------------
     1628// AttrExpr
     1629template< typename pass_type >
     1630void PassVisitor< pass_type >::visit( AttrExpr * node ) {
    21631631        VISIT_START( node );
    21641632
     
    21741642
    21751643template< typename pass_type >
    2176 void PassVisitor< pass_type >::visit( const AlignofExpr * node ) {
    2177         VISIT_START( node );
    2178 
    2179         indexerScopedAccept( node->result, *this );
    2180         if ( node->get_isType() ) {
    2181                 maybeAccept_impl( node->type, *this );
    2182         } else {
    2183                 maybeAccept_impl( node->expr, *this );
    2184         }
    2185 
    2186         VISIT_END( node );
    2187 }
    2188 
    2189 template< typename pass_type >
    2190 Expression * PassVisitor< pass_type >::mutate( AlignofExpr * node ) {
     1644Expression * PassVisitor< pass_type >::mutate( AttrExpr * node ) {
    21911645        MUTATE_START( node );
    21921646
     
    22031657
    22041658//--------------------------------------------------------------------------
    2205 // UntypedOffsetofExpr
    2206 template< typename pass_type >
    2207 void PassVisitor< pass_type >::visit( UntypedOffsetofExpr * node ) {
    2208         VISIT_START( node );
    2209 
    2210         indexerScopedAccept( node->result, *this );
    2211         maybeAccept_impl   ( node->type  , *this );
    2212 
    2213         VISIT_END( node );
    2214 }
    2215 
    2216 template< typename pass_type >
    2217 void PassVisitor< pass_type >::visit( const UntypedOffsetofExpr * node ) {
    2218         VISIT_START( node );
    2219 
    2220         indexerScopedAccept( node->result, *this );
    2221         maybeAccept_impl   ( node->type  , *this );
    2222 
    2223         VISIT_END( node );
    2224 }
    2225 
    2226 template< typename pass_type >
    2227 Expression * PassVisitor< pass_type >::mutate( UntypedOffsetofExpr * node ) {
    2228         MUTATE_START( node );
    2229 
    2230         indexerScopedMutate( node->env   , *this );
    2231         indexerScopedMutate( node->result, *this );
    2232         maybeMutate_impl   ( node->type  , *this );
    2233 
    2234         MUTATE_END( Expression, node );
    2235 }
    2236 
    2237 //--------------------------------------------------------------------------
    2238 // OffsetofExpr
    2239 template< typename pass_type >
    2240 void PassVisitor< pass_type >::visit( OffsetofExpr * node ) {
    2241         VISIT_START( node );
    2242 
    2243         indexerScopedAccept( node->result, *this );
    2244         maybeAccept_impl   ( node->type  , *this );
    2245 
    2246         VISIT_END( node );
    2247 }
    2248 
    2249 template< typename pass_type >
    2250 void PassVisitor< pass_type >::visit( const OffsetofExpr * node ) {
    2251         VISIT_START( node );
    2252 
    2253         indexerScopedAccept( node->result, *this );
    2254         maybeAccept_impl   ( node->type  , *this );
    2255 
    2256         VISIT_END( node );
    2257 }
    2258 
    2259 template< typename pass_type >
    2260 Expression * PassVisitor< pass_type >::mutate( OffsetofExpr * node ) {
    2261         MUTATE_START( node );
    2262 
    2263         indexerScopedMutate( node->env   , *this );
    2264         indexerScopedMutate( node->result, *this );
    2265         maybeMutate_impl   ( node->type  , *this );
    2266 
    2267         MUTATE_END( Expression, node );
    2268 }
    2269 
    2270 //--------------------------------------------------------------------------
    2271 // OffsetPackExpr
    2272 template< typename pass_type >
    2273 void PassVisitor< pass_type >::visit( OffsetPackExpr * node ) {
    2274         VISIT_START( node );
    2275 
    2276         indexerScopedAccept( node->result, *this );
    2277         maybeAccept_impl   ( node->type  , *this );
    2278 
    2279         VISIT_END( node );
    2280 }
    2281 
    2282 template< typename pass_type >
    2283 void PassVisitor< pass_type >::visit( const OffsetPackExpr * node ) {
    2284         VISIT_START( node );
    2285 
    2286         indexerScopedAccept( node->result, *this );
    2287         maybeAccept_impl   ( node->type  , *this );
    2288 
    2289         VISIT_END( node );
    2290 }
    2291 
    2292 template< typename pass_type >
    2293 Expression * PassVisitor< pass_type >::mutate( OffsetPackExpr * node ) {
    2294         MUTATE_START( node );
    2295 
    2296         indexerScopedMutate( node->env   , *this );
    2297         indexerScopedMutate( node->result, *this );
    2298         maybeMutate_impl   ( node->type  , *this );
    2299 
    2300         MUTATE_END( Expression, node );
    2301 }
    2302 
    2303 //--------------------------------------------------------------------------
    2304 // AttrExpr
    2305 template< typename pass_type >
    2306 void PassVisitor< pass_type >::visit( AttrExpr * node ) {
    2307         VISIT_START( node );
    2308 
    2309         indexerScopedAccept( node->result, *this );
    2310         if ( node->get_isType() ) {
    2311                 maybeAccept_impl( node->type, *this );
    2312         } else {
    2313                 maybeAccept_impl( node->expr, *this );
    2314         }
    2315 
    2316         VISIT_END( node );
    2317 }
    2318 
    2319 template< typename pass_type >
    2320 void PassVisitor< pass_type >::visit( const AttrExpr * node ) {
    2321         VISIT_START( node );
    2322 
    2323         indexerScopedAccept( node->result, *this );
    2324         if ( node->get_isType() ) {
    2325                 maybeAccept_impl( node->type, *this );
    2326         } else {
    2327                 maybeAccept_impl( node->expr, *this );
    2328         }
    2329 
    2330         VISIT_END( node );
    2331 }
    2332 
    2333 template< typename pass_type >
    2334 Expression * PassVisitor< pass_type >::mutate( AttrExpr * node ) {
    2335         MUTATE_START( node );
    2336 
    2337         indexerScopedMutate( node->env   , *this );
    2338         indexerScopedMutate( node->result, *this );
    2339         if ( node->get_isType() ) {
    2340                 maybeMutate_impl( node->type, *this );
    2341         } else {
    2342                 maybeMutate_impl( node->expr, *this );
    2343         }
    2344 
    2345         MUTATE_END( Expression, node );
    2346 }
    2347 
    2348 //--------------------------------------------------------------------------
    23491659// LogicalExpr
    23501660template< typename pass_type >
    23511661void PassVisitor< pass_type >::visit( LogicalExpr * node ) {
    2352         VISIT_START( node );
    2353 
    2354         indexerScopedAccept( node->result, *this );
    2355         maybeAccept_impl   ( node->arg1  , *this );
    2356         maybeAccept_impl   ( node->arg2  , *this );
    2357 
    2358         VISIT_END( node );
    2359 }
    2360 
    2361 template< typename pass_type >
    2362 void PassVisitor< pass_type >::visit( const LogicalExpr * node ) {
    23631662        VISIT_START( node );
    23641663
     
    23971696
    23981697template< typename pass_type >
    2399 void PassVisitor< pass_type >::visit( const ConditionalExpr * node ) {
     1698Expression * PassVisitor< pass_type >::mutate( ConditionalExpr * node ) {
     1699        MUTATE_START( node );
     1700
     1701        indexerScopedMutate( node->env   , *this );
     1702        indexerScopedMutate( node->result, *this );
     1703        maybeMutate_impl   ( node->arg1  , *this );
     1704        maybeMutate_impl   ( node->arg2  , *this );
     1705        maybeMutate_impl   ( node->arg3  , *this );
     1706
     1707        MUTATE_END( Expression, node );
     1708}
     1709
     1710//--------------------------------------------------------------------------
     1711// CommaExpr
     1712template< typename pass_type >
     1713void PassVisitor< pass_type >::visit( CommaExpr * node ) {
    24001714        VISIT_START( node );
    24011715
     
    24031717        maybeAccept_impl   ( node->arg1  , *this );
    24041718        maybeAccept_impl   ( node->arg2  , *this );
    2405         maybeAccept_impl   ( node->arg3  , *this );
    2406 
    2407         VISIT_END( node );
    2408 }
    2409 
    2410 template< typename pass_type >
    2411 Expression * PassVisitor< pass_type >::mutate( ConditionalExpr * node ) {
     1719
     1720        VISIT_END( node );
     1721}
     1722
     1723template< typename pass_type >
     1724Expression * PassVisitor< pass_type >::mutate( CommaExpr * node ) {
    24121725        MUTATE_START( node );
    24131726
     
    24161729        maybeMutate_impl   ( node->arg1  , *this );
    24171730        maybeMutate_impl   ( node->arg2  , *this );
    2418         maybeMutate_impl   ( node->arg3  , *this );
    2419 
    2420         MUTATE_END( Expression, node );
    2421 }
    2422 
    2423 //--------------------------------------------------------------------------
    2424 // CommaExpr
    2425 template< typename pass_type >
    2426 void PassVisitor< pass_type >::visit( CommaExpr * node ) {
    2427         VISIT_START( node );
    2428 
    2429         indexerScopedAccept( node->result, *this );
    2430         maybeAccept_impl   ( node->arg1  , *this );
    2431         maybeAccept_impl   ( node->arg2  , *this );
    2432 
    2433         VISIT_END( node );
    2434 }
    2435 
    2436 template< typename pass_type >
    2437 void PassVisitor< pass_type >::visit( const CommaExpr * node ) {
    2438         VISIT_START( node );
    2439 
    2440         indexerScopedAccept( node->result, *this );
    2441         maybeAccept_impl   ( node->arg1  , *this );
    2442         maybeAccept_impl   ( node->arg2  , *this );
    2443 
    2444         VISIT_END( node );
    2445 }
    2446 
    2447 template< typename pass_type >
    2448 Expression * PassVisitor< pass_type >::mutate( CommaExpr * node ) {
    2449         MUTATE_START( node );
    2450 
    2451         indexerScopedMutate( node->env   , *this );
    2452         indexerScopedMutate( node->result, *this );
    2453         maybeMutate_impl   ( node->arg1  , *this );
    2454         maybeMutate_impl   ( node->arg2  , *this );
    24551731
    24561732        MUTATE_END( Expression, node );
     
    24701746
    24711747template< typename pass_type >
    2472 void PassVisitor< pass_type >::visit( const TypeExpr * node ) {
    2473         VISIT_START( node );
    2474 
    2475         indexerScopedAccept( node->result, *this );
    2476         maybeAccept_impl   ( node->type, *this );
    2477 
    2478         VISIT_END( node );
    2479 }
    2480 
    2481 template< typename pass_type >
    24821748Expression * PassVisitor< pass_type >::mutate( TypeExpr * node ) {
    24831749        MUTATE_START( node );
     
    24941760template< typename pass_type >
    24951761void PassVisitor< pass_type >::visit( AsmExpr * node ) {
    2496         VISIT_START( node );
    2497 
    2498         indexerScopedAccept( node->result    , *this );
    2499         maybeAccept_impl   ( node->inout     , *this );
    2500         maybeAccept_impl   ( node->constraint, *this );
    2501         maybeAccept_impl   ( node->operand   , *this );
    2502 
    2503         VISIT_END( node );
    2504 }
    2505 
    2506 template< typename pass_type >
    2507 void PassVisitor< pass_type >::visit( const AsmExpr * node ) {
    25081762        VISIT_START( node );
    25091763
     
    25351789        VISIT_START( node );
    25361790
    2537         indexerScopedAccept( node->result    , *this );
    2538         maybeAccept_impl   ( node->callExpr  , *this );
    2539 
    2540         VISIT_END( node );
    2541 }
    2542 
    2543 template< typename pass_type >
    2544 void PassVisitor< pass_type >::visit( const ImplicitCopyCtorExpr * node ) {
    2545         VISIT_START( node );
    2546 
    2547         indexerScopedAccept( node->result    , *this );
    2548         maybeAccept_impl   ( node->callExpr  , *this );
     1791        indexerScopedAccept( node->result     , *this );
     1792        maybeAccept_impl   ( node->callExpr   , *this );
     1793        maybeAccept_impl   ( node->tempDecls  , *this );
     1794        maybeAccept_impl   ( node->returnDecls, *this );
     1795        maybeAccept_impl   ( node->dtors      , *this );
    25491796
    25501797        VISIT_END( node );
     
    25551802        MUTATE_START( node );
    25561803
    2557         indexerScopedMutate( node->env       , *this );
    2558         indexerScopedMutate( node->result    , *this );
    2559         maybeMutate_impl   ( node->callExpr  , *this );
     1804        indexerScopedMutate( node->env        , *this );
     1805        indexerScopedMutate( node->result     , *this );
     1806        maybeMutate_impl   ( node->callExpr   , *this );
     1807        maybeMutate_impl   ( node->tempDecls  , *this );
     1808        maybeMutate_impl   ( node->returnDecls, *this );
     1809        maybeMutate_impl   ( node->dtors      , *this );
    25601810
    25611811        MUTATE_END( Expression, node );
     
    25661816template< typename pass_type >
    25671817void PassVisitor< pass_type >::visit( ConstructorExpr * node ) {
    2568         VISIT_START( node );
    2569 
    2570         indexerScopedAccept( node->result  , *this );
    2571         maybeAccept_impl   ( node->callExpr, *this );
    2572 
    2573         VISIT_END( node );
    2574 }
    2575 
    2576 template< typename pass_type >
    2577 void PassVisitor< pass_type >::visit( const ConstructorExpr * node ) {
    25781818        VISIT_START( node );
    25791819
     
    26081848
    26091849template< typename pass_type >
    2610 void PassVisitor< pass_type >::visit( const CompoundLiteralExpr * node ) {
    2611         VISIT_START( node );
    2612 
    2613         indexerScopedAccept( node->result     , *this );
    2614         maybeAccept_impl   ( node->initializer, *this );
    2615 
    2616         VISIT_END( node );
    2617 }
    2618 
    2619 template< typename pass_type >
    26201850Expression * PassVisitor< pass_type >::mutate( CompoundLiteralExpr * node ) {
    26211851        MUTATE_START( node );
     
    26421872
    26431873template< typename pass_type >
    2644 void PassVisitor< pass_type >::visit( const RangeExpr * node ) {
    2645         VISIT_START( node );
    2646 
    2647         indexerScopedAccept( node->result, *this );
    2648         maybeAccept_impl   ( node->low   , *this );
    2649         maybeAccept_impl   ( node->high  , *this );
    2650 
    2651         VISIT_END( node );
    2652 }
    2653 
    2654 template< typename pass_type >
    26551874Expression * PassVisitor< pass_type >::mutate( RangeExpr * node ) {
    26561875        MUTATE_START( node );
     
    26771896
    26781897template< typename pass_type >
    2679 void PassVisitor< pass_type >::visit( const UntypedTupleExpr * node ) {
     1898Expression * PassVisitor< pass_type >::mutate( UntypedTupleExpr * node ) {
     1899        MUTATE_START( node );
     1900
     1901        indexerScopedMutate( node->env   , *this );
     1902        indexerScopedMutate( node->result, *this );
     1903        maybeMutate_impl   ( node->exprs , *this );
     1904
     1905        MUTATE_END( Expression, node );
     1906}
     1907
     1908//--------------------------------------------------------------------------
     1909// TupleExpr
     1910template< typename pass_type >
     1911void PassVisitor< pass_type >::visit( TupleExpr * node ) {
    26801912        VISIT_START( node );
    26811913
     
    26871919
    26881920template< typename pass_type >
    2689 Expression * PassVisitor< pass_type >::mutate( UntypedTupleExpr * node ) {
    2690         MUTATE_START( node );
    2691 
    2692         indexerScopedMutate( node->env   , *this );
    2693         indexerScopedMutate( node->result, *this );
    2694         maybeMutate_impl   ( node->exprs , *this );
    2695 
    2696         MUTATE_END( Expression, node );
    2697 }
    2698 
    2699 //--------------------------------------------------------------------------
    2700 // TupleExpr
    2701 template< typename pass_type >
    2702 void PassVisitor< pass_type >::visit( TupleExpr * node ) {
    2703         VISIT_START( node );
    2704 
    2705         indexerScopedAccept( node->result, *this );
    2706         maybeAccept_impl   ( node->exprs , *this );
    2707 
    2708         VISIT_END( node );
    2709 }
    2710 
    2711 template< typename pass_type >
    2712 void PassVisitor< pass_type >::visit( const TupleExpr * node ) {
    2713         VISIT_START( node );
    2714 
    2715         indexerScopedAccept( node->result, *this );
    2716         maybeAccept_impl   ( node->exprs , *this );
    2717 
    2718         VISIT_END( node );
    2719 }
    2720 
    2721 template< typename pass_type >
    27221921Expression * PassVisitor< pass_type >::mutate( TupleExpr * node ) {
    27231922        MUTATE_START( node );
     
    27431942
    27441943template< typename pass_type >
    2745 void PassVisitor< pass_type >::visit( const TupleIndexExpr * node ) {
    2746         VISIT_START( node );
    2747 
    2748         indexerScopedAccept( node->result, *this );
    2749         maybeAccept_impl   ( node->tuple , *this );
    2750 
    2751         VISIT_END( node );
    2752 }
    2753 
    2754 template< typename pass_type >
    27551944Expression * PassVisitor< pass_type >::mutate( TupleIndexExpr * node ) {
    27561945        MUTATE_START( node );
     
    27711960        indexerScopedAccept( node->result  , *this );
    27721961        maybeAccept_impl   ( node->stmtExpr, *this );
    2773 
    2774         VISIT_END( node );
    2775 }
    2776 
    2777 template< typename pass_type >
    2778 void PassVisitor< pass_type >::visit( const TupleAssignExpr * node ) {
    2779         VISIT_START( node );
    2780 
    2781         indexerScopedAccept( node->result  , *this );
    2782         maybeAccept_impl( node->stmtExpr, *this );
    27831962
    27841963        VISIT_END( node );
     
    28161995
    28171996template< typename pass_type >
    2818 void PassVisitor< pass_type >::visit( const StmtExpr * node ) {
    2819         VISIT_START( node );
     1997Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) {
     1998        MUTATE_START( node );
    28201999
    28212000        // don't want statements from outer CompoundStmts to be added to this StmtExpr
     
    28242003        ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
    28252004
    2826         indexerScopedAccept( node->result     , *this );
    2827         maybeAccept_impl   ( node->statements , *this );
    2828         maybeAccept_impl   ( node->returnDecls, *this );
    2829         maybeAccept_impl   ( node->dtors      , *this );
    2830 
    2831         VISIT_END( node );
    2832 }
    2833 
    2834 template< typename pass_type >
    2835 Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) {
    2836         MUTATE_START( node );
    2837 
    2838         // don't want statements from outer CompoundStmts to be added to this StmtExpr
    2839         ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type >  oldEnv( get_env_ptr() );
    2840         ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() );
    2841         ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () );
    2842 
    28432005        indexerScopedMutate( node->result     , *this );
    28442006        maybeMutate_impl   ( node->statements , *this );
     
    28622024
    28632025template< typename pass_type >
    2864 void PassVisitor< pass_type >::visit( const UniqueExpr * node ) {
    2865         VISIT_START( node );
    2866 
    2867         indexerScopedAccept( node->result, *this );
    2868         maybeAccept_impl   ( node->expr  , *this );
    2869 
    2870         VISIT_END( node );
    2871 }
    2872 
    2873 template< typename pass_type >
    28742026Expression * PassVisitor< pass_type >::mutate( UniqueExpr * node ) {
    28752027        MUTATE_START( node );
     
    28962048
    28972049template< typename pass_type >
    2898 void PassVisitor< pass_type >::visit( const UntypedInitExpr * node ) {
    2899         VISIT_START( node );
    2900 
    2901         indexerScopedAccept( node->result, *this );
    2902         maybeAccept_impl   ( node->expr  , *this );
    2903         // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.
    2904 
    2905         VISIT_END( node );
    2906 }
    2907 
    2908 template< typename pass_type >
    29092050Expression * PassVisitor< pass_type >::mutate( UntypedInitExpr * node ) {
    29102051        MUTATE_START( node );
     
    29322073
    29332074template< typename pass_type >
    2934 void PassVisitor< pass_type >::visit( const InitExpr * node ) {
    2935         VISIT_START( node );
    2936 
    2937         indexerScopedAccept( node->result, *this );
    2938         maybeAccept_impl   ( node->expr  , *this );
    2939         maybeAccept_impl   ( node->designation, *this );
    2940 
    2941         VISIT_END( node );
    2942 }
    2943 
    2944 template< typename pass_type >
    29452075Expression * PassVisitor< pass_type >::mutate( InitExpr * node ) {
    29462076        MUTATE_START( node );
     
    29612091
    29622092        indexerScopedAccept( node->result, *this );
    2963         maybeAccept_impl   ( node->expr, *this );
     2093        maybeAccept_impl( node->expr, *this );
    29642094        // don't visit deleteStmt, because it is a pointer to somewhere else in the tree.
    29652095
     
    29682098
    29692099template< typename pass_type >
    2970 void PassVisitor< pass_type >::visit( const DeletedExpr * node ) {
     2100Expression * PassVisitor< pass_type >::mutate( DeletedExpr * node ) {
     2101        MUTATE_START( node );
     2102
     2103        indexerScopedMutate( node->env, *this );
     2104        indexerScopedMutate( node->result, *this );
     2105        maybeMutate_impl( node->expr, *this );
     2106
     2107        MUTATE_END( Expression, node );
     2108}
     2109
     2110//--------------------------------------------------------------------------
     2111// DefaultArgExpr
     2112template< typename pass_type >
     2113void PassVisitor< pass_type >::visit( DefaultArgExpr * node ) {
    29712114        VISIT_START( node );
    29722115
    29732116        indexerScopedAccept( node->result, *this );
    2974         maybeAccept_impl   ( node->expr, *this );
    2975         // don't visit deleteStmt, because it is a pointer to somewhere else in the tree.
    2976 
    2977         VISIT_END( node );
    2978 }
    2979 
    2980 template< typename pass_type >
    2981 Expression * PassVisitor< pass_type >::mutate( DeletedExpr * node ) {
    2982         MUTATE_START( node );
    2983 
    2984         indexerScopedMutate( node->env, *this );
    2985         indexerScopedMutate( node->result, *this );
    2986         maybeMutate_impl( node->expr, *this );
    2987 
    2988         MUTATE_END( Expression, node );
    2989 }
    2990 
    2991 //--------------------------------------------------------------------------
    2992 // DefaultArgExpr
    2993 template< typename pass_type >
    2994 void PassVisitor< pass_type >::visit( DefaultArgExpr * node ) {
    2995         VISIT_START( node );
    2996 
    2997         indexerScopedAccept( node->result, *this );
    2998         maybeAccept_impl   ( node->expr, *this );
    2999 
    3000         VISIT_END( node );
    3001 }
    3002 
    3003 template< typename pass_type >
    3004 void PassVisitor< pass_type >::visit( const DefaultArgExpr * node ) {
    3005         VISIT_START( node );
    3006 
    3007         indexerScopedAccept( node->result, *this );
    3008         maybeAccept_impl   ( node->expr, *this );
     2117        maybeAccept_impl( node->expr, *this );
    30092118
    30102119        VISIT_END( node );
     
    30392148
    30402149template< typename pass_type >
    3041 void PassVisitor< pass_type >::visit( const GenericExpr * node ) {
    3042         VISIT_START( node );
    3043 
    3044         indexerScopedAccept( node->result, *this );
    3045         maybeAccept_impl( node->control, *this );
    3046         for ( const GenericExpr::Association & assoc : node->associations ) {
    3047                 indexerScopedAccept( assoc.type, *this );
    3048                 maybeAccept_impl( assoc.expr, *this );
    3049         }
    3050 
    3051         VISIT_END( node );
    3052 }
    3053 
    3054 template< typename pass_type >
    30552150Expression * PassVisitor< pass_type >::mutate( GenericExpr * node ) {
    30562151        MUTATE_START( node );
     
    30792174
    30802175template< typename pass_type >
    3081 void PassVisitor< pass_type >::visit( const VoidType * node ) {
    3082         VISIT_START( node );
    3083 
    3084         maybeAccept_impl( node->forall, *this );
    3085 
    3086         VISIT_END( node );
    3087 }
    3088 
    3089 template< typename pass_type >
    30902176Type * PassVisitor< pass_type >::mutate( VoidType * node ) {
    30912177        MUTATE_START( node );
     
    31002186template< typename pass_type >
    31012187void PassVisitor< pass_type >::visit( BasicType * node ) {
    3102         VISIT_START( node );
    3103 
    3104         maybeAccept_impl( node->forall, *this );
    3105 
    3106         VISIT_END( node );
    3107 }
    3108 
    3109 template< typename pass_type >
    3110 void PassVisitor< pass_type >::visit( const BasicType * node ) {
    31112188        VISIT_START( node );
    31122189
     
    31392216
    31402217template< typename pass_type >
    3141 void PassVisitor< pass_type >::visit( const PointerType * node ) {
    3142         VISIT_START( node );
    3143 
    3144         maybeAccept_impl( node->forall, *this );
    3145         // xxx - should PointerType visit/mutate dimension?
    3146         maybeAccept_impl( node->base, *this );
    3147 
    3148         VISIT_END( node );
    3149 }
    3150 
    3151 template< typename pass_type >
    31522218Type * PassVisitor< pass_type >::mutate( PointerType * node ) {
    31532219        MUTATE_START( node );
     
    31742240
    31752241template< typename pass_type >
    3176 void PassVisitor< pass_type >::visit( const ArrayType * node ) {
    3177         VISIT_START( node );
    3178 
    3179         maybeAccept_impl( node->forall, *this );
    3180         maybeAccept_impl( node->dimension, *this );
    3181         maybeAccept_impl( node->base, *this );
    3182 
    3183         VISIT_END( node );
    3184 }
    3185 
    3186 template< typename pass_type >
    31872242Type * PassVisitor< pass_type >::mutate( ArrayType * node ) {
    31882243        MUTATE_START( node );
     
    32082263
    32092264template< typename pass_type >
    3210 void PassVisitor< pass_type >::visit( const ReferenceType * node ) {
    3211         VISIT_START( node );
    3212 
    3213         maybeAccept_impl( node->forall, *this );
    3214         maybeAccept_impl( node->base, *this );
    3215 
    3216         VISIT_END( node );
    3217 }
    3218 
    3219 template< typename pass_type >
    32202265Type * PassVisitor< pass_type >::mutate( ReferenceType * node ) {
    32212266        MUTATE_START( node );
     
    32412286
    32422287template< typename pass_type >
    3243 void PassVisitor< pass_type >::visit( const QualifiedType * node ) {
    3244         VISIT_START( node );
    3245 
    3246         maybeAccept_impl( node->forall, *this );
    3247         maybeAccept_impl( node->parent, *this );
    3248         maybeAccept_impl( node->child, *this );
    3249 
    3250         VISIT_END( node );
    3251 }
    3252 
    3253 template< typename pass_type >
    32542288Type * PassVisitor< pass_type >::mutate( QualifiedType * node ) {
    32552289        MUTATE_START( node );
     
    32662300template< typename pass_type >
    32672301void PassVisitor< pass_type >::visit( FunctionType * node ) {
    3268         VISIT_START( node );
    3269 
    3270         maybeAccept_impl( node->forall, *this );
    3271         maybeAccept_impl( node->returnVals, *this );
    3272         maybeAccept_impl( node->parameters, *this );
    3273 
    3274         VISIT_END( node );
    3275 }
    3276 
    3277 template< typename pass_type >
    3278 void PassVisitor< pass_type >::visit( const FunctionType * node ) {
    32792302        VISIT_START( node );
    32802303
     
    33152338
    33162339template< typename pass_type >
    3317 void PassVisitor< pass_type >::visit( const StructInstType * node ) {
     2340Type * PassVisitor< pass_type >::mutate( StructInstType * node ) {
     2341        MUTATE_START( node );
     2342
     2343        indexerAddStruct( node->name );
     2344
     2345        {
     2346                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
     2347                maybeMutate_impl( node->forall    , *this );
     2348                maybeMutate_impl( node->parameters, *this );
     2349        }
     2350
     2351        MUTATE_END( Type, node );
     2352}
     2353
     2354//--------------------------------------------------------------------------
     2355// UnionInstType
     2356template< typename pass_type >
     2357void PassVisitor< pass_type >::visit( UnionInstType * node ) {
    33182358        VISIT_START( node );
    33192359
     
    33302370
    33312371template< typename pass_type >
    3332 Type * PassVisitor< pass_type >::mutate( StructInstType * node ) {
     2372Type * PassVisitor< pass_type >::mutate( UnionInstType * node ) {
    33332373        MUTATE_START( node );
    33342374
     
    33452385
    33462386//--------------------------------------------------------------------------
    3347 // UnionInstType
    3348 template< typename pass_type >
    3349 void PassVisitor< pass_type >::visit( UnionInstType * node ) {
    3350         VISIT_START( node );
    3351 
    3352         indexerAddStruct( node->name );
    3353 
    3354         {
    3355                 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    3356                 maybeAccept_impl( node->forall    , *this );
    3357                 maybeAccept_impl( node->parameters, *this );
    3358         }
    3359 
    3360         VISIT_END( node );
    3361 }
    3362 
    3363 template< typename pass_type >
    3364 void PassVisitor< pass_type >::visit( const UnionInstType * node ) {
    3365         VISIT_START( node );
    3366 
    3367         indexerAddStruct( node->name );
    3368 
    3369         {
    3370                 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    3371                 maybeAccept_impl( node->forall    , *this );
    3372                 maybeAccept_impl( node->parameters, *this );
    3373         }
    3374 
    3375         VISIT_END( node );
    3376 }
    3377 
    3378 template< typename pass_type >
    3379 Type * PassVisitor< pass_type >::mutate( UnionInstType * node ) {
    3380         MUTATE_START( node );
    3381 
    3382         indexerAddStruct( node->name );
    3383 
    3384         {
    3385                 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    3386                 maybeMutate_impl( node->forall    , *this );
    3387                 maybeMutate_impl( node->parameters, *this );
    3388         }
    3389 
    3390         MUTATE_END( Type, node );
    3391 }
    3392 
    3393 //--------------------------------------------------------------------------
    33942387// EnumInstType
    33952388template< typename pass_type >
     
    34042397
    34052398template< typename pass_type >
    3406 void PassVisitor< pass_type >::visit( const EnumInstType * node ) {
    3407         VISIT_START( node );
    3408 
    3409         maybeAccept_impl( node->forall, *this );
    3410         maybeAccept_impl( node->parameters, *this );
    3411 
    3412         VISIT_END( node );
    3413 }
    3414 
    3415 template< typename pass_type >
    34162399Type * PassVisitor< pass_type >::mutate( EnumInstType * node ) {
    34172400        MUTATE_START( node );
     
    34362419
    34372420template< typename pass_type >
    3438 void PassVisitor< pass_type >::visit( const TraitInstType * node ) {
    3439         VISIT_START( node );
    3440 
    3441         maybeAccept_impl( node->forall    , *this );
    3442         maybeAccept_impl( node->parameters, *this );
    3443 
    3444         VISIT_END( node );
    3445 }
    3446 
    3447 template< typename pass_type >
    34482421Type * PassVisitor< pass_type >::mutate( TraitInstType * node ) {
    34492422        MUTATE_START( node );
     
    34592432template< typename pass_type >
    34602433void PassVisitor< pass_type >::visit( TypeInstType * node ) {
    3461         VISIT_START( node );
    3462 
    3463         maybeAccept_impl( node->forall    , *this );
    3464         maybeAccept_impl( node->parameters, *this );
    3465 
    3466         VISIT_END( node );
    3467 }
    3468 
    3469 template< typename pass_type >
    3470 void PassVisitor< pass_type >::visit( const TypeInstType * node ) {
    34712434        VISIT_START( node );
    34722435
     
    35012464
    35022465template< typename pass_type >
    3503 void PassVisitor< pass_type >::visit( const TupleType * node ) {
    3504         VISIT_START( node );
    3505 
    3506         maybeAccept_impl( node->forall, *this );
    3507         maybeAccept_impl( node->types, *this );
    3508         maybeAccept_impl( node->members, *this );
    3509 
    3510         VISIT_END( node );
    3511 }
    3512 
    3513 template< typename pass_type >
    35142466Type * PassVisitor< pass_type >::mutate( TupleType * node ) {
    35152467        MUTATE_START( node );
     
    35262478template< typename pass_type >
    35272479void PassVisitor< pass_type >::visit( TypeofType * node ) {
    3528         VISIT_START( node );
    3529 
    3530         assert( node->expr );
    3531         maybeAccept_impl( node->expr, *this );
    3532 
    3533         VISIT_END( node );
    3534 }
    3535 
    3536 template< typename pass_type >
    3537 void PassVisitor< pass_type >::visit( const TypeofType * node ) {
    35382480        VISIT_START( node );
    35392481
     
    35722514
    35732515template< typename pass_type >
    3574 void PassVisitor< pass_type >::visit( const AttrType * node ) {
    3575         VISIT_START( node );
    3576 
    3577         if ( node->isType ) {
    3578                 assert( node->type );
    3579                 maybeAccept_impl( node->type, *this );
    3580         } else {
    3581                 assert( node->expr );
    3582                 maybeAccept_impl( node->expr, *this );
    3583         } // if
    3584 
    3585         VISIT_END( node );
    3586 }
    3587 
    3588 template< typename pass_type >
    35892516Type * PassVisitor< pass_type >::mutate( AttrType * node ) {
    35902517        MUTATE_START( node );
     
    36132540
    36142541template< typename pass_type >
    3615 void PassVisitor< pass_type >::visit( const VarArgsType * node ) {
     2542Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) {
     2543        MUTATE_START( node );
     2544
     2545        maybeMutate_impl( node->forall, *this );
     2546
     2547        MUTATE_END( Type, node );
     2548}
     2549
     2550//--------------------------------------------------------------------------
     2551// ZeroType
     2552template< typename pass_type >
     2553void PassVisitor< pass_type >::visit( ZeroType * node ) {
    36162554        VISIT_START( node );
    36172555
     
    36222560
    36232561template< typename pass_type >
    3624 Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) {
     2562Type * PassVisitor< pass_type >::mutate( ZeroType * node ) {
    36252563        MUTATE_START( node );
    36262564
     
    36312569
    36322570//--------------------------------------------------------------------------
    3633 // ZeroType
    3634 template< typename pass_type >
    3635 void PassVisitor< pass_type >::visit( ZeroType * node ) {
     2571// OneType
     2572template< typename pass_type >
     2573void PassVisitor< pass_type >::visit( OneType * node ) {
    36362574        VISIT_START( node );
    36372575
     
    36422580
    36432581template< typename pass_type >
    3644 void PassVisitor< pass_type >::visit( const ZeroType * node ) {
     2582Type * PassVisitor< pass_type >::mutate( OneType * node ) {
     2583        MUTATE_START( node );
     2584
     2585        maybeMutate_impl( node->forall, *this );
     2586
     2587        MUTATE_END( Type, node );
     2588}
     2589
     2590//--------------------------------------------------------------------------
     2591// GlobalScopeType
     2592template< typename pass_type >
     2593void PassVisitor< pass_type >::visit( GlobalScopeType * node ) {
    36452594        VISIT_START( node );
    36462595
     
    36512600
    36522601template< typename pass_type >
    3653 Type * PassVisitor< pass_type >::mutate( ZeroType * node ) {
     2602Type * PassVisitor< pass_type >::mutate( GlobalScopeType * node ) {
    36542603        MUTATE_START( node );
    36552604
     
    36602609
    36612610//--------------------------------------------------------------------------
    3662 // OneType
    3663 template< typename pass_type >
    3664 void PassVisitor< pass_type >::visit( OneType * node ) {
    3665         VISIT_START( node );
    3666 
    3667         maybeAccept_impl( node->forall, *this );
    3668 
    3669         VISIT_END( node );
    3670 }
    3671 
    3672 template< typename pass_type >
    3673 void PassVisitor< pass_type >::visit( const OneType * node ) {
    3674         VISIT_START( node );
    3675 
    3676         maybeAccept_impl( node->forall, *this );
    3677 
    3678         VISIT_END( node );
    3679 }
    3680 
    3681 template< typename pass_type >
    3682 Type * PassVisitor< pass_type >::mutate( OneType * node ) {
    3683         MUTATE_START( node );
    3684 
    3685         maybeMutate_impl( node->forall, *this );
    3686 
    3687         MUTATE_END( Type, node );
    3688 }
    3689 
    3690 //--------------------------------------------------------------------------
    3691 // GlobalScopeType
    3692 template< typename pass_type >
    3693 void PassVisitor< pass_type >::visit( GlobalScopeType * node ) {
    3694         VISIT_START( node );
    3695 
    3696         maybeAccept_impl( node->forall, *this );
    3697 
    3698         VISIT_END( node );
    3699 }
    3700 
    3701 template< typename pass_type >
    3702 void PassVisitor< pass_type >::visit( const GlobalScopeType * node ) {
    3703         VISIT_START( node );
    3704 
    3705         maybeAccept_impl( node->forall, *this );
    3706 
    3707         VISIT_END( node );
    3708 }
    3709 
    3710 template< typename pass_type >
    3711 Type * PassVisitor< pass_type >::mutate( GlobalScopeType * node ) {
    3712         MUTATE_START( node );
    3713 
    3714         maybeMutate_impl( node->forall, *this );
    3715 
    3716         MUTATE_END( Type, node );
    3717 }
    3718 
    3719 //--------------------------------------------------------------------------
    37202611// Designation
    37212612template< typename pass_type >
     
    37292620
    37302621template< typename pass_type >
    3731 void PassVisitor< pass_type >::visit( const Designation * node ) {
    3732         VISIT_START( node );
    3733 
    3734         maybeAccept_impl( node->designators, *this );
    3735 
    3736         VISIT_END( node );
    3737 }
    3738 
    3739 template< typename pass_type >
    37402622Designation * PassVisitor< pass_type >::mutate( Designation * node ) {
    37412623        MUTATE_START( node );
     
    37582640
    37592641template< typename pass_type >
    3760 void PassVisitor< pass_type >::visit( const SingleInit * node ) {
    3761         VISIT_START( node );
    3762 
    3763         visitExpression( node->value );
    3764 
    3765         VISIT_END( node );
    3766 }
    3767 
    3768 template< typename pass_type >
    37692642Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) {
    37702643        MUTATE_START( node );
     
    37792652template< typename pass_type >
    37802653void PassVisitor< pass_type >::visit( ListInit * node ) {
    3781         VISIT_START( node );
    3782 
    3783         maybeAccept_impl( node->designations, *this );
    3784         maybeAccept_impl( node->initializers, *this );
    3785 
    3786         VISIT_END( node );
    3787 }
    3788 
    3789 template< typename pass_type >
    3790 void PassVisitor< pass_type >::visit( const ListInit * node ) {
    37912654        VISIT_START( node );
    37922655
     
    38212684
    38222685template< typename pass_type >
    3823 void PassVisitor< pass_type >::visit( const ConstructorInit * node ) {
    3824         VISIT_START( node );
    3825 
    3826         maybeAccept_impl( node->ctor, *this );
    3827         maybeAccept_impl( node->dtor, *this );
    3828         maybeAccept_impl( node->init, *this );
    3829 
    3830         VISIT_END( node );
    3831 }
    3832 
    3833 template< typename pass_type >
    38342686Initializer * PassVisitor< pass_type >::mutate( ConstructorInit * node ) {
    38352687        MUTATE_START( node );
     
    38522704
    38532705template< typename pass_type >
    3854 void PassVisitor< pass_type >::visit( const Constant * node ) {
    3855         VISIT_START( node );
    3856 
    3857         VISIT_END( node );
    3858 }
    3859 
    3860 template< typename pass_type >
    38612706Constant * PassVisitor< pass_type >::mutate( Constant * node  )  {
    38622707        MUTATE_START( node );
     
    38692714template< typename pass_type >
    38702715void PassVisitor< pass_type >::visit( Attribute * node ) {
    3871         VISIT_START( node );
    3872 
    3873         maybeAccept_impl( node->parameters, *this );
    3874 
    3875         VISIT_END( node );
    3876 }
    3877 
    3878 template< typename pass_type >
    3879 void PassVisitor< pass_type >::visit( const Attribute * node ) {
    38802716        VISIT_START( node );
    38812717
Note: See TracChangeset for help on using the changeset viewer.