Changeset c29d9ce
- Timestamp:
- Aug 11, 2015, 4:37:32 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:
- a3a17ba
- Parents:
- ae4c85a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
rae4c85a rc29d9ce 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : T hu Jul 30 14:35:40201513 // Update Count : 5412 // Last Modified On : Tue Aug 11 16:22:35 2015 13 // Update Count : 89 14 14 // 15 15 … … 77 77 Expression *handleIntrinsics( ApplicationExpr *appExpr ); 78 78 ObjectDecl *makeTemporary( Type *type ); 79 79 80 typedef std::map< std::string, FunctionDecl *> AdapterMap; 80 81 std::map< std::string, DeclarationWithType *> assignOps; 81 typedef std::map< std::string, FunctionDecl *> AdapterMap;82 82 std::stack< AdapterMap > adapters; 83 83 DeclarationWithType *retval; … … 168 168 TyVarMap dummyTyVars; 169 169 return isPolyRet( function, name, dummyTyVars ); 170 } 171 172 bool isPolyRet( FunctionType *function, const TyVarMap &otherTyVars ) { 173 std::string dummyString; 174 return isPolyRet( function, dummyString, otherTyVars ); 170 175 } 171 176 … … 526 531 } 527 532 528 void Pass1::passAdapters( ApplicationExpr * appExpr, FunctionType *functionType, const TyVarMap &exprTyVars ) {533 void Pass1::passAdapters( ApplicationExpr * appExpr, FunctionType * functionType, const TyVarMap & exprTyVars ) { 529 534 // collect a list of function types passed as parameters or implicit parameters (assertions) 530 535 std::list< DeclarationWithType *> ¶mList = functionType->get_parameters(); … … 545 550 546 551 for ( std::list< FunctionType *>::iterator funType = functions.begin(); funType != functions.end(); ++funType ) { 552 FunctionType *originalFunction = (*funType)->clone(); 547 553 FunctionType *realFunction = (*funType)->clone(); 548 554 std::string mangleName = SymTab::Mangler::mangle( realFunction ); … … 559 565 env->apply( realFunction ); 560 566 mangleName = SymTab::Mangler::mangle( realFunction ); 561 AdapterMap & adapters = Pass1::adapters.top();562 AdapterMap::iterator adapter = adapters.find( mangleName );563 567 564 568 if ( needsAdapter( realFunction, exprTyVars, true ) ) { … … 567 571 // create a new adapter. 568 572 appExpr->get_args().push_front( new NameExpr( makeAdapterName ( mangleName ) ) ); 569 continue; 570 } else if ( adapter == adapters.end() ) { 571 // adapter has not been created yet in the current scope, so define it 572 FunctionDecl *newAdapter = makeAdapter( *funType, realFunction, mangleName, exprTyVars ); 573 adapter = adapters.insert( adapters.begin(), std::pair< std::string, FunctionDecl *>( mangleName, newAdapter ) ); 574 stmtsToAdd.push_back( new DeclStmt( noLabels, newAdapter ) ); 573 } else { 574 if ( isPolyRet( originalFunction, exprTyVars ) ) { 575 // if the return type involved polymorphic types, then 576 // the adapter will need to take those polymorphic types 577 // as pointers. Therefore, there can be two different 578 // functions with the same mangled name, so we need two adapter map 579 // stacks and also we need the mangled names to be different. 580 mangleName += "polyret_"; 581 } 582 583 AdapterMap & adapters = Pass1::adapters.top(); 584 AdapterMap::iterator adapter = adapters.find( mangleName ); 585 if ( adapter == adapters.end() ) { 586 // adapter has not been created yet in the current scope, so define it 587 FunctionDecl *newAdapter = makeAdapter( *funType, realFunction, mangleName, exprTyVars ); 588 adapter = adapters.insert( adapters.begin(), std::pair< std::string, FunctionDecl *>( mangleName, newAdapter ) ); 589 stmtsToAdd.push_back( new DeclStmt( noLabels, newAdapter ) ); 590 } // if 591 assert( adapter != adapters.end() ); 592 593 // add the appropriate adapter as a parameter 594 appExpr->get_args().push_front( new VariableExpr( adapter->second ) ); 575 595 } // if 576 assert( adapter != adapters.end() );577 578 // add the appropriate adapter as a parameter579 appExpr->get_args().push_front( new VariableExpr( adapter->second ) );580 596 } // if 581 597 } // for
Note: See TracChangeset
for help on using the changeset viewer.