Changeset e497c1d for src/GenPoly
- Timestamp:
- Jul 30, 2015, 4:07:23 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 5aa708c
- Parents:
- e01559c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
re01559c re497c1d 527 527 528 528 void Pass1::passAdapters( ApplicationExpr *appExpr, FunctionType *functionType, const TyVarMap &exprTyVars ) { 529 // collect a list of function types passed as parameters or implicit parameters (assertions) 529 530 std::list< DeclarationWithType *> ¶mList = functionType->get_parameters(); 530 531 std::list< FunctionType *> functions; … … 537 538 findFunction( (*arg)->get_type(), functions, exprTyVars, needsAdapter ); 538 539 } // for 540 541 // parameter function types for which an appropriate adapter has been generated. 542 // we cannot use the types after applying substitutions, since two different 543 // parameter types may be unified to the same type 539 544 std::set< std::string > adaptersDone; 545 540 546 for ( std::list< FunctionType *>::iterator funType = functions.begin(); funType != functions.end(); ++funType ) { 541 547 FunctionType *realFunction = (*funType)->clone(); 542 assert( env );543 env->apply( realFunction );544 545 548 std::string mangleName = SymTab::Mangler::mangle( realFunction ); 549 550 // only attempt to create an adapter or pass one as a parameter if we haven't 551 // already done so for this pre-substitution parameter function type. 546 552 if ( adaptersDone.find( mangleName ) == adaptersDone.end() ) { 553 std::string mangleName = SymTab::Mangler::mangle( realFunction ); 554 adaptersDone.insert( adaptersDone.begin(), mangleName ); 555 556 // apply substitution to type variables to figure out what the 557 // adapter's type should look like 558 assert( env ); 559 env->apply( realFunction ); 560 mangleName = SymTab::Mangler::mangle( realFunction ); 547 561 AdapterMap & adapters = Pass1::adapters.top(); 548 562 AdapterMap::iterator adapter = adapters.find( mangleName ); … … 555 569 continue; 556 570 } else if ( adapter == adapters.end() ) { 571 // adapter has not been created yet in the current scope, so define it 557 572 FunctionDecl *newAdapter = makeAdapter( *funType, realFunction, mangleName, exprTyVars ); 558 573 adapter = adapters.insert( adapters.begin(), std::pair< std::string, FunctionDecl *>( mangleName, newAdapter ) ); … … 560 575 } // if 561 576 assert( adapter != adapters.end() ); 577 578 // add the appropriate adapter as a parameter 562 579 appExpr->get_args().push_front( new VariableExpr( adapter->second ) ); 563 // appExpr->get_args().push_front( new NameExpr( makeAdapterName ( mangleName ) ) );564 adaptersDone.insert( adaptersDone.begin(), mangleName );565 580 } // if 566 581 } // for … … 880 895 881 896 void Pass1::doBeginScope() { 897 // actually, maybe this could (should?) push 898 // a copy of the current map 882 899 adapters.push(AdapterMap()); 883 900 }
Note: See TracChangeset
for help on using the changeset viewer.