Changes in src/Common/PassVisitor.impl.h [033ff37:ee3c93d]
- File:
-
- 1 edited
-
src/Common/PassVisitor.impl.h (modified) (118 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.impl.h
r033ff37 ree3c93d 20 20 21 21 #define MUTATE_END( type, node ) \ 22 auto __return = call_postmutate< type * >( node ); \ 23 assert( __return ); \ 24 return __return; 22 return call_postmutate< type * >( node ); \ 23 24 25 #define VISIT_BODY( node ) \ 26 VISIT_START( node ); \ 27 if( children_guard ) { \ 28 Visitor::visit( node ); \ 29 } \ 30 VISIT_END( node ); \ 31 32 33 #define MUTATE_BODY( type, node ) \ 34 MUTATE_START( node ); \ 35 if( children_guard ) { \ 36 Mutator::mutate( node ); \ 37 } \ 38 MUTATE_END( type, node ); \ 39 25 40 26 41 … … 52 67 SemanticErrorException errors; 53 68 54 pass_visitor_stats.depth++;55 pass_visitor_stats.max->push(pass_visitor_stats.depth);56 pass_visitor_stats.avg->push(pass_visitor_stats.depth);57 69 for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) { 58 59 60 70 // splice in new declarations after previous decl 61 71 if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); } … … 73 83 if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); } 74 84 } 75 pass_visitor_stats.depth--;76 if ( ! errors.isEmpty() ) {77 throw errors;78 }79 }80 81 template< 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 declaration91 maybeAccept_impl( decl, visitor );92 }93 catch( SemanticErrorException &e ) {94 errors.append( e );95 }96 }97 pass_visitor_stats.depth--;98 85 if ( ! errors.isEmpty() ) { 99 86 throw errors; … … 107 94 SemanticErrorException errors; 108 95 109 pass_visitor_stats.depth++;110 pass_visitor_stats.max->push(pass_visitor_stats.depth);111 pass_visitor_stats.avg->push(pass_visitor_stats.depth);112 96 for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) { 113 97 // splice in new declarations after previous decl … … 125 109 if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); } 126 110 } 127 pass_visitor_stats.depth--;128 111 if ( ! errors.isEmpty() ) { 129 112 throw errors; … … 139 122 } 140 123 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 149 124 template< typename Container, typename pass_type > 150 125 inline void maybeAccept_impl( Container & container, PassVisitor< pass_type > & visitor ) { 151 126 if ( ! visitor.get_visit_children() ) return; 152 127 SemanticErrorException errors; 153 154 pass_visitor_stats.depth++;155 pass_visitor_stats.max->push(pass_visitor_stats.depth);156 pass_visitor_stats.avg->push(pass_visitor_stats.depth);157 128 for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) { 158 129 try { … … 164 135 } 165 136 } 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 );184 }185 } catch( SemanticErrorException &e ) {186 errors.append( e );187 }188 }189 pass_visitor_stats.depth--;190 137 if ( ! errors.isEmpty() ) { 191 138 throw errors; … … 204 151 template< typename Container, typename pass_type > 205 152 inline void maybeMutate_impl( Container & container, PassVisitor< pass_type > & mutator ) { 206 207 153 if ( ! mutator.get_visit_children() ) return; 208 154 SemanticErrorException errors; 209 210 pass_visitor_stats.depth++;211 pass_visitor_stats.max->push(pass_visitor_stats.depth);212 pass_visitor_stats.avg->push(pass_visitor_stats.depth);213 155 for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) { 214 156 try { … … 221 163 } // try 222 164 } // for 223 pass_visitor_stats.depth--;224 165 if ( ! errors.isEmpty() ) { 225 166 throw errors; … … 244 185 DeclList_t* afterDecls = get_afterDecls(); 245 186 246 pass_visitor_stats.depth++;247 pass_visitor_stats.max->push(pass_visitor_stats.depth);248 pass_visitor_stats.avg->push(pass_visitor_stats.depth);249 187 for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) { 250 188 … … 254 192 try { 255 193 func( *i ); 256 assert( *i );257 194 assert(( empty( beforeStmts ) && empty( afterStmts )) 258 195 || ( empty( beforeDecls ) && empty( afterDecls )) ); … … 265 202 if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); } 266 203 } 267 pass_visitor_stats.depth--;268 204 269 205 if ( !empty( afterDecls ) ) { splice( std::back_inserter( statements ), afterDecls); } … … 280 216 281 217 template< 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 >301 218 void PassVisitor< pass_type >::mutateStatementList( std::list< Statement * > & statements ) { 302 219 handleStatementList( statements, [this]( Statement *& stmt) { … … 312 229 313 230 // don't want statements from outer CompoundStmts to be added to this CompoundStmt 314 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() );231 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr () ); 315 232 ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() ); 316 233 ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () ); … … 347 264 348 265 template< 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 CompoundStmt353 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 >359 266 Statement * PassVisitor< pass_type >::mutateStatement( Statement * stmt ) { 360 267 return handleStatement( stmt, [this]( Statement * stmt ) { … … 388 295 389 296 template< 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 >403 297 Expression * PassVisitor< pass_type >::mutateExpression( Expression * expr ) { 404 298 return handleExpression(expr, [this]( Expression * expr ) { … … 410 304 template< typename TreeType, typename VisitorType > 411 305 inline 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 ) {422 306 if ( ! visitor.get_visit_children() ) return; 423 307 auto guard = makeFuncGuard( … … 482 366 483 367 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 );491 492 VISIT_END( node );493 }494 495 template< typename pass_type >496 368 DeclarationWithType * PassVisitor< pass_type >::mutate( ObjectDecl * node ) { 497 369 MUTATE_START( node ); … … 532 404 indexerAddId( &func ); 533 405 maybeAccept_impl( node->type, *this ); 534 // function body needs to have the same scope as parameters - CompoundStmt will not enter535 // a new scope if inFunction is true536 ValueGuard< bool > oldInFunction( inFunction );537 inFunction = true;538 maybeAccept_impl( node->statements, *this );539 maybeAccept_impl( node->attributes, *this );540 }541 }542 543 VISIT_END( node );544 }545 546 template< 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 parameters556 // 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.2562 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 nullptr566 );567 indexerAddId( &func );568 maybeAccept_impl( node->type, *this );569 // function body needs to have the same scope as parameters - CompoundStmt will not enter570 // a new scope if inFunction is true571 ValueGuard< bool > oldInFunction( inFunction );572 inFunction = true;573 406 maybeAccept_impl( node->statements, *this ); 574 407 maybeAccept_impl( node->attributes, *this ); … … 601 434 indexerAddId( &func ); 602 435 maybeMutate_impl( node->type, *this ); 603 // function body needs to have the same scope as parameters - CompoundStmt will not enter604 // a new scope if inFunction is true605 ValueGuard< bool > oldInFunction( inFunction );606 inFunction = true;607 436 maybeMutate_impl( node->statements, *this ); 608 437 maybeMutate_impl( node->attributes, *this ); … … 636 465 637 466 template< typename pass_type > 638 void PassVisitor< pass_type >::visit( constStructDecl * node ) {639 VISIT_START( node );467 Declaration * PassVisitor< pass_type >::mutate( StructDecl * node ) { 468 MUTATE_START( node ); 640 469 641 470 // make up a forward declaration and add it before processing the members … … 645 474 { 646 475 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 476 maybeMutate_impl( node->parameters, *this ); 477 maybeMutate_impl( node->members , *this ); 478 } 479 480 // this addition replaces the forward declaration 481 indexerAddStruct( node ); 482 483 MUTATE_END( Declaration, node ); 484 } 485 486 //-------------------------------------------------------------------------- 487 // UnionDecl 488 template< typename pass_type > 489 void PassVisitor< pass_type >::visit( UnionDecl * node ) { 490 VISIT_START( node ); 491 492 // make up a forward declaration and add it before processing the members 493 indexerAddUnionFwd( node ); 494 495 { 496 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 647 497 maybeAccept_impl( node->parameters, *this ); 648 498 maybeAccept_impl( node->members , *this ); 649 499 } 650 500 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 ) { 501 indexerAddUnion( node ); 502 503 VISIT_END( node ); 504 } 505 506 template< typename pass_type > 507 Declaration * PassVisitor< pass_type >::mutate( UnionDecl * node ) { 659 508 MUTATE_START( node ); 660 509 661 510 // 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 ); 511 indexerAddUnionFwd( node ); 664 512 665 513 { … … 669 517 } 670 518 671 // this addition replaces the forward declaration672 indexerAddStruct( node );673 674 MUTATE_END( Declaration, node );675 }676 677 //--------------------------------------------------------------------------678 // UnionDecl679 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 members684 indexerAddUnionFwd( node );685 686 {687 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );688 maybeAccept_impl( node->parameters, *this );689 maybeAccept_impl( node->members , *this );690 }691 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 members701 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 members719 indexerAddUnionFwd( node );720 721 {722 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );723 maybeMutate_impl( node->parameters, *this );724 maybeMutate_impl( node->members , *this );725 }726 727 519 indexerAddUnion( node ); 728 520 … … 746 538 747 539 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 scope754 maybeAccept_impl( node->parameters, *this );755 maybeAccept_impl( node->members , *this );756 757 VISIT_END( node );758 }759 760 template< typename pass_type >761 540 Declaration * PassVisitor< pass_type >::mutate( EnumDecl * node ) { 762 541 MUTATE_START( node ); … … 775 554 template< typename pass_type > 776 555 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 556 VISIT_START( node ); 793 557 … … 842 606 } 843 607 844 845 template< typename pass_type > 846 void PassVisitor< pass_type >::visit( const TypeDecl * node ) { 847 VISIT_START( node ); 608 template< typename pass_type > 609 Declaration * PassVisitor< pass_type >::mutate( TypeDecl * node ) { 610 MUTATE_START( node ); 848 611 849 612 { 850 613 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 851 maybe Accept_impl( node->parameters, *this );852 maybe Accept_impl( node->base , *this );614 maybeMutate_impl( node->parameters, *this ); 615 maybeMutate_impl( node->base , *this ); 853 616 } 854 617 … … 858 621 indexerAddType( node ); 859 622 623 maybeMutate_impl( node->assertions, *this ); 624 625 indexerScopedMutate( node->init, *this ); 626 627 MUTATE_END( Declaration, node ); 628 } 629 630 //-------------------------------------------------------------------------- 631 // TypedefDecl 632 template< typename pass_type > 633 void PassVisitor< pass_type >::visit( TypedefDecl * node ) { 634 VISIT_START( node ); 635 636 { 637 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 638 maybeAccept_impl( node->parameters, *this ); 639 maybeAccept_impl( node->base , *this ); 640 } 641 642 indexerAddType( node ); 643 860 644 maybeAccept_impl( node->assertions, *this ); 861 645 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 ) { 646 VISIT_END( node ); 647 } 648 649 template< typename pass_type > 650 Declaration * PassVisitor< pass_type >::mutate( TypedefDecl * node ) { 869 651 MUTATE_START( node ); 870 652 … … 875 657 } 876 658 877 // see A NOTE ON THE ORDER OF TRAVERSAL, above878 // note that assertions come after the type is added to the symtab, since they are not part of the type proper879 // and may depend on the type itself880 659 indexerAddType( node ); 881 660 882 661 maybeMutate_impl( node->assertions, *this ); 883 662 884 indexerScopedMutate( node->init, *this );885 886 663 MUTATE_END( Declaration, node ); 887 664 } 888 665 889 666 //-------------------------------------------------------------------------- 890 // TypedefDecl891 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 //--------------------------------------------------------------------------943 667 // AsmDecl 944 668 template< typename pass_type > 945 669 void PassVisitor< pass_type >::visit( AsmDecl * node ) { 946 VISIT_START( node );947 948 maybeAccept_impl( node->stmt, *this );949 950 VISIT_END( node );951 }952 953 template< typename pass_type >954 void PassVisitor< pass_type >::visit( const AsmDecl * node ) {955 670 VISIT_START( node ); 956 671 … … 982 697 983 698 template< typename pass_type > 984 void PassVisitor< pass_type >::visit( const StaticAssertDecl * node ) {985 VISIT_START( node );986 987 visitExpression( node->condition );988 maybeAccept_impl( node->message, *this );989 990 VISIT_END( node );991 }992 993 template< typename pass_type >994 699 StaticAssertDecl * PassVisitor< pass_type >::mutate( StaticAssertDecl * node ) { 995 700 MUTATE_START( node ); … … 1007 712 VISIT_START( node ); 1008 713 { 1009 // do not enter a new scope if inFunction is true - needs to check old state before the assignment 1010 ValueGuard< bool > oldInFunction( inFunction ); 1011 auto guard1 = makeFuncGuard( [this, &oldInFunction]() { if ( ! oldInFunction.old ) indexerScopeEnter(); }, [this, &oldInFunction]() { if ( ! oldInFunction.old ) indexerScopeLeave(); } ); 714 auto guard1 = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 1012 715 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } ); 1013 inFunction = false;1014 716 visitStatementList( node->kids ); 1015 717 } … … 1018 720 1019 721 template< 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(); } ); 722 CompoundStmt * PassVisitor< pass_type >::mutate( CompoundStmt * node ) { 723 MUTATE_START( node ); 724 { 725 auto guard1 = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 1026 726 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 >1034 CompoundStmt * PassVisitor< pass_type >::mutate( CompoundStmt * node ) {1035 MUTATE_START( node );1036 {1037 // do not enter a new scope if inFunction is true - needs to check old state before the assignment1038 ValueGuard< bool > oldInFunction( inFunction );1039 auto guard1 = makeFuncGuard( [this, &oldInFunction]() { if ( ! oldInFunction.old ) indexerScopeEnter(); }, [this, &oldInFunction]() { if ( ! oldInFunction.old ) indexerScopeLeave(); } );1040 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } );1041 inFunction = false;1042 727 mutateStatementList( node->kids ); 1043 728 } … … 1049 734 template< typename pass_type > 1050 735 void PassVisitor< pass_type >::visit( ExprStmt * node ) { 1051 VISIT_START( node );1052 1053 visitExpression( node->expr );1054 1055 VISIT_END( node );1056 }1057 1058 template< typename pass_type >1059 void PassVisitor< pass_type >::visit( const ExprStmt * node ) {1060 736 VISIT_START( node ); 1061 737 … … 1089 765 1090 766 template< 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 >1103 767 Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) { 1104 768 MUTATE_START( node ); … … 1122 786 1123 787 template< 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 >1131 788 Statement * PassVisitor< pass_type >::mutate( DirectiveStmt * node ) { 1132 789 MUTATE_START( node ); … … 1143 800 // if statements introduce a level of scope (for the initialization) 1144 801 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 1145 maybeAccept_impl( node-> initialization, *this );802 maybeAccept_impl( node->get_initialization(), *this ); 1146 803 visitExpression ( node->condition ); 1147 804 node->thenPart = visitStatement( node->thenPart ); … … 1152 809 1153 810 template< typename pass_type > 1154 void PassVisitor< pass_type >::visit( constIfStmt * node ) {1155 VISIT_START( node );811 Statement * PassVisitor< pass_type >::mutate( IfStmt * node ) { 812 MUTATE_START( node ); 1156 813 { 1157 814 // if statements introduce a level of scope (for the initialization) 1158 815 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 ); 816 maybeMutate_impl( node->get_initialization(), *this ); 1174 817 node->condition = mutateExpression( node->condition ); 1175 818 node->thenPart = mutateStatement ( node->thenPart ); … … 1191 834 visitExpression ( node->condition ); 1192 835 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 );1208 836 } 1209 837 … … 1244 872 1245 873 template< 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 >1260 874 Statement * PassVisitor< pass_type >::mutate( ForStmt * node ) { 1261 875 MUTATE_START( node ); … … 1284 898 1285 899 template< 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 >1296 900 Statement * PassVisitor< pass_type >::mutate( SwitchStmt * node ) { 1297 901 MUTATE_START( node ); … … 1316 920 1317 921 template< 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 >1328 922 Statement * PassVisitor< pass_type >::mutate( CaseStmt * node ) { 1329 923 MUTATE_START( node ); … … 1344 938 1345 939 template< 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 >1352 940 Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) { 1353 941 MUTATE_START( node ); … … 1367 955 1368 956 template< 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 >1378 957 Statement * PassVisitor< pass_type >::mutate( ReturnStmt * node ) { 1379 958 MUTATE_START( node ); … … 1386 965 //-------------------------------------------------------------------------- 1387 966 // ThrowStmt 967 1388 968 template< typename pass_type > 1389 969 void PassVisitor< pass_type >::visit( ThrowStmt * node ) { … … 1397 977 1398 978 template< 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 >1409 979 Statement * PassVisitor< pass_type >::mutate( ThrowStmt * node ) { 1410 980 MUTATE_START( node ); … … 1420 990 template< typename pass_type > 1421 991 void 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 ) {1433 992 VISIT_START( node ); 1434 993 … … 1467 1026 1468 1027 template< 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 >1482 1028 Statement * PassVisitor< pass_type >::mutate( CatchStmt * node ) { 1483 1029 MUTATE_START( node ); … … 1504 1050 1505 1051 template< 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 >1515 1052 Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) { 1516 1053 MUTATE_START( node ); … … 1545 1082 1546 1083 template< 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 >1568 1084 Statement * PassVisitor< pass_type >::mutate( WaitForStmt * node ) { 1569 1085 MUTATE_START( node ); … … 1589 1105 1590 1106 //-------------------------------------------------------------------------- 1591 // WithStmt1107 // NullStmt 1592 1108 template< typename pass_type > 1593 1109 void PassVisitor< pass_type >::visit( WithStmt * node ) { … … 1604 1120 1605 1121 template< 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 ) { 1122 Statement * PassVisitor< pass_type >::mutate( WithStmt * node ) { 1620 1123 MUTATE_START( node ); 1621 1124 maybeMutate_impl( node->exprs, *this ); … … 1626 1129 maybeMutate_impl( node->stmt, *this ); 1627 1130 } 1628 MUTATE_END( Declaration, node );1131 MUTATE_END( Statement, node ); 1629 1132 } 1630 1133 … … 1638 1141 1639 1142 template< 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 >1646 1143 NullStmt * PassVisitor< pass_type >::mutate( NullStmt * node ) { 1647 1144 MUTATE_START( node ); … … 1661 1158 1662 1159 template< 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 >1672 1160 Statement * PassVisitor< pass_type >::mutate( DeclStmt * node ) { 1673 1161 MUTATE_START( node ); … … 1690 1178 1691 1179 template< 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 >1701 1180 Statement * PassVisitor< pass_type >::mutate( ImplicitCtorDtorStmt * node ) { 1702 1181 MUTATE_START( node ); … … 1714 1193 1715 1194 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 ); 1195 maybeAccept_impl ( node->function, *this ); 1196 maybeAccept_impl ( node->args , *this ); 1729 1197 1730 1198 VISIT_END( node ); … … 1760 1228 1761 1229 template< 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 >1775 1230 Expression * PassVisitor< pass_type >::mutate( UntypedExpr * node ) { 1776 1231 MUTATE_START( node ); … … 1798 1253 1799 1254 template< typename pass_type > 1800 void PassVisitor< pass_type >::visit( const NameExpr * node ) { 1255 Expression * PassVisitor< pass_type >::mutate( NameExpr * node ) { 1256 MUTATE_START( node ); 1257 1258 indexerScopedMutate( node->env , *this ); 1259 indexerScopedMutate( node->result, *this ); 1260 1261 MUTATE_END( Expression, node ); 1262 } 1263 1264 //-------------------------------------------------------------------------- 1265 // CastExpr 1266 template< typename pass_type > 1267 void PassVisitor< pass_type >::visit( CastExpr * node ) { 1801 1268 VISIT_START( node ); 1802 1269 1803 1270 indexerScopedAccept( node->result, *this ); 1804 1805 VISIT_END( node ); 1806 } 1807 1808 template< typename pass_type > 1809 Expression * PassVisitor< pass_type >::mutate( NameExpr * node ) { 1271 maybeAccept_impl ( node->arg , *this ); 1272 1273 VISIT_END( node ); 1274 } 1275 1276 template< typename pass_type > 1277 Expression * PassVisitor< pass_type >::mutate( CastExpr * node ) { 1810 1278 MUTATE_START( node ); 1811 1279 1812 1280 indexerScopedMutate( node->env , *this ); 1813 1281 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 ) { 1282 maybeMutate_impl ( node->arg , *this ); 1283 1284 MUTATE_END( Expression, node ); 1285 } 1286 1287 //-------------------------------------------------------------------------- 1288 // KeywordCastExpr 1289 template< typename pass_type > 1290 void PassVisitor< pass_type >::visit( KeywordCastExpr * node ) { 1291 VISIT_START( node ); 1292 1293 indexerScopedAccept( node->result, *this ); 1294 maybeAccept_impl ( node->arg , *this ); 1295 1296 VISIT_END( node ); 1297 } 1298 1299 template< typename pass_type > 1300 Expression * PassVisitor< pass_type >::mutate( KeywordCastExpr * node ) { 1301 MUTATE_START( node ); 1302 1303 indexerScopedMutate( node->env , *this ); 1304 indexerScopedMutate( node->result, *this ); 1305 maybeMutate_impl ( node->arg , *this ); 1306 1307 MUTATE_END( Expression, node ); 1308 } 1309 1310 //-------------------------------------------------------------------------- 1311 // VirtualCastExpr 1312 template< typename pass_type > 1313 void PassVisitor< pass_type >::visit( VirtualCastExpr * node ) { 1314 VISIT_START( node ); 1315 1316 indexerScopedAccept( node->result, *this ); 1317 maybeAccept_impl( node->arg, *this ); 1318 1319 VISIT_END( node ); 1320 } 1321 1322 template< typename pass_type > 1323 Expression * PassVisitor< pass_type >::mutate( VirtualCastExpr * node ) { 1324 MUTATE_START( node ); 1325 1326 indexerScopedMutate( node->env , *this ); 1327 indexerScopedMutate( node->result, *this ); 1328 maybeMutate_impl ( node->arg , *this ); 1329 1330 MUTATE_END( Expression, node ); 1331 } 1332 1333 //-------------------------------------------------------------------------- 1334 // AddressExpr 1335 template< typename pass_type > 1336 void PassVisitor< pass_type >::visit( AddressExpr * node ) { 1822 1337 VISIT_START( node ); 1823 1338 … … 1829 1344 1830 1345 template< typename pass_type > 1831 void PassVisitor< pass_type >::visit( const CastExpr * node ) { 1346 Expression * PassVisitor< pass_type >::mutate( AddressExpr * node ) { 1347 MUTATE_START( node ); 1348 1349 indexerScopedMutate( node->env , *this ); 1350 indexerScopedMutate( node->result, *this ); 1351 maybeMutate_impl ( node->arg , *this ); 1352 1353 MUTATE_END( Expression, node ); 1354 } 1355 1356 //-------------------------------------------------------------------------- 1357 // LabelAddressExpr 1358 template< typename pass_type > 1359 void PassVisitor< pass_type >::visit( LabelAddressExpr * node ) { 1832 1360 VISIT_START( node ); 1833 1361 1834 1362 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 ) { 1363 1364 VISIT_END( node ); 1365 } 1366 1367 template< typename pass_type > 1368 Expression * PassVisitor< pass_type >::mutate( LabelAddressExpr * node ) { 1842 1369 MUTATE_START( node ); 1843 1370 1844 1371 indexerScopedMutate( node->env , *this ); 1845 1372 indexerScopedMutate( node->result, *this ); 1846 maybeMutate_impl ( node->arg , *this );1847 1848 MUTATE_END( Expression, node );1849 }1850 1851 //--------------------------------------------------------------------------1852 // KeywordCastExpr1853 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 // VirtualCastExpr1886 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 // AddressExpr1919 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 // LabelAddressExpr1952 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 );1976 1373 1977 1374 MUTATE_END( Expression, node ); … … 1982 1379 template< typename pass_type > 1983 1380 void 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 ) {1995 1381 VISIT_START( node ); 1996 1382 … … 2027 1413 2028 1414 template< 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 >2039 1415 Expression * PassVisitor< pass_type >::mutate( MemberExpr * node ) { 2040 1416 MUTATE_START( node ); … … 2059 1435 2060 1436 template< 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 >2070 1437 Expression * PassVisitor< pass_type >::mutate( VariableExpr * node ) { 2071 1438 MUTATE_START( node ); … … 2081 1448 template< typename pass_type > 2082 1449 void 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 ) {2093 1450 VISIT_START( node ); 2094 1451 … … 2129 1486 2130 1487 template< typename pass_type > 2131 void PassVisitor< pass_type >::visit( const SizeofExpr * node ) { 1488 Expression * PassVisitor< pass_type >::mutate( SizeofExpr * node ) { 1489 MUTATE_START( node ); 1490 1491 indexerScopedMutate( node->env , *this ); 1492 indexerScopedMutate( node->result, *this ); 1493 if ( node->get_isType() ) { 1494 maybeMutate_impl( node->type, *this ); 1495 } else { 1496 maybeMutate_impl( node->expr, *this ); 1497 } 1498 1499 MUTATE_END( Expression, node ); 1500 } 1501 1502 //-------------------------------------------------------------------------- 1503 // AlignofExpr 1504 template< typename pass_type > 1505 void PassVisitor< pass_type >::visit( AlignofExpr * node ) { 2132 1506 VISIT_START( node ); 2133 1507 … … 2143 1517 2144 1518 template< typename pass_type > 2145 Expression * PassVisitor< pass_type >::mutate( SizeofExpr * node ) {1519 Expression * PassVisitor< pass_type >::mutate( AlignofExpr * node ) { 2146 1520 MUTATE_START( node ); 2147 1521 … … 2158 1532 2159 1533 //-------------------------------------------------------------------------- 2160 // AlignofExpr 2161 template< typename pass_type > 2162 void PassVisitor< pass_type >::visit( AlignofExpr * node ) { 1534 // UntypedOffsetofExpr 1535 template< typename pass_type > 1536 void PassVisitor< pass_type >::visit( UntypedOffsetofExpr * node ) { 1537 VISIT_START( node ); 1538 1539 indexerScopedAccept( node->result, *this ); 1540 maybeAccept_impl ( node->type , *this ); 1541 1542 VISIT_END( node ); 1543 } 1544 1545 template< typename pass_type > 1546 Expression * PassVisitor< pass_type >::mutate( UntypedOffsetofExpr * node ) { 1547 MUTATE_START( node ); 1548 1549 indexerScopedMutate( node->env , *this ); 1550 indexerScopedMutate( node->result, *this ); 1551 maybeMutate_impl ( node->type , *this ); 1552 1553 MUTATE_END( Expression, node ); 1554 } 1555 1556 //-------------------------------------------------------------------------- 1557 // OffsetofExpr 1558 template< typename pass_type > 1559 void PassVisitor< pass_type >::visit( OffsetofExpr * node ) { 1560 VISIT_START( node ); 1561 1562 indexerScopedAccept( node->result, *this ); 1563 maybeAccept_impl ( node->type , *this ); 1564 1565 VISIT_END( node ); 1566 } 1567 1568 template< typename pass_type > 1569 Expression * PassVisitor< pass_type >::mutate( OffsetofExpr * node ) { 1570 MUTATE_START( node ); 1571 1572 indexerScopedMutate( node->env , *this ); 1573 indexerScopedMutate( node->result, *this ); 1574 maybeMutate_impl ( node->type , *this ); 1575 1576 MUTATE_END( Expression, node ); 1577 } 1578 1579 //-------------------------------------------------------------------------- 1580 // OffsetPackExpr 1581 template< typename pass_type > 1582 void PassVisitor< pass_type >::visit( OffsetPackExpr * node ) { 1583 VISIT_START( node ); 1584 1585 indexerScopedAccept( node->result, *this ); 1586 maybeAccept_impl ( node->type , *this ); 1587 1588 VISIT_END( node ); 1589 } 1590 1591 template< typename pass_type > 1592 Expression * PassVisitor< pass_type >::mutate( OffsetPackExpr * node ) { 1593 MUTATE_START( node ); 1594 1595 indexerScopedMutate( node->env , *this ); 1596 indexerScopedMutate( node->result, *this ); 1597 maybeMutate_impl ( node->type , *this ); 1598 1599 MUTATE_END( Expression, node ); 1600 } 1601 1602 //-------------------------------------------------------------------------- 1603 // AttrExpr 1604 template< typename pass_type > 1605 void PassVisitor< pass_type >::visit( AttrExpr * node ) { 2163 1606 VISIT_START( node ); 2164 1607 … … 2174 1617 2175 1618 template< 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 ) { 1619 Expression * PassVisitor< pass_type >::mutate( AttrExpr * node ) { 2191 1620 MUTATE_START( node ); 2192 1621 … … 2203 1632 2204 1633 //-------------------------------------------------------------------------- 2205 // UntypedOffsetofExpr2206 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 // OffsetofExpr2239 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 // OffsetPackExpr2272 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 1634 // LogicalExpr 2305 1635 template< typename pass_type > 2306 1636 void PassVisitor< pass_type >::visit( LogicalExpr * node ) { 2307 VISIT_START( node );2308 2309 indexerScopedAccept( node->result, *this );2310 maybeAccept_impl ( node->arg1 , *this );2311 maybeAccept_impl ( node->arg2 , *this );2312 2313 VISIT_END( node );2314 }2315 2316 template< typename pass_type >2317 void PassVisitor< pass_type >::visit( const LogicalExpr * node ) {2318 1637 VISIT_START( node ); 2319 1638 … … 2352 1671 2353 1672 template< typename pass_type > 2354 void PassVisitor< pass_type >::visit( const ConditionalExpr * node ) { 1673 Expression * PassVisitor< pass_type >::mutate( ConditionalExpr * node ) { 1674 MUTATE_START( node ); 1675 1676 indexerScopedMutate( node->env , *this ); 1677 indexerScopedMutate( node->result, *this ); 1678 maybeMutate_impl ( node->arg1 , *this ); 1679 maybeMutate_impl ( node->arg2 , *this ); 1680 maybeMutate_impl ( node->arg3 , *this ); 1681 1682 MUTATE_END( Expression, node ); 1683 } 1684 1685 //-------------------------------------------------------------------------- 1686 // CommaExpr 1687 template< typename pass_type > 1688 void PassVisitor< pass_type >::visit( CommaExpr * node ) { 2355 1689 VISIT_START( node ); 2356 1690 … … 2358 1692 maybeAccept_impl ( node->arg1 , *this ); 2359 1693 maybeAccept_impl ( node->arg2 , *this ); 2360 maybeAccept_impl ( node->arg3 , *this ); 2361 2362 VISIT_END( node ); 2363 } 2364 2365 template< typename pass_type > 2366 Expression * PassVisitor< pass_type >::mutate( ConditionalExpr * node ) { 1694 1695 VISIT_END( node ); 1696 } 1697 1698 template< typename pass_type > 1699 Expression * PassVisitor< pass_type >::mutate( CommaExpr * node ) { 2367 1700 MUTATE_START( node ); 2368 1701 … … 2371 1704 maybeMutate_impl ( node->arg1 , *this ); 2372 1705 maybeMutate_impl ( node->arg2 , *this ); 2373 maybeMutate_impl ( node->arg3 , *this );2374 2375 MUTATE_END( Expression, node );2376 }2377 2378 //--------------------------------------------------------------------------2379 // CommaExpr2380 template< typename pass_type >2381 void PassVisitor< pass_type >::visit( CommaExpr * node ) {2382 VISIT_START( node );2383 2384 indexerScopedAccept( node->result, *this );2385 maybeAccept_impl ( node->arg1 , *this );2386 maybeAccept_impl ( node->arg2 , *this );2387 2388 VISIT_END( node );2389 }2390 2391 template< typename pass_type >2392 void PassVisitor< pass_type >::visit( const CommaExpr * node ) {2393 VISIT_START( node );2394 2395 indexerScopedAccept( node->result, *this );2396 maybeAccept_impl ( node->arg1 , *this );2397 maybeAccept_impl ( node->arg2 , *this );2398 2399 VISIT_END( node );2400 }2401 2402 template< typename pass_type >2403 Expression * PassVisitor< pass_type >::mutate( CommaExpr * node ) {2404 MUTATE_START( node );2405 2406 indexerScopedMutate( node->env , *this );2407 indexerScopedMutate( node->result, *this );2408 maybeMutate_impl ( node->arg1 , *this );2409 maybeMutate_impl ( node->arg2 , *this );2410 1706 2411 1707 MUTATE_END( Expression, node ); … … 2425 1721 2426 1722 template< typename pass_type > 2427 void PassVisitor< pass_type >::visit( const TypeExpr * node ) {2428 VISIT_START( node );2429 2430 indexerScopedAccept( node->result, *this );2431 maybeAccept_impl ( node->type, *this );2432 2433 VISIT_END( node );2434 }2435 2436 template< typename pass_type >2437 1723 Expression * PassVisitor< pass_type >::mutate( TypeExpr * node ) { 2438 1724 MUTATE_START( node ); … … 2449 1735 template< typename pass_type > 2450 1736 void PassVisitor< pass_type >::visit( AsmExpr * node ) { 2451 VISIT_START( node );2452 2453 indexerScopedAccept( node->result , *this );2454 maybeAccept_impl ( node->inout , *this );2455 maybeAccept_impl ( node->constraint, *this );2456 maybeAccept_impl ( node->operand , *this );2457 2458 VISIT_END( node );2459 }2460 2461 template< typename pass_type >2462 void PassVisitor< pass_type >::visit( const AsmExpr * node ) {2463 1737 VISIT_START( node ); 2464 1738 … … 2490 1764 VISIT_START( node ); 2491 1765 2492 indexerScopedAccept( node->result , *this ); 2493 maybeAccept_impl ( node->callExpr , *this ); 2494 2495 VISIT_END( node ); 2496 } 2497 2498 template< typename pass_type > 2499 void PassVisitor< pass_type >::visit( const ImplicitCopyCtorExpr * node ) { 2500 VISIT_START( node ); 2501 2502 indexerScopedAccept( node->result , *this ); 2503 maybeAccept_impl ( node->callExpr , *this ); 1766 indexerScopedAccept( node->result , *this ); 1767 maybeAccept_impl ( node->callExpr , *this ); 1768 maybeAccept_impl ( node->tempDecls , *this ); 1769 maybeAccept_impl ( node->returnDecls, *this ); 1770 maybeAccept_impl ( node->dtors , *this ); 2504 1771 2505 1772 VISIT_END( node ); … … 2510 1777 MUTATE_START( node ); 2511 1778 2512 indexerScopedMutate( node->env , *this ); 2513 indexerScopedMutate( node->result , *this ); 2514 maybeMutate_impl ( node->callExpr , *this ); 1779 indexerScopedMutate( node->env , *this ); 1780 indexerScopedMutate( node->result , *this ); 1781 maybeMutate_impl ( node->callExpr , *this ); 1782 maybeMutate_impl ( node->tempDecls , *this ); 1783 maybeMutate_impl ( node->returnDecls, *this ); 1784 maybeMutate_impl ( node->dtors , *this ); 2515 1785 2516 1786 MUTATE_END( Expression, node ); … … 2521 1791 template< typename pass_type > 2522 1792 void PassVisitor< pass_type >::visit( ConstructorExpr * node ) { 2523 VISIT_START( node );2524 2525 indexerScopedAccept( node->result , *this );2526 maybeAccept_impl ( node->callExpr, *this );2527 2528 VISIT_END( node );2529 }2530 2531 template< typename pass_type >2532 void PassVisitor< pass_type >::visit( const ConstructorExpr * node ) {2533 1793 VISIT_START( node ); 2534 1794 … … 2563 1823 2564 1824 template< typename pass_type > 2565 void PassVisitor< pass_type >::visit( const CompoundLiteralExpr * node ) {2566 VISIT_START( node );2567 2568 indexerScopedAccept( node->result , *this );2569 maybeAccept_impl ( node->initializer, *this );2570 2571 VISIT_END( node );2572 }2573 2574 template< typename pass_type >2575 1825 Expression * PassVisitor< pass_type >::mutate( CompoundLiteralExpr * node ) { 2576 1826 MUTATE_START( node ); … … 2597 1847 2598 1848 template< typename pass_type > 2599 void PassVisitor< pass_type >::visit( const RangeExpr * node ) {2600 VISIT_START( node );2601 2602 indexerScopedAccept( node->result, *this );2603 maybeAccept_impl ( node->low , *this );2604 maybeAccept_impl ( node->high , *this );2605 2606 VISIT_END( node );2607 }2608 2609 template< typename pass_type >2610 1849 Expression * PassVisitor< pass_type >::mutate( RangeExpr * node ) { 2611 1850 MUTATE_START( node ); … … 2632 1871 2633 1872 template< typename pass_type > 2634 void PassVisitor< pass_type >::visit( const UntypedTupleExpr * node ) { 1873 Expression * PassVisitor< pass_type >::mutate( UntypedTupleExpr * node ) { 1874 MUTATE_START( node ); 1875 1876 indexerScopedMutate( node->env , *this ); 1877 indexerScopedMutate( node->result, *this ); 1878 maybeMutate_impl ( node->exprs , *this ); 1879 1880 MUTATE_END( Expression, node ); 1881 } 1882 1883 //-------------------------------------------------------------------------- 1884 // TupleExpr 1885 template< typename pass_type > 1886 void PassVisitor< pass_type >::visit( TupleExpr * node ) { 2635 1887 VISIT_START( node ); 2636 1888 … … 2642 1894 2643 1895 template< typename pass_type > 2644 Expression * PassVisitor< pass_type >::mutate( UntypedTupleExpr * node ) {2645 MUTATE_START( node );2646 2647 indexerScopedMutate( node->env , *this );2648 indexerScopedMutate( node->result, *this );2649 maybeMutate_impl ( node->exprs , *this );2650 2651 MUTATE_END( Expression, node );2652 }2653 2654 //--------------------------------------------------------------------------2655 // TupleExpr2656 template< typename pass_type >2657 void PassVisitor< pass_type >::visit( TupleExpr * node ) {2658 VISIT_START( node );2659 2660 indexerScopedAccept( node->result, *this );2661 maybeAccept_impl ( node->exprs , *this );2662 2663 VISIT_END( node );2664 }2665 2666 template< typename pass_type >2667 void PassVisitor< pass_type >::visit( const TupleExpr * node ) {2668 VISIT_START( node );2669 2670 indexerScopedAccept( node->result, *this );2671 maybeAccept_impl ( node->exprs , *this );2672 2673 VISIT_END( node );2674 }2675 2676 template< typename pass_type >2677 1896 Expression * PassVisitor< pass_type >::mutate( TupleExpr * node ) { 2678 1897 MUTATE_START( node ); … … 2698 1917 2699 1918 template< typename pass_type > 2700 void PassVisitor< pass_type >::visit( const TupleIndexExpr * node ) {2701 VISIT_START( node );2702 2703 indexerScopedAccept( node->result, *this );2704 maybeAccept_impl ( node->tuple , *this );2705 2706 VISIT_END( node );2707 }2708 2709 template< typename pass_type >2710 1919 Expression * PassVisitor< pass_type >::mutate( TupleIndexExpr * node ) { 2711 1920 MUTATE_START( node ); … … 2726 1935 indexerScopedAccept( node->result , *this ); 2727 1936 maybeAccept_impl ( node->stmtExpr, *this ); 2728 2729 VISIT_END( node );2730 }2731 2732 template< typename pass_type >2733 void PassVisitor< pass_type >::visit( const TupleAssignExpr * node ) {2734 VISIT_START( node );2735 2736 indexerScopedAccept( node->result , *this );2737 maybeAccept_impl( node->stmtExpr, *this );2738 1937 2739 1938 VISIT_END( node ); … … 2758 1957 2759 1958 // don't want statements from outer CompoundStmts to be added to this StmtExpr 2760 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() );1959 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() ); 2761 1960 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() ); 2762 1961 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); … … 2771 1970 2772 1971 template< typename pass_type > 2773 void PassVisitor< pass_type >::visit( constStmtExpr * node ) {2774 VISIT_START( node );1972 Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) { 1973 MUTATE_START( node ); 2775 1974 2776 1975 // don't want statements from outer CompoundStmts to be added to this StmtExpr 2777 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() ); 2778 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() ); 2779 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); 2780 2781 indexerScopedAccept( node->result , *this ); 2782 maybeAccept_impl ( node->statements , *this ); 2783 maybeAccept_impl ( node->returnDecls, *this ); 2784 maybeAccept_impl ( node->dtors , *this ); 2785 2786 VISIT_END( node ); 2787 } 2788 2789 template< typename pass_type > 2790 Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) { 2791 MUTATE_START( node ); 2792 2793 // don't want statements from outer CompoundStmts to be added to this StmtExpr 2794 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() ); 1976 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() ); 2795 1977 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() ); 2796 1978 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); … … 2817 1999 2818 2000 template< typename pass_type > 2819 void PassVisitor< pass_type >::visit( const UniqueExpr * node ) {2820 VISIT_START( node );2821 2822 indexerScopedAccept( node->result, *this );2823 maybeAccept_impl ( node->expr , *this );2824 2825 VISIT_END( node );2826 }2827 2828 template< typename pass_type >2829 2001 Expression * PassVisitor< pass_type >::mutate( UniqueExpr * node ) { 2830 2002 MUTATE_START( node ); … … 2851 2023 2852 2024 template< typename pass_type > 2853 void PassVisitor< pass_type >::visit( const UntypedInitExpr * node ) {2854 VISIT_START( node );2855 2856 indexerScopedAccept( node->result, *this );2857 maybeAccept_impl ( node->expr , *this );2858 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver.2859 2860 VISIT_END( node );2861 }2862 2863 template< typename pass_type >2864 2025 Expression * PassVisitor< pass_type >::mutate( UntypedInitExpr * node ) { 2865 2026 MUTATE_START( node ); … … 2887 2048 2888 2049 template< typename pass_type > 2889 void PassVisitor< pass_type >::visit( const InitExpr * node ) {2890 VISIT_START( node );2891 2892 indexerScopedAccept( node->result, *this );2893 maybeAccept_impl ( node->expr , *this );2894 maybeAccept_impl ( node->designation, *this );2895 2896 VISIT_END( node );2897 }2898 2899 template< typename pass_type >2900 2050 Expression * PassVisitor< pass_type >::mutate( InitExpr * node ) { 2901 2051 MUTATE_START( node ); … … 2916 2066 2917 2067 indexerScopedAccept( node->result, *this ); 2918 maybeAccept_impl ( node->expr, *this );2068 maybeAccept_impl( node->expr, *this ); 2919 2069 // don't visit deleteStmt, because it is a pointer to somewhere else in the tree. 2920 2070 … … 2923 2073 2924 2074 template< typename pass_type > 2925 void PassVisitor< pass_type >::visit( const DeletedExpr * node ) {2926 VISIT_START( node );2927 2928 indexerScopedAccept( node->result, *this );2929 maybeAccept_impl ( node->expr, *this );2930 // don't visit deleteStmt, because it is a pointer to somewhere else in the tree.2931 2932 VISIT_END( node );2933 }2934 2935 template< typename pass_type >2936 2075 Expression * PassVisitor< pass_type >::mutate( DeletedExpr * node ) { 2937 MUTATE_START( node );2938 2939 indexerScopedMutate( node->env, *this );2940 indexerScopedMutate( node->result, *this );2941 maybeMutate_impl( node->expr, *this );2942 2943 MUTATE_END( Expression, node );2944 }2945 2946 //--------------------------------------------------------------------------2947 // DefaultArgExpr2948 template< typename pass_type >2949 void PassVisitor< pass_type >::visit( DefaultArgExpr * node ) {2950 VISIT_START( node );2951 2952 indexerScopedAccept( node->result, *this );2953 maybeAccept_impl ( node->expr, *this );2954 2955 VISIT_END( node );2956 }2957 2958 template< typename pass_type >2959 void PassVisitor< pass_type >::visit( const DefaultArgExpr * node ) {2960 VISIT_START( node );2961 2962 indexerScopedAccept( node->result, *this );2963 maybeAccept_impl ( node->expr, *this );2964 2965 VISIT_END( node );2966 }2967 2968 template< typename pass_type >2969 Expression * PassVisitor< pass_type >::mutate( DefaultArgExpr * node ) {2970 2076 MUTATE_START( node ); 2971 2077 … … 2994 2100 2995 2101 template< typename pass_type > 2996 void PassVisitor< pass_type >::visit( const GenericExpr * node ) {2997 VISIT_START( node );2998 2999 indexerScopedAccept( node->result, *this );3000 maybeAccept_impl( node->control, *this );3001 for ( const GenericExpr::Association & assoc : node->associations ) {3002 indexerScopedAccept( assoc.type, *this );3003 maybeAccept_impl( assoc.expr, *this );3004 }3005 3006 VISIT_END( node );3007 }3008 3009 template< typename pass_type >3010 2102 Expression * PassVisitor< pass_type >::mutate( GenericExpr * node ) { 3011 2103 MUTATE_START( node ); … … 3034 2126 3035 2127 template< typename pass_type > 3036 void PassVisitor< pass_type >::visit( const VoidType * node ) {3037 VISIT_START( node );3038 3039 maybeAccept_impl( node->forall, *this );3040 3041 VISIT_END( node );3042 }3043 3044 template< typename pass_type >3045 2128 Type * PassVisitor< pass_type >::mutate( VoidType * node ) { 3046 2129 MUTATE_START( node ); … … 3055 2138 template< typename pass_type > 3056 2139 void PassVisitor< pass_type >::visit( BasicType * node ) { 3057 VISIT_START( node );3058 3059 maybeAccept_impl( node->forall, *this );3060 3061 VISIT_END( node );3062 }3063 3064 template< typename pass_type >3065 void PassVisitor< pass_type >::visit( const BasicType * node ) {3066 2140 VISIT_START( node ); 3067 2141 … … 3094 2168 3095 2169 template< typename pass_type > 3096 void PassVisitor< pass_type >::visit( const PointerType * node ) {3097 VISIT_START( node );3098 3099 maybeAccept_impl( node->forall, *this );3100 // xxx - should PointerType visit/mutate dimension?3101 maybeAccept_impl( node->base, *this );3102 3103 VISIT_END( node );3104 }3105 3106 template< typename pass_type >3107 2170 Type * PassVisitor< pass_type >::mutate( PointerType * node ) { 3108 2171 MUTATE_START( node ); … … 3129 2192 3130 2193 template< typename pass_type > 3131 void PassVisitor< pass_type >::visit( const ArrayType * node ) {3132 VISIT_START( node );3133 3134 maybeAccept_impl( node->forall, *this );3135 maybeAccept_impl( node->dimension, *this );3136 maybeAccept_impl( node->base, *this );3137 3138 VISIT_END( node );3139 }3140 3141 template< typename pass_type >3142 2194 Type * PassVisitor< pass_type >::mutate( ArrayType * node ) { 3143 2195 MUTATE_START( node ); … … 3163 2215 3164 2216 template< typename pass_type > 3165 void PassVisitor< pass_type >::visit( const ReferenceType * node ) {3166 VISIT_START( node );3167 3168 maybeAccept_impl( node->forall, *this );3169 maybeAccept_impl( node->base, *this );3170 3171 VISIT_END( node );3172 }3173 3174 template< typename pass_type >3175 2217 Type * PassVisitor< pass_type >::mutate( ReferenceType * node ) { 3176 2218 MUTATE_START( node ); … … 3178 2220 maybeMutate_impl( node->forall, *this ); 3179 2221 maybeMutate_impl( node->base, *this ); 3180 3181 MUTATE_END( Type, node );3182 }3183 3184 //--------------------------------------------------------------------------3185 // QualifiedType3186 template< typename pass_type >3187 void PassVisitor< pass_type >::visit( QualifiedType * node ) {3188 VISIT_START( node );3189 3190 maybeAccept_impl( node->forall, *this );3191 maybeAccept_impl( node->parent, *this );3192 maybeAccept_impl( node->child, *this );3193 3194 VISIT_END( node );3195 }3196 3197 template< typename pass_type >3198 void PassVisitor< pass_type >::visit( const QualifiedType * node ) {3199 VISIT_START( node );3200 3201 maybeAccept_impl( node->forall, *this );3202 maybeAccept_impl( node->parent, *this );3203 maybeAccept_impl( node->child, *this );3204 3205 VISIT_END( node );3206 }3207 3208 template< typename pass_type >3209 Type * PassVisitor< pass_type >::mutate( QualifiedType * node ) {3210 MUTATE_START( node );3211 3212 maybeMutate_impl( node->forall, *this );3213 maybeMutate_impl( node->parent, *this );3214 maybeMutate_impl( node->child, *this );3215 2222 3216 2223 MUTATE_END( Type, node ); … … 3231 2238 3232 2239 template< typename pass_type > 3233 void PassVisitor< pass_type >::visit( const FunctionType * node ) {3234 VISIT_START( node );3235 3236 maybeAccept_impl( node->forall, *this );3237 maybeAccept_impl( node->returnVals, *this );3238 maybeAccept_impl( node->parameters, *this );3239 3240 VISIT_END( node );3241 }3242 3243 template< typename pass_type >3244 2240 Type * PassVisitor< pass_type >::mutate( FunctionType * node ) { 3245 2241 MUTATE_START( node ); … … 3270 2266 3271 2267 template< typename pass_type > 3272 void PassVisitor< pass_type >::visit( const StructInstType * node ) { 2268 Type * PassVisitor< pass_type >::mutate( StructInstType * node ) { 2269 MUTATE_START( node ); 2270 2271 indexerAddStruct( node->name ); 2272 2273 { 2274 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 2275 maybeMutate_impl( node->forall , *this ); 2276 maybeMutate_impl( node->parameters, *this ); 2277 } 2278 2279 MUTATE_END( Type, node ); 2280 } 2281 2282 //-------------------------------------------------------------------------- 2283 // UnionInstType 2284 template< typename pass_type > 2285 void PassVisitor< pass_type >::visit( UnionInstType * node ) { 3273 2286 VISIT_START( node ); 3274 2287 … … 3285 2298 3286 2299 template< typename pass_type > 3287 Type * PassVisitor< pass_type >::mutate( StructInstType * node ) {2300 Type * PassVisitor< pass_type >::mutate( UnionInstType * node ) { 3288 2301 MUTATE_START( node ); 3289 2302 … … 3300 2313 3301 2314 //-------------------------------------------------------------------------- 3302 // UnionInstType3303 template< typename pass_type >3304 void PassVisitor< pass_type >::visit( UnionInstType * node ) {3305 VISIT_START( node );3306 3307 indexerAddStruct( node->name );3308 3309 {3310 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );3311 maybeAccept_impl( node->forall , *this );3312 maybeAccept_impl( node->parameters, *this );3313 }3314 3315 VISIT_END( node );3316 }3317 3318 template< typename pass_type >3319 void PassVisitor< pass_type >::visit( const UnionInstType * node ) {3320 VISIT_START( node );3321 3322 indexerAddStruct( node->name );3323 3324 {3325 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );3326 maybeAccept_impl( node->forall , *this );3327 maybeAccept_impl( node->parameters, *this );3328 }3329 3330 VISIT_END( node );3331 }3332 3333 template< typename pass_type >3334 Type * PassVisitor< pass_type >::mutate( UnionInstType * node ) {3335 MUTATE_START( node );3336 3337 indexerAddStruct( node->name );3338 3339 {3340 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );3341 maybeMutate_impl( node->forall , *this );3342 maybeMutate_impl( node->parameters, *this );3343 }3344 3345 MUTATE_END( Type, node );3346 }3347 3348 //--------------------------------------------------------------------------3349 2315 // EnumInstType 3350 2316 template< typename pass_type > … … 3359 2325 3360 2326 template< typename pass_type > 3361 void PassVisitor< pass_type >::visit( const EnumInstType * node ) {3362 VISIT_START( node );3363 3364 maybeAccept_impl( node->forall, *this );3365 maybeAccept_impl( node->parameters, *this );3366 3367 VISIT_END( node );3368 }3369 3370 template< typename pass_type >3371 2327 Type * PassVisitor< pass_type >::mutate( EnumInstType * node ) { 3372 2328 MUTATE_START( node ); … … 3391 2347 3392 2348 template< typename pass_type > 3393 void PassVisitor< pass_type >::visit( const TraitInstType * node ) {3394 VISIT_START( node );3395 3396 maybeAccept_impl( node->forall , *this );3397 maybeAccept_impl( node->parameters, *this );3398 3399 VISIT_END( node );3400 }3401 3402 template< typename pass_type >3403 2349 Type * PassVisitor< pass_type >::mutate( TraitInstType * node ) { 3404 2350 MUTATE_START( node ); … … 3414 2360 template< typename pass_type > 3415 2361 void PassVisitor< pass_type >::visit( TypeInstType * node ) { 3416 VISIT_START( node );3417 3418 maybeAccept_impl( node->forall , *this );3419 maybeAccept_impl( node->parameters, *this );3420 3421 VISIT_END( node );3422 }3423 3424 template< typename pass_type >3425 void PassVisitor< pass_type >::visit( const TypeInstType * node ) {3426 2362 VISIT_START( node ); 3427 2363 … … 3456 2392 3457 2393 template< typename pass_type > 3458 void PassVisitor< pass_type >::visit( const TupleType * node ) {3459 VISIT_START( node );3460 3461 maybeAccept_impl( node->forall, *this );3462 maybeAccept_impl( node->types, *this );3463 maybeAccept_impl( node->members, *this );3464 3465 VISIT_END( node );3466 }3467 3468 template< typename pass_type >3469 2394 Type * PassVisitor< pass_type >::mutate( TupleType * node ) { 3470 2395 MUTATE_START( node ); … … 3481 2406 template< typename pass_type > 3482 2407 void PassVisitor< pass_type >::visit( TypeofType * node ) { 3483 VISIT_START( node );3484 3485 assert( node->expr );3486 maybeAccept_impl( node->expr, *this );3487 3488 VISIT_END( node );3489 }3490 3491 template< typename pass_type >3492 void PassVisitor< pass_type >::visit( const TypeofType * node ) {3493 2408 VISIT_START( node ); 3494 2409 … … 3527 2442 3528 2443 template< typename pass_type > 3529 void PassVisitor< pass_type >::visit( const AttrType * node ) {3530 VISIT_START( node );3531 3532 if ( node->isType ) {3533 assert( node->type );3534 maybeAccept_impl( node->type, *this );3535 } else {3536 assert( node->expr );3537 maybeAccept_impl( node->expr, *this );3538 } // if3539 3540 VISIT_END( node );3541 }3542 3543 template< typename pass_type >3544 2444 Type * PassVisitor< pass_type >::mutate( AttrType * node ) { 3545 2445 MUTATE_START( node ); … … 3568 2468 3569 2469 template< typename pass_type > 3570 void PassVisitor< pass_type >::visit( const VarArgsType * node ) { 2470 Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) { 2471 MUTATE_START( node ); 2472 2473 maybeMutate_impl( node->forall, *this ); 2474 2475 MUTATE_END( Type, node ); 2476 } 2477 2478 //-------------------------------------------------------------------------- 2479 // ZeroType 2480 template< typename pass_type > 2481 void PassVisitor< pass_type >::visit( ZeroType * node ) { 3571 2482 VISIT_START( node ); 3572 2483 … … 3577 2488 3578 2489 template< typename pass_type > 3579 Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) {2490 Type * PassVisitor< pass_type >::mutate( ZeroType * node ) { 3580 2491 MUTATE_START( node ); 3581 2492 … … 3586 2497 3587 2498 //-------------------------------------------------------------------------- 3588 // ZeroType3589 template< typename pass_type > 3590 void PassVisitor< pass_type >::visit( ZeroType * node ) {2499 // OneType 2500 template< typename pass_type > 2501 void PassVisitor< pass_type >::visit( OneType * node ) { 3591 2502 VISIT_START( node ); 3592 2503 … … 3597 2508 3598 2509 template< typename pass_type > 3599 void PassVisitor< pass_type >::visit( const ZeroType * node ) { 3600 VISIT_START( node ); 3601 3602 maybeAccept_impl( node->forall, *this ); 3603 3604 VISIT_END( node ); 3605 } 3606 3607 template< typename pass_type > 3608 Type * PassVisitor< pass_type >::mutate( ZeroType * node ) { 2510 Type * PassVisitor< pass_type >::mutate( OneType * node ) { 3609 2511 MUTATE_START( node ); 3610 2512 … … 3615 2517 3616 2518 //-------------------------------------------------------------------------- 3617 // OneType3618 template< typename pass_type >3619 void PassVisitor< pass_type >::visit( OneType * node ) {3620 VISIT_START( node );3621 3622 maybeAccept_impl( node->forall, *this );3623 3624 VISIT_END( node );3625 }3626 3627 template< typename pass_type >3628 void PassVisitor< pass_type >::visit( const OneType * node ) {3629 VISIT_START( node );3630 3631 maybeAccept_impl( node->forall, *this );3632 3633 VISIT_END( node );3634 }3635 3636 template< typename pass_type >3637 Type * PassVisitor< pass_type >::mutate( OneType * node ) {3638 MUTATE_START( node );3639 3640 maybeMutate_impl( node->forall, *this );3641 3642 MUTATE_END( Type, node );3643 }3644 3645 //--------------------------------------------------------------------------3646 // GlobalScopeType3647 template< typename pass_type >3648 void PassVisitor< pass_type >::visit( GlobalScopeType * node ) {3649 VISIT_START( node );3650 3651 maybeAccept_impl( node->forall, *this );3652 3653 VISIT_END( node );3654 }3655 3656 template< typename pass_type >3657 void PassVisitor< pass_type >::visit( const GlobalScopeType * node ) {3658 VISIT_START( node );3659 3660 maybeAccept_impl( node->forall, *this );3661 3662 VISIT_END( node );3663 }3664 3665 template< typename pass_type >3666 Type * PassVisitor< pass_type >::mutate( GlobalScopeType * node ) {3667 MUTATE_START( node );3668 3669 maybeMutate_impl( node->forall, *this );3670 3671 MUTATE_END( Type, node );3672 }3673 3674 //--------------------------------------------------------------------------3675 2519 // Designation 3676 2520 template< typename pass_type > … … 3684 2528 3685 2529 template< typename pass_type > 3686 void PassVisitor< pass_type >::visit( const Designation * node ) {3687 VISIT_START( node );3688 3689 maybeAccept_impl( node->designators, *this );3690 3691 VISIT_END( node );3692 }3693 3694 template< typename pass_type >3695 2530 Designation * PassVisitor< pass_type >::mutate( Designation * node ) { 3696 2531 MUTATE_START( node ); … … 3713 2548 3714 2549 template< typename pass_type > 3715 void PassVisitor< pass_type >::visit( const SingleInit * node ) {3716 VISIT_START( node );3717 3718 visitExpression( node->value );3719 3720 VISIT_END( node );3721 }3722 3723 template< typename pass_type >3724 2550 Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) { 3725 2551 MUTATE_START( node ); … … 3734 2560 template< typename pass_type > 3735 2561 void PassVisitor< pass_type >::visit( ListInit * node ) { 3736 VISIT_START( node );3737 3738 maybeAccept_impl( node->designations, *this );3739 maybeAccept_impl( node->initializers, *this );3740 3741 VISIT_END( node );3742 }3743 3744 template< typename pass_type >3745 void PassVisitor< pass_type >::visit( const ListInit * node ) {3746 2562 VISIT_START( node ); 3747 2563 … … 3776 2592 3777 2593 template< typename pass_type > 3778 void PassVisitor< pass_type >::visit( const ConstructorInit * node ) {3779 VISIT_START( node );3780 3781 maybeAccept_impl( node->ctor, *this );3782 maybeAccept_impl( node->dtor, *this );3783 maybeAccept_impl( node->init, *this );3784 3785 VISIT_END( node );3786 }3787 3788 template< typename pass_type >3789 2594 Initializer * PassVisitor< pass_type >::mutate( ConstructorInit * node ) { 3790 2595 MUTATE_START( node ); … … 3798 2603 3799 2604 //-------------------------------------------------------------------------- 2605 // Subrange 2606 template< typename pass_type > 2607 void PassVisitor< pass_type >::visit( Subrange * node ) { 2608 VISIT_START( node ); 2609 2610 VISIT_END( node ); 2611 } 2612 2613 template< typename pass_type > 2614 Subrange * PassVisitor< pass_type >::mutate( Subrange * node ) { 2615 MUTATE_START( node ); 2616 2617 MUTATE_END( Subrange, node ); 2618 } 2619 2620 //-------------------------------------------------------------------------- 3800 2621 // Attribute 3801 2622 template< typename pass_type > … … 3807 2628 3808 2629 template< typename pass_type > 3809 void PassVisitor< pass_type >::visit( const Constant * node ) {3810 VISIT_START( node );3811 3812 VISIT_END( node );3813 }3814 3815 template< typename pass_type >3816 2630 Constant * PassVisitor< pass_type >::mutate( Constant * node ) { 3817 2631 MUTATE_START( node ); … … 3824 2638 template< typename pass_type > 3825 2639 void PassVisitor< pass_type >::visit( Attribute * node ) { 3826 VISIT_START( node );3827 3828 maybeAccept_impl( node->parameters, *this );3829 3830 VISIT_END( node );3831 }3832 3833 template< typename pass_type >3834 void PassVisitor< pass_type >::visit( const Attribute * node ) {3835 2640 VISIT_START( node ); 3836 2641 … … 3864 2669 MUTATE_END( TypeSubstitution, node ); 3865 2670 } 3866 3867 #undef VISIT_START3868 #undef VISIT_END3869 3870 #undef MUTATE_START3871 #undef MUTATE_END
Note:
See TracChangeset
for help on using the changeset viewer.