Changes in src/Common/PassVisitor.impl.h [ee3c93d:033ff37]
- File:
-
- 1 edited
-
src/Common/PassVisitor.impl.h (modified) (119 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.impl.h
ree3c93d r033ff37 20 20 21 21 #define MUTATE_END( type, node ) \ 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 22 auto __return = call_postmutate< type * >( node ); \ 23 assert( __return ); \ 24 return __return; 40 25 41 26 … … 67 52 SemanticErrorException errors; 68 53 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); 69 57 for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) { 58 59 70 60 // splice in new declarations after previous decl 71 61 if ( !empty( afterDecls ) ) { decls.splice( i, *afterDecls ); } … … 83 73 if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); } 84 74 } 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 declaration 91 maybeAccept_impl( decl, visitor ); 92 } 93 catch( SemanticErrorException &e ) { 94 errors.append( e ); 95 } 96 } 97 pass_visitor_stats.depth--; 85 98 if ( ! errors.isEmpty() ) { 86 99 throw errors; … … 94 107 SemanticErrorException errors; 95 108 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); 96 112 for ( std::list< Declaration* >::iterator i = decls.begin(); ; ++i ) { 97 113 // splice in new declarations after previous decl … … 109 125 if ( !empty( beforeDecls ) ) { decls.splice( i, *beforeDecls ); } 110 126 } 127 pass_visitor_stats.depth--; 111 128 if ( ! errors.isEmpty() ) { 112 129 throw errors; … … 122 139 } 123 140 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 124 149 template< typename Container, typename pass_type > 125 150 inline void maybeAccept_impl( Container & container, PassVisitor< pass_type > & visitor ) { 126 151 if ( ! visitor.get_visit_children() ) return; 127 152 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); 128 157 for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) { 129 158 try { … … 135 164 } 136 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 ); 184 } 185 } catch( SemanticErrorException &e ) { 186 errors.append( e ); 187 } 188 } 189 pass_visitor_stats.depth--; 137 190 if ( ! errors.isEmpty() ) { 138 191 throw errors; … … 151 204 template< typename Container, typename pass_type > 152 205 inline void maybeMutate_impl( Container & container, PassVisitor< pass_type > & mutator ) { 206 153 207 if ( ! mutator.get_visit_children() ) return; 154 208 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); 155 213 for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) { 156 214 try { … … 163 221 } // try 164 222 } // for 223 pass_visitor_stats.depth--; 165 224 if ( ! errors.isEmpty() ) { 166 225 throw errors; … … 185 244 DeclList_t* afterDecls = get_afterDecls(); 186 245 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); 187 249 for ( std::list< Statement* >::iterator i = statements.begin(); i != statements.end(); ++i ) { 188 250 … … 192 254 try { 193 255 func( *i ); 256 assert( *i ); 194 257 assert(( empty( beforeStmts ) && empty( afterStmts )) 195 258 || ( empty( beforeDecls ) && empty( afterDecls )) ); … … 202 265 if ( !empty( beforeStmts ) ) { statements.splice( i, *beforeStmts ); } 203 266 } 267 pass_visitor_stats.depth--; 204 268 205 269 if ( !empty( afterDecls ) ) { splice( std::back_inserter( statements ), afterDecls); } … … 216 280 217 281 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 > 218 301 void PassVisitor< pass_type >::mutateStatementList( std::list< Statement * > & statements ) { 219 302 handleStatementList( statements, [this]( Statement *& stmt) { … … 229 312 230 313 // don't want statements from outer CompoundStmts to be added to this CompoundStmt 231 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() );314 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() ); 232 315 ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() ); 233 316 ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () ); … … 264 347 265 348 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 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 > 266 359 Statement * PassVisitor< pass_type >::mutateStatement( Statement * stmt ) { 267 360 return handleStatement( stmt, [this]( Statement * stmt ) { … … 295 388 296 389 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 > 297 403 Expression * PassVisitor< pass_type >::mutateExpression( Expression * expr ) { 298 404 return handleExpression(expr, [this]( Expression * expr ) { … … 304 410 template< typename TreeType, typename VisitorType > 305 411 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 ) { 306 422 if ( ! visitor.get_visit_children() ) return; 307 423 auto guard = makeFuncGuard( … … 366 482 367 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 ); 491 492 VISIT_END( node ); 493 } 494 495 template< typename pass_type > 368 496 DeclarationWithType * PassVisitor< pass_type >::mutate( ObjectDecl * node ) { 369 497 MUTATE_START( node ); … … 404 532 indexerAddId( &func ); 405 533 maybeAccept_impl( node->type, *this ); 534 // function body needs to have the same scope as parameters - CompoundStmt will not enter 535 // a new scope if inFunction is true 536 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 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; 406 573 maybeAccept_impl( node->statements, *this ); 407 574 maybeAccept_impl( node->attributes, *this ); … … 434 601 indexerAddId( &func ); 435 602 maybeMutate_impl( node->type, *this ); 603 // function body needs to have the same scope as parameters - CompoundStmt will not enter 604 // a new scope if inFunction is true 605 ValueGuard< bool > oldInFunction( inFunction ); 606 inFunction = true; 436 607 maybeMutate_impl( node->statements, *this ); 437 608 maybeMutate_impl( node->attributes, *this ); … … 465 636 466 637 template< typename pass_type > 467 Declaration * PassVisitor< pass_type >::mutate(StructDecl * node ) {468 MUTATE_START( node );638 void PassVisitor< pass_type >::visit( const StructDecl * node ) { 639 VISIT_START( node ); 469 640 470 641 // make up a forward declaration and add it before processing the members … … 474 645 { 475 646 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 647 maybeAccept_impl( node->parameters, *this ); 648 maybeAccept_impl( node->members , *this ); 649 } 650 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 ) { 659 MUTATE_START( node ); 660 661 // 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 ); 664 665 { 666 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 476 667 maybeMutate_impl( node->parameters, *this ); 477 668 maybeMutate_impl( node->members , *this ); … … 503 694 VISIT_END( node ); 504 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 } 505 713 506 714 template< typename pass_type > … … 538 746 539 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 > 540 761 Declaration * PassVisitor< pass_type >::mutate( EnumDecl * node ) { 541 762 MUTATE_START( node ); … … 554 775 template< typename pass_type > 555 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 ) { 556 792 VISIT_START( node ); 557 793 … … 606 842 } 607 843 608 template< typename pass_type > 609 Declaration * PassVisitor< pass_type >::mutate( TypeDecl * node ) { 610 MUTATE_START( node ); 844 845 template< typename pass_type > 846 void PassVisitor< pass_type >::visit( const TypeDecl * node ) { 847 VISIT_START( node ); 611 848 612 849 { 613 850 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 614 maybe Mutate_impl( node->parameters, *this );615 maybe Mutate_impl( node->base , *this );851 maybeAccept_impl( node->parameters, *this ); 852 maybeAccept_impl( node->base , *this ); 616 853 } 617 854 … … 621 858 indexerAddType( node ); 622 859 860 maybeAccept_impl( node->assertions, *this ); 861 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 ) { 869 MUTATE_START( node ); 870 871 { 872 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 873 maybeMutate_impl( node->parameters, *this ); 874 maybeMutate_impl( node->base , *this ); 875 } 876 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 880 indexerAddType( node ); 881 623 882 maybeMutate_impl( node->assertions, *this ); 624 883 … … 648 907 649 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 > 650 926 Declaration * PassVisitor< pass_type >::mutate( TypedefDecl * node ) { 651 927 MUTATE_START( node ); … … 676 952 677 953 template< 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 > 678 963 AsmDecl * PassVisitor< pass_type >::mutate( AsmDecl * node ) { 679 964 MUTATE_START( node ); … … 697 982 698 983 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 > 699 994 StaticAssertDecl * PassVisitor< pass_type >::mutate( StaticAssertDecl * node ) { 700 995 MUTATE_START( node ); … … 712 1007 VISIT_START( node ); 713 1008 { 714 auto guard1 = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 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(); } ); 715 1012 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } ); 1013 inFunction = false; 716 1014 visitStatementList( node->kids ); 717 1015 } … … 720 1018 721 1019 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(); } ); 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 > 722 1034 CompoundStmt * PassVisitor< pass_type >::mutate( CompoundStmt * node ) { 723 1035 MUTATE_START( node ); 724 1036 { 725 auto guard1 = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 1037 // do not enter a new scope if inFunction is true - needs to check old state before the assignment 1038 ValueGuard< bool > oldInFunction( inFunction ); 1039 auto guard1 = makeFuncGuard( [this, &oldInFunction]() { if ( ! oldInFunction.old ) indexerScopeEnter(); }, [this, &oldInFunction]() { if ( ! oldInFunction.old ) indexerScopeLeave(); } ); 726 1040 auto guard2 = makeFuncGuard( [this]() { call_beginScope(); }, [this]() { call_endScope(); } ); 1041 inFunction = false; 727 1042 mutateStatementList( node->kids ); 728 1043 } … … 734 1049 template< typename pass_type > 735 1050 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 ) { 736 1060 VISIT_START( node ); 737 1061 … … 765 1089 766 1090 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 > 767 1103 Statement * PassVisitor< pass_type >::mutate( AsmStmt * node ) { 768 1104 MUTATE_START( node ); … … 786 1122 787 1123 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 > 788 1131 Statement * PassVisitor< pass_type >::mutate( DirectiveStmt * node ) { 789 1132 MUTATE_START( node ); … … 800 1143 // if statements introduce a level of scope (for the initialization) 801 1144 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 802 maybeAccept_impl( node-> get_initialization(), *this );1145 maybeAccept_impl( node->initialization, *this ); 803 1146 visitExpression ( node->condition ); 804 1147 node->thenPart = visitStatement( node->thenPart ); … … 809 1152 810 1153 template< typename pass_type > 811 Statement * PassVisitor< pass_type >::mutate(IfStmt * node ) {812 MUTATE_START( node );1154 void PassVisitor< pass_type >::visit( const IfStmt * node ) { 1155 VISIT_START( node ); 813 1156 { 814 1157 // if statements introduce a level of scope (for the initialization) 815 1158 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 816 maybeMutate_impl( node->get_initialization(), *this ); 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 ); 817 1174 node->condition = mutateExpression( node->condition ); 818 1175 node->thenPart = mutateStatement ( node->thenPart ); … … 834 1191 visitExpression ( node->condition ); 835 1192 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 ); 836 1208 } 837 1209 … … 872 1244 873 1245 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 > 874 1260 Statement * PassVisitor< pass_type >::mutate( ForStmt * node ) { 875 1261 MUTATE_START( node ); … … 898 1284 899 1285 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 > 900 1296 Statement * PassVisitor< pass_type >::mutate( SwitchStmt * node ) { 901 1297 MUTATE_START( node ); … … 920 1316 921 1317 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 > 922 1328 Statement * PassVisitor< pass_type >::mutate( CaseStmt * node ) { 923 1329 MUTATE_START( node ); … … 938 1344 939 1345 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 > 940 1352 Statement * PassVisitor< pass_type >::mutate( BranchStmt * node ) { 941 1353 MUTATE_START( node ); … … 955 1367 956 1368 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 > 957 1378 Statement * PassVisitor< pass_type >::mutate( ReturnStmt * node ) { 958 1379 MUTATE_START( node ); … … 965 1386 //-------------------------------------------------------------------------- 966 1387 // ThrowStmt 967 968 1388 template< typename pass_type > 969 1389 void PassVisitor< pass_type >::visit( ThrowStmt * node ) { … … 977 1397 978 1398 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 > 979 1409 Statement * PassVisitor< pass_type >::mutate( ThrowStmt * node ) { 980 1410 MUTATE_START( node ); … … 990 1420 template< typename pass_type > 991 1421 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 ) { 992 1433 VISIT_START( node ); 993 1434 … … 1026 1467 1027 1468 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 > 1028 1482 Statement * PassVisitor< pass_type >::mutate( CatchStmt * node ) { 1029 1483 MUTATE_START( node ); … … 1050 1504 1051 1505 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 > 1052 1515 Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) { 1053 1516 MUTATE_START( node ); … … 1082 1545 1083 1546 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 > 1084 1568 Statement * PassVisitor< pass_type >::mutate( WaitForStmt * node ) { 1085 1569 MUTATE_START( node ); … … 1105 1589 1106 1590 //-------------------------------------------------------------------------- 1107 // NullStmt1591 // WithStmt 1108 1592 template< typename pass_type > 1109 1593 void PassVisitor< pass_type >::visit( WithStmt * node ) { … … 1120 1604 1121 1605 template< typename pass_type > 1122 Statement * PassVisitor< pass_type >::mutate( WithStmt * node ) { 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 ) { 1123 1620 MUTATE_START( node ); 1124 1621 maybeMutate_impl( node->exprs, *this ); … … 1129 1626 maybeMutate_impl( node->stmt, *this ); 1130 1627 } 1628 MUTATE_END( Declaration, node ); 1629 } 1630 1631 //-------------------------------------------------------------------------- 1632 // NullStmt 1633 template< typename pass_type > 1634 void PassVisitor< pass_type >::visit( NullStmt * node ) { 1635 VISIT_START( node ); 1636 VISIT_END( node ); 1637 } 1638 1639 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 NullStmt * PassVisitor< pass_type >::mutate( NullStmt * node ) { 1647 MUTATE_START( node ); 1648 MUTATE_END( NullStmt, node ); 1649 } 1650 1651 //-------------------------------------------------------------------------- 1652 // DeclStmt 1653 template< typename pass_type > 1654 void PassVisitor< pass_type >::visit( DeclStmt * node ) { 1655 VISIT_START( node ); 1656 1657 maybeAccept_impl( node->decl, *this ); 1658 1659 VISIT_END( node ); 1660 } 1661 1662 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 Statement * PassVisitor< pass_type >::mutate( DeclStmt * node ) { 1673 MUTATE_START( node ); 1674 1675 maybeMutate_impl( node->decl, *this ); 1676 1131 1677 MUTATE_END( Statement, node ); 1132 1678 } 1133 1679 1134 1680 //-------------------------------------------------------------------------- 1135 // NullStmt 1136 template< typename pass_type > 1137 void PassVisitor< pass_type >::visit( NullStmt * node ) { 1138 VISIT_START( node ); 1139 VISIT_END( node ); 1140 } 1141 1142 template< typename pass_type > 1143 NullStmt * PassVisitor< pass_type >::mutate( NullStmt * node ) { 1144 MUTATE_START( node ); 1145 MUTATE_END( NullStmt, node ); 1146 } 1147 1148 //-------------------------------------------------------------------------- 1149 // DeclStmt 1150 template< typename pass_type > 1151 void PassVisitor< pass_type >::visit( DeclStmt * node ) { 1152 VISIT_START( node ); 1153 1154 maybeAccept_impl( node->decl, *this ); 1155 1156 VISIT_END( node ); 1157 } 1158 1159 template< typename pass_type > 1160 Statement * PassVisitor< pass_type >::mutate( DeclStmt * node ) { 1161 MUTATE_START( node ); 1162 1163 maybeMutate_impl( node->decl, *this ); 1681 // ImplicitCtorDtorStmt 1682 template< typename pass_type > 1683 void PassVisitor< pass_type >::visit( ImplicitCtorDtorStmt * node ) { 1684 VISIT_START( node ); 1685 1686 maybeAccept_impl( node->callStmt, *this ); 1687 1688 VISIT_END( node ); 1689 } 1690 1691 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 Statement * PassVisitor< pass_type >::mutate( ImplicitCtorDtorStmt * node ) { 1702 MUTATE_START( node ); 1703 1704 maybeMutate_impl( node->callStmt, *this ); 1164 1705 1165 1706 MUTATE_END( Statement, node ); … … 1167 1708 1168 1709 //-------------------------------------------------------------------------- 1169 // ImplicitCtorDtorStmt1170 template< typename pass_type >1171 void PassVisitor< pass_type >::visit( ImplicitCtorDtorStmt * node ) {1172 VISIT_START( node );1173 1174 maybeAccept_impl( node->callStmt, *this );1175 1176 VISIT_END( node );1177 }1178 1179 template< typename pass_type >1180 Statement * PassVisitor< pass_type >::mutate( ImplicitCtorDtorStmt * node ) {1181 MUTATE_START( node );1182 1183 maybeMutate_impl( node->callStmt, *this );1184 1185 MUTATE_END( Statement, node );1186 }1187 1188 //--------------------------------------------------------------------------1189 1710 // ApplicationExpr 1190 1711 template< typename pass_type > … … 1193 1714 1194 1715 indexerScopedAccept( node->result , *this ); 1195 maybeAccept_impl ( node->function, *this ); 1196 maybeAccept_impl ( node->args , *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 ); 1197 1729 1198 1730 VISIT_END( node ); … … 1228 1760 1229 1761 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 > 1230 1775 Expression * PassVisitor< pass_type >::mutate( UntypedExpr * node ) { 1231 1776 MUTATE_START( node ); … … 1253 1798 1254 1799 template< typename pass_type > 1800 void PassVisitor< pass_type >::visit( const NameExpr * node ) { 1801 VISIT_START( node ); 1802 1803 indexerScopedAccept( node->result, *this ); 1804 1805 VISIT_END( node ); 1806 } 1807 1808 template< typename pass_type > 1255 1809 Expression * PassVisitor< pass_type >::mutate( NameExpr * node ) { 1256 1810 MUTATE_START( node ); … … 1269 1823 1270 1824 indexerScopedAccept( node->result, *this ); 1271 maybeAccept_impl ( node->arg , *this ); 1825 maybeAccept_impl ( node->arg , *this ); 1826 1827 VISIT_END( node ); 1828 } 1829 1830 template< typename pass_type > 1831 void PassVisitor< pass_type >::visit( const CastExpr * node ) { 1832 VISIT_START( node ); 1833 1834 indexerScopedAccept( node->result, *this ); 1835 maybeAccept_impl ( node->arg , *this ); 1272 1836 1273 1837 VISIT_END( node ); … … 1298 1862 1299 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 > 1300 1874 Expression * PassVisitor< pass_type >::mutate( KeywordCastExpr * node ) { 1301 1875 MUTATE_START( node ); … … 1315 1889 1316 1890 indexerScopedAccept( node->result, *this ); 1317 maybeAccept_impl( node->arg, *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 ); 1318 1902 1319 1903 VISIT_END( node ); … … 1344 1928 1345 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 > 1346 1940 Expression * PassVisitor< pass_type >::mutate( AddressExpr * node ) { 1347 1941 MUTATE_START( node ); … … 1366 1960 1367 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 > 1368 1971 Expression * PassVisitor< pass_type >::mutate( LabelAddressExpr * node ) { 1369 1972 MUTATE_START( node ); … … 1379 1982 template< typename pass_type > 1380 1983 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 ) { 1381 1995 VISIT_START( node ); 1382 1996 … … 1413 2027 1414 2028 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 > 1415 2039 Expression * PassVisitor< pass_type >::mutate( MemberExpr * node ) { 1416 2040 MUTATE_START( node ); … … 1435 2059 1436 2060 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 > 1437 2070 Expression * PassVisitor< pass_type >::mutate( VariableExpr * node ) { 1438 2071 MUTATE_START( node ); … … 1448 2081 template< typename pass_type > 1449 2082 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 ) { 1450 2093 VISIT_START( node ); 1451 2094 … … 1473 2116 template< typename pass_type > 1474 2117 void PassVisitor< pass_type >::visit( SizeofExpr * node ) { 2118 VISIT_START( node ); 2119 2120 indexerScopedAccept( node->result, *this ); 2121 if ( node->get_isType() ) { 2122 maybeAccept_impl( node->type, *this ); 2123 } else { 2124 maybeAccept_impl( node->expr, *this ); 2125 } 2126 2127 VISIT_END( node ); 2128 } 2129 2130 template< typename pass_type > 2131 void PassVisitor< pass_type >::visit( const SizeofExpr * node ) { 1475 2132 VISIT_START( node ); 1476 2133 … … 1517 2174 1518 2175 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 > 1519 2190 Expression * PassVisitor< pass_type >::mutate( AlignofExpr * node ) { 1520 2191 MUTATE_START( node ); … … 1544 2215 1545 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 > 1546 2227 Expression * PassVisitor< pass_type >::mutate( UntypedOffsetofExpr * node ) { 1547 2228 MUTATE_START( node ); … … 1567 2248 1568 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 > 1569 2260 Expression * PassVisitor< pass_type >::mutate( OffsetofExpr * node ) { 1570 2261 MUTATE_START( node ); … … 1590 2281 1591 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 > 1592 2293 Expression * PassVisitor< pass_type >::mutate( OffsetPackExpr * node ) { 1593 2294 MUTATE_START( node ); … … 1601 2302 1602 2303 //-------------------------------------------------------------------------- 1603 // AttrExpr1604 template< typename pass_type >1605 void PassVisitor< pass_type >::visit( AttrExpr * node ) {1606 VISIT_START( node );1607 1608 indexerScopedAccept( node->result, *this );1609 if ( node->get_isType() ) {1610 maybeAccept_impl( node->type, *this );1611 } else {1612 maybeAccept_impl( node->expr, *this );1613 }1614 1615 VISIT_END( node );1616 }1617 1618 template< typename pass_type >1619 Expression * PassVisitor< pass_type >::mutate( AttrExpr * node ) {1620 MUTATE_START( node );1621 1622 indexerScopedMutate( node->env , *this );1623 indexerScopedMutate( node->result, *this );1624 if ( node->get_isType() ) {1625 maybeMutate_impl( node->type, *this );1626 } else {1627 maybeMutate_impl( node->expr, *this );1628 }1629 1630 MUTATE_END( Expression, node );1631 }1632 1633 //--------------------------------------------------------------------------1634 2304 // LogicalExpr 1635 2305 template< typename pass_type > 1636 2306 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 ) { 1637 2318 VISIT_START( node ); 1638 2319 … … 1666 2347 maybeAccept_impl ( node->arg2 , *this ); 1667 2348 maybeAccept_impl ( node->arg3 , *this ); 2349 2350 VISIT_END( node ); 2351 } 2352 2353 template< typename pass_type > 2354 void PassVisitor< pass_type >::visit( const ConditionalExpr * node ) { 2355 VISIT_START( node ); 2356 2357 indexerScopedAccept( node->result, *this ); 2358 maybeAccept_impl ( node->arg1 , *this ); 2359 maybeAccept_impl ( node->arg2 , *this ); 2360 maybeAccept_impl ( node->arg3 , *this ); 1668 2361 1669 2362 VISIT_END( node ); … … 1697 2390 1698 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 > 1699 2403 Expression * PassVisitor< pass_type >::mutate( CommaExpr * node ) { 1700 2404 MUTATE_START( node ); … … 1721 2425 1722 2426 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 > 1723 2437 Expression * PassVisitor< pass_type >::mutate( TypeExpr * node ) { 1724 2438 MUTATE_START( node ); … … 1735 2449 template< typename pass_type > 1736 2450 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 ) { 1737 2463 VISIT_START( node ); 1738 2464 … … 1764 2490 VISIT_START( node ); 1765 2491 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 ); 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 ); 1771 2504 1772 2505 VISIT_END( node ); … … 1777 2510 MUTATE_START( node ); 1778 2511 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 ); 2512 indexerScopedMutate( node->env , *this ); 2513 indexerScopedMutate( node->result , *this ); 2514 maybeMutate_impl ( node->callExpr , *this ); 1785 2515 1786 2516 MUTATE_END( Expression, node ); … … 1791 2521 template< typename pass_type > 1792 2522 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 ) { 1793 2533 VISIT_START( node ); 1794 2534 … … 1823 2563 1824 2564 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 > 1825 2575 Expression * PassVisitor< pass_type >::mutate( CompoundLiteralExpr * node ) { 1826 2576 MUTATE_START( node ); … … 1837 2587 template< typename pass_type > 1838 2588 void PassVisitor< pass_type >::visit( RangeExpr * node ) { 2589 VISIT_START( node ); 2590 2591 indexerScopedAccept( node->result, *this ); 2592 maybeAccept_impl ( node->low , *this ); 2593 maybeAccept_impl ( node->high , *this ); 2594 2595 VISIT_END( node ); 2596 } 2597 2598 template< typename pass_type > 2599 void PassVisitor< pass_type >::visit( const RangeExpr * node ) { 1839 2600 VISIT_START( node ); 1840 2601 … … 1871 2632 1872 2633 template< typename pass_type > 2634 void PassVisitor< pass_type >::visit( const UntypedTupleExpr * node ) { 2635 VISIT_START( node ); 2636 2637 indexerScopedAccept( node->result, *this ); 2638 maybeAccept_impl ( node->exprs , *this ); 2639 2640 VISIT_END( node ); 2641 } 2642 2643 template< typename pass_type > 1873 2644 Expression * PassVisitor< pass_type >::mutate( UntypedTupleExpr * node ) { 1874 2645 MUTATE_START( node ); … … 1894 2665 1895 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 > 1896 2677 Expression * PassVisitor< pass_type >::mutate( TupleExpr * node ) { 1897 2678 MUTATE_START( node ); … … 1917 2698 1918 2699 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 > 1919 2710 Expression * PassVisitor< pass_type >::mutate( TupleIndexExpr * node ) { 1920 2711 MUTATE_START( node ); … … 1940 2731 1941 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 2739 VISIT_END( node ); 2740 } 2741 2742 template< typename pass_type > 1942 2743 Expression * PassVisitor< pass_type >::mutate( TupleAssignExpr * node ) { 1943 2744 MUTATE_START( node ); … … 1957 2758 1958 2759 // don't want statements from outer CompoundStmts to be added to this StmtExpr 1959 ValueGuardPtr< TypeSubstitution * > oldEnv( get_env_ptr() );2760 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() ); 1960 2761 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() ); 1961 2762 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); … … 1970 2771 1971 2772 template< typename pass_type > 2773 void PassVisitor< pass_type >::visit( const StmtExpr * node ) { 2774 VISIT_START( node ); 2775 2776 // 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 > 1972 2790 Expression * PassVisitor< pass_type >::mutate( StmtExpr * node ) { 1973 2791 MUTATE_START( node ); 1974 2792 1975 2793 // don't want statements from outer CompoundStmts to be added to this StmtExpr 1976 ValueGuardPtr< TypeSubstitution * > oldEnv( get_env_ptr() );2794 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() ); 1977 2795 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() ); 1978 2796 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); … … 1999 2817 2000 2818 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 > 2001 2829 Expression * PassVisitor< pass_type >::mutate( UniqueExpr * node ) { 2002 2830 MUTATE_START( node ); … … 2013 2841 template< typename pass_type > 2014 2842 void PassVisitor< pass_type >::visit( UntypedInitExpr * node ) { 2843 VISIT_START( node ); 2844 2845 indexerScopedAccept( node->result, *this ); 2846 maybeAccept_impl ( node->expr , *this ); 2847 // not currently visiting initAlts, but this doesn't matter since this node is only used in the resolver. 2848 2849 VISIT_END( node ); 2850 } 2851 2852 template< typename pass_type > 2853 void PassVisitor< pass_type >::visit( const UntypedInitExpr * node ) { 2015 2854 VISIT_START( node ); 2016 2855 … … 2048 2887 2049 2888 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 > 2050 2900 Expression * PassVisitor< pass_type >::mutate( InitExpr * node ) { 2051 2901 MUTATE_START( node ); … … 2066 2916 2067 2917 indexerScopedAccept( node->result, *this ); 2068 maybeAccept_impl( node->expr, *this ); 2918 maybeAccept_impl ( node->expr, *this ); 2919 // don't visit deleteStmt, because it is a pointer to somewhere else in the tree. 2920 2921 VISIT_END( node ); 2922 } 2923 2924 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 ); 2069 2930 // don't visit deleteStmt, because it is a pointer to somewhere else in the tree. 2070 2931 … … 2084 2945 2085 2946 //-------------------------------------------------------------------------- 2947 // DefaultArgExpr 2948 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 MUTATE_START( node ); 2971 2972 indexerScopedMutate( node->env, *this ); 2973 indexerScopedMutate( node->result, *this ); 2974 maybeMutate_impl( node->expr, *this ); 2975 2976 MUTATE_END( Expression, node ); 2977 } 2978 2979 //-------------------------------------------------------------------------- 2086 2980 // GenericExpr 2087 2981 template< typename pass_type > … … 2092 2986 maybeAccept_impl( node->control, *this ); 2093 2987 for ( GenericExpr::Association & assoc : node->associations ) { 2988 indexerScopedAccept( assoc.type, *this ); 2989 maybeAccept_impl( assoc.expr, *this ); 2990 } 2991 2992 VISIT_END( node ); 2993 } 2994 2995 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 ) { 2094 3002 indexerScopedAccept( assoc.type, *this ); 2095 3003 maybeAccept_impl( assoc.expr, *this ); … … 2126 3034 2127 3035 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 > 2128 3045 Type * PassVisitor< pass_type >::mutate( VoidType * node ) { 2129 3046 MUTATE_START( node ); … … 2138 3055 template< typename pass_type > 2139 3056 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 ) { 2140 3066 VISIT_START( node ); 2141 3067 … … 2168 3094 2169 3095 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 > 2170 3107 Type * PassVisitor< pass_type >::mutate( PointerType * node ) { 2171 3108 MUTATE_START( node ); … … 2192 3129 2193 3130 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 > 2194 3142 Type * PassVisitor< pass_type >::mutate( ArrayType * node ) { 2195 3143 MUTATE_START( node ); … … 2215 3163 2216 3164 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 > 2217 3175 Type * PassVisitor< pass_type >::mutate( ReferenceType * node ) { 2218 3176 MUTATE_START( node ); … … 2220 3178 maybeMutate_impl( node->forall, *this ); 2221 3179 maybeMutate_impl( node->base, *this ); 3180 3181 MUTATE_END( Type, node ); 3182 } 3183 3184 //-------------------------------------------------------------------------- 3185 // QualifiedType 3186 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 ); 2222 3215 2223 3216 MUTATE_END( Type, node ); … … 2238 3231 2239 3232 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 > 2240 3244 Type * PassVisitor< pass_type >::mutate( FunctionType * node ) { 2241 3245 MUTATE_START( node ); … … 2266 3270 2267 3271 template< typename pass_type > 3272 void PassVisitor< pass_type >::visit( const StructInstType * node ) { 3273 VISIT_START( node ); 3274 3275 indexerAddStruct( node->name ); 3276 3277 { 3278 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 3279 maybeAccept_impl( node->forall , *this ); 3280 maybeAccept_impl( node->parameters, *this ); 3281 } 3282 3283 VISIT_END( node ); 3284 } 3285 3286 template< typename pass_type > 2268 3287 Type * PassVisitor< pass_type >::mutate( StructInstType * node ) { 2269 3288 MUTATE_START( node ); … … 2298 3317 2299 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 > 2300 3334 Type * PassVisitor< pass_type >::mutate( UnionInstType * node ) { 2301 3335 MUTATE_START( node ); … … 2325 3359 2326 3360 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 > 2327 3371 Type * PassVisitor< pass_type >::mutate( EnumInstType * node ) { 2328 3372 MUTATE_START( node ); … … 2347 3391 2348 3392 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 > 2349 3403 Type * PassVisitor< pass_type >::mutate( TraitInstType * node ) { 2350 3404 MUTATE_START( node ); … … 2360 3414 template< typename pass_type > 2361 3415 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 ) { 2362 3426 VISIT_START( node ); 2363 3427 … … 2392 3456 2393 3457 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 > 2394 3469 Type * PassVisitor< pass_type >::mutate( TupleType * node ) { 2395 3470 MUTATE_START( node ); … … 2406 3481 template< typename pass_type > 2407 3482 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 ) { 2408 3493 VISIT_START( node ); 2409 3494 … … 2442 3527 2443 3528 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 } // if 3539 3540 VISIT_END( node ); 3541 } 3542 3543 template< typename pass_type > 2444 3544 Type * PassVisitor< pass_type >::mutate( AttrType * node ) { 2445 3545 MUTATE_START( node ); … … 2468 3568 2469 3569 template< typename pass_type > 3570 void PassVisitor< pass_type >::visit( const VarArgsType * node ) { 3571 VISIT_START( node ); 3572 3573 maybeAccept_impl( node->forall, *this ); 3574 3575 VISIT_END( node ); 3576 } 3577 3578 template< typename pass_type > 2470 3579 Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) { 2471 3580 MUTATE_START( node ); … … 2488 3597 2489 3598 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 > 2490 3608 Type * PassVisitor< pass_type >::mutate( ZeroType * node ) { 2491 3609 MUTATE_START( node ); … … 2508 3626 2509 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 > 2510 3637 Type * PassVisitor< pass_type >::mutate( OneType * node ) { 2511 3638 MUTATE_START( node ); … … 2517 3644 2518 3645 //-------------------------------------------------------------------------- 3646 // GlobalScopeType 3647 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 //-------------------------------------------------------------------------- 2519 3675 // Designation 2520 3676 template< typename pass_type > … … 2528 3684 2529 3685 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 > 2530 3695 Designation * PassVisitor< pass_type >::mutate( Designation * node ) { 2531 3696 MUTATE_START( node ); … … 2548 3713 2549 3714 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 > 2550 3724 Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) { 2551 3725 MUTATE_START( node ); … … 2560 3734 template< typename pass_type > 2561 3735 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 ) { 2562 3746 VISIT_START( node ); 2563 3747 … … 2592 3776 2593 3777 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 > 2594 3789 Initializer * PassVisitor< pass_type >::mutate( ConstructorInit * node ) { 2595 3790 MUTATE_START( node ); … … 2603 3798 2604 3799 //-------------------------------------------------------------------------- 2605 // Subrange2606 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 //--------------------------------------------------------------------------2621 3800 // Attribute 2622 3801 template< typename pass_type > … … 2628 3807 2629 3808 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 > 2630 3816 Constant * PassVisitor< pass_type >::mutate( Constant * node ) { 2631 3817 MUTATE_START( node ); … … 2638 3824 template< typename pass_type > 2639 3825 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 ) { 2640 3835 VISIT_START( node ); 2641 3836 … … 2669 3864 MUTATE_END( TypeSubstitution, node ); 2670 3865 } 3866 3867 #undef VISIT_START 3868 #undef VISIT_END 3869 3870 #undef MUTATE_START 3871 #undef MUTATE_END
Note:
See TracChangeset
for help on using the changeset viewer.