Changes in src/GenPoly/Box.cc [8c49c0e:62e5546]
- File:
-
- 1 edited
-
src/GenPoly/Box.cc (modified) (31 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
r8c49c0e r62e5546 64 64 65 65 /// Adds layout-generation functions to polymorphic types 66 class LayoutFunctionBuilder : public DeclMutator {66 class LayoutFunctionBuilder final : public DeclMutator { 67 67 unsigned int functionNesting; // current level of nested functions 68 68 public: 69 69 LayoutFunctionBuilder() : functionNesting( 0 ) {} 70 70 71 virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ); 72 virtual Declaration *mutate( StructDecl *structDecl ); 73 virtual Declaration *mutate( UnionDecl *unionDecl ); 71 using DeclMutator::mutate; 72 virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ) override; 73 virtual Declaration *mutate( StructDecl *structDecl ) override; 74 virtual Declaration *mutate( UnionDecl *unionDecl ) override; 74 75 }; 75 76 76 77 /// Replaces polymorphic return types with out-parameters, replaces calls to polymorphic functions with adapter calls as needed, and adds appropriate type variables to the function call 77 class Pass1 : public PolyMutator {78 class Pass1 final : public PolyMutator { 78 79 public: 79 80 Pass1(); 80 virtual Expression *mutate( ApplicationExpr *appExpr ); 81 virtual Expression *mutate( AddressExpr *addrExpr ); 82 virtual Expression *mutate( UntypedExpr *expr ); 83 virtual DeclarationWithType* mutate( FunctionDecl *functionDecl ); 84 virtual TypeDecl *mutate( TypeDecl *typeDecl ); 85 virtual Expression *mutate( CommaExpr *commaExpr ); 86 virtual Expression *mutate( ConditionalExpr *condExpr ); 87 virtual Statement * mutate( ReturnStmt *returnStmt ); 88 virtual Type *mutate( PointerType *pointerType ); 89 virtual Type * mutate( FunctionType *functionType ); 90 91 virtual void doBeginScope(); 92 virtual void doEndScope(); 81 82 using PolyMutator::mutate; 83 virtual Expression *mutate( ApplicationExpr *appExpr ) override; 84 virtual Expression *mutate( AddressExpr *addrExpr ) override; 85 virtual Expression *mutate( UntypedExpr *expr ) override; 86 virtual DeclarationWithType* mutate( FunctionDecl *functionDecl ) override; 87 virtual TypeDecl *mutate( TypeDecl *typeDecl ) override; 88 virtual Expression *mutate( CommaExpr *commaExpr ) override; 89 virtual Expression *mutate( ConditionalExpr *condExpr ) override; 90 virtual Statement * mutate( ReturnStmt *returnStmt ) override; 91 virtual Type *mutate( PointerType *pointerType ) override; 92 virtual Type * mutate( FunctionType *functionType ) override; 93 94 virtual void doBeginScope() override; 95 virtual void doEndScope() override; 93 96 private: 94 97 /// Pass the extra type parameters from polymorphic generic arguments or return types into a function application … … 110 113 void addInferredParams( ApplicationExpr *appExpr, FunctionType *functionType, std::list< Expression *>::iterator &arg, const TyVarMap &tyVars ); 111 114 /// Stores assignment operators from assertion list in local map of assignment operations 112 void findTypeOps( const Type::ForallList&forall );115 void findTypeOps( const std::list< TypeDecl *> &forall ); 113 116 void passAdapters( ApplicationExpr *appExpr, FunctionType *functionType, const TyVarMap &exprTyVars ); 114 117 FunctionDecl *makeAdapter( FunctionType *adaptee, FunctionType *realType, const std::string &mangleName, const TyVarMap &tyVars ); … … 135 138 /// * Moves polymorphic returns in function types to pointer-type parameters 136 139 /// * adds type size and assertion parameters to parameter lists 137 class Pass2 : public PolyMutator {140 class Pass2 final : public PolyMutator { 138 141 public: 139 142 template< typename DeclClass > 140 143 DeclClass *handleDecl( DeclClass *decl, Type *type ); 141 virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ); 142 virtual ObjectDecl *mutate( ObjectDecl *objectDecl ); 143 virtual TypeDecl *mutate( TypeDecl *typeDecl ); 144 virtual TypedefDecl *mutate( TypedefDecl *typedefDecl ); 145 virtual Type *mutate( PointerType *pointerType ); 146 virtual Type *mutate( FunctionType *funcType ); 144 145 using PolyMutator::mutate; 146 virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ) override; 147 virtual ObjectDecl *mutate( ObjectDecl *objectDecl ) override; 148 virtual TypeDecl *mutate( TypeDecl *typeDecl ) override; 149 virtual TypedefDecl *mutate( TypedefDecl *typedefDecl ) override; 150 virtual Type *mutate( PointerType *pointerType ) override; 151 virtual Type *mutate( FunctionType *funcType ) override; 147 152 148 153 private: … … 156 161 /// * Calculates polymorphic offsetof expressions from offset array 157 162 /// * Inserts dynamic calculation of polymorphic type layouts where needed 158 class PolyGenericCalculator : public PolyMutator {163 class PolyGenericCalculator final : public PolyMutator { 159 164 public: 160 165 typedef PolyMutator Parent; … … 163 168 template< typename DeclClass > 164 169 DeclClass *handleDecl( DeclClass *decl, Type *type ); 165 virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ) ;166 virtual ObjectDecl *mutate( ObjectDecl *objectDecl ) ;167 virtual TypedefDecl *mutate( TypedefDecl *objectDecl ) ;168 virtual TypeDecl *mutate( TypeDecl *objectDecl ) ;169 virtual Statement *mutate( DeclStmt *declStmt ) ;170 virtual Type *mutate( PointerType *pointerType ) ;171 virtual Type *mutate( FunctionType *funcType ) ;172 virtual Expression *mutate( MemberExpr *memberExpr ) ;173 virtual Expression *mutate( SizeofExpr *sizeofExpr ) ;174 virtual Expression *mutate( AlignofExpr *alignofExpr ) ;175 virtual Expression *mutate( OffsetofExpr *offsetofExpr ) ;176 virtual Expression *mutate( OffsetPackExpr *offsetPackExpr ) ;177 178 virtual void doBeginScope() ;179 virtual void doEndScope() ;170 virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ) override; 171 virtual ObjectDecl *mutate( ObjectDecl *objectDecl ) override; 172 virtual TypedefDecl *mutate( TypedefDecl *objectDecl ) override; 173 virtual TypeDecl *mutate( TypeDecl *objectDecl ) override; 174 virtual Statement *mutate( DeclStmt *declStmt ) override; 175 virtual Type *mutate( PointerType *pointerType ) override; 176 virtual Type *mutate( FunctionType *funcType ) override; 177 virtual Expression *mutate( MemberExpr *memberExpr ) override; 178 virtual Expression *mutate( SizeofExpr *sizeofExpr ) override; 179 virtual Expression *mutate( AlignofExpr *alignofExpr ) override; 180 virtual Expression *mutate( OffsetofExpr *offsetofExpr ) override; 181 virtual Expression *mutate( OffsetPackExpr *offsetPackExpr ) override; 182 183 virtual void doBeginScope() override; 184 virtual void doEndScope() override; 180 185 181 186 private: … … 197 202 198 203 /// Replaces initialization of polymorphic values with alloca, declaration of dtype/ftype with appropriate void expression, and sizeof expressions of polymorphic types with the proper variable 199 class Pass3 : public PolyMutator {204 class Pass3 final : public PolyMutator { 200 205 public: 201 206 template< typename DeclClass > 202 207 DeclClass *handleDecl( DeclClass *decl, Type *type ); 203 virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ); 204 virtual ObjectDecl *mutate( ObjectDecl *objectDecl ); 205 virtual TypedefDecl *mutate( TypedefDecl *objectDecl ); 206 virtual TypeDecl *mutate( TypeDecl *objectDecl ); 207 virtual Type *mutate( PointerType *pointerType ); 208 virtual Type *mutate( FunctionType *funcType ); 208 209 using PolyMutator::mutate; 210 virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ) override; 211 virtual ObjectDecl *mutate( ObjectDecl *objectDecl ) override; 212 virtual TypedefDecl *mutate( TypedefDecl *objectDecl ) override; 213 virtual TypeDecl *mutate( TypeDecl *objectDecl ) override; 214 virtual Type *mutate( PointerType *pointerType ) override; 215 virtual Type *mutate( FunctionType *funcType ) override; 209 216 private: 210 217 }; … … 612 619 } 613 620 614 void Pass1::findTypeOps( const Type::ForallList&forall ) {621 void Pass1::findTypeOps( const std::list< TypeDecl *> &forall ) { 615 622 // what if a nested function uses an assignment operator? 616 623 // assignOps.clear(); 617 for ( Type::ForallList::const_iterator i = forall.begin(); i != forall.end(); ++i ) {624 for ( std::list< TypeDecl *>::const_iterator i = forall.begin(); i != forall.end(); ++i ) { 618 625 for ( std::list< DeclarationWithType *>::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) { 619 626 std::string typeName; … … 680 687 std::list< DeclarationWithType *> ¶mList = functionType->get_parameters(); 681 688 std::list< FunctionType *> functions; 682 for ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {689 for ( std::list< TypeDecl *>::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) { 683 690 for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) { 684 691 findFunction( (*assert)->get_type(), functions, scopeTyVars, needsAdapter ); … … 782 789 783 790 // add size/align for generic types to parameter list 784 if ( ! appExpr->get_function()->has_result() ) return;785 FunctionType *funcType = getFunctionType( appExpr->get_function()->get_result () );791 if ( appExpr->get_function()->get_results().empty() ) return; 792 FunctionType *funcType = getFunctionType( appExpr->get_function()->get_results().front() ); 786 793 assert( funcType ); 787 794 … … 799 806 for ( ; fnParm != funcType->get_parameters().end() && fnArg != appExpr->get_args().end(); ++fnParm, ++fnArg ) { 800 807 VariableExpr *fnArgBase = getBaseVar( *fnArg ); 801 if ( ! fnArgBase ) continue; // xxx - previously had check for non-empty fnArgBase results802 passArgTypeVars( appExpr, (*fnParm)->get_type(), fnArgBase->get_result (), arg, exprTyVars, seenTypes );808 if ( ! fnArgBase || fnArgBase->get_results().empty() ) continue; 809 passArgTypeVars( appExpr, (*fnParm)->get_type(), fnArgBase->get_results().front(), arg, exprTyVars, seenTypes ); 803 810 } 804 811 } … … 890 897 Type * adapteeType = new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ); 891 898 appExpr->get_args().push_front( new CastExpr( appExpr->get_function(), adapteeType ) ); 892 appExpr->set_function( new NameExpr( adapterName ) ); // xxx - result is never set on NameExpr899 appExpr->set_function( new NameExpr( adapterName ) ); 893 900 894 901 return ret; … … 896 903 897 904 void Pass1::boxParam( Type *param, Expression *&arg, const TyVarMap &exprTyVars ) { 898 assert( arg->has_result() );905 assert( ! arg->get_results().empty() ); 899 906 if ( isPolyType( param, exprTyVars ) ) { 900 if ( isPolyType( arg->get_result () ) ) {907 if ( isPolyType( arg->get_results().front() ) ) { 901 908 // if the argument's type is polymorphic, we don't need to box again! 902 909 return; 903 } else if ( arg->get_result ()->get_isLvalue() ) {910 } else if ( arg->get_results().front()->get_isLvalue() ) { 904 911 // VariableExpr and MemberExpr are lvalues; need to check this isn't coming from the second arg of a comma expression though (not an lvalue) 905 912 // xxx - need to test that this code is still reachable … … 946 953 void Pass1::addInferredParams( ApplicationExpr *appExpr, FunctionType *functionType, std::list< Expression *>::iterator &arg, const TyVarMap &tyVars ) { 947 954 std::list< Expression *>::iterator cur = arg; 948 for ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {955 for ( std::list< TypeDecl *>::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) { 949 956 for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) { 950 957 InferredParams::const_iterator inferParam = appExpr->get_inferParams().find( (*assert)->get_uniqueId() ); … … 987 994 UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) ); 988 995 deref->get_args().push_back( new CastExpr( new VariableExpr( param ), new PointerType( Type::Qualifiers(), arg->get_type()->clone() ) ) ); 989 deref-> set_result( arg->get_type()->clone() );996 deref->get_results().push_back( arg->get_type()->clone() ); 990 997 return deref; 991 998 } // if … … 1013 1020 Statement *bodyStmt; 1014 1021 1015 Type::ForallList::iterator tyArg = realType->get_forall().begin();1016 Type::ForallList::iterator tyParam = adapterType->get_forall().begin();1017 Type::ForallList::iterator realTyParam = adaptee->get_forall().begin();1022 std::list< TypeDecl *>::iterator tyArg = realType->get_forall().begin(); 1023 std::list< TypeDecl *>::iterator tyParam = adapterType->get_forall().begin(); 1024 std::list< TypeDecl *>::iterator realTyParam = adaptee->get_forall().begin(); 1018 1025 for ( ; tyParam != adapterType->get_forall().end(); ++tyArg, ++tyParam, ++realTyParam ) { 1019 1026 assert( tyArg != realType->get_forall().end() ); … … 1064 1071 std::list< DeclarationWithType *> ¶mList = functionType->get_parameters(); 1065 1072 std::list< FunctionType *> functions; 1066 for ( Type::ForallList::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) {1073 for ( std::list< TypeDecl *>::iterator tyVar = functionType->get_forall().begin(); tyVar != functionType->get_forall().end(); ++tyVar ) { 1067 1074 for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) { 1068 1075 findFunction( (*assert)->get_type(), functions, exprTyVars, needsAdapter ); … … 1124 1131 } // if 1125 1132 addAssign->get_args().push_back( new NameExpr( sizeofName( mangleType( polyType ) ) ) ); 1126 addAssign-> set_result( appExpr->get_result()->clone());1133 addAssign->get_results().front() = appExpr->get_results().front()->clone(); 1127 1134 if ( appExpr->get_env() ) { 1128 1135 addAssign->set_env( appExpr->get_env() ); … … 1138 1145 if ( varExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic ) { 1139 1146 if ( varExpr->get_var()->get_name() == "?[?]" ) { 1140 assert( appExpr->has_result() );1147 assert( ! appExpr->get_results().empty() ); 1141 1148 assert( appExpr->get_args().size() == 2 ); 1142 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result (), scopeTyVars, env );1143 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_result (), scopeTyVars, env );1149 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_results().front(), scopeTyVars, env ); 1150 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_results().front(), scopeTyVars, env ); 1144 1151 assert( ! baseType1 || ! baseType2 ); // the arguments cannot both be polymorphic pointers 1145 1152 UntypedExpr *ret = 0; … … 1161 1168 } // if 1162 1169 if ( baseType1 || baseType2 ) { 1163 ret-> set_result( appExpr->get_result()->clone() );1170 ret->get_results().push_front( appExpr->get_results().front()->clone() ); 1164 1171 if ( appExpr->get_env() ) { 1165 1172 ret->set_env( appExpr->get_env() ); … … 1171 1178 } // if 1172 1179 } else if ( varExpr->get_var()->get_name() == "*?" ) { 1173 assert( appExpr->has_result() );1180 assert( ! appExpr->get_results().empty() ); 1174 1181 assert( ! appExpr->get_args().empty() ); 1175 if ( isPolyType( appExpr->get_result (), scopeTyVars, env ) ) {1182 if ( isPolyType( appExpr->get_results().front(), scopeTyVars, env ) ) { 1176 1183 Expression *ret = appExpr->get_args().front(); 1177 delete ret->get_result ();1178 ret-> set_result( appExpr->get_result()->clone());1184 delete ret->get_results().front(); 1185 ret->get_results().front() = appExpr->get_results().front()->clone(); 1179 1186 if ( appExpr->get_env() ) { 1180 1187 ret->set_env( appExpr->get_env() ); … … 1186 1193 } // if 1187 1194 } else if ( varExpr->get_var()->get_name() == "?++" || varExpr->get_var()->get_name() == "?--" ) { 1188 assert( appExpr->has_result() );1195 assert( ! appExpr->get_results().empty() ); 1189 1196 assert( appExpr->get_args().size() == 1 ); 1190 if ( Type *baseType = isPolyPtr( appExpr->get_result (), scopeTyVars, env ) ) {1191 Type *tempType = appExpr->get_result ()->clone();1197 if ( Type *baseType = isPolyPtr( appExpr->get_results().front(), scopeTyVars, env ) ) { 1198 Type *tempType = appExpr->get_results().front()->clone(); 1192 1199 if ( env ) { 1193 1200 env->apply( tempType ); … … 1206 1213 } // if 1207 1214 } else if ( varExpr->get_var()->get_name() == "++?" || varExpr->get_var()->get_name() == "--?" ) { 1208 assert( appExpr->has_result() );1215 assert( ! appExpr->get_results().empty() ); 1209 1216 assert( appExpr->get_args().size() == 1 ); 1210 if ( Type *baseType = isPolyPtr( appExpr->get_result (), scopeTyVars, env ) ) {1217 if ( Type *baseType = isPolyPtr( appExpr->get_results().front(), scopeTyVars, env ) ) { 1211 1218 return makeIncrDecrExpr( appExpr, baseType, varExpr->get_var()->get_name() == "++?" ); 1212 1219 } // if 1213 1220 } else if ( varExpr->get_var()->get_name() == "?+?" || varExpr->get_var()->get_name() == "?-?" ) { 1214 assert( appExpr->has_result() );1221 assert( ! appExpr->get_results().empty() ); 1215 1222 assert( appExpr->get_args().size() == 2 ); 1216 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result (), scopeTyVars, env );1217 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_result (), scopeTyVars, env );1223 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_results().front(), scopeTyVars, env ); 1224 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_results().front(), scopeTyVars, env ); 1218 1225 if ( baseType1 && baseType2 ) { 1219 1226 UntypedExpr *divide = new UntypedExpr( new NameExpr( "?/?" ) ); 1220 1227 divide->get_args().push_back( appExpr ); 1221 1228 divide->get_args().push_back( new SizeofExpr( baseType1->clone() ) ); 1222 divide-> set_result( appExpr->get_result()->clone() );1229 divide->get_results().push_front( appExpr->get_results().front()->clone() ); 1223 1230 if ( appExpr->get_env() ) { 1224 1231 divide->set_env( appExpr->get_env() ); … … 1238 1245 } // if 1239 1246 } else if ( varExpr->get_var()->get_name() == "?+=?" || varExpr->get_var()->get_name() == "?-=?" ) { 1240 assert( appExpr->has_result() );1247 assert( ! appExpr->get_results().empty() ); 1241 1248 assert( appExpr->get_args().size() == 2 ); 1242 Type *baseType = isPolyPtr( appExpr->get_result (), scopeTyVars, env );1249 Type *baseType = isPolyPtr( appExpr->get_results().front(), scopeTyVars, env ); 1243 1250 if ( baseType ) { 1244 1251 UntypedExpr *multiply = new UntypedExpr( new NameExpr( "?*?" ) ); … … 1266 1273 useRetval = oldUseRetval; 1267 1274 1268 assert( appExpr->get_function()->has_result() ); 1269 PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() ); 1270 FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base() ); 1275 assert( ! appExpr->get_function()->get_results().empty() ); 1276 PointerType *pointer = dynamic_cast< PointerType *>( appExpr->get_function()->get_results().front() ); 1277 assert( pointer ); 1278 FunctionType *function = dynamic_cast< FunctionType *>( pointer->get_base() ); 1279 assert( function ); 1271 1280 1272 1281 if ( Expression *newExpr = handleIntrinsics( appExpr ) ) { … … 1306 1315 1307 1316 Expression *Pass1::mutate( UntypedExpr *expr ) { 1308 if ( expr->has_result() && isPolyType( expr->get_result(), scopeTyVars, env ) ) {1317 if ( ! expr->get_results().empty() && isPolyType( expr->get_results().front(), scopeTyVars, env ) ) { 1309 1318 if ( NameExpr *name = dynamic_cast< NameExpr *>( expr->get_function() ) ) { 1310 1319 if ( name->get_name() == "*?" ) { … … 1320 1329 1321 1330 Expression *Pass1::mutate( AddressExpr *addrExpr ) { 1322 assert( addrExpr->get_arg()->has_result() && ! addrExpr->get_arg()->get_result()->isVoid() );1331 assert( ! addrExpr->get_arg()->get_results().empty() ); 1323 1332 1324 1333 bool needs = false; 1325 1334 if ( UntypedExpr *expr = dynamic_cast< UntypedExpr *>( addrExpr->get_arg() ) ) { 1326 if ( expr->has_result() && isPolyType( expr->get_result(), scopeTyVars, env ) ) {1335 if ( ! expr->get_results().empty() && isPolyType( expr->get_results().front(), scopeTyVars, env ) ) { 1327 1336 if ( NameExpr *name = dynamic_cast< NameExpr *>( expr->get_function() ) ) { 1328 1337 if ( name->get_name() == "*?" ) { 1329 1338 if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr->get_args().front() ) ) { 1330 assert( appExpr->get_function()->has_result() ); 1331 PointerType *pointer = safe_dynamic_cast< PointerType *>( appExpr->get_function()->get_result() ); 1332 FunctionType *function = safe_dynamic_cast< FunctionType *>( pointer->get_base() ); 1339 assert( ! appExpr->get_function()->get_results().empty() ); 1340 PointerType *pointer = dynamic_cast< PointerType *>( appExpr->get_function()->get_results().front() ); 1341 assert( pointer ); 1342 FunctionType *function = dynamic_cast< FunctionType *>( pointer->get_base() ); 1343 assert( function ); 1333 1344 needs = needsAdapter( function, scopeTyVars ); 1334 1345 } // if … … 1339 1350 // isPolyType check needs to happen before mutating addrExpr arg, so pull it forward 1340 1351 // out of the if condition. 1341 bool polytype = isPolyType( addrExpr->get_arg()->get_result (), scopeTyVars, env );1352 bool polytype = isPolyType( addrExpr->get_arg()->get_results().front(), scopeTyVars, env ); 1342 1353 addrExpr->set_arg( mutateExpression( addrExpr->get_arg() ) ); 1343 1354 if ( polytype || needs ) { 1344 1355 Expression *ret = addrExpr->get_arg(); 1345 delete ret->get_result ();1346 ret-> set_result( addrExpr->get_result()->clone());1356 delete ret->get_results().front(); 1357 ret->get_results().front() = addrExpr->get_results().front()->clone(); 1347 1358 addrExpr->set_arg( 0 ); 1348 1359 delete addrExpr; … … 1382 1393 Statement * Pass1::mutate( ReturnStmt *returnStmt ) { 1383 1394 if ( retval && returnStmt->get_expr() ) { 1384 assert( returnStmt->get_expr()->has_result() && ! returnStmt->get_expr()->get_result()->isVoid() );1395 assert( ! returnStmt->get_expr()->get_results().empty() ); 1385 1396 // ***** Code Removal ***** After introducing a temporary variable for all return expressions, the following code appears superfluous. 1386 1397 // if ( returnStmt->get_expr()->get_results().front()->get_isLvalue() ) { … … 1416 1427 // find each of its needed secondary assignment operators 1417 1428 std::list< Expression* > &tyParams = refType->get_parameters(); 1418 Type::ForallList&forallParams = functionDecl->get_type()->get_forall();1429 std::list< TypeDecl* > &forallParams = functionDecl->get_type()->get_forall(); 1419 1430 std::list< Expression* >::const_iterator tyIt = tyParams.begin(); 1420 Type::ForallList::const_iterator forallIt = forallParams.begin();1431 std::list< TypeDecl* >::const_iterator forallIt = forallParams.begin(); 1421 1432 for ( ; tyIt != tyParams.end() && forallIt != forallParams.end(); ++tyIt, ++forallIt ) { 1422 1433 // Add appropriate mapping to assignment expression environment … … 1462 1473 // replace return statement with appropriate assignment to out parameter 1463 1474 Expression *retParm = new NameExpr( retval->get_name() ); 1464 retParm-> set_result( new PointerType( Type::Qualifiers(), retval->get_type()->clone() ) );1475 retParm->get_results().push_back( new PointerType( Type::Qualifiers(), retval->get_type()->clone() ) ); 1465 1476 assignExpr->get_args().push_back( retParm ); 1466 1477 assignExpr->get_args().push_back( returnStmt->get_expr() ); … … 1592 1603 ObjectDecl newPtr( "", DeclarationNode::NoStorageClass, LinkageSpec::C, 0, 1593 1604 new PointerType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ), 0 ); 1594 for ( Type::ForallList::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) {1605 for ( std::list< TypeDecl *>::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) { 1595 1606 ObjectDecl *sizeParm, *alignParm; 1596 1607 // add all size and alignment parameters to parameter list
Note:
See TracChangeset
for help on using the changeset viewer.