Changes in src/GenPoly/Box.cc [d7dc824:8ca3a72]
- File:
-
- 1 edited
-
src/GenPoly/Box.cc (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
rd7dc824 r8ca3a72 62 62 namespace GenPoly { 63 63 namespace { 64 const std::list<Label> noLabels;65 66 64 FunctionType *makeAdapterType( FunctionType *adaptee, const TyVarMap &tyVars ); 67 65 … … 103 101 void passTypeVars( ApplicationExpr *appExpr, Type *polyRetType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ); 104 102 /// wraps a function application with a new temporary for the out-parameter return value 105 Expression *addRetParam( ApplicationExpr *appExpr, Type *retType, std::list< Expression *>::iterator &arg );103 Expression *addRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *retType, std::list< Expression *>::iterator &arg ); 106 104 /// Replaces all the type parameters of a generic type with their concrete equivalents under the current environment 107 105 void replaceParametersWithConcrete( ApplicationExpr *appExpr, std::list< Expression* >& params ); … … 110 108 Type *replaceWithConcrete( ApplicationExpr *appExpr, Type *type, bool doClone = true ); 111 109 /// wraps a function application returning a polymorphic type with a new temporary for the out-parameter return value 112 Expression *addDynRetParam( ApplicationExpr *appExpr, Type *polyType, std::list< Expression *>::iterator &arg );110 Expression *addDynRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *polyType, std::list< Expression *>::iterator &arg ); 113 111 Expression *applyAdapter( ApplicationExpr *appExpr, FunctionType *function, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ); 114 112 void boxParam( Type *formal, Expression *&arg, const TyVarMap &exprTyVars ); … … 136 134 public: 137 135 template< typename DeclClass > 138 DeclClass *handleDecl( DeclClass *decl );136 DeclClass *handleDecl( DeclClass *decl, Type *type ); 139 137 template< typename AggDecl > 140 138 AggDecl * handleAggDecl( AggDecl * aggDecl ); … … 665 663 } 666 664 667 Expression *Pass1::addRetParam( ApplicationExpr *appExpr, Type *retType, std::list< Expression *>::iterator &arg ) {665 Expression *Pass1::addRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *retType, std::list< Expression *>::iterator &arg ) { 668 666 // Create temporary to hold return value of polymorphic function and produce that temporary as a result 669 667 // using a comma expression. … … 728 726 } 729 727 730 Expression *Pass1::addDynRetParam( ApplicationExpr *appExpr, Type *dynType, std::list< Expression *>::iterator &arg ) {728 Expression *Pass1::addDynRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *dynType, std::list< Expression *>::iterator &arg ) { 731 729 assert( env ); 732 730 Type *concrete = replaceWithConcrete( appExpr, dynType ); 733 731 // add out-parameter for return value 734 return addRetParam( appExpr, concrete, arg );732 return addRetParam( appExpr, function, concrete, arg ); 735 733 } 736 734 … … 739 737 // if ( ! function->get_returnVals().empty() && isPolyType( function->get_returnVals().front()->get_type(), tyVars ) ) { 740 738 if ( isDynRet( function, tyVars ) ) { 741 ret = addRetParam( appExpr, function ->get_returnVals().front()->get_type(), arg );739 ret = addRetParam( appExpr, function, function->get_returnVals().front()->get_type(), arg ); 742 740 } // if 743 741 std::string mangleName = mangleAdapterName( function, tyVars ); … … 1148 1146 if ( dynRetType ) { 1149 1147 Type *concRetType = appExpr->get_result()->isVoid() ? nullptr : appExpr->get_result(); 1150 ret = addDynRetParam( appExpr, concRetType, arg ); // xxx - used to use dynRetType instead of concRetType1148 ret = addDynRetParam( appExpr, function, concRetType, arg ); // xxx - used to use dynRetType instead of concRetType 1151 1149 } else if ( needsAdapter( function, scopeTyVars ) && ! needsAdapter( function, exprTyVars) ) { // xxx - exprTyVars is used above...? 1152 1150 // xxx - the ! needsAdapter check may be incorrect. It seems there is some situation where an adapter is applied where it shouldn't be, and this fixes it for some cases. More investigation is needed. … … 1282 1280 1283 1281 template< typename DeclClass > 1284 DeclClass * Pass2::handleDecl( DeclClass *decl ) {1282 DeclClass * Pass2::handleDecl( DeclClass *decl, Type *type ) { 1285 1283 DeclClass *ret = static_cast< DeclClass *>( Parent::mutate( decl ) ); 1286 1284 … … 1296 1294 1297 1295 DeclarationWithType * Pass2::mutate( FunctionDecl *functionDecl ) { 1298 functionDecl = safe_dynamic_cast< FunctionDecl * > ( handleDecl( functionDecl ) );1296 functionDecl = safe_dynamic_cast< FunctionDecl * > ( handleDecl( functionDecl, functionDecl->get_functionType() ) ); 1299 1297 FunctionType * ftype = functionDecl->get_functionType(); 1300 1298 if ( ! ftype->get_returnVals().empty() && functionDecl->get_statements() ) { … … 1321 1319 1322 1320 ObjectDecl * Pass2::mutate( ObjectDecl *objectDecl ) { 1323 return handleDecl( objectDecl );1321 return handleDecl( objectDecl, objectDecl->get_type() ); 1324 1322 } 1325 1323 … … 1344 1342 addToTyVarMap( typeDecl, scopeTyVars ); 1345 1343 if ( typeDecl->get_base() ) { 1346 return handleDecl( typeDecl );1344 return handleDecl( typeDecl, typeDecl->get_base() ); 1347 1345 } else { 1348 1346 return Parent::mutate( typeDecl ); … … 1351 1349 1352 1350 TypedefDecl * Pass2::mutate( TypedefDecl *typedefDecl ) { 1353 return handleDecl( typedefDecl );1351 return handleDecl( typedefDecl, typedefDecl->get_base() ); 1354 1352 } 1355 1353
Note:
See TracChangeset
for help on using the changeset viewer.