Changes in / [f5234f3:b81096f]
- Location:
- src/GenPoly
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
rf5234f3 rb81096f 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 ); -
src/GenPoly/GenPoly.cc
rf5234f3 rb81096f 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:23:44201513 // Update Count : 1 011 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Nov 24 15:23:08 2015 13 // Update Count : 11 14 14 // 15 15 … … 75 75 } 76 76 77 bool isPolyObj( Type *type, const TyVarMap &tyVars ) { 78 if ( isPolyVal( type, tyVars ) ) { 79 return true; 80 } else if ( PointerType *pt = dynamic_cast<PointerType*>( type ) ) { 81 return isPolyObj( pt->get_base(), tyVars ); 82 } else { 83 return false; 84 } 85 } 86 77 87 void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap ) { 78 88 for ( TyVarMap::const_iterator i = tyVarMap.begin(); i != tyVarMap.end(); ++i ) { -
src/GenPoly/GenPoly.h
rf5234f3 rb81096f 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:24:03201513 // Update Count : 411 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Nov 24 15:24:38 2015 13 // Update Count : 6 14 14 // 15 15 … … 31 31 // bool isPolyFun( FunctionType *fun, const TyVarMap &tyVars ); 32 32 bool isPolyVal( Type *type, const TyVarMap &tyVars ); 33 34 // true if type variable or any number of pointers to type variable 35 bool isPolyObj( Type *type, const TyVarMap &tyVars ); 33 36 void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap ); 34 37 } // namespace GenPoly
Note: See TracChangeset
for help on using the changeset viewer.