Changes in src/GenPoly/Box.cc [5802a4f:dd0c97b]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
r5802a4f rdd0c97b 136 136 template< typename DeclClass > 137 137 DeclClass *handleDecl( DeclClass *decl, Type *type ); 138 139 using PolyMutator::mutate; 138 template< typename AggDecl > 139 AggDecl * handleAggDecl( AggDecl * aggDecl ); 140 141 typedef PolyMutator Parent; 142 using Parent::mutate; 140 143 virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ) override; 141 144 virtual ObjectDecl *mutate( ObjectDecl *objectDecl ) override; 145 virtual StructDecl *mutate( StructDecl *structDecl ) override; 146 virtual UnionDecl *mutate( UnionDecl *unionDecl ) override; 142 147 virtual TypeDecl *mutate( TypeDecl *typeDecl ) override; 143 148 virtual TypedefDecl *mutate( TypedefDecl *typedefDecl ) override; … … 686 691 for ( std::list< Expression* >::iterator param = params.begin(); param != params.end(); ++param ) { 687 692 TypeExpr *paramType = dynamic_cast< TypeExpr* >( *param ); 688 assert (paramType &&"Aggregate parameters should be type expressions");693 assertf(paramType, "Aggregate parameters should be type expressions"); 689 694 paramType->set_type( replaceWithConcrete( appExpr, paramType->get_type(), false ) ); 690 695 } … … 783 788 void Pass1::boxParams( ApplicationExpr *appExpr, FunctionType *function, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ) { 784 789 for ( std::list< DeclarationWithType *>::const_iterator param = function->get_parameters().begin(); param != function->get_parameters().end(); ++param, ++arg ) { 785 assert ( arg != appExpr->get_args().end() );790 assertf( arg != appExpr->get_args().end(), "boxParams: missing argument for param %s to %s in %s", toString( *param ).c_str(), toString( function ).c_str(), toString( appExpr ).c_str() ); 786 791 addCast( *arg, (*param)->get_type(), exprTyVars ); 787 792 boxParam( (*param)->get_type(), *arg, exprTyVars ); … … 1127 1132 makeTyVarMap( function, exprTyVars ); // xxx - should this take into account the variables already bound in scopeTyVars (i.e. remove them from exprTyVars?) 1128 1133 ReferenceToType *dynRetType = isDynRet( function, exprTyVars ); 1129 Type *concRetType = appExpr->get_result()->isVoid() ? nullptr : appExpr->get_result();// ?: dynRetType; // xxx - is concRetType a good name? 1130 1134 1135 // NOTE: addDynRetParam needs to know the actual (generated) return type so it can make a temp variable, so pass the result type from the appExpr 1136 // passTypeVars needs to know the program-text return type (i.e. the distinction between _conc_T30 and T3(int)) 1137 // concRetType may not be a good name in one or both of these places. A more appropriate name change is welcome. 1131 1138 if ( dynRetType ) { 1139 Type *concRetType = appExpr->get_result()->isVoid() ? nullptr : appExpr->get_result(); 1132 1140 ret = addDynRetParam( appExpr, function, concRetType, arg ); // xxx - used to use dynRetType instead of concRetType 1133 1141 } else if ( needsAdapter( function, scopeTyVars ) && ! needsAdapter( function, exprTyVars) ) { // xxx - exprTyVars is used above...? … … 1142 1150 arg = appExpr->get_args().begin(); 1143 1151 1152 Type *concRetType = replaceWithConcrete( appExpr, dynRetType ); 1144 1153 passTypeVars( appExpr, concRetType, arg, exprTyVars ); // xxx - used to use dynRetType instead of concRetType; this changed so that the correct type paramaters are passed for return types (it should be the concrete type's parameters, not the formal type's) 1145 1154 addInferredParams( appExpr, function, arg, exprTyVars ); … … 1271 1280 template< typename DeclClass > 1272 1281 DeclClass * Pass2::handleDecl( DeclClass *decl, Type *type ) { 1273 DeclClass *ret = static_cast< DeclClass *>( Mutator::mutate( decl ) );1282 DeclClass *ret = static_cast< DeclClass *>( Parent::mutate( decl ) ); 1274 1283 1275 1284 return ret; … … 1305 1314 } 1306 1315 1316 template< typename AggDecl > 1317 AggDecl * Pass2::handleAggDecl( AggDecl * aggDecl ) { 1318 // prevent tyVars from leaking into containing scope 1319 scopeTyVars.beginScope(); 1320 Parent::mutate( aggDecl ); 1321 scopeTyVars.endScope(); 1322 return aggDecl; 1323 } 1324 1325 StructDecl * Pass2::mutate( StructDecl *aggDecl ) { 1326 return handleAggDecl( aggDecl ); 1327 } 1328 1329 UnionDecl * Pass2::mutate( UnionDecl *aggDecl ) { 1330 return handleAggDecl( aggDecl ); 1331 } 1332 1307 1333 TypeDecl * Pass2::mutate( TypeDecl *typeDecl ) { 1308 1334 addToTyVarMap( typeDecl, scopeTyVars ); … … 1310 1336 return handleDecl( typeDecl, typeDecl->get_base() ); 1311 1337 } else { 1312 return Mutator::mutate( typeDecl );1338 return Parent::mutate( typeDecl ); 1313 1339 } 1314 1340 } … … 1322 1348 makeTyVarMap( pointerType, scopeTyVars ); 1323 1349 1324 Type *ret = Mutator::mutate( pointerType );1350 Type *ret = Parent::mutate( pointerType ); 1325 1351 1326 1352 scopeTyVars.endScope();
Note:
See TracChangeset
for help on using the changeset viewer.