Changeset 7ff3e522
- Timestamp:
- Aug 12, 2020, 10:31:58 AM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- f8d05ee
- Parents:
- 343d10e
- Location:
- src
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Copy.hpp
r343d10e r7ff3e522 121 121 Pass< DeepCopyCore > dc; 122 122 node_t const * newRoot = localRoot->accept( dc ); 123 dc. pass.readonlyUpdates();123 dc.core.readonlyUpdates(); 124 124 return const_cast< node_t * >( newRoot ); 125 125 } -
src/AST/GenericSubstitution.cpp
r343d10e r7ff3e522 62 62 Pass<GenericSubstitutionBuilder> builder; 63 63 maybe_accept( ty, builder ); 64 return std::move(builder. pass.sub);64 return std::move(builder.core.sub); 65 65 } 66 66 -
src/AST/Pass.hpp
r343d10e r7ff3e522 66 66 // | WithForallSubstitutor - maintains links between TypeInstType and TypeDecl under mutation 67 67 //------------------------------------------------------------------------------------------------- 68 template< typename pass_t >68 template< typename core_t > 69 69 class Pass final : public ast::Visitor { 70 70 public: 71 using core_type = core_t; 72 using type = Pass<core_t>; 73 71 74 /// Forward any arguments to the pass constructor 72 75 /// Propagate 'this' if necessary 73 76 template< typename... Args > 74 77 Pass( Args &&... args) 75 : pass( std::forward<Args>( args )... )78 : core( std::forward<Args>( args )... ) 76 79 { 77 80 // After the pass is constructed, check if it wants the have a pointer to the wrapping visitor 78 typedef Pass<pass_t> this_t; 79 this_t * const * visitor = __pass::visitor(pass, 0); 81 type * const * visitor = __pass::visitor(core, 0); 80 82 if(visitor) { 81 *const_cast<t his_t**>( visitor ) = this;83 *const_cast<type **>( visitor ) = this; 82 84 } 83 85 } … … 88 90 template< typename... Args > 89 91 static void run( std::list< ptr<Decl> > & decls, Args &&... args ) { 90 Pass< pass_t> visitor( std::forward<Args>( args )... );92 Pass<core_t> visitor( std::forward<Args>( args )... ); 91 93 accept_all( decls, visitor ); 92 94 } 93 95 94 96 /// Storage for the actual pass 95 pass_t pass;97 core_t core; 96 98 97 99 /// Visit function declarations … … 189 191 const ast::TypeSubstitution * visit( const ast::TypeSubstitution * ) override final; 190 192 191 template<typename pass_type>192 friend void accept_all( std::list< ptr<Decl> > & decls, Pass< pass_type>& visitor );193 template<typename core_type> 194 friend void accept_all( std::list< ptr<Decl> > & decls, Pass<core_type>& visitor ); 193 195 private: 194 196 195 bool __visit_children() { __pass::bool_ref * ptr = __pass::visit_children( pass, 0); return ptr ? *ptr : true; }197 bool __visit_children() { __pass::bool_ref * ptr = __pass::visit_children(core, 0); return ptr ? *ptr : true; } 196 198 197 199 private: … … 224 226 /// Internal RAII guard for symbol table features 225 227 struct guard_symtab { 226 guard_symtab( Pass< pass_t> & pass ): pass( pass ) { __pass::symtab::enter(pass.pass, 0); }227 ~guard_symtab() { __pass::symtab::leave(pass. pass, 0); }228 Pass< pass_t> & pass;228 guard_symtab( Pass<core_t> & pass ): pass( pass ) { __pass::symtab::enter(pass.core, 0); } 229 ~guard_symtab() { __pass::symtab::leave(pass.core, 0); } 230 Pass<core_t> & pass; 229 231 }; 230 232 231 233 /// Internal RAII guard for scope features 232 234 struct guard_scope { 233 guard_scope( Pass< pass_t> & pass ): pass( pass ) { __pass::scope::enter(pass.pass, 0); }234 ~guard_scope() { __pass::scope::leave(pass. pass, 0); }235 Pass< pass_t> & pass;235 guard_scope( Pass<core_t> & pass ): pass( pass ) { __pass::scope::enter(pass.core, 0); } 236 ~guard_scope() { __pass::scope::leave(pass.core, 0); } 237 Pass<core_t> & pass; 236 238 }; 237 239 238 240 /// Internal RAII guard for forall substitutions 239 241 struct guard_forall_subs { 240 guard_forall_subs( Pass< pass_t> & pass, const ParameterizedType * type )241 : pass( pass ), type( type ) { __pass::forall::enter(pass. pass, 0, type ); }242 ~guard_forall_subs() { __pass::forall::leave(pass. pass, 0, type ); }243 Pass< pass_t> & pass;242 guard_forall_subs( Pass<core_t> & pass, const ParameterizedType * type ) 243 : pass( pass ), type( type ) { __pass::forall::enter(pass.core, 0, type ); } 244 ~guard_forall_subs() { __pass::forall::leave(pass.core, 0, type ); } 245 Pass<core_t> & pass; 244 246 const ParameterizedType * type; 245 247 }; … … 250 252 251 253 /// Apply a pass to an entire translation unit 252 template<typename pass_t>253 void accept_all( std::list< ast::ptr<ast::Decl> > &, ast::Pass< pass_t> & visitor );254 template<typename core_t> 255 void accept_all( std::list< ast::ptr<ast::Decl> > &, ast::Pass<core_t> & visitor ); 254 256 255 257 //------------------------------------------------------------------------------------------------- … … 291 293 }; 292 294 293 template< typename pass_t>294 friend auto __pass::at_cleanup( pass_t & pass, int ) -> decltype( &pass.at_cleanup );295 template< typename core_t> 296 friend auto __pass::at_cleanup( core_t & core, int ) -> decltype( &core.at_cleanup ); 295 297 public: 296 298 … … 328 330 329 331 /// Used to get a pointer to the pass with its wrapped type 330 template<typename pass_t>332 template<typename core_t> 331 333 struct WithVisitorRef { 332 Pass< pass_t> * const visitor = nullptr;334 Pass<core_t> * const visitor = nullptr; 333 335 }; 334 336 -
src/AST/Pass.impl.hpp
r343d10e r7ff3e522 25 25 using namespace ast; \ 26 26 /* back-up the visit children */ \ 27 __attribute__((unused)) ast::__pass::visit_children_guard guard1( ast::__pass::visit_children( pass, 0) ); \27 __attribute__((unused)) ast::__pass::visit_children_guard guard1( ast::__pass::visit_children(core, 0) ); \ 28 28 /* setup the scope for passes that want to run code at exit */ \ 29 __attribute__((unused)) ast::__pass::guard_value guard2( ast::__pass::at_cleanup ( pass, 0) ); \29 __attribute__((unused)) ast::__pass::guard_value guard2( ast::__pass::at_cleanup (core, 0) ); \ 30 30 /* begin tracing memory allocation if requested by this pass */ \ 31 __pass::beginTrace( pass, 0 ); \31 __pass::beginTrace( core, 0 ); \ 32 32 /* call the implementation of the previsit of this pass */ \ 33 __pass::previsit( pass, node, 0 );33 __pass::previsit( core, node, 0 ); 34 34 35 35 #define VISIT( code... ) \ … … 42 42 #define VISIT_END( type, node ) \ 43 43 /* call the implementation of the postvisit of this pass */ \ 44 auto __return = __pass::postvisit( pass, node, 0 ); \44 auto __return = __pass::postvisit( core, node, 0 ); \ 45 45 assertf(__return, "post visit should never return null"); \ 46 46 /* end tracing memory allocation if requested by this pass */ \ 47 __pass::endTrace( pass, 0 ); \47 __pass::endTrace( core, 0 ); \ 48 48 return __return; 49 49 … … 123 123 } 124 124 125 template< typename pass_t >125 template< typename core_t > 126 126 template< typename node_t > 127 auto ast::Pass< pass_t >::call_accept( const node_t * node )127 auto ast::Pass< core_t >::call_accept( const node_t * node ) 128 128 -> typename std::enable_if< 129 129 !std::is_base_of<ast::Expr, node_t>::value && … … 141 141 } 142 142 143 template< typename pass_t >144 const ast::Expr * ast::Pass< pass_t >::call_accept( const ast::Expr * expr ) {143 template< typename core_t > 144 const ast::Expr * ast::Pass< core_t >::call_accept( const ast::Expr * expr ) { 145 145 __pedantic_pass_assert( __visit_children() ); 146 146 __pedantic_pass_assert( expr ); 147 147 148 const ast::TypeSubstitution ** env_ptr = __pass::env( pass, 0);148 const ast::TypeSubstitution ** env_ptr = __pass::env( core, 0); 149 149 if ( env_ptr && expr->env ) { 150 150 *env_ptr = expr->env; … … 154 154 } 155 155 156 template< typename pass_t >157 const ast::Stmt * ast::Pass< pass_t >::call_accept( const ast::Stmt * stmt ) {156 template< typename core_t > 157 const ast::Stmt * ast::Pass< core_t >::call_accept( const ast::Stmt * stmt ) { 158 158 __pedantic_pass_assert( __visit_children() ); 159 159 __pedantic_pass_assert( stmt ); … … 163 163 164 164 // get the stmts/decls that will need to be spliced in 165 auto stmts_before = __pass::stmtsToAddBefore( pass, 0);166 auto stmts_after = __pass::stmtsToAddAfter ( pass, 0);167 auto decls_before = __pass::declsToAddBefore( pass, 0);168 auto decls_after = __pass::declsToAddAfter ( pass, 0);165 auto stmts_before = __pass::stmtsToAddBefore( core, 0); 166 auto stmts_after = __pass::stmtsToAddAfter ( core, 0); 167 auto decls_before = __pass::declsToAddBefore( core, 0); 168 auto decls_after = __pass::declsToAddAfter ( core, 0); 169 169 170 170 // These may be modified by subnode but most be restored once we exit this statemnet. 171 ValueGuardPtr< const ast::TypeSubstitution * > __old_env ( __pass::env( pass, 0) );171 ValueGuardPtr< const ast::TypeSubstitution * > __old_env ( __pass::env( core, 0) ); 172 172 ValueGuardPtr< typename std::remove_pointer< decltype(stmts_before) >::type > __old_decls_before( stmts_before ); 173 173 ValueGuardPtr< typename std::remove_pointer< decltype(stmts_after ) >::type > __old_decls_after ( stmts_after ); … … 205 205 } 206 206 207 template< typename pass_t >207 template< typename core_t > 208 208 template< template <class...> class container_t > 209 container_t< ptr<Stmt> > ast::Pass< pass_t >::call_accept( const container_t< ptr<Stmt> > & statements ) {209 container_t< ptr<Stmt> > ast::Pass< core_t >::call_accept( const container_t< ptr<Stmt> > & statements ) { 210 210 __pedantic_pass_assert( __visit_children() ); 211 211 if( statements.empty() ) return {}; … … 218 218 219 219 // get the stmts/decls that will need to be spliced in 220 auto stmts_before = __pass::stmtsToAddBefore( pass, 0);221 auto stmts_after = __pass::stmtsToAddAfter ( pass, 0);222 auto decls_before = __pass::declsToAddBefore( pass, 0);223 auto decls_after = __pass::declsToAddAfter ( pass, 0);220 auto stmts_before = __pass::stmtsToAddBefore( core, 0); 221 auto stmts_after = __pass::stmtsToAddAfter ( core, 0); 222 auto decls_before = __pass::declsToAddBefore( core, 0); 223 auto decls_after = __pass::declsToAddAfter ( core, 0); 224 224 225 225 // These may be modified by subnode but most be restored once we exit this statemnet. … … 271 271 } 272 272 273 template< typename pass_t >273 template< typename core_t > 274 274 template< template <class...> class container_t, typename node_t > 275 container_t< ast::ptr<node_t> > ast::Pass< pass_t >::call_accept( const container_t< ast::ptr<node_t> > & container ) {275 container_t< ast::ptr<node_t> > ast::Pass< core_t >::call_accept( const container_t< ast::ptr<node_t> > & container ) { 276 276 __pedantic_pass_assert( __visit_children() ); 277 277 if( container.empty() ) return {}; … … 302 302 } 303 303 304 template< typename pass_t >304 template< typename core_t > 305 305 template<typename node_t, typename parent_t, typename child_t> 306 void ast::Pass< pass_t >::maybe_accept(306 void ast::Pass< core_t >::maybe_accept( 307 307 const node_t * & parent, 308 308 child_t parent_t::*child … … 327 327 328 328 329 template< typename pass_t >329 template< typename core_t > 330 330 template< typename node_t > 331 void ast::Pass< pass_t >::mutate_forall( const node_t *& node ) {332 if ( auto subs = __pass::forall::subs( pass, 0 ) ) {331 void ast::Pass< core_t >::mutate_forall( const node_t *& node ) { 332 if ( auto subs = __pass::forall::subs( core, 0 ) ) { 333 333 // tracking TypeDecl substitution, full clone 334 334 if ( node->forall.empty() ) return; … … 352 352 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 353 353 354 template< typename pass_t >355 inline void ast::accept_all( std::list< ast::ptr<ast::Decl> > & decls, ast::Pass< pass_t > & visitor ) {354 template< typename core_t > 355 inline void ast::accept_all( std::list< ast::ptr<ast::Decl> > & decls, ast::Pass< core_t > & visitor ) { 356 356 // We are going to aggregate errors for all these statements 357 357 SemanticErrorException errors; … … 361 361 362 362 // get the stmts/decls that will need to be spliced in 363 auto decls_before = __pass::declsToAddBefore( visitor. pass, 0);364 auto decls_after = __pass::declsToAddAfter ( visitor. pass, 0);363 auto decls_before = __pass::declsToAddBefore( visitor.core, 0); 364 auto decls_after = __pass::declsToAddAfter ( visitor.core, 0); 365 365 366 366 // update pass statitistics … … 411 411 //-------------------------------------------------------------------------- 412 412 // ObjectDecl 413 template< typename pass_t >414 const ast::DeclWithType * ast::Pass< pass_t >::visit( const ast::ObjectDecl * node ) {413 template< typename core_t > 414 const ast::DeclWithType * ast::Pass< core_t >::visit( const ast::ObjectDecl * node ) { 415 415 VISIT_START( node ); 416 416 … … 425 425 ) 426 426 427 __pass::symtab::addId( pass, 0, node );427 __pass::symtab::addId( core, 0, node ); 428 428 429 429 VISIT_END( DeclWithType, node ); … … 432 432 //-------------------------------------------------------------------------- 433 433 // FunctionDecl 434 template< typename pass_t >435 const ast::DeclWithType * ast::Pass< pass_t >::visit( const ast::FunctionDecl * node ) {436 VISIT_START( node ); 437 438 __pass::symtab::addId( pass, 0, node );434 template< typename core_t > 435 const ast::DeclWithType * ast::Pass< core_t >::visit( const ast::FunctionDecl * node ) { 436 VISIT_START( node ); 437 438 __pass::symtab::addId( core, 0, node ); 439 439 440 440 VISIT(maybe_accept( node, &FunctionDecl::withExprs );) … … 444 444 // shadow with exprs and not the other way around. 445 445 guard_symtab guard { *this }; 446 __pass::symtab::addWith( pass, 0, node->withExprs, node );446 __pass::symtab::addWith( core, 0, node->withExprs, node ); 447 447 { 448 448 guard_symtab guard { *this }; … … 455 455 } 456 456 } }; 457 __pass::symtab::addId( pass, 0, func );457 __pass::symtab::addId( core, 0, func ); 458 458 VISIT( 459 459 maybe_accept( node, &FunctionDecl::type ); … … 473 473 //-------------------------------------------------------------------------- 474 474 // StructDecl 475 template< typename pass_t >476 const ast::Decl * ast::Pass< pass_t >::visit( const ast::StructDecl * node ) {475 template< typename core_t > 476 const ast::Decl * ast::Pass< core_t >::visit( const ast::StructDecl * node ) { 477 477 VISIT_START( node ); 478 478 479 479 // make up a forward declaration and add it before processing the members 480 480 // needs to be on the heap because addStruct saves the pointer 481 __pass::symtab::addStructFwd( pass, 0, node );481 __pass::symtab::addStructFwd( core, 0, node ); 482 482 483 483 VISIT({ … … 488 488 489 489 // this addition replaces the forward declaration 490 __pass::symtab::addStruct( pass, 0, node );490 __pass::symtab::addStruct( core, 0, node ); 491 491 492 492 VISIT_END( Decl, node ); … … 495 495 //-------------------------------------------------------------------------- 496 496 // UnionDecl 497 template< typename pass_t >498 const ast::Decl * ast::Pass< pass_t >::visit( const ast::UnionDecl * node ) {497 template< typename core_t > 498 const ast::Decl * ast::Pass< core_t >::visit( const ast::UnionDecl * node ) { 499 499 VISIT_START( node ); 500 500 501 501 // make up a forward declaration and add it before processing the members 502 __pass::symtab::addUnionFwd( pass, 0, node );502 __pass::symtab::addUnionFwd( core, 0, node ); 503 503 504 504 VISIT({ … … 508 508 }) 509 509 510 __pass::symtab::addUnion( pass, 0, node );510 __pass::symtab::addUnion( core, 0, node ); 511 511 512 512 VISIT_END( Decl, node ); … … 515 515 //-------------------------------------------------------------------------- 516 516 // EnumDecl 517 template< typename pass_t >518 const ast::Decl * ast::Pass< pass_t >::visit( const ast::EnumDecl * node ) {519 VISIT_START( node ); 520 521 __pass::symtab::addEnum( pass, 0, node );517 template< typename core_t > 518 const ast::Decl * ast::Pass< core_t >::visit( const ast::EnumDecl * node ) { 519 VISIT_START( node ); 520 521 __pass::symtab::addEnum( core, 0, node ); 522 522 523 523 VISIT( … … 532 532 //-------------------------------------------------------------------------- 533 533 // TraitDecl 534 template< typename pass_t >535 const ast::Decl * ast::Pass< pass_t >::visit( const ast::TraitDecl * node ) {534 template< typename core_t > 535 const ast::Decl * ast::Pass< core_t >::visit( const ast::TraitDecl * node ) { 536 536 VISIT_START( node ); 537 537 … … 542 542 }) 543 543 544 __pass::symtab::addTrait( pass, 0, node );544 __pass::symtab::addTrait( core, 0, node ); 545 545 546 546 VISIT_END( Decl, node ); … … 549 549 //-------------------------------------------------------------------------- 550 550 // TypeDecl 551 template< typename pass_t >552 const ast::Decl * ast::Pass< pass_t >::visit( const ast::TypeDecl * node ) {551 template< typename core_t > 552 const ast::Decl * ast::Pass< core_t >::visit( const ast::TypeDecl * node ) { 553 553 VISIT_START( node ); 554 554 … … 562 562 // note that assertions come after the type is added to the symtab, since they are not part of the type proper 563 563 // and may depend on the type itself 564 __pass::symtab::addType( pass, 0, node );564 __pass::symtab::addType( core, 0, node ); 565 565 566 566 VISIT( … … 578 578 //-------------------------------------------------------------------------- 579 579 // TypedefDecl 580 template< typename pass_t >581 const ast::Decl * ast::Pass< pass_t >::visit( const ast::TypedefDecl * node ) {580 template< typename core_t > 581 const ast::Decl * ast::Pass< core_t >::visit( const ast::TypedefDecl * node ) { 582 582 VISIT_START( node ); 583 583 … … 588 588 }) 589 589 590 __pass::symtab::addType( pass, 0, node );590 __pass::symtab::addType( core, 0, node ); 591 591 592 592 VISIT( maybe_accept( node, &TypedefDecl::assertions ); ) … … 597 597 //-------------------------------------------------------------------------- 598 598 // AsmDecl 599 template< typename pass_t >600 const ast::AsmDecl * ast::Pass< pass_t >::visit( const ast::AsmDecl * node ) {599 template< typename core_t > 600 const ast::AsmDecl * ast::Pass< core_t >::visit( const ast::AsmDecl * node ) { 601 601 VISIT_START( node ); 602 602 … … 610 610 //-------------------------------------------------------------------------- 611 611 // StaticAssertDecl 612 template< typename pass_t >613 const ast::StaticAssertDecl * ast::Pass< pass_t >::visit( const ast::StaticAssertDecl * node ) {612 template< typename core_t > 613 const ast::StaticAssertDecl * ast::Pass< core_t >::visit( const ast::StaticAssertDecl * node ) { 614 614 VISIT_START( node ); 615 615 … … 624 624 //-------------------------------------------------------------------------- 625 625 // CompoundStmt 626 template< typename pass_t >627 const ast::CompoundStmt * ast::Pass< pass_t >::visit( const ast::CompoundStmt * node ) {626 template< typename core_t > 627 const ast::CompoundStmt * ast::Pass< core_t >::visit( const ast::CompoundStmt * node ) { 628 628 VISIT_START( node ); 629 629 VISIT({ 630 630 // do not enter a new scope if inFunction is true - needs to check old state before the assignment 631 631 auto guard1 = makeFuncGuard( [this, inFunctionCpy = this->inFunction]() { 632 if ( ! inFunctionCpy ) __pass::symtab::enter( pass, 0);632 if ( ! inFunctionCpy ) __pass::symtab::enter(core, 0); 633 633 }, [this, inFunctionCpy = this->inFunction]() { 634 if ( ! inFunctionCpy ) __pass::symtab::leave( pass, 0);634 if ( ! inFunctionCpy ) __pass::symtab::leave(core, 0); 635 635 }); 636 636 ValueGuard< bool > guard2( inFunction ); … … 644 644 //-------------------------------------------------------------------------- 645 645 // ExprStmt 646 template< typename pass_t >647 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::ExprStmt * node ) {646 template< typename core_t > 647 const ast::Stmt * ast::Pass< core_t >::visit( const ast::ExprStmt * node ) { 648 648 VISIT_START( node ); 649 649 … … 657 657 //-------------------------------------------------------------------------- 658 658 // AsmStmt 659 template< typename pass_t >660 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::AsmStmt * node ) {659 template< typename core_t > 660 const ast::Stmt * ast::Pass< core_t >::visit( const ast::AsmStmt * node ) { 661 661 VISIT_START( node ) 662 662 … … 673 673 //-------------------------------------------------------------------------- 674 674 // DirectiveStmt 675 template< typename pass_t >676 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::DirectiveStmt * node ) {675 template< typename core_t > 676 const ast::Stmt * ast::Pass< core_t >::visit( const ast::DirectiveStmt * node ) { 677 677 VISIT_START( node ) 678 678 … … 682 682 //-------------------------------------------------------------------------- 683 683 // IfStmt 684 template< typename pass_t >685 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::IfStmt * node ) {684 template< typename core_t > 685 const ast::Stmt * ast::Pass< core_t >::visit( const ast::IfStmt * node ) { 686 686 VISIT_START( node ); 687 687 … … 700 700 //-------------------------------------------------------------------------- 701 701 // WhileStmt 702 template< typename pass_t >703 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::WhileStmt * node ) {702 template< typename core_t > 703 const ast::Stmt * ast::Pass< core_t >::visit( const ast::WhileStmt * node ) { 704 704 VISIT_START( node ); 705 705 … … 717 717 //-------------------------------------------------------------------------- 718 718 // ForStmt 719 template< typename pass_t >720 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::ForStmt * node ) {719 template< typename core_t > 720 const ast::Stmt * ast::Pass< core_t >::visit( const ast::ForStmt * node ) { 721 721 VISIT_START( node ); 722 722 … … 735 735 //-------------------------------------------------------------------------- 736 736 // SwitchStmt 737 template< typename pass_t >738 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::SwitchStmt * node ) {737 template< typename core_t > 738 const ast::Stmt * ast::Pass< core_t >::visit( const ast::SwitchStmt * node ) { 739 739 VISIT_START( node ); 740 740 … … 749 749 //-------------------------------------------------------------------------- 750 750 // CaseStmt 751 template< typename pass_t >752 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::CaseStmt * node ) {751 template< typename core_t > 752 const ast::Stmt * ast::Pass< core_t >::visit( const ast::CaseStmt * node ) { 753 753 VISIT_START( node ); 754 754 … … 763 763 //-------------------------------------------------------------------------- 764 764 // BranchStmt 765 template< typename pass_t >766 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::BranchStmt * node ) {765 template< typename core_t > 766 const ast::Stmt * ast::Pass< core_t >::visit( const ast::BranchStmt * node ) { 767 767 VISIT_START( node ); 768 768 VISIT_END( Stmt, node ); … … 771 771 //-------------------------------------------------------------------------- 772 772 // ReturnStmt 773 template< typename pass_t >774 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::ReturnStmt * node ) {773 template< typename core_t > 774 const ast::Stmt * ast::Pass< core_t >::visit( const ast::ReturnStmt * node ) { 775 775 VISIT_START( node ); 776 776 … … 784 784 //-------------------------------------------------------------------------- 785 785 // ThrowStmt 786 template< typename pass_t >787 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::ThrowStmt * node ) {786 template< typename core_t > 787 const ast::Stmt * ast::Pass< core_t >::visit( const ast::ThrowStmt * node ) { 788 788 VISIT_START( node ); 789 789 … … 798 798 //-------------------------------------------------------------------------- 799 799 // TryStmt 800 template< typename pass_t >801 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::TryStmt * node ) {800 template< typename core_t > 801 const ast::Stmt * ast::Pass< core_t >::visit( const ast::TryStmt * node ) { 802 802 VISIT_START( node ); 803 803 … … 813 813 //-------------------------------------------------------------------------- 814 814 // CatchStmt 815 template< typename pass_t >816 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::CatchStmt * node ) {815 template< typename core_t > 816 const ast::Stmt * ast::Pass< core_t >::visit( const ast::CatchStmt * node ) { 817 817 VISIT_START( node ); 818 818 … … 830 830 //-------------------------------------------------------------------------- 831 831 // FinallyStmt 832 template< typename pass_t >833 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::FinallyStmt * node ) {832 template< typename core_t > 833 const ast::Stmt * ast::Pass< core_t >::visit( const ast::FinallyStmt * node ) { 834 834 VISIT_START( node ); 835 835 … … 843 843 //-------------------------------------------------------------------------- 844 844 // FinallyStmt 845 template< typename pass_t >846 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::SuspendStmt * node ) {845 template< typename core_t > 846 const ast::Stmt * ast::Pass< core_t >::visit( const ast::SuspendStmt * node ) { 847 847 VISIT_START( node ); 848 848 … … 856 856 //-------------------------------------------------------------------------- 857 857 // WaitForStmt 858 template< typename pass_t >859 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::WaitForStmt * node ) {858 template< typename core_t > 859 const ast::Stmt * ast::Pass< core_t >::visit( const ast::WaitForStmt * node ) { 860 860 VISIT_START( node ); 861 861 // for( auto & clause : node->clauses ) { … … 925 925 //-------------------------------------------------------------------------- 926 926 // WithStmt 927 template< typename pass_t >928 const ast::Decl * ast::Pass< pass_t >::visit( const ast::WithStmt * node ) {927 template< typename core_t > 928 const ast::Decl * ast::Pass< core_t >::visit( const ast::WithStmt * node ) { 929 929 VISIT_START( node ); 930 930 … … 934 934 // catch statements introduce a level of scope (for the caught exception) 935 935 guard_symtab guard { *this }; 936 __pass::symtab::addWith( pass, 0, node->exprs, node );936 __pass::symtab::addWith( core, 0, node->exprs, node ); 937 937 maybe_accept( node, &WithStmt::stmt ); 938 938 } … … 943 943 //-------------------------------------------------------------------------- 944 944 // NullStmt 945 template< typename pass_t >946 const ast::NullStmt * ast::Pass< pass_t >::visit( const ast::NullStmt * node ) {945 template< typename core_t > 946 const ast::NullStmt * ast::Pass< core_t >::visit( const ast::NullStmt * node ) { 947 947 VISIT_START( node ); 948 948 VISIT_END( NullStmt, node ); … … 951 951 //-------------------------------------------------------------------------- 952 952 // DeclStmt 953 template< typename pass_t >954 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::DeclStmt * node ) {953 template< typename core_t > 954 const ast::Stmt * ast::Pass< core_t >::visit( const ast::DeclStmt * node ) { 955 955 VISIT_START( node ); 956 956 … … 964 964 //-------------------------------------------------------------------------- 965 965 // ImplicitCtorDtorStmt 966 template< typename pass_t >967 const ast::Stmt * ast::Pass< pass_t >::visit( const ast::ImplicitCtorDtorStmt * node ) {966 template< typename core_t > 967 const ast::Stmt * ast::Pass< core_t >::visit( const ast::ImplicitCtorDtorStmt * node ) { 968 968 VISIT_START( node ); 969 969 … … 979 979 //-------------------------------------------------------------------------- 980 980 // ApplicationExpr 981 template< typename pass_t >982 const ast::Expr * ast::Pass< pass_t >::visit( const ast::ApplicationExpr * node ) {981 template< typename core_t > 982 const ast::Expr * ast::Pass< core_t >::visit( const ast::ApplicationExpr * node ) { 983 983 VISIT_START( node ); 984 984 … … 997 997 //-------------------------------------------------------------------------- 998 998 // UntypedExpr 999 template< typename pass_t >1000 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UntypedExpr * node ) {999 template< typename core_t > 1000 const ast::Expr * ast::Pass< core_t >::visit( const ast::UntypedExpr * node ) { 1001 1001 VISIT_START( node ); 1002 1002 … … 1015 1015 //-------------------------------------------------------------------------- 1016 1016 // NameExpr 1017 template< typename pass_t >1018 const ast::Expr * ast::Pass< pass_t >::visit( const ast::NameExpr * node ) {1017 template< typename core_t > 1018 const ast::Expr * ast::Pass< core_t >::visit( const ast::NameExpr * node ) { 1019 1019 VISIT_START( node ); 1020 1020 … … 1029 1029 //-------------------------------------------------------------------------- 1030 1030 // CastExpr 1031 template< typename pass_t >1032 const ast::Expr * ast::Pass< pass_t >::visit( const ast::CastExpr * node ) {1031 template< typename core_t > 1032 const ast::Expr * ast::Pass< core_t >::visit( const ast::CastExpr * node ) { 1033 1033 VISIT_START( node ); 1034 1034 … … 1045 1045 //-------------------------------------------------------------------------- 1046 1046 // KeywordCastExpr 1047 template< typename pass_t >1048 const ast::Expr * ast::Pass< pass_t >::visit( const ast::KeywordCastExpr * node ) {1047 template< typename core_t > 1048 const ast::Expr * ast::Pass< core_t >::visit( const ast::KeywordCastExpr * node ) { 1049 1049 VISIT_START( node ); 1050 1050 … … 1061 1061 //-------------------------------------------------------------------------- 1062 1062 // VirtualCastExpr 1063 template< typename pass_t >1064 const ast::Expr * ast::Pass< pass_t >::visit( const ast::VirtualCastExpr * node ) {1063 template< typename core_t > 1064 const ast::Expr * ast::Pass< core_t >::visit( const ast::VirtualCastExpr * node ) { 1065 1065 VISIT_START( node ); 1066 1066 … … 1077 1077 //-------------------------------------------------------------------------- 1078 1078 // AddressExpr 1079 template< typename pass_t >1080 const ast::Expr * ast::Pass< pass_t >::visit( const ast::AddressExpr * node ) {1079 template< typename core_t > 1080 const ast::Expr * ast::Pass< core_t >::visit( const ast::AddressExpr * node ) { 1081 1081 VISIT_START( node ); 1082 1082 … … 1093 1093 //-------------------------------------------------------------------------- 1094 1094 // LabelAddressExpr 1095 template< typename pass_t >1096 const ast::Expr * ast::Pass< pass_t >::visit( const ast::LabelAddressExpr * node ) {1095 template< typename core_t > 1096 const ast::Expr * ast::Pass< core_t >::visit( const ast::LabelAddressExpr * node ) { 1097 1097 VISIT_START( node ); 1098 1098 … … 1107 1107 //-------------------------------------------------------------------------- 1108 1108 // UntypedMemberExpr 1109 template< typename pass_t >1110 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UntypedMemberExpr * node ) {1109 template< typename core_t > 1110 const ast::Expr * ast::Pass< core_t >::visit( const ast::UntypedMemberExpr * node ) { 1111 1111 VISIT_START( node ); 1112 1112 … … 1124 1124 //-------------------------------------------------------------------------- 1125 1125 // MemberExpr 1126 template< typename pass_t >1127 const ast::Expr * ast::Pass< pass_t >::visit( const ast::MemberExpr * node ) {1126 template< typename core_t > 1127 const ast::Expr * ast::Pass< core_t >::visit( const ast::MemberExpr * node ) { 1128 1128 VISIT_START( node ); 1129 1129 … … 1140 1140 //-------------------------------------------------------------------------- 1141 1141 // VariableExpr 1142 template< typename pass_t >1143 const ast::Expr * ast::Pass< pass_t >::visit( const ast::VariableExpr * node ) {1142 template< typename core_t > 1143 const ast::Expr * ast::Pass< core_t >::visit( const ast::VariableExpr * node ) { 1144 1144 VISIT_START( node ); 1145 1145 … … 1154 1154 //-------------------------------------------------------------------------- 1155 1155 // ConstantExpr 1156 template< typename pass_t >1157 const ast::Expr * ast::Pass< pass_t >::visit( const ast::ConstantExpr * node ) {1156 template< typename core_t > 1157 const ast::Expr * ast::Pass< core_t >::visit( const ast::ConstantExpr * node ) { 1158 1158 VISIT_START( node ); 1159 1159 … … 1168 1168 //-------------------------------------------------------------------------- 1169 1169 // SizeofExpr 1170 template< typename pass_t >1171 const ast::Expr * ast::Pass< pass_t >::visit( const ast::SizeofExpr * node ) {1170 template< typename core_t > 1171 const ast::Expr * ast::Pass< core_t >::visit( const ast::SizeofExpr * node ) { 1172 1172 VISIT_START( node ); 1173 1173 … … 1188 1188 //-------------------------------------------------------------------------- 1189 1189 // AlignofExpr 1190 template< typename pass_t >1191 const ast::Expr * ast::Pass< pass_t >::visit( const ast::AlignofExpr * node ) {1190 template< typename core_t > 1191 const ast::Expr * ast::Pass< core_t >::visit( const ast::AlignofExpr * node ) { 1192 1192 VISIT_START( node ); 1193 1193 … … 1208 1208 //-------------------------------------------------------------------------- 1209 1209 // UntypedOffsetofExpr 1210 template< typename pass_t >1211 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UntypedOffsetofExpr * node ) {1210 template< typename core_t > 1211 const ast::Expr * ast::Pass< core_t >::visit( const ast::UntypedOffsetofExpr * node ) { 1212 1212 VISIT_START( node ); 1213 1213 … … 1224 1224 //-------------------------------------------------------------------------- 1225 1225 // OffsetofExpr 1226 template< typename pass_t >1227 const ast::Expr * ast::Pass< pass_t >::visit( const ast::OffsetofExpr * node ) {1226 template< typename core_t > 1227 const ast::Expr * ast::Pass< core_t >::visit( const ast::OffsetofExpr * node ) { 1228 1228 VISIT_START( node ); 1229 1229 … … 1240 1240 //-------------------------------------------------------------------------- 1241 1241 // OffsetPackExpr 1242 template< typename pass_t >1243 const ast::Expr * ast::Pass< pass_t >::visit( const ast::OffsetPackExpr * node ) {1242 template< typename core_t > 1243 const ast::Expr * ast::Pass< core_t >::visit( const ast::OffsetPackExpr * node ) { 1244 1244 VISIT_START( node ); 1245 1245 … … 1256 1256 //-------------------------------------------------------------------------- 1257 1257 // LogicalExpr 1258 template< typename pass_t >1259 const ast::Expr * ast::Pass< pass_t >::visit( const ast::LogicalExpr * node ) {1258 template< typename core_t > 1259 const ast::Expr * ast::Pass< core_t >::visit( const ast::LogicalExpr * node ) { 1260 1260 VISIT_START( node ); 1261 1261 … … 1273 1273 //-------------------------------------------------------------------------- 1274 1274 // ConditionalExpr 1275 template< typename pass_t >1276 const ast::Expr * ast::Pass< pass_t >::visit( const ast::ConditionalExpr * node ) {1275 template< typename core_t > 1276 const ast::Expr * ast::Pass< core_t >::visit( const ast::ConditionalExpr * node ) { 1277 1277 VISIT_START( node ); 1278 1278 … … 1291 1291 //-------------------------------------------------------------------------- 1292 1292 // CommaExpr 1293 template< typename pass_t >1294 const ast::Expr * ast::Pass< pass_t >::visit( const ast::CommaExpr * node ) {1293 template< typename core_t > 1294 const ast::Expr * ast::Pass< core_t >::visit( const ast::CommaExpr * node ) { 1295 1295 VISIT_START( node ); 1296 1296 … … 1308 1308 //-------------------------------------------------------------------------- 1309 1309 // TypeExpr 1310 template< typename pass_t >1311 const ast::Expr * ast::Pass< pass_t >::visit( const ast::TypeExpr * node ) {1310 template< typename core_t > 1311 const ast::Expr * ast::Pass< core_t >::visit( const ast::TypeExpr * node ) { 1312 1312 VISIT_START( node ); 1313 1313 … … 1324 1324 //-------------------------------------------------------------------------- 1325 1325 // AsmExpr 1326 template< typename pass_t >1327 const ast::Expr * ast::Pass< pass_t >::visit( const ast::AsmExpr * node ) {1326 template< typename core_t > 1327 const ast::Expr * ast::Pass< core_t >::visit( const ast::AsmExpr * node ) { 1328 1328 VISIT_START( node ); 1329 1329 … … 1341 1341 //-------------------------------------------------------------------------- 1342 1342 // ImplicitCopyCtorExpr 1343 template< typename pass_t >1344 const ast::Expr * ast::Pass< pass_t >::visit( const ast::ImplicitCopyCtorExpr * node ) {1343 template< typename core_t > 1344 const ast::Expr * ast::Pass< core_t >::visit( const ast::ImplicitCopyCtorExpr * node ) { 1345 1345 VISIT_START( node ); 1346 1346 … … 1357 1357 //-------------------------------------------------------------------------- 1358 1358 // ConstructorExpr 1359 template< typename pass_t >1360 const ast::Expr * ast::Pass< pass_t >::visit( const ast::ConstructorExpr * node ) {1359 template< typename core_t > 1360 const ast::Expr * ast::Pass< core_t >::visit( const ast::ConstructorExpr * node ) { 1361 1361 VISIT_START( node ); 1362 1362 … … 1373 1373 //-------------------------------------------------------------------------- 1374 1374 // CompoundLiteralExpr 1375 template< typename pass_t >1376 const ast::Expr * ast::Pass< pass_t >::visit( const ast::CompoundLiteralExpr * node ) {1375 template< typename core_t > 1376 const ast::Expr * ast::Pass< core_t >::visit( const ast::CompoundLiteralExpr * node ) { 1377 1377 VISIT_START( node ); 1378 1378 … … 1389 1389 //-------------------------------------------------------------------------- 1390 1390 // RangeExpr 1391 template< typename pass_t >1392 const ast::Expr * ast::Pass< pass_t >::visit( const ast::RangeExpr * node ) {1391 template< typename core_t > 1392 const ast::Expr * ast::Pass< core_t >::visit( const ast::RangeExpr * node ) { 1393 1393 VISIT_START( node ); 1394 1394 … … 1406 1406 //-------------------------------------------------------------------------- 1407 1407 // UntypedTupleExpr 1408 template< typename pass_t >1409 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UntypedTupleExpr * node ) {1408 template< typename core_t > 1409 const ast::Expr * ast::Pass< core_t >::visit( const ast::UntypedTupleExpr * node ) { 1410 1410 VISIT_START( node ); 1411 1411 … … 1422 1422 //-------------------------------------------------------------------------- 1423 1423 // TupleExpr 1424 template< typename pass_t >1425 const ast::Expr * ast::Pass< pass_t >::visit( const ast::TupleExpr * node ) {1424 template< typename core_t > 1425 const ast::Expr * ast::Pass< core_t >::visit( const ast::TupleExpr * node ) { 1426 1426 VISIT_START( node ); 1427 1427 … … 1438 1438 //-------------------------------------------------------------------------- 1439 1439 // TupleIndexExpr 1440 template< typename pass_t >1441 const ast::Expr * ast::Pass< pass_t >::visit( const ast::TupleIndexExpr * node ) {1440 template< typename core_t > 1441 const ast::Expr * ast::Pass< core_t >::visit( const ast::TupleIndexExpr * node ) { 1442 1442 VISIT_START( node ); 1443 1443 … … 1454 1454 //-------------------------------------------------------------------------- 1455 1455 // TupleAssignExpr 1456 template< typename pass_t >1457 const ast::Expr * ast::Pass< pass_t >::visit( const ast::TupleAssignExpr * node ) {1456 template< typename core_t > 1457 const ast::Expr * ast::Pass< core_t >::visit( const ast::TupleAssignExpr * node ) { 1458 1458 VISIT_START( node ); 1459 1459 … … 1470 1470 //-------------------------------------------------------------------------- 1471 1471 // StmtExpr 1472 template< typename pass_t >1473 const ast::Expr * ast::Pass< pass_t >::visit( const ast::StmtExpr * node ) {1472 template< typename core_t > 1473 const ast::Expr * ast::Pass< core_t >::visit( const ast::StmtExpr * node ) { 1474 1474 VISIT_START( node ); 1475 1475 1476 1476 VISIT(// don't want statements from outer CompoundStmts to be added to this StmtExpr 1477 1477 // get the stmts that will need to be spliced in 1478 auto stmts_before = __pass::stmtsToAddBefore( pass, 0);1479 auto stmts_after = __pass::stmtsToAddAfter ( pass, 0);1478 auto stmts_before = __pass::stmtsToAddBefore( core, 0); 1479 auto stmts_after = __pass::stmtsToAddAfter ( core, 0); 1480 1480 1481 1481 // These may be modified by subnode but most be restored once we exit this statemnet. 1482 ValueGuardPtr< const ast::TypeSubstitution * > __old_env( __pass::env( pass, 0) );1482 ValueGuardPtr< const ast::TypeSubstitution * > __old_env( __pass::env( core, 0) ); 1483 1483 ValueGuardPtr< typename std::remove_pointer< decltype(stmts_before) >::type > __old_decls_before( stmts_before ); 1484 1484 ValueGuardPtr< typename std::remove_pointer< decltype(stmts_after ) >::type > __old_decls_after ( stmts_after ); … … 1498 1498 //-------------------------------------------------------------------------- 1499 1499 // UniqueExpr 1500 template< typename pass_t >1501 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UniqueExpr * node ) {1500 template< typename core_t > 1501 const ast::Expr * ast::Pass< core_t >::visit( const ast::UniqueExpr * node ) { 1502 1502 VISIT_START( node ); 1503 1503 … … 1514 1514 //-------------------------------------------------------------------------- 1515 1515 // UntypedInitExpr 1516 template< typename pass_t >1517 const ast::Expr * ast::Pass< pass_t >::visit( const ast::UntypedInitExpr * node ) {1516 template< typename core_t > 1517 const ast::Expr * ast::Pass< core_t >::visit( const ast::UntypedInitExpr * node ) { 1518 1518 VISIT_START( node ); 1519 1519 … … 1531 1531 //-------------------------------------------------------------------------- 1532 1532 // InitExpr 1533 template< typename pass_t >1534 const ast::Expr * ast::Pass< pass_t >::visit( const ast::InitExpr * node ) {1533 template< typename core_t > 1534 const ast::Expr * ast::Pass< core_t >::visit( const ast::InitExpr * node ) { 1535 1535 VISIT_START( node ); 1536 1536 … … 1548 1548 //-------------------------------------------------------------------------- 1549 1549 // DeletedExpr 1550 template< typename pass_t >1551 const ast::Expr * ast::Pass< pass_t >::visit( const ast::DeletedExpr * node ) {1550 template< typename core_t > 1551 const ast::Expr * ast::Pass< core_t >::visit( const ast::DeletedExpr * node ) { 1552 1552 VISIT_START( node ); 1553 1553 … … 1565 1565 //-------------------------------------------------------------------------- 1566 1566 // DefaultArgExpr 1567 template< typename pass_t >1568 const ast::Expr * ast::Pass< pass_t >::visit( const ast::DefaultArgExpr * node ) {1567 template< typename core_t > 1568 const ast::Expr * ast::Pass< core_t >::visit( const ast::DefaultArgExpr * node ) { 1569 1569 VISIT_START( node ); 1570 1570 … … 1581 1581 //-------------------------------------------------------------------------- 1582 1582 // GenericExpr 1583 template< typename pass_t >1584 const ast::Expr * ast::Pass< pass_t >::visit( const ast::GenericExpr * node ) {1583 template< typename core_t > 1584 const ast::Expr * ast::Pass< core_t >::visit( const ast::GenericExpr * node ) { 1585 1585 VISIT_START( node ); 1586 1586 … … 1621 1621 //-------------------------------------------------------------------------- 1622 1622 // VoidType 1623 template< typename pass_t >1624 const ast::Type * ast::Pass< pass_t >::visit( const ast::VoidType * node ) {1623 template< typename core_t > 1624 const ast::Type * ast::Pass< core_t >::visit( const ast::VoidType * node ) { 1625 1625 VISIT_START( node ); 1626 1626 … … 1630 1630 //-------------------------------------------------------------------------- 1631 1631 // BasicType 1632 template< typename pass_t >1633 const ast::Type * ast::Pass< pass_t >::visit( const ast::BasicType * node ) {1632 template< typename core_t > 1633 const ast::Type * ast::Pass< core_t >::visit( const ast::BasicType * node ) { 1634 1634 VISIT_START( node ); 1635 1635 … … 1639 1639 //-------------------------------------------------------------------------- 1640 1640 // PointerType 1641 template< typename pass_t >1642 const ast::Type * ast::Pass< pass_t >::visit( const ast::PointerType * node ) {1641 template< typename core_t > 1642 const ast::Type * ast::Pass< core_t >::visit( const ast::PointerType * node ) { 1643 1643 VISIT_START( node ); 1644 1644 … … 1653 1653 //-------------------------------------------------------------------------- 1654 1654 // ArrayType 1655 template< typename pass_t >1656 const ast::Type * ast::Pass< pass_t >::visit( const ast::ArrayType * node ) {1655 template< typename core_t > 1656 const ast::Type * ast::Pass< core_t >::visit( const ast::ArrayType * node ) { 1657 1657 VISIT_START( node ); 1658 1658 … … 1667 1667 //-------------------------------------------------------------------------- 1668 1668 // ReferenceType 1669 template< typename pass_t >1670 const ast::Type * ast::Pass< pass_t >::visit( const ast::ReferenceType * node ) {1669 template< typename core_t > 1670 const ast::Type * ast::Pass< core_t >::visit( const ast::ReferenceType * node ) { 1671 1671 VISIT_START( node ); 1672 1672 … … 1680 1680 //-------------------------------------------------------------------------- 1681 1681 // QualifiedType 1682 template< typename pass_t >1683 const ast::Type * ast::Pass< pass_t >::visit( const ast::QualifiedType * node ) {1682 template< typename core_t > 1683 const ast::Type * ast::Pass< core_t >::visit( const ast::QualifiedType * node ) { 1684 1684 VISIT_START( node ); 1685 1685 … … 1694 1694 //-------------------------------------------------------------------------- 1695 1695 // FunctionType 1696 template< typename pass_t >1697 const ast::Type * ast::Pass< pass_t >::visit( const ast::FunctionType * node ) {1696 template< typename core_t > 1697 const ast::Type * ast::Pass< core_t >::visit( const ast::FunctionType * node ) { 1698 1698 VISIT_START( node ); 1699 1699 … … 1710 1710 //-------------------------------------------------------------------------- 1711 1711 // StructInstType 1712 template< typename pass_t >1713 const ast::Type * ast::Pass< pass_t >::visit( const ast::StructInstType * node ) {1714 VISIT_START( node ); 1715 1716 __pass::symtab::addStruct( pass, 0, node->name );1712 template< typename core_t > 1713 const ast::Type * ast::Pass< core_t >::visit( const ast::StructInstType * node ) { 1714 VISIT_START( node ); 1715 1716 __pass::symtab::addStruct( core, 0, node->name ); 1717 1717 1718 1718 VISIT({ … … 1728 1728 //-------------------------------------------------------------------------- 1729 1729 // UnionInstType 1730 template< typename pass_t >1731 const ast::Type * ast::Pass< pass_t >::visit( const ast::UnionInstType * node ) {1732 VISIT_START( node ); 1733 1734 __pass::symtab::addUnion( pass, 0, node->name );1730 template< typename core_t > 1731 const ast::Type * ast::Pass< core_t >::visit( const ast::UnionInstType * node ) { 1732 VISIT_START( node ); 1733 1734 __pass::symtab::addUnion( core, 0, node->name ); 1735 1735 1736 1736 VISIT({ … … 1746 1746 //-------------------------------------------------------------------------- 1747 1747 // EnumInstType 1748 template< typename pass_t >1749 const ast::Type * ast::Pass< pass_t >::visit( const ast::EnumInstType * node ) {1748 template< typename core_t > 1749 const ast::Type * ast::Pass< core_t >::visit( const ast::EnumInstType * node ) { 1750 1750 VISIT_START( node ); 1751 1751 … … 1761 1761 //-------------------------------------------------------------------------- 1762 1762 // TraitInstType 1763 template< typename pass_t >1764 const ast::Type * ast::Pass< pass_t >::visit( const ast::TraitInstType * node ) {1763 template< typename core_t > 1764 const ast::Type * ast::Pass< core_t >::visit( const ast::TraitInstType * node ) { 1765 1765 VISIT_START( node ); 1766 1766 … … 1776 1776 //-------------------------------------------------------------------------- 1777 1777 // TypeInstType 1778 template< typename pass_t >1779 const ast::Type * ast::Pass< pass_t >::visit( const ast::TypeInstType * node ) {1778 template< typename core_t > 1779 const ast::Type * ast::Pass< core_t >::visit( const ast::TypeInstType * node ) { 1780 1780 VISIT_START( node ); 1781 1781 … … 1787 1787 } 1788 1788 // ensure that base re-bound if doing substitution 1789 __pass::forall::replace( pass, 0, node );1789 __pass::forall::replace( core, 0, node ); 1790 1790 ) 1791 1791 … … 1795 1795 //-------------------------------------------------------------------------- 1796 1796 // TupleType 1797 template< typename pass_t >1798 const ast::Type * ast::Pass< pass_t >::visit( const ast::TupleType * node ) {1797 template< typename core_t > 1798 const ast::Type * ast::Pass< core_t >::visit( const ast::TupleType * node ) { 1799 1799 VISIT_START( node ); 1800 1800 … … 1809 1809 //-------------------------------------------------------------------------- 1810 1810 // TypeofType 1811 template< typename pass_t >1812 const ast::Type * ast::Pass< pass_t >::visit( const ast::TypeofType * node ) {1811 template< typename core_t > 1812 const ast::Type * ast::Pass< core_t >::visit( const ast::TypeofType * node ) { 1813 1813 VISIT_START( node ); 1814 1814 … … 1822 1822 //-------------------------------------------------------------------------- 1823 1823 // VarArgsType 1824 template< typename pass_t >1825 const ast::Type * ast::Pass< pass_t >::visit( const ast::VarArgsType * node ) {1824 template< typename core_t > 1825 const ast::Type * ast::Pass< core_t >::visit( const ast::VarArgsType * node ) { 1826 1826 VISIT_START( node ); 1827 1827 … … 1831 1831 //-------------------------------------------------------------------------- 1832 1832 // ZeroType 1833 template< typename pass_t >1834 const ast::Type * ast::Pass< pass_t >::visit( const ast::ZeroType * node ) {1833 template< typename core_t > 1834 const ast::Type * ast::Pass< core_t >::visit( const ast::ZeroType * node ) { 1835 1835 VISIT_START( node ); 1836 1836 … … 1840 1840 //-------------------------------------------------------------------------- 1841 1841 // OneType 1842 template< typename pass_t >1843 const ast::Type * ast::Pass< pass_t >::visit( const ast::OneType * node ) {1842 template< typename core_t > 1843 const ast::Type * ast::Pass< core_t >::visit( const ast::OneType * node ) { 1844 1844 VISIT_START( node ); 1845 1845 … … 1849 1849 //-------------------------------------------------------------------------- 1850 1850 // GlobalScopeType 1851 template< typename pass_t >1852 const ast::Type * ast::Pass< pass_t >::visit( const ast::GlobalScopeType * node ) {1851 template< typename core_t > 1852 const ast::Type * ast::Pass< core_t >::visit( const ast::GlobalScopeType * node ) { 1853 1853 VISIT_START( node ); 1854 1854 … … 1859 1859 //-------------------------------------------------------------------------- 1860 1860 // Designation 1861 template< typename pass_t >1862 const ast::Designation * ast::Pass< pass_t >::visit( const ast::Designation * node ) {1861 template< typename core_t > 1862 const ast::Designation * ast::Pass< core_t >::visit( const ast::Designation * node ) { 1863 1863 VISIT_START( node ); 1864 1864 … … 1870 1870 //-------------------------------------------------------------------------- 1871 1871 // SingleInit 1872 template< typename pass_t >1873 const ast::Init * ast::Pass< pass_t >::visit( const ast::SingleInit * node ) {1872 template< typename core_t > 1873 const ast::Init * ast::Pass< core_t >::visit( const ast::SingleInit * node ) { 1874 1874 VISIT_START( node ); 1875 1875 … … 1883 1883 //-------------------------------------------------------------------------- 1884 1884 // ListInit 1885 template< typename pass_t >1886 const ast::Init * ast::Pass< pass_t >::visit( const ast::ListInit * node ) {1885 template< typename core_t > 1886 const ast::Init * ast::Pass< core_t >::visit( const ast::ListInit * node ) { 1887 1887 VISIT_START( node ); 1888 1888 … … 1897 1897 //-------------------------------------------------------------------------- 1898 1898 // ConstructorInit 1899 template< typename pass_t >1900 const ast::Init * ast::Pass< pass_t >::visit( const ast::ConstructorInit * node ) {1899 template< typename core_t > 1900 const ast::Init * ast::Pass< core_t >::visit( const ast::ConstructorInit * node ) { 1901 1901 VISIT_START( node ); 1902 1902 … … 1912 1912 //-------------------------------------------------------------------------- 1913 1913 // Attribute 1914 template< typename pass_t >1915 const ast::Attribute * ast::Pass< pass_t >::visit( const ast::Attribute * node ) {1914 template< typename core_t > 1915 const ast::Attribute * ast::Pass< core_t >::visit( const ast::Attribute * node ) { 1916 1916 VISIT_START( node ); 1917 1917 … … 1925 1925 //-------------------------------------------------------------------------- 1926 1926 // TypeSubstitution 1927 template< typename pass_t >1928 const ast::TypeSubstitution * ast::Pass< pass_t >::visit( const ast::TypeSubstitution * node ) {1927 template< typename core_t > 1928 const ast::TypeSubstitution * ast::Pass< core_t >::visit( const ast::TypeSubstitution * node ) { 1929 1929 VISIT_START( node ); 1930 1930 -
src/AST/Pass.proto.hpp
r343d10e r7ff3e522 20 20 21 21 namespace ast { 22 template<typename pass_type>22 template<typename core_t> 23 23 class Pass; 24 24 … … 113 113 /// "Short hand" to check if this is a valid previsit function 114 114 /// Mostly used to make the static_assert look (and print) prettier 115 template<typename pass_t, typename node_t>115 template<typename core_t, typename node_t> 116 116 struct is_valid_previsit { 117 using ret_t = decltype( (( pass_t*)nullptr)->previsit( (const node_t *)nullptr ) );117 using ret_t = decltype( ((core_t*)nullptr)->previsit( (const node_t *)nullptr ) ); 118 118 119 119 static constexpr bool value = std::is_void< ret_t >::value || … … 129 129 template<> 130 130 struct __assign<true> { 131 template<typename pass_t, typename node_t>132 static inline void result( pass_t & pass, const node_t * & node ) {133 pass.previsit( node );131 template<typename core_t, typename node_t> 132 static inline void result( core_t & core, const node_t * & node ) { 133 core.previsit( node ); 134 134 } 135 135 }; … … 137 137 template<> 138 138 struct __assign<false> { 139 template<typename pass_t, typename node_t>140 static inline void result( pass_t & pass, const node_t * & node ) {141 node = pass.previsit( node );139 template<typename core_t, typename node_t> 140 static inline void result( core_t & core, const node_t * & node ) { 141 node = core.previsit( node ); 142 142 assertf(node, "Previsit must not return NULL"); 143 143 } … … 152 152 template<> 153 153 struct __return<true> { 154 template<typename pass_t, typename node_t>155 static inline const node_t * result( pass_t & pass, const node_t * & node ) {156 pass.postvisit( node );154 template<typename core_t, typename node_t> 155 static inline const node_t * result( core_t & core, const node_t * & node ) { 156 core.postvisit( node ); 157 157 return node; 158 158 } … … 161 161 template<> 162 162 struct __return<false> { 163 template<typename pass_t, typename node_t>164 static inline auto result( pass_t & pass, const node_t * & node ) {165 return pass.postvisit( node );163 template<typename core_t, typename node_t> 164 static inline auto result( core_t & core, const node_t * & node ) { 165 return core.postvisit( node ); 166 166 } 167 167 }; … … 182 182 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 183 183 // PreVisit : may mutate the pointer passed in if the node is mutated in the previsit call 184 template<typename pass_t, typename node_t>185 static inline auto previsit( pass_t & pass, const node_t * & node, int ) -> decltype( pass.previsit( node ), void() ) {184 template<typename core_t, typename node_t> 185 static inline auto previsit( core_t & core, const node_t * & node, int ) -> decltype( core.previsit( node ), void() ) { 186 186 static_assert( 187 is_valid_previsit< pass_t, node_t>::value,187 is_valid_previsit<core_t, node_t>::value, 188 188 "Previsit may not change the type of the node. It must return its paremeter or void." 189 189 ); … … 191 191 __assign< 192 192 std::is_void< 193 decltype( pass.previsit( node ) )193 decltype( core.previsit( node ) ) 194 194 >::value 195 >::result( pass, node );195 >::result( core, node ); 196 196 } 197 197 198 template<typename pass_t, typename node_t>199 static inline auto previsit( pass_t &, const node_t *, long ) {}198 template<typename core_t, typename node_t> 199 static inline auto previsit( core_t &, const node_t *, long ) {} 200 200 201 201 // PostVisit : never mutates the passed pointer but may return a different node 202 template<typename pass_t, typename node_t>203 static inline auto postvisit( pass_t & pass, const node_t * node, int ) ->204 decltype( pass.postvisit( node ), node->accept( *(Visitor*)nullptr ) )202 template<typename core_t, typename node_t> 203 static inline auto postvisit( core_t & core, const node_t * node, int ) -> 204 decltype( core.postvisit( node ), node->accept( *(Visitor*)nullptr ) ) 205 205 { 206 206 return __return< 207 207 std::is_void< 208 decltype( pass.postvisit( node ) )208 decltype( core.postvisit( node ) ) 209 209 >::value 210 >::result( pass, node );210 >::result( core, node ); 211 211 } 212 212 213 template<typename pass_t, typename node_t>214 static inline const node_t * postvisit( pass_t &, const node_t * node, long ) { return node; }213 template<typename core_t, typename node_t> 214 static inline const node_t * postvisit( core_t &, const node_t * node, long ) { return node; } 215 215 216 216 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------- … … 227 227 // The type is not strictly enforced but does match the accessory 228 228 #define FIELD_PTR( name, default_type ) \ 229 template< typename pass_t > \230 static inline auto name( pass_t & pass, int ) -> decltype( &pass.name ) { return &pass.name; } \229 template< typename core_t > \ 230 static inline auto name( core_t & core, int ) -> decltype( &core.name ) { return &core.name; } \ 231 231 \ 232 template< typename pass_t > \233 static inline default_type * name( pass_t &, long ) { return nullptr; }232 template< typename core_t > \ 233 static inline default_type * name( core_t &, long ) { return nullptr; } 234 234 235 235 // List of fields and their expected types … … 241 241 FIELD_PTR( visit_children, __pass::bool_ref ) 242 242 FIELD_PTR( at_cleanup, __pass::at_cleanup_t ) 243 FIELD_PTR( visitor, ast::Pass< pass_t> * const )243 FIELD_PTR( visitor, ast::Pass<core_t> * const ) 244 244 245 245 // Remove the macro to make sure we don't clash 246 246 #undef FIELD_PTR 247 247 248 template< typename pass_t >249 static inline auto beginTrace( pass_t &, int) -> decltype( pass_t::traceId, void() ) {250 // Stats::Heap::stacktrace_push( pass_t::traceId);248 template< typename core_t > 249 static inline auto beginTrace(core_t &, int) -> decltype( core_t::traceId, void() ) { 250 // Stats::Heap::stacktrace_push(core_t::traceId); 251 251 } 252 252 253 template< typename pass_t >254 static inline auto endTrace( pass_t &, int) -> decltype( pass_t::traceId, void() ) {253 template< typename core_t > 254 static inline auto endTrace(core_t &, int) -> decltype( core_t::traceId, void() ) { 255 255 // Stats::Heap::stacktrace_pop(); 256 256 } 257 257 258 template< typename pass_t >259 static void beginTrace( pass_t &, long) {}260 261 template< typename pass_t >262 static void endTrace( pass_t &, long) {}258 template< typename core_t > 259 static void beginTrace(core_t &, long) {} 260 261 template< typename core_t > 262 static void endTrace(core_t &, long) {} 263 263 264 264 // Another feature of the templated visitor is that it calls beginScope()/endScope() for compound statement. … … 266 266 // detect it using the same strategy 267 267 namespace scope { 268 template<typename pass_t>269 static inline auto enter( pass_t & pass, int ) -> decltype( pass.beginScope(), void() ) {270 pass.beginScope();271 } 272 273 template<typename pass_t>274 static inline void enter( pass_t &, long ) {}275 276 template<typename pass_t>277 static inline auto leave( pass_t & pass, int ) -> decltype( pass.endScope(), void() ) {278 pass.endScope();279 } 280 281 template<typename pass_t>282 static inline void leave( pass_t &, long ) {}268 template<typename core_t> 269 static inline auto enter( core_t & core, int ) -> decltype( core.beginScope(), void() ) { 270 core.beginScope(); 271 } 272 273 template<typename core_t> 274 static inline void enter( core_t &, long ) {} 275 276 template<typename core_t> 277 static inline auto leave( core_t & core, int ) -> decltype( core.endScope(), void() ) { 278 core.endScope(); 279 } 280 281 template<typename core_t> 282 static inline void leave( core_t &, long ) {} 283 283 } // namespace scope 284 284 … … 287 287 namespace symtab { 288 288 // Some simple scoping rules 289 template<typename pass_t>290 static inline auto enter( pass_t & pass, int ) -> decltype( pass.symtab, void() ) {291 pass.symtab.enterScope();292 } 293 294 template<typename pass_t>295 static inline auto enter( pass_t &, long ) {}296 297 template<typename pass_t>298 static inline auto leave( pass_t & pass, int ) -> decltype( pass.symtab, void() ) {299 pass.symtab.leaveScope();300 } 301 302 template<typename pass_t>303 static inline auto leave( pass_t &, long ) {}289 template<typename core_t> 290 static inline auto enter( core_t & core, int ) -> decltype( core.symtab, void() ) { 291 core.symtab.enterScope(); 292 } 293 294 template<typename core_t> 295 static inline auto enter( core_t &, long ) {} 296 297 template<typename core_t> 298 static inline auto leave( core_t & core, int ) -> decltype( core.symtab, void() ) { 299 core.symtab.leaveScope(); 300 } 301 302 template<typename core_t> 303 static inline auto leave( core_t &, long ) {} 304 304 305 305 // The symbol table has 2 kind of functions mostly, 1 argument and 2 arguments 306 306 // Create macro to condense these common patterns 307 307 #define SYMTAB_FUNC1( func, type ) \ 308 template<typename pass_t> \309 static inline auto func( pass_t & pass, int, type arg ) -> decltype( pass.symtab.func( arg ), void() ) {\310 pass.symtab.func( arg ); \308 template<typename core_t> \ 309 static inline auto func( core_t & core, int, type arg ) -> decltype( core.symtab.func( arg ), void() ) {\ 310 core.symtab.func( arg ); \ 311 311 } \ 312 312 \ 313 template<typename pass_t> \314 static inline void func( pass_t &, long, type ) {}313 template<typename core_t> \ 314 static inline void func( core_t &, long, type ) {} 315 315 316 316 #define SYMTAB_FUNC2( func, type1, type2 ) \ 317 template<typename pass_t> \318 static inline auto func( pass_t & pass, int, type1 arg1, type2 arg2 ) -> decltype( pass.symtab.func( arg1, arg2 ), void () ) {\319 pass.symtab.func( arg1, arg2 ); \317 template<typename core_t> \ 318 static inline auto func( core_t & core, int, type1 arg1, type2 arg2 ) -> decltype( core.symtab.func( arg1, arg2 ), void () ) {\ 319 core.symtab.func( arg1, arg2 ); \ 320 320 } \ 321 321 \ 322 template<typename pass_t> \323 static inline void func( pass_t &, long, type1, type2 ) {}322 template<typename core_t> \ 323 static inline void func( core_t &, long, type1, type2 ) {} 324 324 325 325 SYMTAB_FUNC1( addId , const DeclWithType * ); … … 332 332 333 333 // A few extra functions have more complicated behaviour, they are hand written 334 template<typename pass_t>335 static inline auto addStructFwd( pass_t & pass, int, const ast::StructDecl * decl ) -> decltype( pass.symtab.addStruct( decl ), void() ) {334 template<typename core_t> 335 static inline auto addStructFwd( core_t & core, int, const ast::StructDecl * decl ) -> decltype( core.symtab.addStruct( decl ), void() ) { 336 336 ast::StructDecl * fwd = new ast::StructDecl( decl->location, decl->name ); 337 337 fwd->params = decl->params; 338 pass.symtab.addStruct( fwd );339 } 340 341 template<typename pass_t>342 static inline void addStructFwd( pass_t &, long, const ast::StructDecl * ) {}343 344 template<typename pass_t>345 static inline auto addUnionFwd( pass_t & pass, int, const ast::UnionDecl * decl ) -> decltype( pass.symtab.addUnion( decl ), void() ) {338 core.symtab.addStruct( fwd ); 339 } 340 341 template<typename core_t> 342 static inline void addStructFwd( core_t &, long, const ast::StructDecl * ) {} 343 344 template<typename core_t> 345 static inline auto addUnionFwd( core_t & core, int, const ast::UnionDecl * decl ) -> decltype( core.symtab.addUnion( decl ), void() ) { 346 346 UnionDecl * fwd = new UnionDecl( decl->location, decl->name ); 347 347 fwd->params = decl->params; 348 pass.symtab.addUnion( fwd );349 } 350 351 template<typename pass_t>352 static inline void addUnionFwd( pass_t &, long, const ast::UnionDecl * ) {}353 354 template<typename pass_t>355 static inline auto addStruct( pass_t & pass, int, const std::string & str ) -> decltype( pass.symtab.addStruct( str ), void() ) {356 if ( ! pass.symtab.lookupStruct( str ) ) {357 pass.symtab.addStruct( str );348 core.symtab.addUnion( fwd ); 349 } 350 351 template<typename core_t> 352 static inline void addUnionFwd( core_t &, long, const ast::UnionDecl * ) {} 353 354 template<typename core_t> 355 static inline auto addStruct( core_t & core, int, const std::string & str ) -> decltype( core.symtab.addStruct( str ), void() ) { 356 if ( ! core.symtab.lookupStruct( str ) ) { 357 core.symtab.addStruct( str ); 358 358 } 359 359 } 360 360 361 template<typename pass_t>362 static inline void addStruct( pass_t &, long, const std::string & ) {}363 364 template<typename pass_t>365 static inline auto addUnion( pass_t & pass, int, const std::string & str ) -> decltype( pass.symtab.addUnion( str ), void() ) {366 if ( ! pass.symtab.lookupUnion( str ) ) {367 pass.symtab.addUnion( str );361 template<typename core_t> 362 static inline void addStruct( core_t &, long, const std::string & ) {} 363 364 template<typename core_t> 365 static inline auto addUnion( core_t & core, int, const std::string & str ) -> decltype( core.symtab.addUnion( str ), void() ) { 366 if ( ! core.symtab.lookupUnion( str ) ) { 367 core.symtab.addUnion( str ); 368 368 } 369 369 } 370 370 371 template<typename pass_t>372 static inline void addUnion( pass_t &, long, const std::string & ) {}371 template<typename core_t> 372 static inline void addUnion( core_t &, long, const std::string & ) {} 373 373 374 374 #undef SYMTAB_FUNC1 … … 380 380 namespace forall { 381 381 // Some simple scoping rules 382 template<typename pass_t>383 static inline auto enter( pass_t & pass, int, const ast::ParameterizedType * type )384 -> decltype( pass.subs, void() ) {385 if ( ! type->forall.empty() ) pass.subs.beginScope();386 } 387 388 template<typename pass_t>389 static inline auto enter( pass_t &, long, const ast::ParameterizedType * ) {}390 391 template<typename pass_t>392 static inline auto leave( pass_t & pass, int, const ast::ParameterizedType * type )393 -> decltype( pass.subs, void() ) {394 if ( ! type->forall.empty() ) { pass.subs.endScope(); }395 } 396 397 template<typename pass_t>398 static inline auto leave( pass_t &, long, const ast::ParameterizedType * ) {}382 template<typename core_t> 383 static inline auto enter( core_t & core, int, const ast::ParameterizedType * type ) 384 -> decltype( core.subs, void() ) { 385 if ( ! type->forall.empty() ) core.subs.beginScope(); 386 } 387 388 template<typename core_t> 389 static inline auto enter( core_t &, long, const ast::ParameterizedType * ) {} 390 391 template<typename core_t> 392 static inline auto leave( core_t & core, int, const ast::ParameterizedType * type ) 393 -> decltype( core.subs, void() ) { 394 if ( ! type->forall.empty() ) { core.subs.endScope(); } 395 } 396 397 template<typename core_t> 398 static inline auto leave( core_t &, long, const ast::ParameterizedType * ) {} 399 399 400 400 // Get the substitution table, if present 401 template<typename pass_t>402 static inline auto subs( pass_t & pass, int ) -> decltype( &pass.subs ) {403 return & pass.subs;404 } 405 406 template<typename pass_t>407 static inline ast::ForallSubstitutionTable * subs( pass_t &, long ) { return nullptr; }401 template<typename core_t> 402 static inline auto subs( core_t & core, int ) -> decltype( &core.subs ) { 403 return &core.subs; 404 } 405 406 template<typename core_t> 407 static inline ast::ForallSubstitutionTable * subs( core_t &, long ) { return nullptr; } 408 408 409 409 // Replaces a TypeInstType's base TypeDecl according to the table 410 template<typename pass_t>411 static inline auto replace( pass_t & pass, int, const ast::TypeInstType *& inst )412 -> decltype( pass.subs, void() ) {410 template<typename core_t> 411 static inline auto replace( core_t & core, int, const ast::TypeInstType *& inst ) 412 -> decltype( core.subs, void() ) { 413 413 inst = ast::mutate_field( 414 inst, &ast::TypeInstType::base, pass.subs.replace( inst->base ) );415 } 416 417 template<typename pass_t>418 static inline auto replace( pass_t &, long, const ast::TypeInstType *& ) {}414 inst, &ast::TypeInstType::base, core.subs.replace( inst->base ) ); 415 } 416 417 template<typename core_t> 418 static inline auto replace( core_t &, long, const ast::TypeInstType *& ) {} 419 419 420 420 } // namespace forall -
src/AST/Type.cpp
r343d10e r7ff3e522 94 94 // --- ParameterizedType 95 95 96 void ParameterizedType::initWithSub( 97 const ParameterizedType & o, Pass< ForallSubstitutor > & sub 96 void ParameterizedType::initWithSub( 97 const ParameterizedType & o, Pass< ForallSubstitutor > & sub 98 98 ) { 99 forall = sub. pass( o.forall );99 forall = sub.core( o.forall ); 100 100 } 101 101 … … 103 103 104 104 FunctionType::FunctionType( const FunctionType & o ) 105 : ParameterizedType( o.qualifiers, copy( o.attributes ) ), returns(), params(), 105 : ParameterizedType( o.qualifiers, copy( o.attributes ) ), returns(), params(), 106 106 isVarArgs( o.isVarArgs ) { 107 107 Pass< ForallSubstitutor > sub; 108 108 initWithSub( o, sub ); // initialize substitution map 109 returns = sub. pass( o.returns ); // apply to return and parameter types110 params = sub. pass( o.params );109 returns = sub.core( o.returns ); // apply to return and parameter types 110 params = sub.core( o.params ); 111 111 } 112 112 … … 128 128 void ReferenceToType::initWithSub( const ReferenceToType & o, Pass< ForallSubstitutor > & sub ) { 129 129 ParameterizedType::initWithSub( o, sub ); // initialize substitution 130 params = sub. pass( o.params ); // apply to parameters130 params = sub.core( o.params ); // apply to parameters 131 131 } 132 132 … … 166 166 // --- TraitInstType 167 167 168 TraitInstType::TraitInstType( 168 TraitInstType::TraitInstType( 169 169 const TraitDecl * b, CV::Qualifiers q, std::vector<ptr<Attribute>>&& as ) 170 170 : ReferenceToType( b->name, q, move(as) ), base( b ) {} … … 172 172 // --- TypeInstType 173 173 174 TypeInstType::TypeInstType( const TypeInstType & o ) 174 TypeInstType::TypeInstType( const TypeInstType & o ) 175 175 : ReferenceToType( o.name, o.qualifiers, copy( o.attributes ) ), base(), kind( o.kind ) { 176 176 Pass< ForallSubstitutor > sub; 177 177 initWithSub( o, sub ); // initialize substitution 178 base = sub. pass( o.base ); // apply to base type178 base = sub.core( o.base ); // apply to base type 179 179 } 180 180 -
src/AST/TypeEnvironment.cpp
r343d10e r7ff3e522 59 59 std::copy( clz.vars.begin(), clz.vars.end(), std::ostream_iterator< std::string >( out, " " ) ); 60 60 out << ")"; 61 61 62 62 if ( clz.bound ) { 63 63 out << " -> "; … … 92 92 } 93 93 } 94 94 95 95 i = next; // go to next node even if this removed 96 96 } … … 161 161 Pass<Occurs> occur{ var, env }; 162 162 maybe_accept( ty, occur ); 163 return occur. pass.result;164 } 165 } 166 167 bool TypeEnvironment::combine( 163 return occur.core.result; 164 } 165 } 166 167 bool TypeEnvironment::combine( 168 168 const TypeEnvironment & o, OpenVarSet & open, const SymbolTable & symtab ) { 169 169 // short-circuit easy cases … … 199 199 auto st = internal_lookup( *vt ); 200 200 if ( st == env.end() ) { 201 // unbound, safe to add if occurs 201 // unbound, safe to add if occurs 202 202 if ( r.bound && occurs( r.bound, *vt, *this ) ) return false; 203 203 r.vars.emplace( *vt ); … … 266 266 } 267 267 268 bool TypeEnvironment::bindVar( 269 const TypeInstType * typeInst, const Type * bindTo, const TypeDecl::Data & data, 270 AssertionSet & need, AssertionSet & have, const OpenVarSet & open, WidenMode widen, 271 const SymbolTable & symtab 268 bool TypeEnvironment::bindVar( 269 const TypeInstType * typeInst, const Type * bindTo, const TypeDecl::Data & data, 270 AssertionSet & need, AssertionSet & have, const OpenVarSet & open, WidenMode widen, 271 const SymbolTable & symtab 272 272 ) { 273 273 // remove references from bound type, so that type variables can only bind to value types … … 286 286 ptr<Type> newType = it->bound; 287 287 reset_qualifiers( newType, typeInst->qualifiers ); 288 if ( unifyInexact( 289 newType, target, *this, need, have, open, 288 if ( unifyInexact( 289 newType, target, *this, need, have, open, 290 290 widen & WidenMode{ it->allowWidening, true }, symtab, common ) ) { 291 291 if ( common ) { … … 300 300 } 301 301 } else { 302 env.emplace_back( 302 env.emplace_back( 303 303 typeInst->name, target, widen.first && widen.second, data ); 304 304 } … … 306 306 } 307 307 308 bool TypeEnvironment::bindVarToVar( 309 const TypeInstType * var1, const TypeInstType * var2, TypeDecl::Data && data, 310 AssertionSet & need, AssertionSet & have, const OpenVarSet & open, 311 WidenMode widen, const SymbolTable & symtab 308 bool TypeEnvironment::bindVarToVar( 309 const TypeInstType * var1, const TypeInstType * var2, TypeDecl::Data && data, 310 AssertionSet & need, AssertionSet & have, const OpenVarSet & open, 311 WidenMode widen, const SymbolTable & symtab 312 312 ) { 313 313 auto c1 = internal_lookup( var1->name ); 314 314 auto c2 = internal_lookup( var2->name ); 315 315 316 316 // exit early if variables already bound together 317 317 if ( c1 != env.end() && c1 == c2 ) { … … 396 396 } 397 397 398 bool TypeEnvironment::mergeBound( 398 bool TypeEnvironment::mergeBound( 399 399 EqvClass & to, const EqvClass & from, OpenVarSet & open, const SymbolTable & symtab ) { 400 400 if ( from.bound ) { … … 406 406 AssertionSet need, have; 407 407 408 if ( unifyInexact( 408 if ( unifyInexact( 409 409 toType, fromType, *this, need, have, open, widen, symtab, common ) ) { 410 410 // unifies, set common type if necessary … … 424 424 } 425 425 426 bool TypeEnvironment::mergeClasses( 426 bool TypeEnvironment::mergeClasses( 427 427 ClassList::iterator to, ClassList::iterator from, OpenVarSet & open, const SymbolTable & symtab 428 428 ) { -
src/AST/TypeSubstitution.cpp
r343d10e r7ff3e522 121 121 Pass<Substituter> sub( *this, true ); 122 122 do { 123 sub. pass.subCount = 0;124 sub. pass.freeOnly = true;123 sub.core.subCount = 0; 124 sub.core.freeOnly = true; 125 125 for ( TypeEnvType::iterator i = typeEnv.begin(); i != typeEnv.end(); ++i ) { 126 126 i->second = i->second->accept( sub ); 127 127 } 128 } while ( sub. pass.subCount );128 } while ( sub.core.subCount ); 129 129 } 130 130 -
src/AST/TypeSubstitution.hpp
r343d10e r7ff3e522 99 99 void initialize( const TypeSubstitution &src, TypeSubstitution &dest ); 100 100 101 template<typename pass_type>101 template<typename core_t> 102 102 friend class Pass; 103 103 … … 188 188 Pass<Substituter> sub( *this, false ); 189 189 input = strict_dynamic_cast< const SynTreeClass * >( deepCopy(input)->accept( sub ) ); 190 return { input, sub. pass.subCount };190 return { input, sub.core.subCount }; 191 191 } 192 192 … … 196 196 Pass<Substituter> sub( *this, true ); 197 197 input = strict_dynamic_cast< const SynTreeClass * >( input->accept( sub ) ); 198 return { input, sub. pass.subCount };198 return { input, sub.core.subCount }; 199 199 } 200 200 -
src/Common/Eval.cc
r343d10e r7ff3e522 168 168 if (expr) { 169 169 expr->accept(ev); 170 return std::make_pair(ev. pass.value, ev.pass.valid);170 return std::make_pair(ev.core.value, ev.core.valid); 171 171 } else { 172 172 return std::make_pair(0, false); -
src/InitTweak/InitTweak.cc
r343d10e r7ff3e522 127 127 ast::Pass< InitFlattener_new > flattener; 128 128 maybe_accept( init, flattener ); 129 return std::move( flattener. pass.argList );129 return std::move( flattener.core.argList ); 130 130 } 131 131 … … 561 561 ast::Pass< CallFinder_new > finder{ std::vector< std::string >{ "?{}", "^?{}" } }; 562 562 maybe_accept( stmt, finder ); 563 return std::move( finder. pass.matches );563 return std::move( finder.core.matches ); 564 564 } 565 565 -
src/ResolvExpr/CandidateFinder.cpp
r343d10e r7ff3e522 1590 1590 1591 1591 if ( mode.failFast && candidates.empty() ) { 1592 switch(finder. pass.reason.code) {1592 switch(finder.core.reason.code) { 1593 1593 case Finder::NotFound: 1594 1594 { SemanticError( expr, "No alternatives for expression " ); break; } -
src/ResolvExpr/CastCost.cc
r343d10e r7ff3e522 242 242 dst, srcIsLvalue, symtab, env, localCastCost ); 243 243 src->accept( converter ); 244 return converter. pass.cost;244 return converter.core.cost; 245 245 } 246 246 } -
src/ResolvExpr/CommonType.cc
r343d10e r7ff3e522 968 968 ast::Pass<CommonType_new> visitor{ type2, widen, symtab, env, open }; 969 969 type1->accept( visitor ); 970 ast::ptr< ast::Type > result = visitor. pass.result;970 ast::ptr< ast::Type > result = visitor.core.result; 971 971 972 972 // handling for opaque type declarations (?) -
src/ResolvExpr/ConversionCost.cc
r343d10e r7ff3e522 522 522 ast::Pass<ConversionCost_new> converter( dst, srcIsLvalue, symtab, env, localConversionCost ); 523 523 src->accept( converter ); 524 return converter. pass.cost;524 return converter.core.cost; 525 525 } 526 526 } … … 565 565 ast::Pass<ConversionCost_new> converter( dst, srcIsLvalue, symtab, env, localConversionCost ); 566 566 src->accept( converter ); 567 return converter. pass.cost;567 return converter.core.cost; 568 568 } 569 569 } else { -
src/ResolvExpr/PolyCost.cc
r343d10e r7ff3e522 87 87 ast::Pass<PolyCost_new> costing( symtab, env ); 88 88 type->accept( costing ); 89 return costing. pass.result;89 return costing.core.result; 90 90 } 91 91 -
src/ResolvExpr/PtrsAssignable.cc
r343d10e r7ff3e522 155 155 ast::Pass<PtrsAssignable_new> visitor( dst, env ); 156 156 src->accept( visitor ); 157 return visitor. pass.result;157 return visitor.core.result; 158 158 } 159 159 -
src/ResolvExpr/PtrsCastable.cc
r343d10e r7ff3e522 293 293 ast::Pass< PtrsCastable_new > ptrs{ dst, env, symtab }; 294 294 src->accept( ptrs ); 295 return ptrs. pass.result;295 return ptrs.core.result; 296 296 } 297 297 } -
src/ResolvExpr/Resolver.cc
r343d10e r7ff3e522 982 982 ast::Pass<DeleteFinder_new> finder; 983 983 expr->accept( finder ); 984 return finder. pass.delExpr;984 return finder.core.delExpr; 985 985 } 986 986 -
src/ResolvExpr/SpecCost.cc
r343d10e r7ff3e522 217 217 } 218 218 ast::Pass<SpecCounter> counter; 219 type->accept( *counter.pass.visitor );220 return counter. pass.get_count();219 type->accept( counter ); 220 return counter.core.get_count(); 221 221 } 222 222 -
src/ResolvExpr/Unify.cc
r343d10e r7ff3e522 1185 1185 ast::Pass<Unify_new> comparator{ type2, env, need, have, open, widen, symtab }; 1186 1186 type1->accept( comparator ); 1187 return comparator. pass.result;1187 return comparator.core.result; 1188 1188 } 1189 1189 } -
src/SymTab/FixFunction.cc
r343d10e r7ff3e522 141 141 ast::Pass< FixFunction_new > fixer; 142 142 dwt = dwt->accept( fixer ); 143 isVoid |= fixer. pass.isVoid;143 isVoid |= fixer.core.isVoid; 144 144 return dwt; 145 145 } -
src/SymTab/Mangler.cc
r343d10e r7ff3e522 447 447 ast::Pass<Mangler_new> mangler( mode ); 448 448 maybeAccept( decl, mangler ); 449 return mangler. pass.get_mangleName();449 return mangler.core.get_mangleName(); 450 450 } 451 451 … … 691 691 mangleOverridable, typeMode, mangleGenericParams, nextVarNum, varNums ); 692 692 assert->accept( sub_mangler ); 693 assertionNames.push_back( sub_mangler. pass.get_mangleName() );693 assertionNames.push_back( sub_mangler.core.get_mangleName() ); 694 694 acount++; 695 695 } // for -
src/Tuples/Explode.cc
r343d10e r7ff3e522 179 179 ast::Pass<CastExploderCore> exploder; 180 180 expr = expr->accept( exploder ); 181 if ( ! exploder. pass.foundUniqueExpr ) {181 if ( ! exploder.core.foundUniqueExpr ) { 182 182 expr = new ast::CastExpr{ expr, new ast::ReferenceType{ expr->result } }; 183 183 } -
src/Tuples/Tuples.cc
r343d10e r7ff3e522 53 53 ast::Pass<Detector> detector; 54 54 expr->accept( detector ); 55 return detector. pass.maybeImpure;55 return detector.core.maybeImpure; 56 56 } 57 57 } // namespace
Note: See TracChangeset
for help on using the changeset viewer.