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