Changes in src/AST/Pass.impl.hpp [3e5dd913:665f432]
- File:
-
- 1 edited
-
src/AST/Pass.impl.hpp (modified) (124 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Pass.impl.hpp
r3e5dd913 r665f432 20 20 #include <unordered_map> 21 21 22 #include "AST/TranslationUnit.hpp"23 22 #include "AST/TypeSubstitution.hpp" 24 23 … … 26 25 using namespace ast; \ 27 26 /* back-up the visit children */ \ 28 __attribute__((unused)) ast::__pass::visit_children_guard guard1( ast::__pass::visit_children( core, 0) ); \27 __attribute__((unused)) ast::__pass::visit_children_guard guard1( ast::__pass::visit_children(pass, 0) ); \ 29 28 /* setup the scope for passes that want to run code at exit */ \ 30 __attribute__((unused)) ast::__pass::guard_value guard2( ast::__pass::at_cleanup (core, 0) ); \ 31 /* begin tracing memory allocation if requested by this pass */ \ 32 __pass::beginTrace( core, 0 ); \ 29 __attribute__((unused)) ast::__pass::guard_value guard2( ast::__pass::at_cleanup (pass, 0) ); \ 33 30 /* call the implementation of the previsit of this pass */ \ 34 __pass::previsit( core, node, 0 );31 __pass::previsit( pass, node, 0 ); 35 32 36 33 #define VISIT( code... ) \ … … 43 40 #define VISIT_END( type, node ) \ 44 41 /* call the implementation of the postvisit of this pass */ \ 45 auto __return = __pass::postvisit( core, node, 0 ); \42 auto __return = __pass::postvisit( pass, node, 0 ); \ 46 43 assertf(__return, "post visit should never return null"); \ 47 /* end tracing memory allocation if requested by this pass */ \48 __pass::endTrace( core, 0 ); \49 44 return __return; 50 45 … … 58 53 59 54 namespace ast { 60 template<typename node_t>61 node_t * shallowCopy( const node_t * node );62 63 55 namespace __pass { 64 56 // Check if this is either a null pointer or a pointer to an empty container … … 68 60 } 69 61 70 template< typename core_t, typename node_t >71 static inline node_t* mutate(const node_t *node) {72 return std::is_base_of<PureVisitor, core_t>::value ? ::ast::shallowCopy(node) : ::ast::mutate(node);73 }74 75 62 //------------------------------ 76 63 template<typename it_t, template <class...> class container_t> … … 132 119 } 133 120 134 template< typename core_t >121 template< typename pass_t > 135 122 template< typename node_t > 136 auto ast::Pass< core_t >::call_accept( const node_t * node )123 auto ast::Pass< pass_t >::call_accept( const node_t * node ) 137 124 -> typename std::enable_if< 138 125 !std::is_base_of<ast::Expr, node_t>::value && … … 140 127 , decltype( node->accept(*this) ) 141 128 >::type 129 142 130 { 143 131 __pedantic_pass_assert( __visit_children() ); 144 __pedantic_pass_assert( node);132 __pedantic_pass_assert( expr ); 145 133 146 134 static_assert( !std::is_base_of<ast::Expr, node_t>::value, "ERROR"); … … 150 138 } 151 139 152 template< typename core_t >153 const ast::Expr * ast::Pass< core_t >::call_accept( const ast::Expr * expr ) {140 template< typename pass_t > 141 const ast::Expr * ast::Pass< pass_t >::call_accept( const ast::Expr * expr ) { 154 142 __pedantic_pass_assert( __visit_children() ); 155 143 __pedantic_pass_assert( expr ); 156 144 157 const ast::TypeSubstitution ** typeSubs_ptr = __pass::typeSubs( core, 0);158 if ( typeSubs_ptr && expr->env ) {159 * typeSubs_ptr = expr->env;145 const ast::TypeSubstitution ** env_ptr = __pass::env( pass, 0); 146 if ( env_ptr && expr->env ) { 147 *env_ptr = expr->env; 160 148 } 161 149 … … 163 151 } 164 152 165 template< typename core_t >166 const ast::Stmt * ast::Pass< core_t >::call_accept( const ast::Stmt * stmt ) {153 template< typename pass_t > 154 const ast::Stmt * ast::Pass< pass_t >::call_accept( const ast::Stmt * stmt ) { 167 155 __pedantic_pass_assert( __visit_children() ); 168 156 __pedantic_pass_assert( stmt ); 169 157 170 return stmt->accept( *this );171 }172 173 template< typename core_t >174 const ast::Stmt * ast::Pass< core_t >::call_accept_as_compound( const ast::Stmt * stmt ) {175 __pedantic_pass_assert( __visit_children() );176 __pedantic_pass_assert( stmt );177 178 158 // add a few useful symbols to the scope 179 159 using __pass::empty; 180 160 181 161 // get the stmts/decls that will need to be spliced in 182 auto stmts_before = __pass::stmtsToAddBefore( core, 0);183 auto stmts_after = __pass::stmtsToAddAfter ( core, 0);184 auto decls_before = __pass::declsToAddBefore( core, 0);185 auto decls_after = __pass::declsToAddAfter ( core, 0);162 auto stmts_before = __pass::stmtsToAddBefore( pass, 0); 163 auto stmts_after = __pass::stmtsToAddAfter ( pass, 0); 164 auto decls_before = __pass::declsToAddBefore( pass, 0); 165 auto decls_after = __pass::declsToAddAfter ( pass, 0); 186 166 187 167 // These may be modified by subnode but most be restored once we exit this statemnet. 188 ValueGuardPtr< const ast::TypeSubstitution * > __old_env ( __pass:: typeSubs( core, 0) );168 ValueGuardPtr< const ast::TypeSubstitution * > __old_env ( __pass::env( pass, 0) ); 189 169 ValueGuardPtr< typename std::remove_pointer< decltype(stmts_before) >::type > __old_decls_before( stmts_before ); 190 170 ValueGuardPtr< typename std::remove_pointer< decltype(stmts_after ) >::type > __old_decls_after ( stmts_after ); … … 222 202 } 223 203 224 template< typename core_t >204 template< typename pass_t > 225 205 template< template <class...> class container_t > 226 container_t< ptr<Stmt> > ast::Pass< core_t >::call_accept( const container_t< ptr<Stmt> > & statements ) {206 container_t< ptr<Stmt> > ast::Pass< pass_t >::call_accept( const container_t< ptr<Stmt> > & statements ) { 227 207 __pedantic_pass_assert( __visit_children() ); 228 208 if( statements.empty() ) return {}; … … 235 215 236 216 // get the stmts/decls that will need to be spliced in 237 auto stmts_before = __pass::stmtsToAddBefore( core, 0);238 auto stmts_after = __pass::stmtsToAddAfter ( core, 0);239 auto decls_before = __pass::declsToAddBefore( core, 0);240 auto decls_after = __pass::declsToAddAfter ( core, 0);217 auto stmts_before = __pass::stmtsToAddBefore( pass, 0); 218 auto stmts_after = __pass::stmtsToAddAfter ( pass, 0); 219 auto decls_before = __pass::declsToAddBefore( pass, 0); 220 auto decls_after = __pass::declsToAddAfter ( pass, 0); 241 221 242 222 // These may be modified by subnode but most be restored once we exit this statemnet. … … 288 268 } 289 269 290 template< typename core_t >270 template< typename pass_t > 291 271 template< template <class...> class container_t, typename node_t > 292 container_t< ast::ptr<node_t> > ast::Pass< core_t >::call_accept( const container_t< ast::ptr<node_t> > & container ) {272 container_t< ast::ptr<node_t> > ast::Pass< pass_t >::call_accept( const container_t< ast::ptr<node_t> > & container ) { 293 273 __pedantic_pass_assert( __visit_children() ); 294 274 if( container.empty() ) return {}; … … 319 299 } 320 300 321 template< typename core_t >301 template< typename pass_t > 322 302 template<typename node_t, typename parent_t, typename child_t> 323 void ast::Pass< core_t >::maybe_accept(303 void ast::Pass< pass_t >::maybe_accept( 324 304 const node_t * & parent, 325 305 child_t parent_t::*child … … 337 317 338 318 if( __pass::differs(old_val, new_val) ) { 339 auto new_parent = __pass::mutate<core_t>(parent); 340 new_parent->*child = new_val; 341 parent = new_parent; 342 } 343 } 344 345 template< typename core_t > 346 template<typename node_t, typename parent_t, typename child_t> 347 void ast::Pass< core_t >::maybe_accept_as_compound( 348 const node_t * & parent, 349 child_t parent_t::*child 350 ) { 351 static_assert( std::is_base_of<parent_t, node_t>::value, "Error deducing member object" ); 352 353 if(__pass::skip(parent->*child)) return; 354 const auto & old_val = __pass::get(parent->*child, 0); 355 356 static_assert( !std::is_same<const ast::Node * &, decltype(old_val)>::value, "ERROR"); 357 358 auto new_val = call_accept_as_compound( old_val ); 359 360 static_assert( !std::is_same<const ast::Node *, decltype(new_val)>::value || std::is_same<int, decltype(old_val)>::value, "ERROR"); 361 362 if( __pass::differs(old_val, new_val) ) { 363 auto new_parent = __pass::mutate<core_t>(parent); 319 auto new_parent = mutate(parent); 364 320 new_parent->*child = new_val; 365 321 parent = new_parent; … … 377 333 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 378 334 379 template< typename core_t >380 inline void ast::accept_all( std::list< ast::ptr<ast::Decl> > & decls, ast::Pass< core_t > & visitor ) {335 template< typename pass_t > 336 inline void ast::accept_all( std::list< ast::ptr<ast::Decl> > & decls, ast::Pass< pass_t > & visitor ) { 381 337 // We are going to aggregate errors for all these statements 382 338 SemanticErrorException errors; … … 386 342 387 343 // get the stmts/decls that will need to be spliced in 388 auto decls_before = __pass::declsToAddBefore( visitor. core, 0);389 auto decls_after = __pass::declsToAddAfter ( visitor. core, 0);344 auto decls_before = __pass::declsToAddBefore( visitor.pass, 0); 345 auto decls_after = __pass::declsToAddAfter ( visitor.pass, 0); 390 346 391 347 // update pass statitistics … … 407 363 } 408 364 catch( SemanticErrorException &e ) { 409 if (__pass::on_error (visitor.core, *i, 0)) 410 errors.append( e ); 365 errors.append( e ); 411 366 } 412 367 … … 416 371 pass_visitor_stats.depth--; 417 372 if ( !errors.isEmpty() ) { throw errors; } 418 }419 420 template< typename core_t >421 inline void ast::accept_all( ast::TranslationUnit & unit, ast::Pass< core_t > & visitor ) {422 return ast::accept_all( unit.decls, visitor );423 373 } 424 374 … … 442 392 //-------------------------------------------------------------------------- 443 393 // ObjectDecl 444 template< typename core_t >445 const ast::DeclWithType * ast::Pass< core_t >::visit( const ast::ObjectDecl * node ) {394 template< typename pass_t > 395 const ast::DeclWithType * ast::Pass< pass_t >::visit( const ast::ObjectDecl * node ) { 446 396 VISIT_START( node ); 447 397 … … 456 406 ) 457 407 458 __pass::symtab::addId( core, 0, node );408 __pass::symtab::addId( pass, 0, node ); 459 409 460 410 VISIT_END( DeclWithType, node ); … … 463 413 //-------------------------------------------------------------------------- 464 414 // FunctionDecl 465 template< typename core_t >466 const ast::DeclWithType * ast::Pass< core_t >::visit( const ast::FunctionDecl * node ) {467 VISIT_START( node ); 468 469 __pass::symtab::addId( core, 0, node );415 template< typename pass_t > 416 const ast::DeclWithType * ast::Pass< pass_t >::visit( const ast::FunctionDecl * node ) { 417 VISIT_START( node ); 418 419 __pass::symtab::addId( pass, 0, node ); 470 420 471 421 VISIT(maybe_accept( node, &FunctionDecl::withExprs );) … … 475 425 // shadow with exprs and not the other way around. 476 426 guard_symtab guard { *this }; 477 __pass::symtab::addWith( core, 0, node->withExprs, node );427 __pass::symtab::addWith( pass, 0, node->withExprs, node ); 478 428 { 479 429 guard_symtab guard { *this }; 480 430 // implicit add __func__ identifier as specified in the C manual 6.4.2.2 481 static ast:: ptr< ast::ObjectDecl > func{ new ast::ObjectDecl{482 CodeLocation{}, "__func__",483 new ast::ArrayType {484 new ast::BasicType { ast::BasicType::Char, ast::CV::Const },431 static ast::ObjectDecl func( 432 node->location, "__func__", 433 new ast::ArrayType( 434 new ast::BasicType( ast::BasicType::Char, ast::CV::Qualifiers( ast::CV::Const ) ), 485 435 nullptr, VariableLen, DynamicDim 486 }487 } };488 __pass::symtab::addId( core, 0,func );436 ) 437 ); 438 __pass::symtab::addId( pass, 0, &func ); 489 439 VISIT( 490 // parameter declarations 491 maybe_accept( node, &FunctionDecl::params ); 492 maybe_accept( node, &FunctionDecl::returns ); 493 // type params and assertions 494 maybe_accept( node, &FunctionDecl::type_params ); 495 maybe_accept( node, &FunctionDecl::assertions ); 496 // First remember that we are now within a function. 440 maybe_accept( node, &FunctionDecl::type ); 441 // function body needs to have the same scope as parameters - CompoundStmt will not enter 442 // a new scope if inFunction is true 497 443 ValueGuard< bool > oldInFunction( inFunction ); 498 444 inFunction = true; 499 // The function body needs to have the same scope as parameters.500 // A CompoundStmt will not enter a new scope if atFunctionTop is true.501 ValueGuard< bool > oldAtFunctionTop( atFunctionTop );502 atFunctionTop = true;503 445 maybe_accept( node, &FunctionDecl::stmts ); 504 446 maybe_accept( node, &FunctionDecl::attributes ); … … 512 454 //-------------------------------------------------------------------------- 513 455 // StructDecl 514 template< typename core_t >515 const ast::Decl * ast::Pass< core_t >::visit( const ast::StructDecl * node ) {456 template< typename pass_t > 457 const ast::Decl * ast::Pass< pass_t >::visit( const ast::StructDecl * node ) { 516 458 VISIT_START( node ); 517 459 518 460 // make up a forward declaration and add it before processing the members 519 461 // needs to be on the heap because addStruct saves the pointer 520 __pass::symtab::addStructFwd( core, 0, node );462 __pass::symtab::addStructFwd( pass, 0, node ); 521 463 522 464 VISIT({ … … 527 469 528 470 // this addition replaces the forward declaration 529 __pass::symtab::addStruct( core, 0, node );471 __pass::symtab::addStruct( pass, 0, node ); 530 472 531 473 VISIT_END( Decl, node ); … … 534 476 //-------------------------------------------------------------------------- 535 477 // UnionDecl 536 template< typename core_t >537 const ast::Decl * ast::Pass< core_t >::visit( const ast::UnionDecl * node ) {478 template< typename pass_t > 479 const ast::Decl * ast::Pass< pass_t >::visit( const ast::UnionDecl * node ) { 538 480 VISIT_START( node ); 539 481 540 482 // make up a forward declaration and add it before processing the members 541 __pass::symtab::addUnionFwd( core, 0, node );483 __pass::symtab::addUnionFwd( pass, 0, node ); 542 484 543 485 VISIT({ … … 547 489 }) 548 490 549 __pass::symtab::addUnion( core, 0, node );491 __pass::symtab::addUnion( pass, 0, node ); 550 492 551 493 VISIT_END( Decl, node ); … … 554 496 //-------------------------------------------------------------------------- 555 497 // EnumDecl 556 template< typename core_t >557 const ast::Decl * ast::Pass< core_t >::visit( const ast::EnumDecl * node ) {558 VISIT_START( node ); 559 560 __pass::symtab::addEnum( core, 0, node );498 template< typename pass_t > 499 const ast::Decl * ast::Pass< pass_t >::visit( const ast::EnumDecl * node ) { 500 VISIT_START( node ); 501 502 __pass::symtab::addEnum( pass, 0, node ); 561 503 562 504 VISIT( … … 571 513 //-------------------------------------------------------------------------- 572 514 // TraitDecl 573 template< typename core_t >574 const ast::Decl * ast::Pass< core_t >::visit( const ast::TraitDecl * node ) {515 template< typename pass_t > 516 const ast::Decl * ast::Pass< pass_t >::visit( const ast::TraitDecl * node ) { 575 517 VISIT_START( node ); 576 518 … … 581 523 }) 582 524 583 __pass::symtab::addTrait( core, 0, node );525 __pass::symtab::addTrait( pass, 0, node ); 584 526 585 527 VISIT_END( Decl, node ); … … 588 530 //-------------------------------------------------------------------------- 589 531 // TypeDecl 590 template< typename core_t >591 const ast::Decl * ast::Pass< core_t >::visit( const ast::TypeDecl * node ) {532 template< typename pass_t > 533 const ast::Decl * ast::Pass< pass_t >::visit( const ast::TypeDecl * node ) { 592 534 VISIT_START( node ); 593 535 594 536 VISIT({ 595 537 guard_symtab guard { *this }; 538 maybe_accept( node, &TypeDecl::params ); 596 539 maybe_accept( node, &TypeDecl::base ); 597 540 }) … … 600 543 // note that assertions come after the type is added to the symtab, since they are not part of the type proper 601 544 // and may depend on the type itself 602 __pass::symtab::addType( core, 0, node );545 __pass::symtab::addType( pass, 0, node ); 603 546 604 547 VISIT( … … 616 559 //-------------------------------------------------------------------------- 617 560 // TypedefDecl 618 template< typename core_t >619 const ast::Decl * ast::Pass< core_t >::visit( const ast::TypedefDecl * node ) {561 template< typename pass_t > 562 const ast::Decl * ast::Pass< pass_t >::visit( const ast::TypedefDecl * node ) { 620 563 VISIT_START( node ); 621 564 622 565 VISIT({ 623 566 guard_symtab guard { *this }; 567 maybe_accept( node, &TypedefDecl::params ); 624 568 maybe_accept( node, &TypedefDecl::base ); 625 569 }) 626 570 627 __pass::symtab::addType( core, 0, node );571 __pass::symtab::addType( pass, 0, node ); 628 572 629 573 VISIT( maybe_accept( node, &TypedefDecl::assertions ); ) … … 634 578 //-------------------------------------------------------------------------- 635 579 // AsmDecl 636 template< typename core_t >637 const ast::AsmDecl * ast::Pass< core_t >::visit( const ast::AsmDecl * node ) {580 template< typename pass_t > 581 const ast::AsmDecl * ast::Pass< pass_t >::visit( const ast::AsmDecl * node ) { 638 582 VISIT_START( node ); 639 583 … … 647 591 //-------------------------------------------------------------------------- 648 592 // StaticAssertDecl 649 template< typename core_t >650 const ast::StaticAssertDecl * ast::Pass< core_t >::visit( const ast::StaticAssertDecl * node ) {593 template< typename pass_t > 594 const ast::StaticAssertDecl * ast::Pass< pass_t >::visit( const ast::StaticAssertDecl * node ) { 651 595 VISIT_START( node ); 652 596 … … 661 605 //-------------------------------------------------------------------------- 662 606 // CompoundStmt 663 template< typename core_t > 664 const ast::CompoundStmt * ast::Pass< core_t >::visit( const ast::CompoundStmt * node ) { 665 VISIT_START( node ); 666 VISIT( 667 // Do not enter (or leave) a new scope if atFunctionTop. Remember to save the result. 668 auto guard1 = makeFuncGuard( [this, enterScope = !this->atFunctionTop]() { 669 if ( enterScope ) { 670 __pass::symtab::enter(core, 0); 671 __pass::scope::enter(core, 0); 672 } 673 }, [this, leaveScope = !this->atFunctionTop]() { 674 if ( leaveScope ) { 675 __pass::symtab::leave(core, 0); 676 __pass::scope::leave(core, 0); 677 } 607 template< typename pass_t > 608 const ast::CompoundStmt * ast::Pass< pass_t >::visit( const ast::CompoundStmt * node ) { 609 VISIT_START( node ); 610 VISIT({ 611 // do not enter a new scope if inFunction is true - needs to check old state before the assignment 612 auto guard1 = makeFuncGuard( [this, inFunction = this->inFunction]() { 613 if ( ! inFunction ) __pass::symtab::enter(pass, 0); 614 }, [this, inFunction = this->inFunction]() { 615 if ( ! inFunction ) __pass::symtab::leave(pass, 0); 678 616 }); 679 ValueGuard< bool > guard2( atFunctionTop ); 680 atFunctionTop = false; 617 ValueGuard< bool > guard2( inFunction ); 681 618 guard_scope guard3 { *this }; 619 inFunction = false; 682 620 maybe_accept( node, &CompoundStmt::kids ); 683 )621 }) 684 622 VISIT_END( CompoundStmt, node ); 685 623 } … … 687 625 //-------------------------------------------------------------------------- 688 626 // ExprStmt 689 template< typename core_t >690 const ast::Stmt * ast::Pass< core_t >::visit( const ast::ExprStmt * node ) {627 template< typename pass_t > 628 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::ExprStmt * node ) { 691 629 VISIT_START( node ); 692 630 … … 700 638 //-------------------------------------------------------------------------- 701 639 // AsmStmt 702 template< typename core_t >703 const ast::Stmt * ast::Pass< core_t >::visit( const ast::AsmStmt * node ) {640 template< typename pass_t > 641 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::AsmStmt * node ) { 704 642 VISIT_START( node ) 705 643 … … 716 654 //-------------------------------------------------------------------------- 717 655 // DirectiveStmt 718 template< typename core_t >719 const ast::Stmt * ast::Pass< core_t >::visit( const ast::DirectiveStmt * node ) {656 template< typename pass_t > 657 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::DirectiveStmt * node ) { 720 658 VISIT_START( node ) 721 659 … … 725 663 //-------------------------------------------------------------------------- 726 664 // IfStmt 727 template< typename core_t >728 const ast::Stmt * ast::Pass< core_t >::visit( const ast::IfStmt * node ) {665 template< typename pass_t > 666 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::IfStmt * node ) { 729 667 VISIT_START( node ); 730 668 … … 734 672 maybe_accept( node, &IfStmt::inits ); 735 673 maybe_accept( node, &IfStmt::cond ); 736 maybe_accept _as_compound( node, &IfStmt::thenPart );737 maybe_accept _as_compound( node, &IfStmt::elsePart );674 maybe_accept( node, &IfStmt::thenPart ); 675 maybe_accept( node, &IfStmt::elsePart ); 738 676 }) 739 677 … … 743 681 //-------------------------------------------------------------------------- 744 682 // WhileStmt 745 template< typename core_t >746 const ast::Stmt * ast::Pass< core_t >::visit( const ast::WhileStmt * node ) {683 template< typename pass_t > 684 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::WhileStmt * node ) { 747 685 VISIT_START( node ); 748 686 … … 752 690 maybe_accept( node, &WhileStmt::inits ); 753 691 maybe_accept( node, &WhileStmt::cond ); 754 maybe_accept _as_compound( node, &WhileStmt::body );692 maybe_accept( node, &WhileStmt::body ); 755 693 }) 756 694 … … 760 698 //-------------------------------------------------------------------------- 761 699 // ForStmt 762 template< typename core_t >763 const ast::Stmt * ast::Pass< core_t >::visit( const ast::ForStmt * node ) {700 template< typename pass_t > 701 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::ForStmt * node ) { 764 702 VISIT_START( node ); 765 703 … … 767 705 // for statements introduce a level of scope (for the initialization) 768 706 guard_symtab guard { *this }; 769 // xxx - old ast does not create WithStmtsToAdd scope for loop inits. should revisit this later.770 707 maybe_accept( node, &ForStmt::inits ); 771 708 maybe_accept( node, &ForStmt::cond ); 772 709 maybe_accept( node, &ForStmt::inc ); 773 maybe_accept _as_compound( node, &ForStmt::body );710 maybe_accept( node, &ForStmt::body ); 774 711 }) 775 712 … … 779 716 //-------------------------------------------------------------------------- 780 717 // SwitchStmt 781 template< typename core_t >782 const ast::Stmt * ast::Pass< core_t >::visit( const ast::SwitchStmt * node ) {718 template< typename pass_t > 719 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::SwitchStmt * node ) { 783 720 VISIT_START( node ); 784 721 … … 793 730 //-------------------------------------------------------------------------- 794 731 // CaseStmt 795 template< typename core_t >796 const ast::Stmt * ast::Pass< core_t >::visit( const ast::CaseStmt * node ) {732 template< typename pass_t > 733 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::CaseStmt * node ) { 797 734 VISIT_START( node ); 798 735 … … 807 744 //-------------------------------------------------------------------------- 808 745 // BranchStmt 809 template< typename core_t >810 const ast::Stmt * ast::Pass< core_t >::visit( const ast::BranchStmt * node ) {746 template< typename pass_t > 747 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::BranchStmt * node ) { 811 748 VISIT_START( node ); 812 749 VISIT_END( Stmt, node ); … … 815 752 //-------------------------------------------------------------------------- 816 753 // ReturnStmt 817 template< typename core_t >818 const ast::Stmt * ast::Pass< core_t >::visit( const ast::ReturnStmt * node ) {754 template< typename pass_t > 755 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::ReturnStmt * node ) { 819 756 VISIT_START( node ); 820 757 … … 828 765 //-------------------------------------------------------------------------- 829 766 // ThrowStmt 830 template< typename core_t >831 const ast::Stmt * ast::Pass< core_t >::visit( const ast::ThrowStmt * node ) {767 template< typename pass_t > 768 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::ThrowStmt * node ) { 832 769 VISIT_START( node ); 833 770 … … 842 779 //-------------------------------------------------------------------------- 843 780 // TryStmt 844 template< typename core_t >845 const ast::Stmt * ast::Pass< core_t >::visit( const ast::TryStmt * node ) {781 template< typename pass_t > 782 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::TryStmt * node ) { 846 783 VISIT_START( node ); 847 784 … … 857 794 //-------------------------------------------------------------------------- 858 795 // CatchStmt 859 template< typename core_t >860 const ast::Stmt * ast::Pass< core_t >::visit( const ast::CatchStmt * node ) {796 template< typename pass_t > 797 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::CatchStmt * node ) { 861 798 VISIT_START( node ); 862 799 … … 866 803 maybe_accept( node, &CatchStmt::decl ); 867 804 maybe_accept( node, &CatchStmt::cond ); 868 maybe_accept _as_compound( node, &CatchStmt::body );805 maybe_accept( node, &CatchStmt::body ); 869 806 }) 870 807 … … 874 811 //-------------------------------------------------------------------------- 875 812 // FinallyStmt 876 template< typename core_t >877 const ast::Stmt * ast::Pass< core_t >::visit( const ast::FinallyStmt * node ) {813 template< typename pass_t > 814 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::FinallyStmt * node ) { 878 815 VISIT_START( node ); 879 816 … … 886 823 887 824 //-------------------------------------------------------------------------- 888 // FinallyStmt889 template< typename core_t >890 const ast::Stmt * ast::Pass< core_t >::visit( const ast::SuspendStmt * node ) {891 VISIT_START( node );892 893 VISIT(894 maybe_accept( node, &SuspendStmt::then );895 )896 897 VISIT_END( Stmt, node );898 }899 900 //--------------------------------------------------------------------------901 825 // WaitForStmt 902 template< typename core_t >903 const ast::Stmt * ast::Pass< core_t >::visit( const ast::WaitForStmt * node ) {826 template< typename pass_t > 827 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::WaitForStmt * node ) { 904 828 VISIT_START( node ); 905 829 // for( auto & clause : node->clauses ) { … … 938 862 939 863 if(mutated) { 940 auto n = __pass::mutate<core_t>(node);864 auto n = mutate(node); 941 865 n->clauses = std::move( new_clauses ); 942 866 node = n; … … 948 872 auto nval = call_accept( node->field ); \ 949 873 if(nval != node->field ) { \ 950 auto nparent = __pass::mutate<core_t>(node); \874 auto nparent = mutate(node); \ 951 875 nparent->field = nval; \ 952 876 node = nparent; \ … … 969 893 //-------------------------------------------------------------------------- 970 894 // WithStmt 971 template< typename core_t >972 const ast::Decl * ast::Pass< core_t >::visit( const ast::WithStmt * node ) {895 template< typename pass_t > 896 const ast::Decl * ast::Pass< pass_t >::visit( const ast::WithStmt * node ) { 973 897 VISIT_START( node ); 974 898 … … 978 902 // catch statements introduce a level of scope (for the caught exception) 979 903 guard_symtab guard { *this }; 980 __pass::symtab::addWith( core, 0, node->exprs, node );904 __pass::symtab::addWith( pass, 0, node->exprs, node ); 981 905 maybe_accept( node, &WithStmt::stmt ); 982 906 } … … 987 911 //-------------------------------------------------------------------------- 988 912 // NullStmt 989 template< typename core_t >990 const ast::NullStmt * ast::Pass< core_t >::visit( const ast::NullStmt * node ) {913 template< typename pass_t > 914 const ast::NullStmt * ast::Pass< pass_t >::visit( const ast::NullStmt * node ) { 991 915 VISIT_START( node ); 992 916 VISIT_END( NullStmt, node ); … … 995 919 //-------------------------------------------------------------------------- 996 920 // DeclStmt 997 template< typename core_t >998 const ast::Stmt * ast::Pass< core_t >::visit( const ast::DeclStmt * node ) {921 template< typename pass_t > 922 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::DeclStmt * node ) { 999 923 VISIT_START( node ); 1000 924 … … 1008 932 //-------------------------------------------------------------------------- 1009 933 // ImplicitCtorDtorStmt 1010 template< typename core_t >1011 const ast::Stmt * ast::Pass< core_t >::visit( const ast::ImplicitCtorDtorStmt * node ) {934 template< typename pass_t > 935 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::ImplicitCtorDtorStmt * node ) { 1012 936 VISIT_START( node ); 1013 937 1014 938 // For now this isn't visited, it is unclear if this causes problem 1015 939 // if all tests are known to pass, remove this code 1016 VISIT(1017 maybe_accept( node, &ImplicitCtorDtorStmt::callStmt );1018 )940 // VISIT( 941 // maybe_accept( node, &ImplicitCtorDtorStmt::callStmt ); 942 // ) 1019 943 1020 944 VISIT_END( Stmt, node ); … … 1023 947 //-------------------------------------------------------------------------- 1024 948 // ApplicationExpr 1025 template< typename core_t >1026 const ast::Expr * ast::Pass< core_t >::visit( const ast::ApplicationExpr * node ) {949 template< typename pass_t > 950 const ast::Expr * ast::Pass< pass_t >::visit( const ast::ApplicationExpr * node ) { 1027 951 VISIT_START( node ); 1028 952 … … 1041 965 //-------------------------------------------------------------------------- 1042 966 // UntypedExpr 1043 template< typename core_t >1044 const ast::Expr * ast::Pass< core_t >::visit( const ast::UntypedExpr * node ) {967 template< typename pass_t > 968 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UntypedExpr * node ) { 1045 969 VISIT_START( node ); 1046 970 … … 1059 983 //-------------------------------------------------------------------------- 1060 984 // NameExpr 1061 template< typename core_t >1062 const ast::Expr * ast::Pass< core_t >::visit( const ast::NameExpr * node ) {985 template< typename pass_t > 986 const ast::Expr * ast::Pass< pass_t >::visit( const ast::NameExpr * node ) { 1063 987 VISIT_START( node ); 1064 988 … … 1073 997 //-------------------------------------------------------------------------- 1074 998 // CastExpr 1075 template< typename core_t >1076 const ast::Expr * ast::Pass< core_t >::visit( const ast::CastExpr * node ) {999 template< typename pass_t > 1000 const ast::Expr * ast::Pass< pass_t >::visit( const ast::CastExpr * node ) { 1077 1001 VISIT_START( node ); 1078 1002 … … 1089 1013 //-------------------------------------------------------------------------- 1090 1014 // KeywordCastExpr 1091 template< typename core_t >1092 const ast::Expr * ast::Pass< core_t >::visit( const ast::KeywordCastExpr * node ) {1015 template< typename pass_t > 1016 const ast::Expr * ast::Pass< pass_t >::visit( const ast::KeywordCastExpr * node ) { 1093 1017 VISIT_START( node ); 1094 1018 … … 1105 1029 //-------------------------------------------------------------------------- 1106 1030 // VirtualCastExpr 1107 template< typename core_t >1108 const ast::Expr * ast::Pass< core_t >::visit( const ast::VirtualCastExpr * node ) {1031 template< typename pass_t > 1032 const ast::Expr * ast::Pass< pass_t >::visit( const ast::VirtualCastExpr * node ) { 1109 1033 VISIT_START( node ); 1110 1034 … … 1121 1045 //-------------------------------------------------------------------------- 1122 1046 // AddressExpr 1123 template< typename core_t >1124 const ast::Expr * ast::Pass< core_t >::visit( const ast::AddressExpr * node ) {1047 template< typename pass_t > 1048 const ast::Expr * ast::Pass< pass_t >::visit( const ast::AddressExpr * node ) { 1125 1049 VISIT_START( node ); 1126 1050 … … 1137 1061 //-------------------------------------------------------------------------- 1138 1062 // LabelAddressExpr 1139 template< typename core_t >1140 const ast::Expr * ast::Pass< core_t >::visit( const ast::LabelAddressExpr * node ) {1063 template< typename pass_t > 1064 const ast::Expr * ast::Pass< pass_t >::visit( const ast::LabelAddressExpr * node ) { 1141 1065 VISIT_START( node ); 1142 1066 … … 1151 1075 //-------------------------------------------------------------------------- 1152 1076 // UntypedMemberExpr 1153 template< typename core_t >1154 const ast::Expr * ast::Pass< core_t >::visit( const ast::UntypedMemberExpr * node ) {1077 template< typename pass_t > 1078 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UntypedMemberExpr * node ) { 1155 1079 VISIT_START( node ); 1156 1080 … … 1168 1092 //-------------------------------------------------------------------------- 1169 1093 // MemberExpr 1170 template< typename core_t >1171 const ast::Expr * ast::Pass< core_t >::visit( const ast::MemberExpr * node ) {1094 template< typename pass_t > 1095 const ast::Expr * ast::Pass< pass_t >::visit( const ast::MemberExpr * node ) { 1172 1096 VISIT_START( node ); 1173 1097 … … 1184 1108 //-------------------------------------------------------------------------- 1185 1109 // VariableExpr 1186 template< typename core_t >1187 const ast::Expr * ast::Pass< core_t >::visit( const ast::VariableExpr * node ) {1110 template< typename pass_t > 1111 const ast::Expr * ast::Pass< pass_t >::visit( const ast::VariableExpr * node ) { 1188 1112 VISIT_START( node ); 1189 1113 … … 1198 1122 //-------------------------------------------------------------------------- 1199 1123 // ConstantExpr 1200 template< typename core_t >1201 const ast::Expr * ast::Pass< core_t >::visit( const ast::ConstantExpr * node ) {1124 template< typename pass_t > 1125 const ast::Expr * ast::Pass< pass_t >::visit( const ast::ConstantExpr * node ) { 1202 1126 VISIT_START( node ); 1203 1127 … … 1212 1136 //-------------------------------------------------------------------------- 1213 1137 // SizeofExpr 1214 template< typename core_t >1215 const ast::Expr * ast::Pass< core_t >::visit( const ast::SizeofExpr * node ) {1138 template< typename pass_t > 1139 const ast::Expr * ast::Pass< pass_t >::visit( const ast::SizeofExpr * node ) { 1216 1140 VISIT_START( node ); 1217 1141 … … 1232 1156 //-------------------------------------------------------------------------- 1233 1157 // AlignofExpr 1234 template< typename core_t >1235 const ast::Expr * ast::Pass< core_t >::visit( const ast::AlignofExpr * node ) {1158 template< typename pass_t > 1159 const ast::Expr * ast::Pass< pass_t >::visit( const ast::AlignofExpr * node ) { 1236 1160 VISIT_START( node ); 1237 1161 … … 1252 1176 //-------------------------------------------------------------------------- 1253 1177 // UntypedOffsetofExpr 1254 template< typename core_t >1255 const ast::Expr * ast::Pass< core_t >::visit( const ast::UntypedOffsetofExpr * node ) {1178 template< typename pass_t > 1179 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UntypedOffsetofExpr * node ) { 1256 1180 VISIT_START( node ); 1257 1181 … … 1268 1192 //-------------------------------------------------------------------------- 1269 1193 // OffsetofExpr 1270 template< typename core_t >1271 const ast::Expr * ast::Pass< core_t >::visit( const ast::OffsetofExpr * node ) {1194 template< typename pass_t > 1195 const ast::Expr * ast::Pass< pass_t >::visit( const ast::OffsetofExpr * node ) { 1272 1196 VISIT_START( node ); 1273 1197 … … 1284 1208 //-------------------------------------------------------------------------- 1285 1209 // OffsetPackExpr 1286 template< typename core_t >1287 const ast::Expr * ast::Pass< core_t >::visit( const ast::OffsetPackExpr * node ) {1210 template< typename pass_t > 1211 const ast::Expr * ast::Pass< pass_t >::visit( const ast::OffsetPackExpr * node ) { 1288 1212 VISIT_START( node ); 1289 1213 … … 1300 1224 //-------------------------------------------------------------------------- 1301 1225 // LogicalExpr 1302 template< typename core_t >1303 const ast::Expr * ast::Pass< core_t >::visit( const ast::LogicalExpr * node ) {1226 template< typename pass_t > 1227 const ast::Expr * ast::Pass< pass_t >::visit( const ast::LogicalExpr * node ) { 1304 1228 VISIT_START( node ); 1305 1229 … … 1317 1241 //-------------------------------------------------------------------------- 1318 1242 // ConditionalExpr 1319 template< typename core_t >1320 const ast::Expr * ast::Pass< core_t >::visit( const ast::ConditionalExpr * node ) {1243 template< typename pass_t > 1244 const ast::Expr * ast::Pass< pass_t >::visit( const ast::ConditionalExpr * node ) { 1321 1245 VISIT_START( node ); 1322 1246 … … 1335 1259 //-------------------------------------------------------------------------- 1336 1260 // CommaExpr 1337 template< typename core_t >1338 const ast::Expr * ast::Pass< core_t >::visit( const ast::CommaExpr * node ) {1261 template< typename pass_t > 1262 const ast::Expr * ast::Pass< pass_t >::visit( const ast::CommaExpr * node ) { 1339 1263 VISIT_START( node ); 1340 1264 … … 1352 1276 //-------------------------------------------------------------------------- 1353 1277 // TypeExpr 1354 template< typename core_t >1355 const ast::Expr * ast::Pass< core_t >::visit( const ast::TypeExpr * node ) {1278 template< typename pass_t > 1279 const ast::Expr * ast::Pass< pass_t >::visit( const ast::TypeExpr * node ) { 1356 1280 VISIT_START( node ); 1357 1281 … … 1368 1292 //-------------------------------------------------------------------------- 1369 1293 // AsmExpr 1370 template< typename core_t >1371 const ast::Expr * ast::Pass< core_t >::visit( const ast::AsmExpr * node ) {1294 template< typename pass_t > 1295 const ast::Expr * ast::Pass< pass_t >::visit( const ast::AsmExpr * node ) { 1372 1296 VISIT_START( node ); 1373 1297 … … 1385 1309 //-------------------------------------------------------------------------- 1386 1310 // ImplicitCopyCtorExpr 1387 template< typename core_t >1388 const ast::Expr * ast::Pass< core_t >::visit( const ast::ImplicitCopyCtorExpr * node ) {1311 template< typename pass_t > 1312 const ast::Expr * ast::Pass< pass_t >::visit( const ast::ImplicitCopyCtorExpr * node ) { 1389 1313 VISIT_START( node ); 1390 1314 … … 1401 1325 //-------------------------------------------------------------------------- 1402 1326 // ConstructorExpr 1403 template< typename core_t >1404 const ast::Expr * ast::Pass< core_t >::visit( const ast::ConstructorExpr * node ) {1327 template< typename pass_t > 1328 const ast::Expr * ast::Pass< pass_t >::visit( const ast::ConstructorExpr * node ) { 1405 1329 VISIT_START( node ); 1406 1330 … … 1417 1341 //-------------------------------------------------------------------------- 1418 1342 // CompoundLiteralExpr 1419 template< typename core_t >1420 const ast::Expr * ast::Pass< core_t >::visit( const ast::CompoundLiteralExpr * node ) {1343 template< typename pass_t > 1344 const ast::Expr * ast::Pass< pass_t >::visit( const ast::CompoundLiteralExpr * node ) { 1421 1345 VISIT_START( node ); 1422 1346 … … 1433 1357 //-------------------------------------------------------------------------- 1434 1358 // RangeExpr 1435 template< typename core_t >1436 const ast::Expr * ast::Pass< core_t >::visit( const ast::RangeExpr * node ) {1359 template< typename pass_t > 1360 const ast::Expr * ast::Pass< pass_t >::visit( const ast::RangeExpr * node ) { 1437 1361 VISIT_START( node ); 1438 1362 … … 1450 1374 //-------------------------------------------------------------------------- 1451 1375 // UntypedTupleExpr 1452 template< typename core_t >1453 const ast::Expr * ast::Pass< core_t >::visit( const ast::UntypedTupleExpr * node ) {1376 template< typename pass_t > 1377 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UntypedTupleExpr * node ) { 1454 1378 VISIT_START( node ); 1455 1379 … … 1466 1390 //-------------------------------------------------------------------------- 1467 1391 // TupleExpr 1468 template< typename core_t >1469 const ast::Expr * ast::Pass< core_t >::visit( const ast::TupleExpr * node ) {1392 template< typename pass_t > 1393 const ast::Expr * ast::Pass< pass_t >::visit( const ast::TupleExpr * node ) { 1470 1394 VISIT_START( node ); 1471 1395 … … 1482 1406 //-------------------------------------------------------------------------- 1483 1407 // TupleIndexExpr 1484 template< typename core_t >1485 const ast::Expr * ast::Pass< core_t >::visit( const ast::TupleIndexExpr * node ) {1408 template< typename pass_t > 1409 const ast::Expr * ast::Pass< pass_t >::visit( const ast::TupleIndexExpr * node ) { 1486 1410 VISIT_START( node ); 1487 1411 … … 1498 1422 //-------------------------------------------------------------------------- 1499 1423 // TupleAssignExpr 1500 template< typename core_t >1501 const ast::Expr * ast::Pass< core_t >::visit( const ast::TupleAssignExpr * node ) {1424 template< typename pass_t > 1425 const ast::Expr * ast::Pass< pass_t >::visit( const ast::TupleAssignExpr * node ) { 1502 1426 VISIT_START( node ); 1503 1427 … … 1514 1438 //-------------------------------------------------------------------------- 1515 1439 // StmtExpr 1516 template< typename core_t >1517 const ast::Expr * ast::Pass< core_t >::visit( const ast::StmtExpr * node ) {1440 template< typename pass_t > 1441 const ast::Expr * ast::Pass< pass_t >::visit( const ast::StmtExpr * node ) { 1518 1442 VISIT_START( node ); 1519 1443 1520 1444 VISIT(// don't want statements from outer CompoundStmts to be added to this StmtExpr 1521 1445 // get the stmts that will need to be spliced in 1522 auto stmts_before = __pass::stmtsToAddBefore( core, 0);1523 auto stmts_after = __pass::stmtsToAddAfter ( core, 0);1446 auto stmts_before = __pass::stmtsToAddBefore( pass, 0); 1447 auto stmts_after = __pass::stmtsToAddAfter ( pass, 0); 1524 1448 1525 1449 // These may be modified by subnode but most be restored once we exit this statemnet. 1526 ValueGuardPtr< const ast::TypeSubstitution * > __old_env( __pass:: typeSubs( core, 0) );1450 ValueGuardPtr< const ast::TypeSubstitution * > __old_env( __pass::env( pass, 0) ); 1527 1451 ValueGuardPtr< typename std::remove_pointer< decltype(stmts_before) >::type > __old_decls_before( stmts_before ); 1528 1452 ValueGuardPtr< typename std::remove_pointer< decltype(stmts_after ) >::type > __old_decls_after ( stmts_after ); … … 1542 1466 //-------------------------------------------------------------------------- 1543 1467 // UniqueExpr 1544 template< typename core_t >1545 const ast::Expr * ast::Pass< core_t >::visit( const ast::UniqueExpr * node ) {1468 template< typename pass_t > 1469 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UniqueExpr * node ) { 1546 1470 VISIT_START( node ); 1547 1471 … … 1558 1482 //-------------------------------------------------------------------------- 1559 1483 // UntypedInitExpr 1560 template< typename core_t >1561 const ast::Expr * ast::Pass< core_t >::visit( const ast::UntypedInitExpr * node ) {1484 template< typename pass_t > 1485 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UntypedInitExpr * node ) { 1562 1486 VISIT_START( node ); 1563 1487 … … 1575 1499 //-------------------------------------------------------------------------- 1576 1500 // InitExpr 1577 template< typename core_t >1578 const ast::Expr * ast::Pass< core_t >::visit( const ast::InitExpr * node ) {1501 template< typename pass_t > 1502 const ast::Expr * ast::Pass< pass_t >::visit( const ast::InitExpr * node ) { 1579 1503 VISIT_START( node ); 1580 1504 … … 1592 1516 //-------------------------------------------------------------------------- 1593 1517 // DeletedExpr 1594 template< typename core_t >1595 const ast::Expr * ast::Pass< core_t >::visit( const ast::DeletedExpr * node ) {1518 template< typename pass_t > 1519 const ast::Expr * ast::Pass< pass_t >::visit( const ast::DeletedExpr * node ) { 1596 1520 VISIT_START( node ); 1597 1521 … … 1609 1533 //-------------------------------------------------------------------------- 1610 1534 // DefaultArgExpr 1611 template< typename core_t >1612 const ast::Expr * ast::Pass< core_t >::visit( const ast::DefaultArgExpr * node ) {1535 template< typename pass_t > 1536 const ast::Expr * ast::Pass< pass_t >::visit( const ast::DefaultArgExpr * node ) { 1613 1537 VISIT_START( node ); 1614 1538 … … 1625 1549 //-------------------------------------------------------------------------- 1626 1550 // GenericExpr 1627 template< typename core_t >1628 const ast::Expr * ast::Pass< core_t >::visit( const ast::GenericExpr * node ) {1551 template< typename pass_t > 1552 const ast::Expr * ast::Pass< pass_t >::visit( const ast::GenericExpr * node ) { 1629 1553 VISIT_START( node ); 1630 1554 … … 1654 1578 1655 1579 if(mutated) { 1656 auto n = __pass::mutate<core_t>(node);1580 auto n = mutate(node); 1657 1581 n->associations = std::move( new_kids ); 1658 1582 node = n; … … 1665 1589 //-------------------------------------------------------------------------- 1666 1590 // VoidType 1667 template< typename core_t >1668 const ast::Type * ast::Pass< core_t >::visit( const ast::VoidType * node ) {1591 template< typename pass_t > 1592 const ast::Type * ast::Pass< pass_t >::visit( const ast::VoidType * node ) { 1669 1593 VISIT_START( node ); 1670 1594 … … 1674 1598 //-------------------------------------------------------------------------- 1675 1599 // BasicType 1676 template< typename core_t >1677 const ast::Type * ast::Pass< core_t >::visit( const ast::BasicType * node ) {1600 template< typename pass_t > 1601 const ast::Type * ast::Pass< pass_t >::visit( const ast::BasicType * node ) { 1678 1602 VISIT_START( node ); 1679 1603 … … 1683 1607 //-------------------------------------------------------------------------- 1684 1608 // PointerType 1685 template< typename core_t >1686 const ast::Type * ast::Pass< core_t >::visit( const ast::PointerType * node ) {1609 template< typename pass_t > 1610 const ast::Type * ast::Pass< pass_t >::visit( const ast::PointerType * node ) { 1687 1611 VISIT_START( node ); 1688 1612 … … 1697 1621 //-------------------------------------------------------------------------- 1698 1622 // ArrayType 1699 template< typename core_t >1700 const ast::Type * ast::Pass< core_t >::visit( const ast::ArrayType * node ) {1623 template< typename pass_t > 1624 const ast::Type * ast::Pass< pass_t >::visit( const ast::ArrayType * node ) { 1701 1625 VISIT_START( node ); 1702 1626 … … 1711 1635 //-------------------------------------------------------------------------- 1712 1636 // ReferenceType 1713 template< typename core_t >1714 const ast::Type * ast::Pass< core_t >::visit( const ast::ReferenceType * node ) {1637 template< typename pass_t > 1638 const ast::Type * ast::Pass< pass_t >::visit( const ast::ReferenceType * node ) { 1715 1639 VISIT_START( node ); 1716 1640 … … 1724 1648 //-------------------------------------------------------------------------- 1725 1649 // QualifiedType 1726 template< typename core_t >1727 const ast::Type * ast::Pass< core_t >::visit( const ast::QualifiedType * node ) {1650 template< typename pass_t > 1651 const ast::Type * ast::Pass< pass_t >::visit( const ast::QualifiedType * node ) { 1728 1652 VISIT_START( node ); 1729 1653 … … 1738 1662 //-------------------------------------------------------------------------- 1739 1663 // FunctionType 1740 template< typename core_t > 1741 const ast::Type * ast::Pass< core_t >::visit( const ast::FunctionType * node ) { 1742 VISIT_START( node ); 1743 1744 VISIT({ 1745 // guard_forall_subs forall_guard { *this, node }; 1746 // mutate_forall( node ); 1747 maybe_accept( node, &FunctionType::assertions ); 1664 template< typename pass_t > 1665 const ast::Type * ast::Pass< pass_t >::visit( const ast::FunctionType * node ) { 1666 VISIT_START( node ); 1667 1668 VISIT( 1669 maybe_accept( node, &FunctionType::forall ); 1748 1670 maybe_accept( node, &FunctionType::returns ); 1749 1671 maybe_accept( node, &FunctionType::params ); 1750 })1672 ) 1751 1673 1752 1674 VISIT_END( Type, node ); … … 1755 1677 //-------------------------------------------------------------------------- 1756 1678 // StructInstType 1757 template< typename core_t >1758 const ast::Type * ast::Pass< core_t >::visit( const ast::StructInstType * node ) {1759 VISIT_START( node ); 1760 1761 __pass::symtab::addStruct( core, 0, node->name );1679 template< typename pass_t > 1680 const ast::Type * ast::Pass< pass_t >::visit( const ast::StructInstType * node ) { 1681 VISIT_START( node ); 1682 1683 __pass::symtab::addStruct( pass, 0, node->name ); 1762 1684 1763 1685 VISIT({ 1764 1686 guard_symtab guard { *this }; 1687 maybe_accept( node, &StructInstType::forall ); 1765 1688 maybe_accept( node, &StructInstType::params ); 1766 1689 }) … … 1771 1694 //-------------------------------------------------------------------------- 1772 1695 // UnionInstType 1773 template< typename core_t >1774 const ast::Type * ast::Pass< core_t >::visit( const ast::UnionInstType * node ) {1775 VISIT_START( node ); 1776 1777 __pass::symtab::add Union( core, 0, node->name );1778 1779 VISIT({1696 template< typename pass_t > 1697 const ast::Type * ast::Pass< pass_t >::visit( const ast::UnionInstType * node ) { 1698 VISIT_START( node ); 1699 1700 __pass::symtab::addStruct( pass, 0, node->name ); 1701 1702 { 1780 1703 guard_symtab guard { *this }; 1704 maybe_accept( node, &UnionInstType::forall ); 1781 1705 maybe_accept( node, &UnionInstType::params ); 1782 } )1706 } 1783 1707 1784 1708 VISIT_END( Type, node ); … … 1787 1711 //-------------------------------------------------------------------------- 1788 1712 // EnumInstType 1789 template< typename core_t > 1790 const ast::Type * ast::Pass< core_t >::visit( const ast::EnumInstType * node ) { 1791 VISIT_START( node ); 1792 1793 VISIT({ 1713 template< typename pass_t > 1714 const ast::Type * ast::Pass< pass_t >::visit( const ast::EnumInstType * node ) { 1715 VISIT_START( node ); 1716 1717 VISIT( 1718 maybe_accept( node, &EnumInstType::forall ); 1794 1719 maybe_accept( node, &EnumInstType::params ); 1795 })1720 ) 1796 1721 1797 1722 VISIT_END( Type, node ); … … 1800 1725 //-------------------------------------------------------------------------- 1801 1726 // TraitInstType 1802 template< typename core_t > 1803 const ast::Type * ast::Pass< core_t >::visit( const ast::TraitInstType * node ) { 1804 VISIT_START( node ); 1805 1806 VISIT({ 1727 template< typename pass_t > 1728 const ast::Type * ast::Pass< pass_t >::visit( const ast::TraitInstType * node ) { 1729 VISIT_START( node ); 1730 1731 VISIT( 1732 maybe_accept( node, &TraitInstType::forall ); 1807 1733 maybe_accept( node, &TraitInstType::params ); 1808 })1734 ) 1809 1735 1810 1736 VISIT_END( Type, node ); … … 1813 1739 //-------------------------------------------------------------------------- 1814 1740 // TypeInstType 1815 template< typename core_t > 1816 const ast::Type * ast::Pass< core_t >::visit( const ast::TypeInstType * node ) { 1817 VISIT_START( node ); 1818 1819 VISIT( 1820 { 1821 maybe_accept( node, &TypeInstType::params ); 1822 } 1823 // ensure that base re-bound if doing substitution 1824 __pass::forall::replace( core, 0, node ); 1741 template< typename pass_t > 1742 const ast::Type * ast::Pass< pass_t >::visit( const ast::TypeInstType * node ) { 1743 VISIT_START( node ); 1744 1745 VISIT( 1746 maybe_accept( node, &TypeInstType::forall ); 1747 maybe_accept( node, &TypeInstType::params ); 1825 1748 ) 1826 1749 … … 1830 1753 //-------------------------------------------------------------------------- 1831 1754 // TupleType 1832 template< typename core_t >1833 const ast::Type * ast::Pass< core_t >::visit( const ast::TupleType * node ) {1755 template< typename pass_t > 1756 const ast::Type * ast::Pass< pass_t >::visit( const ast::TupleType * node ) { 1834 1757 VISIT_START( node ); 1835 1758 … … 1844 1767 //-------------------------------------------------------------------------- 1845 1768 // TypeofType 1846 template< typename core_t >1847 const ast::Type * ast::Pass< core_t >::visit( const ast::TypeofType * node ) {1769 template< typename pass_t > 1770 const ast::Type * ast::Pass< pass_t >::visit( const ast::TypeofType * node ) { 1848 1771 VISIT_START( node ); 1849 1772 … … 1857 1780 //-------------------------------------------------------------------------- 1858 1781 // VarArgsType 1859 template< typename core_t >1860 const ast::Type * ast::Pass< core_t >::visit( const ast::VarArgsType * node ) {1782 template< typename pass_t > 1783 const ast::Type * ast::Pass< pass_t >::visit( const ast::VarArgsType * node ) { 1861 1784 VISIT_START( node ); 1862 1785 … … 1866 1789 //-------------------------------------------------------------------------- 1867 1790 // ZeroType 1868 template< typename core_t >1869 const ast::Type * ast::Pass< core_t >::visit( const ast::ZeroType * node ) {1791 template< typename pass_t > 1792 const ast::Type * ast::Pass< pass_t >::visit( const ast::ZeroType * node ) { 1870 1793 VISIT_START( node ); 1871 1794 … … 1875 1798 //-------------------------------------------------------------------------- 1876 1799 // OneType 1877 template< typename core_t >1878 const ast::Type * ast::Pass< core_t >::visit( const ast::OneType * node ) {1800 template< typename pass_t > 1801 const ast::Type * ast::Pass< pass_t >::visit( const ast::OneType * node ) { 1879 1802 VISIT_START( node ); 1880 1803 … … 1884 1807 //-------------------------------------------------------------------------- 1885 1808 // GlobalScopeType 1886 template< typename core_t >1887 const ast::Type * ast::Pass< core_t >::visit( const ast::GlobalScopeType * node ) {1809 template< typename pass_t > 1810 const ast::Type * ast::Pass< pass_t >::visit( const ast::GlobalScopeType * node ) { 1888 1811 VISIT_START( node ); 1889 1812 … … 1894 1817 //-------------------------------------------------------------------------- 1895 1818 // Designation 1896 template< typename core_t >1897 const ast::Designation * ast::Pass< core_t >::visit( const ast::Designation * node ) {1819 template< typename pass_t > 1820 const ast::Designation * ast::Pass< pass_t >::visit( const ast::Designation * node ) { 1898 1821 VISIT_START( node ); 1899 1822 … … 1905 1828 //-------------------------------------------------------------------------- 1906 1829 // SingleInit 1907 template< typename core_t >1908 const ast::Init * ast::Pass< core_t >::visit( const ast::SingleInit * node ) {1830 template< typename pass_t > 1831 const ast::Init * ast::Pass< pass_t >::visit( const ast::SingleInit * node ) { 1909 1832 VISIT_START( node ); 1910 1833 … … 1918 1841 //-------------------------------------------------------------------------- 1919 1842 // ListInit 1920 template< typename core_t >1921 const ast::Init * ast::Pass< core_t >::visit( const ast::ListInit * node ) {1843 template< typename pass_t > 1844 const ast::Init * ast::Pass< pass_t >::visit( const ast::ListInit * node ) { 1922 1845 VISIT_START( node ); 1923 1846 … … 1932 1855 //-------------------------------------------------------------------------- 1933 1856 // ConstructorInit 1934 template< typename core_t >1935 const ast::Init * ast::Pass< core_t >::visit( const ast::ConstructorInit * node ) {1857 template< typename pass_t > 1858 const ast::Init * ast::Pass< pass_t >::visit( const ast::ConstructorInit * node ) { 1936 1859 VISIT_START( node ); 1937 1860 … … 1947 1870 //-------------------------------------------------------------------------- 1948 1871 // Attribute 1949 template< typename core_t >1950 const ast::Attribute * ast::Pass< core_t >::visit( const ast::Attribute * node ) {1872 template< typename pass_t > 1873 const ast::Attribute * ast::Pass< pass_t >::visit( const ast::Attribute * node ) { 1951 1874 VISIT_START( node ); 1952 1875 … … 1960 1883 //-------------------------------------------------------------------------- 1961 1884 // TypeSubstitution 1962 template< typename core_t >1963 const ast::TypeSubstitution * ast::Pass< core_t >::visit( const ast::TypeSubstitution * node ) {1885 template< typename pass_t > 1886 const ast::TypeSubstitution * ast::Pass< pass_t >::visit( const ast::TypeSubstitution * node ) { 1964 1887 VISIT_START( node ); 1965 1888 … … 1967 1890 { 1968 1891 bool mutated = false; 1969 std::unordered_map< ast::TypeInstType::TypeEnvKey, ast::ptr< ast::Type > > new_map;1892 std::unordered_map< std::string, ast::ptr< ast::Type > > new_map; 1970 1893 for ( const auto & p : node->typeEnv ) { 1971 1894 guard_symtab guard { *this }; 1972 1895 auto new_node = p.second->accept( *this ); 1973 if (new_node != p.second) mutated = true;1896 if (new_node != p.second) mutated = false; 1974 1897 new_map.insert({ p.first, new_node }); 1975 1898 } 1976 1899 if (mutated) { 1977 auto new_node = __pass::mutate<core_t>( node );1900 auto new_node = mutate( node ); 1978 1901 new_node->typeEnv.swap( new_map ); 1979 1902 node = new_node; 1980 1903 } 1981 1904 } 1905 1906 { 1907 bool mutated = false; 1908 std::unordered_map< std::string, ast::ptr< ast::Expr > > new_map; 1909 for ( const auto & p : node->varEnv ) { 1910 guard_symtab guard { *this }; 1911 auto new_node = p.second->accept( *this ); 1912 if (new_node != p.second) mutated = false; 1913 new_map.insert({ p.first, new_node }); 1914 } 1915 if (mutated) { 1916 auto new_node = mutate( node ); 1917 new_node->varEnv.swap( new_map ); 1918 node = new_node; 1919 } 1920 } 1982 1921 ) 1983 1922
Note:
See TracChangeset
for help on using the changeset viewer.