Changeset bdf1954 for src/GenPoly/Box.cc
- Timestamp:
- Nov 24, 2015, 4:01:31 PM (7 years ago)
- Branches:
- aaron-thesis, arm-eh, 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:
- 704c9dd
- Parents:
- 5189888
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
r5189888 rbdf1954 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : T hu Nov 19 17:40:51201513 // Update Count : 1 3311 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Nov 24 15:59:33 2015 13 // Update Count : 169 14 14 // 15 15 … … 142 142 143 143 namespace { 144 std::string makePolyMonoSuffix( FunctionType * function, const TyVarMap &tyVars ) { 145 std::stringstream name; 146 147 // if the return type or a parameter type involved polymorphic types, then the adapter will need 148 // to take those polymorphic types as pointers. Therefore, there can be two different functions 149 // with the same mangled name, so we need to further mangle the names. 150 if ( isPolyRet( function, tyVars ) ) { 151 name << "P"; 152 } else { 153 name << "M"; 154 } 155 name << "_"; 156 std::list< DeclarationWithType *> ¶mList = function->get_parameters(); 157 for ( std::list< DeclarationWithType *>::iterator arg = paramList.begin(); arg != paramList.end(); ++arg ) { 158 if ( isPolyObj( (*arg)->get_type(), tyVars ) ) { 159 name << "P"; 160 } else { 161 name << "M"; 162 } 163 } // for 164 return name.str(); 165 } 166 167 std::string mangleAdapterName( FunctionType * function, const TyVarMap &tyVars ) { 168 return SymTab::Mangler::mangle( function ) + makePolyMonoSuffix( function, tyVars ); 169 } 170 144 171 std::string makeAdapterName( const std::string &mangleName ) { 145 172 return "_adapter" + mangleName; … … 217 244 AdapterMap & adapters = Pass1::adapters.top(); 218 245 for ( std::list< FunctionType *>::iterator funType = functions.begin(); funType != functions.end(); ++funType ) { 219 std::string mangleName = SymTab::Mangler::mangle( *funType ); 220 if ( isPolyRet( *funType, scopeTyVars ) ) { 221 // if the return type involved polymorphic types, then the adapter will need to take those 222 // polymorphic types as pointers. Therefore, there can be two different functions with the same 223 // mangled name, so we need the mangled names to be different. 224 mangleName += "polyret_"; 225 } // if 246 std::string mangleName = mangleAdapterName( *funType, scopeTyVars ); 226 247 if ( adapters.find( mangleName ) == adapters.end() ) { 227 248 std::string adapterName = makeAdapterName( mangleName ); … … 347 368 ret = addRetParam( appExpr, function, function->get_returnVals().front()->get_type(), arg ); 348 369 } // if 349 std::string mangleName = SymTab::Mangler::mangle( function ); 350 if ( isPolyRet( function, tyVars ) ) { 351 mangleName += "polyret_"; 352 } // if 370 std::string mangleName = mangleAdapterName( function, tyVars ); 353 371 std::string adapterName = makeAdapterName( mangleName ); 354 372 … … 565 583 assert( env ); 566 584 env->apply( realFunction ); 567 mangleName = SymTab::Mangler::mangle( realFunction ); 568 569 if ( isPolyRet( originalFunction, exprTyVars ) ) { 570 mangleName += "polyret_"; 571 } // if 585 mangleName = SymTab::Mangler::mangle( realFunction ); 586 mangleName += makePolyMonoSuffix( originalFunction, exprTyVars ); 572 587 573 588 AdapterMap & adapters = Pass1::adapters.top(); … … 900 915 901 916 void Pass1::doBeginScope() { 902 // actually, maybe this could (should?) push 903 // a copy of the current map 917 // push a copy of the current map 904 918 adapters.push(adapters.top()); 905 919 } … … 923 937 std::set< std::string > adaptersDone; 924 938 for ( std::list< FunctionType *>::iterator funType = functions.begin(); funType != functions.end(); ++funType ) { 925 std::string mangleName = SymTab::Mangler::mangle( *funType ); 926 if ( isPolyRet( *funType, scopeTyVars ) ) { 927 mangleName += "polyret_"; 928 } // if 939 std::string mangleName = mangleAdapterName( *funType, scopeTyVars ); 929 940 if ( adaptersDone.find( mangleName ) == adaptersDone.end() ) { 930 941 std::string adapterName = makeAdapterName( mangleName );
Note: See TracChangeset
for help on using the changeset viewer.