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