Changes in / [704c9dd:7e23d0a]
- Location:
- src/GenPoly
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
r704c9dd r7e23d0a 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : T ue Nov 24 15:59:33201513 // Update Count : 1 6911 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Nov 19 17:40:51 2015 13 // Update Count : 133 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 need148 // to take those polymorphic types as pointers. Therefore, there can be two different functions149 // 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 } // for164 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 171 144 std::string makeAdapterName( const std::string &mangleName ) { 172 145 return "_adapter" + mangleName; … … 244 217 AdapterMap & adapters = Pass1::adapters.top(); 245 218 for ( std::list< FunctionType *>::iterator funType = functions.begin(); funType != functions.end(); ++funType ) { 246 std::string mangleName = mangleAdapterName( *funType, scopeTyVars ); 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 247 226 if ( adapters.find( mangleName ) == adapters.end() ) { 248 227 std::string adapterName = makeAdapterName( mangleName ); … … 368 347 ret = addRetParam( appExpr, function, function->get_returnVals().front()->get_type(), arg ); 369 348 } // if 370 std::string mangleName = mangleAdapterName( function, tyVars ); 349 std::string mangleName = SymTab::Mangler::mangle( function ); 350 if ( isPolyRet( function, tyVars ) ) { 351 mangleName += "polyret_"; 352 } // if 371 353 std::string adapterName = makeAdapterName( mangleName ); 372 354 … … 583 565 assert( env ); 584 566 env->apply( realFunction ); 585 mangleName = SymTab::Mangler::mangle( realFunction ); 586 mangleName += makePolyMonoSuffix( originalFunction, exprTyVars ); 567 mangleName = SymTab::Mangler::mangle( realFunction ); 568 569 if ( isPolyRet( originalFunction, exprTyVars ) ) { 570 mangleName += "polyret_"; 571 } // if 587 572 588 573 AdapterMap & adapters = Pass1::adapters.top(); … … 915 900 916 901 void Pass1::doBeginScope() { 917 // push a copy of the current map 902 // actually, maybe this could (should?) push 903 // a copy of the current map 918 904 adapters.push(adapters.top()); 919 905 } … … 937 923 std::set< std::string > adaptersDone; 938 924 for ( std::list< FunctionType *>::iterator funType = functions.begin(); funType != functions.end(); ++funType ) { 939 std::string mangleName = mangleAdapterName( *funType, scopeTyVars ); 925 std::string mangleName = SymTab::Mangler::mangle( *funType ); 926 if ( isPolyRet( *funType, scopeTyVars ) ) { 927 mangleName += "polyret_"; 928 } // if 940 929 if ( adaptersDone.find( mangleName ) == adaptersDone.end() ) { 941 930 std::string adapterName = makeAdapterName( mangleName ); -
src/GenPoly/GenPoly.cc
r704c9dd r7e23d0a 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : T ue Nov 24 15:23:08201513 // Update Count : 1 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Nov 19 17:23:44 2015 13 // Update Count : 10 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 87 77 void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap ) { 88 78 for ( TyVarMap::const_iterator i = tyVarMap.begin(); i != tyVarMap.end(); ++i ) { -
src/GenPoly/GenPoly.h
r704c9dd r7e23d0a 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : T ue Nov 24 15:24:38201513 // Update Count : 611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Nov 19 17:24:03 2015 13 // Update Count : 4 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 variable35 bool isPolyObj( Type *type, const TyVarMap &tyVars );36 33 void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap ); 37 34 } // namespace GenPoly
Note: See TracChangeset
for help on using the changeset viewer.