Changes in src/Common/PassVisitor.impl.h [b11d8e2:447c356]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.impl.h
rb11d8e2 r447c356 2 2 // IWYU pragma: private, include "PassVisitor.h" 3 3 4 #define VISIT_START( node ) \ 5 __attribute__((unused)) \ 4 #define VISIT_START( node ) \ 5 __attribute__((unused)) \ 6 ChildrenGuard children_guard( get_visit_children_ptr() ); \ 7 __attribute__((unused)) \ 6 8 guard_value_impl guard( at_cleanup_impl(pass, 0) ); \ 7 bool visit_children = true; \ 8 set_visit_children( visit_children ); \ 9 call_previsit( node ); \ 10 if( visit_children ) { \ 9 call_previsit( node ); \ 11 10 12 11 #define VISIT_END( node ) \ 13 } \14 12 call_postvisit( node ); \ 15 13 16 #define MUTATE_START( node ) \ 17 __attribute__((unused)) \ 14 #define MUTATE_START( node ) \ 15 __attribute__((unused)) \ 16 ChildrenGuard children_guard( get_visit_children_ptr() ); \ 17 __attribute__((unused)) \ 18 18 guard_value_impl guard( at_cleanup_impl(pass, 0) ); \ 19 bool visit_children = true; \ 20 set_visit_children( visit_children ); \ 21 call_premutate( node ); \ 22 if( visit_children ) { \ 19 call_premutate( node ); \ 23 20 24 21 #define MUTATE_END( type, node ) \ 25 } \26 22 return call_postmutate< type * >( node ); \ 27 23 28 24 29 #define VISIT_BODY( node ) \ 30 VISIT_START( node ); \ 31 Visitor::visit( node ); \ 32 VISIT_END( node ); \ 33 34 35 #define MUTATE_BODY( type, node ) \ 36 MUTATE_START( node ); \ 37 Mutator::mutate( node ); \ 38 MUTATE_END( type, node ); \ 25 #define VISIT_BODY( node ) \ 26 VISIT_START( node ); \ 27 if( children_guard ) { \ 28 Visitor::visit( node ); \ 29 } \ 30 VISIT_END( node ); \ 31 32 33 #define MUTATE_BODY( type, node ) \ 34 MUTATE_START( node ); \ 35 if( children_guard ) { \ 36 Mutator::mutate( node ); \ 37 } \ 38 MUTATE_END( type, node ); \ 39 39 40 40 … … 63 63 template< typename pass_type > 64 64 static inline void acceptAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& visitor ) { 65 66 65 DeclList_t* beforeDecls = visitor.get_beforeDecls(); 67 66 DeclList_t* afterDecls = visitor.get_afterDecls(); … … 76 75 try { 77 76 // run visitor on declaration 78 maybeAccept ( *i, visitor );77 maybeAccept_impl( *i, visitor ); 79 78 } catch( SemanticError &e ) { 80 79 e.set_location( (*i)->location ); … … 92 91 template< typename pass_type > 93 92 static inline void mutateAll( std::list< Declaration* > &decls, PassVisitor< pass_type >& mutator ) { 94 95 93 DeclList_t* beforeDecls = mutator.get_beforeDecls(); 96 94 DeclList_t* afterDecls = mutator.get_afterDecls(); … … 104 102 try { 105 103 // run mutator on declaration 106 *i = maybeMutate( *i, mutator );104 maybeMutate_impl( *i, mutator ); 107 105 } catch( SemanticError &e ) { 108 106 e.set_location( (*i)->location ); … … 118 116 } 119 117 120 template< typename Container, typename VisitorType > 121 inline void maybeAccept( Container &container, VisitorType &visitor ) { 118 template< typename TreeType, typename pass_type > 119 inline void maybeAccept_impl( TreeType * tree, PassVisitor< pass_type > & visitor ) { 120 if ( ! visitor.get_visit_children() ) return; 121 if ( tree ) { 122 tree->accept( visitor ); 123 } 124 } 125 126 template< typename Container, typename pass_type > 127 inline void maybeAccept_impl( Container & container, PassVisitor< pass_type > & visitor ) { 128 if ( ! visitor.get_visit_children() ) return; 122 129 SemanticError errors; 123 130 for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) { … … 136 143 } 137 144 138 template< typename Container, typename MutatorType > 139 inline void maybeMutateRef( Container &container, MutatorType &mutator ) { 145 template< typename TreeType, typename pass_type > 146 inline void maybeMutate_impl( TreeType *& tree, PassVisitor< pass_type > & mutator ) { 147 if ( ! mutator.get_visit_children() ) return; 148 149 if ( tree ) { 150 tree = strict_dynamic_cast< TreeType * >( tree->acceptMutator( mutator ) ); 151 } 152 } 153 154 template< typename Container, typename pass_type > 155 inline void maybeMutate_impl( Container & container, PassVisitor< pass_type > & mutator ) { 156 if ( ! mutator.get_visit_children() ) return; 140 157 SemanticError errors; 141 158 for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) { 142 159 try { 143 160 if ( *i ) { 144 /// *i = (*i)->acceptMutator( mutator );145 161 *i = dynamic_cast< typename Container::value_type >( (*i)->acceptMutator( mutator ) ); 146 162 assert( *i ); … … 159 175 template< typename func_t > 160 176 void PassVisitor< pass_type >::handleStatementList( std::list< Statement * > & statements, func_t func ) { 177 if ( ! get_visit_children() ) return; 161 178 SemanticError errors; 162 179 … … 199 216 void PassVisitor< pass_type >::visitStatementList( std::list< Statement * > & statements ) { 200 217 handleStatementList( statements, [this]( Statement * stmt) { 201 stmt->accept(*this );218 maybeAccept_impl( stmt, *this ); 202 219 }); 203 220 } … … 206 223 void PassVisitor< pass_type >::mutateStatementList( std::list< Statement * > & statements ) { 207 224 handleStatementList( statements, [this]( Statement *& stmt) { 208 stmt = stmt->acceptMutator(*this );225 maybeMutate_impl( stmt, *this ); 209 226 }); 210 227 } … … 214 231 template< typename func_t > 215 232 Statement * PassVisitor< pass_type >::handleStatement( Statement * stmt, func_t func ) { 233 if ( ! get_visit_children() ) return stmt; 234 216 235 // don't want statements from outer CompoundStmts to be added to this CompoundStmt 217 236 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr () ); … … 244 263 Statement * PassVisitor< pass_type >::visitStatement( Statement * stmt ) { 245 264 return handleStatement( stmt, [this]( Statement * stmt ) { 246 maybeAccept ( stmt, *this );265 maybeAccept_impl( stmt, *this ); 247 266 return stmt; 248 267 }); … … 252 271 Statement * PassVisitor< pass_type >::mutateStatement( Statement * stmt ) { 253 272 return handleStatement( stmt, [this]( Statement * stmt ) { 254 return maybeMutate( stmt, *this ); 273 maybeMutate_impl( stmt, *this ); 274 return stmt; 255 275 }); 256 276 } … … 259 279 template< typename func_t > 260 280 Expression * PassVisitor< pass_type >::handleExpression( Expression * expr, func_t func ) { 281 if ( ! get_visit_children() ) return expr; 261 282 if( !expr ) return nullptr; 262 283 … … 266 287 } 267 288 268 // should env be cloned (or moved)onto the result of the mutate?289 // should env be moved onto the result of the mutate? 269 290 return func( expr ); 270 291 } … … 273 294 Expression * PassVisitor< pass_type >::visitExpression( Expression * expr ) { 274 295 return handleExpression(expr, [this]( Expression * expr ) { 275 expr->accept(*this );296 maybeAccept_impl( expr, *this ); 276 297 return expr; 277 298 }); … … 281 302 Expression * PassVisitor< pass_type >::mutateExpression( Expression * expr ) { 282 303 return handleExpression(expr, [this]( Expression * expr ) { 283 return expr->acceptMutator( *this ); 304 maybeMutate_impl( expr, *this ); 305 return expr; 284 306 }); 307 } 308 309 template< typename TreeType, typename VisitorType > 310 inline void indexerScopedAccept( TreeType * tree, VisitorType & visitor ) { 311 if ( ! visitor.get_visit_children() ) return; 312 auto guard = makeFuncGuard( 313 [&visitor]() { visitor.indexerScopeEnter(); }, 314 [&visitor]() { visitor.indexerScopeLeave(); } 315 ); 316 maybeAccept_impl( tree, visitor ); 317 } 318 319 template< typename TreeType, typename MutatorType > 320 inline void indexerScopedMutate( TreeType *& tree, MutatorType & mutator ) { 321 if ( ! mutator.get_visit_children() ) return; 322 auto guard = makeFuncGuard( 323 [&mutator]() { mutator.indexerScopeEnter(); }, 324 [&mutator]() { mutator.indexerScopeLeave(); } 325 ); 326 maybeMutate_impl( tree, mutator ); 285 327 } 286 328 … … 319 361 320 362 indexerScopedAccept( node->type , *this ); 321 maybeAccept ( node->init , *this ); 322 maybeAccept ( node->bitfieldWidth, *this ); 363 maybeAccept_impl ( node->init , *this ); 364 maybeAccept_impl ( node->bitfieldWidth, *this ); 365 maybeAccept_impl ( node->attributes , *this ); 323 366 324 367 if ( node->name != "" ) { … … 334 377 335 378 indexerScopedMutate( node->type , *this ); 336 maybeMutateRef ( node->init , *this ); 337 maybeMutateRef ( node->bitfieldWidth, *this ); 379 maybeMutate_impl ( node->init , *this ); 380 maybeMutate_impl ( node->bitfieldWidth, *this ); 381 maybeMutate_impl ( node->attributes , *this ); 338 382 339 383 if ( node->name != "" ) { … … 356 400 { 357 401 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 358 maybeAccept( node->type, *this ); 359 maybeAccept( node->statements, *this ); 402 maybeAccept_impl( node->type, *this ); 403 maybeAccept_impl( node->statements, *this ); 404 maybeAccept_impl( node->attributes, *this ); 360 405 } 361 406 … … 373 418 { 374 419 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 375 maybeMutateRef( node->type, *this ); 376 maybeMutateRef( node->statements, *this ); 420 maybeMutate_impl( node->type, *this ); 421 maybeMutate_impl( node->statements, *this ); 422 maybeMutate_impl( node->attributes, *this ); 377 423 } 378 424 … … 392 438 { 393 439 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 394 maybeAccept ( node->parameters, *this );395 maybeAccept ( node->members , *this );440 maybeAccept_impl( node->parameters, *this ); 441 maybeAccept_impl( node->members , *this ); 396 442 } 397 443 … … 412 458 { 413 459 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 414 maybeMutate Ref( node->parameters, *this );415 maybeMutate Ref( node->members , *this );460 maybeMutate_impl( node->parameters, *this ); 461 maybeMutate_impl( node->members , *this ); 416 462 } 417 463 … … 433 479 { 434 480 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 435 maybeAccept ( node->parameters, *this );436 maybeAccept ( node->members , *this );481 maybeAccept_impl( node->parameters, *this ); 482 maybeAccept_impl( node->members , *this ); 437 483 } 438 484 … … 451 497 { 452 498 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 453 maybeMutate Ref( node->parameters, *this );454 maybeMutate Ref( node->members , *this );499 maybeMutate_impl( node->parameters, *this ); 500 maybeMutate_impl( node->members , *this ); 455 501 } 456 502 … … 469 515 470 516 // unlike structs, traits, and unions, enums inject their members into the global scope 471 maybeAccept ( node->parameters, *this );472 maybeAccept ( node->members , *this );517 maybeAccept_impl( node->parameters, *this ); 518 maybeAccept_impl( node->members , *this ); 473 519 474 520 VISIT_END( node ); … … 482 528 483 529 // unlike structs, traits, and unions, enums inject their members into the global scope 484 maybeMutate Ref( node->parameters, *this );485 maybeMutate Ref( node->members , *this );530 maybeMutate_impl( node->parameters, *this ); 531 maybeMutate_impl( node->members , *this ); 486 532 487 533 MUTATE_END( Declaration, node ); … … 496 542 { 497 543 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 498 maybeAccept ( node->parameters, *this );499 maybeAccept ( node->members , *this );544 maybeAccept_impl( node->parameters, *this ); 545 maybeAccept_impl( node->members , *this ); 500 546 } 501 547 … … 511 557 { 512 558 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 513 maybeMutate Ref( node->parameters, *this );514 maybeMutate Ref( node->members , *this );559 maybeMutate_impl( node->parameters, *this ); 560 maybeMutate_impl( node->members , *this ); 515 561 } 516 562 … … 528 574 { 529 575 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 530 maybeAccept ( node->parameters, *this );531 maybeAccept ( node->base , *this );576 maybeAccept_impl( node->parameters, *this ); 577 maybeAccept_impl( node->base , *this ); 532 578 } 533 579 … … 537 583 indexerAddType( node ); 538 584 539 maybeAccept ( node->assertions, *this );585 maybeAccept_impl( node->assertions, *this ); 540 586 541 587 indexerScopedAccept( node->init, *this ); … … 550 596 { 551 597 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 552 maybeMutate Ref( node->parameters, *this );553 maybeMutate Ref( node->base , *this );598 maybeMutate_impl( node->parameters, *this ); 599 maybeMutate_impl( node->base , *this ); 554 600 } 555 601 … … 559 605 indexerAddType( node ); 560 606 561 maybeMutate Ref( node->assertions, *this );607 maybeMutate_impl( node->assertions, *this ); 562 608 563 609 indexerScopedMutate( node->init, *this ); … … 574 620 { 575 621 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 576 maybeAccept ( node->parameters, *this );577 maybeAccept ( node->base , *this );622 maybeAccept_impl( node->parameters, *this ); 623 maybeAccept_impl( node->base , *this ); 578 624 } 579 625 580 626 indexerAddType( node ); 581 627 582 maybeAccept ( node->assertions, *this );628 maybeAccept_impl( node->assertions, *this ); 583 629 584 630 VISIT_END( node ); … … 591 637 { 592 638 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 593 maybeMutate Ref( node->parameters, *this );594 maybeMutate Ref( node->base , *this );639 maybeMutate_impl( node->parameters, *this ); 640 maybeMutate_impl( node->base , *this ); 595 641 } 596 642 597 643 indexerAddType( node ); 598 644 599 maybeMutate Ref( node->assertions, *this );645 maybeMutate_impl( node->assertions, *this ); 600 646 601 647 MUTATE_END( Declaration, node ); … … 608 654 VISIT_START( node ); 609 655 610 maybeAccept ( node->stmt, *this );656 maybeAccept_impl( node->stmt, *this ); 611 657 612 658 VISIT_END( node ); … … 617 663 MUTATE_START( node ); 618 664 619 maybeMutate Ref( node->stmt, *this );665 maybeMutate_impl( node->stmt, *this ); 620 666 621 667 MUTATE_END( AsmDecl, node ); … … 686 732 // if statements introduce a level of scope (for the initialization) 687 733 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 688 acceptAll( node->get_initialization(), *this );689 visitExpression ( node->condition );734 maybeAccept_impl( node->get_initialization(), *this ); 735 visitExpression ( node->condition ); 690 736 node->thenPart = visitStatement( node->thenPart ); 691 737 node->elsePart = visitStatement( node->elsePart ); … … 700 746 // if statements introduce a level of scope (for the initialization) 701 747 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 702 maybeMutate Ref( node->get_initialization(), *this );748 maybeMutate_impl( node->get_initialization(), *this ); 703 749 node->condition = mutateExpression( node->condition ); 704 750 node->thenPart = mutateStatement ( node->thenPart ); … … 738 784 // for statements introduce a level of scope (for the initialization) 739 785 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 740 maybeAccept ( node->initialization, *this );786 maybeAccept_impl( node->initialization, *this ); 741 787 visitExpression( node->condition ); 742 788 visitExpression( node->increment ); … … 752 798 // for statements introduce a level of scope (for the initialization) 753 799 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 754 maybeMutate Ref( node->initialization, *this );800 maybeMutate_impl( node->initialization, *this ); 755 801 node->condition = mutateExpression( node->condition ); 756 802 node->increment = mutateExpression( node->increment ); … … 855 901 VISIT_START( node ); 856 902 857 maybeAccept ( node->block , *this );858 maybeAccept ( node->handlers , *this );859 maybeAccept ( node->finallyBlock, *this );903 maybeAccept_impl( node->block , *this ); 904 maybeAccept_impl( node->handlers , *this ); 905 maybeAccept_impl( node->finallyBlock, *this ); 860 906 861 907 VISIT_END( node ); … … 866 912 MUTATE_START( node ); 867 913 868 maybeMutate Ref( node->block , *this );869 maybeMutate Ref( node->handlers , *this );870 maybeMutate Ref( node->finallyBlock, *this );914 maybeMutate_impl( node->block , *this ); 915 maybeMutate_impl( node->handlers , *this ); 916 maybeMutate_impl( node->finallyBlock, *this ); 871 917 872 918 MUTATE_END( Statement, node ); … … 881 927 // catch statements introduce a level of scope (for the caught exception) 882 928 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 883 maybeAccept ( node->decl, *this );929 maybeAccept_impl( node->decl, *this ); 884 930 node->cond = visitExpression( node->cond ); 885 931 node->body = visitStatement ( node->body ); … … 894 940 // catch statements introduce a level of scope (for the caught exception) 895 941 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 896 maybeMutate Ref( node->decl, *this );942 maybeMutate_impl( node->decl, *this ); 897 943 node->cond = mutateExpression( node->cond ); 898 944 node->body = mutateStatement ( node->body ); … … 968 1014 969 1015 indexerScopedAccept( node->result , *this ); 970 maybeAccept ( node->function, *this );971 maybeAccept ( node->args , *this );1016 maybeAccept_impl ( node->function, *this ); 1017 maybeAccept_impl ( node->args , *this ); 972 1018 973 1019 VISIT_END( node ); … … 980 1026 indexerScopedMutate( node->env , *this ); 981 1027 indexerScopedMutate( node->result , *this ); 982 maybeMutate Ref( node->function, *this );983 maybeMutate Ref( node->args , *this );1028 maybeMutate_impl ( node->function, *this ); 1029 maybeMutate_impl ( node->args , *this ); 984 1030 985 1031 MUTATE_END( Expression, node ); … … 992 1038 VISIT_START( node ); 993 1039 994 // maybeAccept ( node->get_env(), *this );1040 // maybeAccept_impl( node->get_env(), *this ); 995 1041 indexerScopedAccept( node->result, *this ); 996 1042 … … 1044 1090 1045 1091 indexerScopedAccept( node->result, *this ); 1046 maybeAccept ( node->arg , *this );1092 maybeAccept_impl ( node->arg , *this ); 1047 1093 1048 1094 VISIT_END( node ); … … 1055 1101 indexerScopedMutate( node->env , *this ); 1056 1102 indexerScopedMutate( node->result, *this ); 1057 maybeMutate Ref( node->arg , *this );1103 maybeMutate_impl ( node->arg , *this ); 1058 1104 1059 1105 MUTATE_END( Expression, node ); … … 1067 1113 1068 1114 indexerScopedAccept( node->result, *this ); 1069 maybeAccept ( node->arg, *this );1115 maybeAccept_impl( node->arg, *this ); 1070 1116 1071 1117 VISIT_END( node ); … … 1078 1124 indexerScopedMutate( node->env , *this ); 1079 1125 indexerScopedMutate( node->result, *this ); 1080 maybeMutate Ref( node->arg , *this );1126 maybeMutate_impl ( node->arg , *this ); 1081 1127 1082 1128 MUTATE_END( Expression, node ); … … 1090 1136 1091 1137 indexerScopedAccept( node->result, *this ); 1092 maybeAccept 1138 maybeAccept_impl ( node->arg , *this ); 1093 1139 1094 1140 VISIT_END( node ); … … 1101 1147 indexerScopedMutate( node->env , *this ); 1102 1148 indexerScopedMutate( node->result, *this ); 1103 maybeMutate Ref( node->arg , *this );1149 maybeMutate_impl ( node->arg , *this ); 1104 1150 1105 1151 MUTATE_END( Expression, node ); … … 1134 1180 1135 1181 indexerScopedAccept( node->result , *this ); 1136 maybeAccept 1137 maybeAccept 1182 maybeAccept_impl ( node->aggregate, *this ); 1183 maybeAccept_impl ( node->member , *this ); 1138 1184 1139 1185 VISIT_END( node ); … … 1146 1192 indexerScopedMutate( node->env , *this ); 1147 1193 indexerScopedMutate( node->result , *this ); 1148 maybeMutate Ref( node->aggregate, *this );1149 maybeMutate Ref( node->member , *this );1194 maybeMutate_impl ( node->aggregate, *this ); 1195 maybeMutate_impl ( node->member , *this ); 1150 1196 1151 1197 MUTATE_END( Expression, node ); … … 1159 1205 1160 1206 indexerScopedAccept( node->result , *this ); 1161 maybeAccept 1207 maybeAccept_impl ( node->aggregate, *this ); 1162 1208 1163 1209 VISIT_END( node ); … … 1170 1216 indexerScopedMutate( node->env , *this ); 1171 1217 indexerScopedMutate( node->result , *this ); 1172 maybeMutate Ref( node->aggregate, *this );1218 maybeMutate_impl ( node->aggregate, *this ); 1173 1219 1174 1220 MUTATE_END( Expression, node ); … … 1203 1249 1204 1250 indexerScopedAccept( node->result , *this ); 1205 maybeAccept 1251 maybeAccept_impl ( &node->constant, *this ); 1206 1252 1207 1253 VISIT_END( node ); … … 1214 1260 indexerScopedMutate( node->env , *this ); 1215 1261 indexerScopedMutate( node->result, *this ); 1216 node->constant = *maybeMutate( &node->constant, *this ); 1262 Constant * ptr = &node->constant; 1263 maybeMutate_impl( ptr, *this ); 1264 node->constant = *ptr; 1217 1265 1218 1266 MUTATE_END( Expression, node ); … … 1227 1275 indexerScopedAccept( node->result, *this ); 1228 1276 if ( node->get_isType() ) { 1229 maybeAccept ( node->type, *this );1277 maybeAccept_impl( node->type, *this ); 1230 1278 } else { 1231 maybeAccept ( node->expr, *this );1279 maybeAccept_impl( node->expr, *this ); 1232 1280 } 1233 1281 … … 1242 1290 indexerScopedMutate( node->result, *this ); 1243 1291 if ( node->get_isType() ) { 1244 maybeMutate Ref( node->type, *this );1292 maybeMutate_impl( node->type, *this ); 1245 1293 } else { 1246 maybeMutate Ref( node->expr, *this );1294 maybeMutate_impl( node->expr, *this ); 1247 1295 } 1248 1296 … … 1258 1306 indexerScopedAccept( node->result, *this ); 1259 1307 if ( node->get_isType() ) { 1260 maybeAccept ( node->type, *this );1308 maybeAccept_impl( node->type, *this ); 1261 1309 } else { 1262 maybeAccept ( node->expr, *this );1310 maybeAccept_impl( node->expr, *this ); 1263 1311 } 1264 1312 … … 1273 1321 indexerScopedMutate( node->result, *this ); 1274 1322 if ( node->get_isType() ) { 1275 maybeMutate Ref( node->type, *this );1323 maybeMutate_impl( node->type, *this ); 1276 1324 } else { 1277 maybeMutate Ref( node->expr, *this );1325 maybeMutate_impl( node->expr, *this ); 1278 1326 } 1279 1327 … … 1288 1336 1289 1337 indexerScopedAccept( node->result, *this ); 1290 maybeAccept 1338 maybeAccept_impl ( node->type , *this ); 1291 1339 1292 1340 VISIT_END( node ); … … 1299 1347 indexerScopedMutate( node->env , *this ); 1300 1348 indexerScopedMutate( node->result, *this ); 1301 maybeMutate Ref( node->type , *this );1349 maybeMutate_impl ( node->type , *this ); 1302 1350 1303 1351 MUTATE_END( Expression, node ); … … 1311 1359 1312 1360 indexerScopedAccept( node->result, *this ); 1313 maybeAccept 1314 maybeAccept 1361 maybeAccept_impl ( node->type , *this ); 1362 maybeAccept_impl ( node->member, *this ); 1315 1363 1316 1364 VISIT_END( node ); … … 1323 1371 indexerScopedMutate( node->env , *this ); 1324 1372 indexerScopedMutate( node->result, *this ); 1325 maybeMutate Ref( node->type , *this );1326 maybeMutate Ref( node->member, *this );1373 maybeMutate_impl ( node->type , *this ); 1374 maybeMutate_impl ( node->member, *this ); 1327 1375 1328 1376 MUTATE_END( Expression, node ); … … 1336 1384 1337 1385 indexerScopedAccept( node->result, *this ); 1338 maybeAccept 1386 maybeAccept_impl ( node->type , *this ); 1339 1387 1340 1388 VISIT_END( node ); … … 1347 1395 indexerScopedMutate( node->env , *this ); 1348 1396 indexerScopedMutate( node->result, *this ); 1349 maybeMutate Ref( node->type , *this );1397 maybeMutate_impl ( node->type , *this ); 1350 1398 1351 1399 MUTATE_END( Expression, node ); … … 1360 1408 indexerScopedAccept( node->result, *this ); 1361 1409 if ( node->get_isType() ) { 1362 maybeAccept ( node->type, *this );1410 maybeAccept_impl( node->type, *this ); 1363 1411 } else { 1364 maybeAccept ( node->expr, *this );1412 maybeAccept_impl( node->expr, *this ); 1365 1413 } 1366 1414 … … 1375 1423 indexerScopedMutate( node->result, *this ); 1376 1424 if ( node->get_isType() ) { 1377 maybeMutate Ref( node->type, *this );1425 maybeMutate_impl( node->type, *this ); 1378 1426 } else { 1379 maybeMutate Ref( node->expr, *this );1427 maybeMutate_impl( node->expr, *this ); 1380 1428 } 1381 1429 … … 1390 1438 1391 1439 indexerScopedAccept( node->result, *this ); 1392 maybeAccept 1393 maybeAccept 1440 maybeAccept_impl ( node->arg1 , *this ); 1441 maybeAccept_impl ( node->arg2 , *this ); 1394 1442 1395 1443 VISIT_END( node ); … … 1402 1450 indexerScopedMutate( node->env , *this ); 1403 1451 indexerScopedMutate( node->result, *this ); 1404 maybeMutate Ref( node->arg1 , *this );1405 maybeMutate Ref( node->arg2 , *this );1452 maybeMutate_impl ( node->arg1 , *this ); 1453 maybeMutate_impl ( node->arg2 , *this ); 1406 1454 1407 1455 MUTATE_END( Expression, node ); … … 1415 1463 1416 1464 indexerScopedAccept( node->result, *this ); 1417 maybeAccept ( node->arg1 , *this );1418 maybeAccept ( node->arg2 , *this );1419 maybeAccept ( node->arg3 , *this );1465 maybeAccept_impl ( node->arg1 , *this ); 1466 maybeAccept_impl ( node->arg2 , *this ); 1467 maybeAccept_impl ( node->arg3 , *this ); 1420 1468 1421 1469 VISIT_END( node ); … … 1428 1476 indexerScopedMutate( node->env , *this ); 1429 1477 indexerScopedMutate( node->result, *this ); 1430 maybeMutate Ref( node->arg1 , *this );1431 maybeMutate Ref( node->arg2 , *this );1432 maybeMutate Ref( node->arg3 , *this );1478 maybeMutate_impl ( node->arg1 , *this ); 1479 maybeMutate_impl ( node->arg2 , *this ); 1480 maybeMutate_impl ( node->arg3 , *this ); 1433 1481 1434 1482 MUTATE_END( Expression, node ); … … 1442 1490 1443 1491 indexerScopedAccept( node->result, *this ); 1444 maybeAccept 1445 maybeAccept 1492 maybeAccept_impl ( node->arg1 , *this ); 1493 maybeAccept_impl ( node->arg2 , *this ); 1446 1494 1447 1495 VISIT_END( node ); … … 1454 1502 indexerScopedMutate( node->env , *this ); 1455 1503 indexerScopedMutate( node->result, *this ); 1456 maybeMutate Ref( node->arg1 , *this );1457 maybeMutate Ref( node->arg2 , *this );1504 maybeMutate_impl ( node->arg1 , *this ); 1505 maybeMutate_impl ( node->arg2 , *this ); 1458 1506 1459 1507 MUTATE_END( Expression, node ); … … 1467 1515 1468 1516 indexerScopedAccept( node->result, *this ); 1469 maybeAccept 1517 maybeAccept_impl ( node->type, *this ); 1470 1518 1471 1519 VISIT_END( node ); … … 1478 1526 indexerScopedMutate( node->env , *this ); 1479 1527 indexerScopedMutate( node->result, *this ); 1480 maybeMutate Ref( node->type , *this );1528 maybeMutate_impl ( node->type , *this ); 1481 1529 1482 1530 MUTATE_END( Expression, node ); … … 1490 1538 1491 1539 indexerScopedAccept( node->result , *this ); 1492 maybeAccept 1493 maybeAccept 1494 maybeAccept 1540 maybeAccept_impl ( node->inout , *this ); 1541 maybeAccept_impl ( node->constraint, *this ); 1542 maybeAccept_impl ( node->operand , *this ); 1495 1543 1496 1544 VISIT_END( node ); … … 1503 1551 indexerScopedMutate( node->env , *this ); 1504 1552 indexerScopedMutate( node->result , *this ); 1505 maybeMutate Ref( node->inout , *this );1506 maybeMutate Ref( node->constraint, *this );1507 maybeMutate Ref( node->operand , *this );1553 maybeMutate_impl ( node->inout , *this ); 1554 maybeMutate_impl ( node->constraint, *this ); 1555 maybeMutate_impl ( node->operand , *this ); 1508 1556 1509 1557 MUTATE_END( Expression, node ); … … 1517 1565 1518 1566 indexerScopedAccept( node->result , *this ); 1519 maybeAccept 1520 maybeAccept 1521 maybeAccept 1522 maybeAccept 1567 maybeAccept_impl ( node->callExpr , *this ); 1568 maybeAccept_impl ( node->tempDecls , *this ); 1569 maybeAccept_impl ( node->returnDecls, *this ); 1570 maybeAccept_impl ( node->dtors , *this ); 1523 1571 1524 1572 VISIT_END( node ); … … 1531 1579 indexerScopedMutate( node->env , *this ); 1532 1580 indexerScopedMutate( node->result , *this ); 1533 maybeMutate Ref( node->callExpr , *this );1534 maybeMutate Ref( node->tempDecls , *this );1535 maybeMutate Ref( node->returnDecls, *this );1536 maybeMutate Ref( node->dtors , *this );1581 maybeMutate_impl ( node->callExpr , *this ); 1582 maybeMutate_impl ( node->tempDecls , *this ); 1583 maybeMutate_impl ( node->returnDecls, *this ); 1584 maybeMutate_impl ( node->dtors , *this ); 1537 1585 1538 1586 MUTATE_END( Expression, node ); … … 1546 1594 1547 1595 indexerScopedAccept( node->result , *this ); 1548 maybeAccept 1596 maybeAccept_impl ( node->callExpr, *this ); 1549 1597 1550 1598 VISIT_END( node ); … … 1557 1605 indexerScopedMutate( node->env , *this ); 1558 1606 indexerScopedMutate( node->result , *this ); 1559 maybeMutate Ref( node->callExpr, *this );1607 maybeMutate_impl ( node->callExpr, *this ); 1560 1608 1561 1609 MUTATE_END( Expression, node ); … … 1569 1617 1570 1618 indexerScopedAccept( node->result , *this ); 1571 maybeAccept 1619 maybeAccept_impl ( node->initializer, *this ); 1572 1620 1573 1621 VISIT_END( node ); … … 1580 1628 indexerScopedMutate( node->env , *this ); 1581 1629 indexerScopedMutate( node->result , *this ); 1582 maybeMutate Ref( node->initializer, *this );1630 maybeMutate_impl ( node->initializer, *this ); 1583 1631 1584 1632 MUTATE_END( Expression, node ); … … 1592 1640 1593 1641 indexerScopedAccept( node->result, *this ); 1594 maybeAccept 1595 maybeAccept 1642 maybeAccept_impl ( node->low , *this ); 1643 maybeAccept_impl ( node->high , *this ); 1596 1644 1597 1645 VISIT_END( node ); … … 1604 1652 indexerScopedMutate( node->env , *this ); 1605 1653 indexerScopedMutate( node->result, *this ); 1606 maybeMutate Ref( node->low , *this );1607 maybeMutate Ref( node->high , *this );1654 maybeMutate_impl ( node->low , *this ); 1655 maybeMutate_impl ( node->high , *this ); 1608 1656 1609 1657 MUTATE_END( Expression, node ); … … 1617 1665 1618 1666 indexerScopedAccept( node->result, *this ); 1619 maybeAccept 1667 maybeAccept_impl ( node->exprs , *this ); 1620 1668 1621 1669 VISIT_END( node ); … … 1628 1676 indexerScopedMutate( node->env , *this ); 1629 1677 indexerScopedMutate( node->result, *this ); 1630 maybeMutate Ref( node->exprs , *this );1678 maybeMutate_impl ( node->exprs , *this ); 1631 1679 1632 1680 MUTATE_END( Expression, node ); … … 1640 1688 1641 1689 indexerScopedAccept( node->result, *this ); 1642 maybeAccept 1690 maybeAccept_impl ( node->exprs , *this ); 1643 1691 1644 1692 VISIT_END( node ); … … 1651 1699 indexerScopedMutate( node->env , *this ); 1652 1700 indexerScopedMutate( node->result, *this ); 1653 maybeMutate Ref( node->exprs , *this );1701 maybeMutate_impl ( node->exprs , *this ); 1654 1702 1655 1703 MUTATE_END( Expression, node ); … … 1663 1711 1664 1712 indexerScopedAccept( node->result, *this ); 1665 maybeAccept 1713 maybeAccept_impl ( node->tuple , *this ); 1666 1714 1667 1715 VISIT_END( node ); … … 1674 1722 indexerScopedMutate( node->env , *this ); 1675 1723 indexerScopedMutate( node->result, *this ); 1676 maybeMutate Ref( node->tuple , *this );1724 maybeMutate_impl ( node->tuple , *this ); 1677 1725 1678 1726 MUTATE_END( Expression, node ); … … 1686 1734 1687 1735 indexerScopedAccept( node->result , *this ); 1688 maybeAccept 1736 maybeAccept_impl ( node->stmtExpr, *this ); 1689 1737 1690 1738 VISIT_END( node ); … … 1697 1745 indexerScopedMutate( node->env , *this ); 1698 1746 indexerScopedMutate( node->result , *this ); 1699 maybeMutate Ref( node->stmtExpr, *this );1747 maybeMutate_impl ( node->stmtExpr, *this ); 1700 1748 1701 1749 MUTATE_END( Expression, node ); … … 1714 1762 1715 1763 indexerScopedAccept( node->result , *this ); 1716 maybeAccept 1717 maybeAccept 1718 maybeAccept 1764 maybeAccept_impl ( node->statements , *this ); 1765 maybeAccept_impl ( node->returnDecls, *this ); 1766 maybeAccept_impl ( node->dtors , *this ); 1719 1767 1720 1768 VISIT_END( node ); … … 1731 1779 1732 1780 indexerScopedMutate( node->result , *this ); 1733 maybeMutate Ref( node->statements , *this );1734 maybeMutate Ref( node->returnDecls, *this );1735 maybeMutate Ref( node->dtors , *this );1781 maybeMutate_impl ( node->statements , *this ); 1782 maybeMutate_impl ( node->returnDecls, *this ); 1783 maybeMutate_impl ( node->dtors , *this ); 1736 1784 1737 1785 MUTATE_END( Expression, node ); … … 1745 1793 1746 1794 indexerScopedAccept( node->result, *this ); 1747 maybeAccept 1795 maybeAccept_impl ( node->expr , *this ); 1748 1796 1749 1797 VISIT_END( node ); … … 1756 1804 indexerScopedMutate( node->env , *this ); 1757 1805 indexerScopedMutate( node->result, *this ); 1758 maybeMutate Ref( node->expr , *this );1806 maybeMutate_impl ( node->expr , *this ); 1759 1807 1760 1808 MUTATE_END( Expression, node ); … … 1801 1849 { 1802 1850 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 1803 maybeAccept ( node->forall , *this );1804 maybeAccept ( node->parameters, *this );1851 maybeAccept_impl( node->forall , *this ); 1852 maybeAccept_impl( node->parameters, *this ); 1805 1853 } 1806 1854 … … 1816 1864 { 1817 1865 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 1818 maybeMutate Ref( node->forall , *this );1819 maybeMutate Ref( node->parameters, *this );1866 maybeMutate_impl( node->forall , *this ); 1867 maybeMutate_impl( node->parameters, *this ); 1820 1868 } 1821 1869 … … 1833 1881 { 1834 1882 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 1835 maybeAccept ( node->forall , *this );1836 maybeAccept ( node->parameters, *this );1883 maybeAccept_impl( node->forall , *this ); 1884 maybeAccept_impl( node->parameters, *this ); 1837 1885 } 1838 1886 … … 1848 1896 { 1849 1897 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } ); 1850 maybeMutate Ref( node->forall , *this );1851 maybeMutate Ref( node->parameters, *this );1898 maybeMutate_impl( node->forall , *this ); 1899 maybeMutate_impl( node->parameters, *this ); 1852 1900 } 1853 1901 … … 1873 1921 VISIT_START( node ); 1874 1922 1875 maybeAccept ( node->forall , *this );1876 maybeAccept ( node->parameters, *this );1923 maybeAccept_impl( node->forall , *this ); 1924 maybeAccept_impl( node->parameters, *this ); 1877 1925 1878 1926 VISIT_END( node ); … … 1883 1931 MUTATE_START( node ); 1884 1932 1885 maybeMutate Ref( node->forall , *this );1886 maybeMutate Ref( node->parameters, *this );1933 maybeMutate_impl( node->forall , *this ); 1934 maybeMutate_impl( node->parameters, *this ); 1887 1935 1888 1936 MUTATE_END( Type, node ); … … 1930 1978 VISIT_START( node ); 1931 1979 1932 maybeAccept ( node->get_designators(), *this );1980 maybeAccept_impl( node->get_designators(), *this ); 1933 1981 1934 1982 VISIT_END( node ); … … 1939 1987 MUTATE_START( node ); 1940 1988 1941 maybeMutate Ref( node->get_designators(), *this );1989 maybeMutate_impl( node->get_designators(), *this ); 1942 1990 1943 1991 MUTATE_END( Designation, node ); … … 1981 2029 template< typename pass_type > 1982 2030 void PassVisitor< pass_type >::visit( Constant * node ) { 2031 VISIT_BODY( node ); 2032 } 2033 2034 template< typename pass_type > 2035 void PassVisitor< pass_type >::visit( Attribute * node ) { 1983 2036 VISIT_BODY( node ); 1984 2037 } … … 2069 2122 MUTATE_BODY( Constant, node ); 2070 2123 } 2124 2125 template< typename pass_type > 2126 Attribute * PassVisitor< pass_type >::mutate( Attribute * node ) { 2127 MUTATE_BODY( Attribute, node ); 2128 } 2129 2130 template< typename pass_type > 2131 TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) { 2132 MUTATE_START( node ); 2133 2134 for ( auto & p : node->typeEnv ) { 2135 indexerScopedMutate( p.second, *this ); 2136 } 2137 for ( auto & p : node->varEnv ) { 2138 indexerScopedMutate( p.second, *this ); 2139 } 2140 2141 MUTATE_END( TypeSubstitution, node ); 2142 }
Note:
See TracChangeset
for help on using the changeset viewer.