Changes in / [aa8f9df:fd782b2]
- Location:
- src
- Files:
-
- 2 added
- 30 edited
-
CodeGen/CodeGenerator.cc (modified) (2 diffs)
-
ControlStruct/LabelTypeChecker.cc (added)
-
ControlStruct/LabelTypeChecker.h (added)
-
ControlStruct/Mutate.cc (modified) (2 diffs)
-
ControlStruct/module.mk (modified) (2 diffs)
-
GenPoly/Box.cc (modified) (18 diffs)
-
GenPoly/Lvalue.cc (modified) (6 diffs)
-
GenPoly/Specialize.cc (modified) (4 diffs)
-
InitTweak/FixInit.cc (modified) (6 diffs)
-
InitTweak/InitTweak.cc (modified) (1 diff)
-
Makefile.in (modified) (6 diffs)
-
ResolvExpr/Alternative.cc (modified) (3 diffs)
-
ResolvExpr/AlternativeFinder.cc (modified) (23 diffs)
-
ResolvExpr/AlternativeFinder.h (modified) (1 diff)
-
ResolvExpr/AlternativePrinter.cc (modified) (2 diffs)
-
ResolvExpr/ResolveTypeof.cc (modified) (2 diffs)
-
ResolvExpr/Resolver.cc (modified) (6 diffs)
-
ResolvExpr/Unify.cc (modified) (1 diff)
-
ResolvExpr/typeops.h (modified) (6 diffs)
-
SymTab/Autogen.cc (modified) (1 diff)
-
SymTab/Indexer.cc (modified) (12 diffs)
-
SynTree/AddressExpr.cc (modified) (2 diffs)
-
SynTree/ApplicationExpr.cc (modified) (2 diffs)
-
SynTree/CommaExpr.cc (modified) (1 diff)
-
SynTree/Expression.cc (modified) (17 diffs)
-
SynTree/Expression.h (modified) (2 diffs)
-
SynTree/Mutator.cc (modified) (26 diffs)
-
SynTree/TupleExpr.cc (modified) (6 diffs)
-
SynTree/Type.h (modified) (5 diffs)
-
SynTree/Visitor.cc (modified) (15 diffs)
-
Tuples/TupleAssignment.cc (modified) (3 diffs)
-
Tuples/TupleExpansion.cc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
raa8f9df rfd782b2 309 309 UntypedExpr * newExpr = new UntypedExpr( new NameExpr( "*?" ) ); 310 310 newExpr->get_args().push_back( *arg ); 311 Type * type = InitTweak::getPointerBase( (*arg)->get_result() ); 311 assert( (*arg)->get_results().size() == 1 ); 312 Type * type = InitTweak::getPointerBase( (*arg)->get_results().front() ); 312 313 assert( type ); 313 newExpr-> set_result( type->clone() );314 newExpr->get_results().push_back( type->clone() ); 314 315 *arg = newExpr; 315 316 } // if … … 526 527 extension( castExpr ); 527 528 output << "("; 528 if ( castExpr->get_result ()->isVoid() ) {529 if ( castExpr->get_results().empty() ) { 529 530 output << "(void)" ; 530 } else if ( ! castExpr->get_result ()->get_isLvalue() ) {531 } else if ( ! castExpr->get_results().front()->get_isLvalue() ) { 531 532 // at least one result type of cast, but not an lvalue 532 533 output << "("; 533 output << genType( castExpr->get_result (), "" );534 output << genType( castExpr->get_results().front(), "" ); 534 535 output << ")"; 535 536 } else { -
src/ControlStruct/Mutate.cc
raa8f9df rfd782b2 23 23 #include "MLEMutator.h" 24 24 #include "ForExprMutator.h" 25 #include "LabelTypeChecker.h" 25 26 //#include "ExceptMutator.h" 26 27 … … 40 41 41 42 //ExceptMutator exc; 43 // LabelTypeChecker lbl; 42 44 43 45 mutateAll( translationUnit, formut ); 44 46 acceptAll( translationUnit, lfix ); 45 47 //mutateAll( translationUnit, exc ); 48 //acceptAll( translationUnit, lbl ); 46 49 } 47 50 } // namespace CodeGen -
src/ControlStruct/module.mk
raa8f9df rfd782b2 6 6 ## file "LICENCE" distributed with Cforall. 7 7 ## 8 ## module.mk -- 8 ## module.mk -- 9 9 ## 10 10 ## Author : Richard C. Bilson … … 19 19 ControlStruct/MLEMutator.cc \ 20 20 ControlStruct/Mutate.cc \ 21 ControlStruct/ForExprMutator.cc 21 ControlStruct/ForExprMutator.cc \ 22 ControlStruct/LabelTypeChecker.cc 22 23 -
src/GenPoly/Box.cc
raa8f9df rfd782b2 782 782 783 783 // 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 () );784 if ( appExpr->get_function()->get_results().empty() ) return; 785 FunctionType *funcType = getFunctionType( appExpr->get_function()->get_results().front() ); 786 786 assert( funcType ); 787 787 … … 799 799 for ( ; fnParm != funcType->get_parameters().end() && fnArg != appExpr->get_args().end(); ++fnParm, ++fnArg ) { 800 800 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 );801 if ( ! fnArgBase || fnArgBase->get_results().empty() ) continue; 802 passArgTypeVars( appExpr, (*fnParm)->get_type(), fnArgBase->get_results().front(), arg, exprTyVars, seenTypes ); 803 803 } 804 804 } … … 890 890 Type * adapteeType = new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ); 891 891 appExpr->get_args().push_front( new CastExpr( appExpr->get_function(), adapteeType ) ); 892 appExpr->set_function( new NameExpr( adapterName ) ); // xxx - result is never set on NameExpr892 appExpr->set_function( new NameExpr( adapterName ) ); 893 893 894 894 return ret; … … 896 896 897 897 void Pass1::boxParam( Type *param, Expression *&arg, const TyVarMap &exprTyVars ) { 898 assert( arg->has_result() );898 assert( ! arg->get_results().empty() ); 899 899 if ( isPolyType( param, exprTyVars ) ) { 900 if ( isPolyType( arg->get_result () ) ) {900 if ( isPolyType( arg->get_results().front() ) ) { 901 901 // if the argument's type is polymorphic, we don't need to box again! 902 902 return; 903 } else if ( arg->get_result ()->get_isLvalue() ) {903 } else if ( arg->get_results().front()->get_isLvalue() ) { 904 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) 905 905 // xxx - need to test that this code is still reachable … … 987 987 UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) ); 988 988 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() );989 deref->get_results().push_back( arg->get_type()->clone() ); 990 990 return deref; 991 991 } // if … … 1124 1124 } // if 1125 1125 addAssign->get_args().push_back( new NameExpr( sizeofName( mangleType( polyType ) ) ) ); 1126 addAssign-> set_result( appExpr->get_result()->clone());1126 addAssign->get_results().front() = appExpr->get_results().front()->clone(); 1127 1127 if ( appExpr->get_env() ) { 1128 1128 addAssign->set_env( appExpr->get_env() ); … … 1138 1138 if ( varExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic ) { 1139 1139 if ( varExpr->get_var()->get_name() == "?[?]" ) { 1140 assert( appExpr->has_result() );1140 assert( ! appExpr->get_results().empty() ); 1141 1141 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 );1142 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_results().front(), scopeTyVars, env ); 1143 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_results().front(), scopeTyVars, env ); 1144 1144 assert( ! baseType1 || ! baseType2 ); // the arguments cannot both be polymorphic pointers 1145 1145 UntypedExpr *ret = 0; … … 1161 1161 } // if 1162 1162 if ( baseType1 || baseType2 ) { 1163 ret-> set_result( appExpr->get_result()->clone() );1163 ret->get_results().push_front( appExpr->get_results().front()->clone() ); 1164 1164 if ( appExpr->get_env() ) { 1165 1165 ret->set_env( appExpr->get_env() ); … … 1171 1171 } // if 1172 1172 } else if ( varExpr->get_var()->get_name() == "*?" ) { 1173 assert( appExpr->has_result() );1173 assert( ! appExpr->get_results().empty() ); 1174 1174 assert( ! appExpr->get_args().empty() ); 1175 if ( isPolyType( appExpr->get_result (), scopeTyVars, env ) ) {1175 if ( isPolyType( appExpr->get_results().front(), scopeTyVars, env ) ) { 1176 1176 Expression *ret = appExpr->get_args().front(); 1177 delete ret->get_result ();1178 ret-> set_result( appExpr->get_result()->clone());1177 delete ret->get_results().front(); 1178 ret->get_results().front() = appExpr->get_results().front()->clone(); 1179 1179 if ( appExpr->get_env() ) { 1180 1180 ret->set_env( appExpr->get_env() ); … … 1186 1186 } // if 1187 1187 } else if ( varExpr->get_var()->get_name() == "?++" || varExpr->get_var()->get_name() == "?--" ) { 1188 assert( appExpr->has_result() );1188 assert( ! appExpr->get_results().empty() ); 1189 1189 assert( appExpr->get_args().size() == 1 ); 1190 if ( Type *baseType = isPolyPtr( appExpr->get_result (), scopeTyVars, env ) ) {1191 Type *tempType = appExpr->get_result ()->clone();1190 if ( Type *baseType = isPolyPtr( appExpr->get_results().front(), scopeTyVars, env ) ) { 1191 Type *tempType = appExpr->get_results().front()->clone(); 1192 1192 if ( env ) { 1193 1193 env->apply( tempType ); … … 1206 1206 } // if 1207 1207 } else if ( varExpr->get_var()->get_name() == "++?" || varExpr->get_var()->get_name() == "--?" ) { 1208 assert( appExpr->has_result() );1208 assert( ! appExpr->get_results().empty() ); 1209 1209 assert( appExpr->get_args().size() == 1 ); 1210 if ( Type *baseType = isPolyPtr( appExpr->get_result (), scopeTyVars, env ) ) {1210 if ( Type *baseType = isPolyPtr( appExpr->get_results().front(), scopeTyVars, env ) ) { 1211 1211 return makeIncrDecrExpr( appExpr, baseType, varExpr->get_var()->get_name() == "++?" ); 1212 1212 } // if 1213 1213 } else if ( varExpr->get_var()->get_name() == "?+?" || varExpr->get_var()->get_name() == "?-?" ) { 1214 assert( appExpr->has_result() );1214 assert( ! appExpr->get_results().empty() ); 1215 1215 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 );1216 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_results().front(), scopeTyVars, env ); 1217 Type *baseType2 = isPolyPtr( appExpr->get_args().back()->get_results().front(), scopeTyVars, env ); 1218 1218 if ( baseType1 && baseType2 ) { 1219 1219 UntypedExpr *divide = new UntypedExpr( new NameExpr( "?/?" ) ); 1220 1220 divide->get_args().push_back( appExpr ); 1221 1221 divide->get_args().push_back( new SizeofExpr( baseType1->clone() ) ); 1222 divide-> set_result( appExpr->get_result()->clone() );1222 divide->get_results().push_front( appExpr->get_results().front()->clone() ); 1223 1223 if ( appExpr->get_env() ) { 1224 1224 divide->set_env( appExpr->get_env() ); … … 1238 1238 } // if 1239 1239 } else if ( varExpr->get_var()->get_name() == "?+=?" || varExpr->get_var()->get_name() == "?-=?" ) { 1240 assert( appExpr->has_result() );1240 assert( ! appExpr->get_results().empty() ); 1241 1241 assert( appExpr->get_args().size() == 2 ); 1242 Type *baseType = isPolyPtr( appExpr->get_result (), scopeTyVars, env );1242 Type *baseType = isPolyPtr( appExpr->get_results().front(), scopeTyVars, env ); 1243 1243 if ( baseType ) { 1244 1244 UntypedExpr *multiply = new UntypedExpr( new NameExpr( "?*?" ) ); … … 1266 1266 useRetval = oldUseRetval; 1267 1267 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() ); 1268 assert( ! appExpr->get_function()->get_results().empty() ); 1269 PointerType *pointer = dynamic_cast< PointerType *>( appExpr->get_function()->get_results().front() ); 1270 assert( pointer ); 1271 FunctionType *function = dynamic_cast< FunctionType *>( pointer->get_base() ); 1272 assert( function ); 1271 1273 1272 1274 if ( Expression *newExpr = handleIntrinsics( appExpr ) ) { … … 1306 1308 1307 1309 Expression *Pass1::mutate( UntypedExpr *expr ) { 1308 if ( expr->has_result() && isPolyType( expr->get_result(), scopeTyVars, env ) ) {1310 if ( ! expr->get_results().empty() && isPolyType( expr->get_results().front(), scopeTyVars, env ) ) { 1309 1311 if ( NameExpr *name = dynamic_cast< NameExpr *>( expr->get_function() ) ) { 1310 1312 if ( name->get_name() == "*?" ) { … … 1320 1322 1321 1323 Expression *Pass1::mutate( AddressExpr *addrExpr ) { 1322 assert( addrExpr->get_arg()->has_result() && ! addrExpr->get_arg()->get_result()->isVoid() );1324 assert( ! addrExpr->get_arg()->get_results().empty() ); 1323 1325 1324 1326 bool needs = false; 1325 1327 if ( UntypedExpr *expr = dynamic_cast< UntypedExpr *>( addrExpr->get_arg() ) ) { 1326 if ( expr->has_result() && isPolyType( expr->get_result(), scopeTyVars, env ) ) {1328 if ( ! expr->get_results().empty() && isPolyType( expr->get_results().front(), scopeTyVars, env ) ) { 1327 1329 if ( NameExpr *name = dynamic_cast< NameExpr *>( expr->get_function() ) ) { 1328 1330 if ( name->get_name() == "*?" ) { 1329 1331 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() ); 1332 assert( ! appExpr->get_function()->get_results().empty() ); 1333 PointerType *pointer = dynamic_cast< PointerType *>( appExpr->get_function()->get_results().front() ); 1334 assert( pointer ); 1335 FunctionType *function = dynamic_cast< FunctionType *>( pointer->get_base() ); 1336 assert( function ); 1333 1337 needs = needsAdapter( function, scopeTyVars ); 1334 1338 } // if … … 1339 1343 // isPolyType check needs to happen before mutating addrExpr arg, so pull it forward 1340 1344 // out of the if condition. 1341 bool polytype = isPolyType( addrExpr->get_arg()->get_result (), scopeTyVars, env );1345 bool polytype = isPolyType( addrExpr->get_arg()->get_results().front(), scopeTyVars, env ); 1342 1346 addrExpr->set_arg( mutateExpression( addrExpr->get_arg() ) ); 1343 1347 if ( polytype || needs ) { 1344 1348 Expression *ret = addrExpr->get_arg(); 1345 delete ret->get_result ();1346 ret-> set_result( addrExpr->get_result()->clone());1349 delete ret->get_results().front(); 1350 ret->get_results().front() = addrExpr->get_results().front()->clone(); 1347 1351 addrExpr->set_arg( 0 ); 1348 1352 delete addrExpr; … … 1382 1386 Statement * Pass1::mutate( ReturnStmt *returnStmt ) { 1383 1387 if ( retval && returnStmt->get_expr() ) { 1384 assert( returnStmt->get_expr()->has_result() && ! returnStmt->get_expr()->get_result()->isVoid() );1388 assert( ! returnStmt->get_expr()->get_results().empty() ); 1385 1389 // ***** Code Removal ***** After introducing a temporary variable for all return expressions, the following code appears superfluous. 1386 1390 // if ( returnStmt->get_expr()->get_results().front()->get_isLvalue() ) { … … 1462 1466 // replace return statement with appropriate assignment to out parameter 1463 1467 Expression *retParm = new NameExpr( retval->get_name() ); 1464 retParm-> set_result( new PointerType( Type::Qualifiers(), retval->get_type()->clone() ) );1468 retParm->get_results().push_back( new PointerType( Type::Qualifiers(), retval->get_type()->clone() ) ); 1465 1469 assignExpr->get_args().push_back( retParm ); 1466 1470 assignExpr->get_args().push_back( returnStmt->get_expr() ); -
src/GenPoly/Lvalue.cc
raa8f9df rfd782b2 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Lvalue.cc -- 7 // Lvalue.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 41 41 public: 42 42 Pass1(); 43 43 44 44 virtual Expression *mutate( ApplicationExpr *appExpr ); 45 45 virtual Statement *mutate( ReturnStmt *appExpr ); … … 99 99 appExpr->get_function()->acceptMutator( *this ); 100 100 mutateAll( appExpr->get_args(), *this ); 101 102 assert( ! appExpr->get_function()->get_results().empty() ); 101 103 102 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() ); 103 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() ); 104 PointerType *pointer = dynamic_cast< PointerType* >( appExpr->get_function()->get_results().front() ); 105 assert( pointer ); 106 FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ); 107 assert( function ); 104 108 105 109 Type *funType = isLvalueRet( function ); 106 110 if ( funType && ! isIntrinsicApp( appExpr ) ) { 107 111 Expression *expr = appExpr; 108 Type *appType = appExpr->get_result ();112 Type *appType = appExpr->get_results().front(); 109 113 if ( isPolyType( funType ) && ! isPolyType( appType ) ) { 110 114 // make sure cast for polymorphic type is inside dereference … … 112 116 } 113 117 UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) ); 114 deref-> set_result( appType->clone() );115 appExpr-> set_result( new PointerType( Type::Qualifiers(), appType ));118 deref->get_results().push_back( appType->clone() ); 119 appExpr->get_results().front() = new PointerType( Type::Qualifiers(), appType ); 116 120 deref->get_args().push_back( expr ); 117 121 return deref; … … 123 127 Statement * Pass1::mutate(ReturnStmt *retStmt) { 124 128 if ( retval && retStmt->get_expr() ) { 125 if ( retStmt->get_expr()->get_result()->get_isLvalue() ) { 129 assert( ! retStmt->get_expr()->get_results().empty() ); 130 if ( retStmt->get_expr()->get_results().front()->get_isLvalue() ) { 126 131 // ***** Code Removal ***** because casts may be stripped already 127 132 … … 150 155 retParm->set_type( new PointerType( Type::Qualifiers(), retParm->get_type() ) ); 151 156 } // if 152 157 153 158 Visitor::visit( funType ); 154 159 } -
src/GenPoly/Specialize.cc
raa8f9df rfd782b2 147 147 148 148 Expression * Specialize::doSpecialization( Type *formalType, Expression *actual, InferredParams *inferParams ) { 149 assert( actual->has_result() );150 if ( needsSpecialization( formalType, actual->get_result (), env ) ) {149 assert( ! actual->get_results().empty() ); // using front, should have this assert 150 if ( needsSpecialization( formalType, actual->get_results().front(), env ) ) { 151 151 FunctionType *funType; 152 152 if ( ( funType = getFunctionType( formalType ) ) ) { … … 171 171 void Specialize::handleExplicitParams( ApplicationExpr *appExpr ) { 172 172 // create thunks for the explicit parameters 173 assert( appExpr->get_function()->has_result() );174 FunctionType *function = getFunctionType( appExpr->get_function()->get_result () );173 assert( ! appExpr->get_function()->get_results().empty() ); 174 FunctionType *function = getFunctionType( appExpr->get_function()->get_results().front() ); 175 175 assert( function ); 176 176 std::list< DeclarationWithType* >::iterator formal; … … 200 200 Expression * Specialize::mutate( AddressExpr *addrExpr ) { 201 201 addrExpr->get_arg()->acceptMutator( *this ); 202 assert( addrExpr->has_result() );203 addrExpr->set_arg( doSpecialization( addrExpr->get_result (), addrExpr->get_arg() ) );202 assert( ! addrExpr->get_results().empty() ); 203 addrExpr->set_arg( doSpecialization( addrExpr->get_results().front(), addrExpr->get_arg() ) ); 204 204 return addrExpr; 205 205 } … … 207 207 Expression * Specialize::mutate( CastExpr *castExpr ) { 208 208 castExpr->get_arg()->acceptMutator( *this ); 209 if ( castExpr->get_result ()->isVoid() ) {209 if ( castExpr->get_results().empty() ) { 210 210 // can't specialize if we don't have a return value 211 211 return castExpr; 212 212 } 213 Expression *specialized = doSpecialization( castExpr->get_result (), castExpr->get_arg() );213 Expression *specialized = doSpecialization( castExpr->get_results().front(), castExpr->get_arg() ); 214 214 if ( specialized != castExpr->get_arg() ) { 215 215 // assume here that the specialization incorporates the cast -
src/InitTweak/FixInit.cc
raa8f9df rfd782b2 391 391 CP_CTOR_PRINT( std::cerr << "Type Substitution: " << *impCpCtorExpr->get_env() << std::endl; ) 392 392 // xxx - need to handle tuple arguments 393 assert( arg->has_result() );394 Type * result = arg->get_result ();393 assert( ! arg->get_results().empty() ); 394 Type * result = arg->get_results().front(); 395 395 if ( skipCopyConstruct( result ) ) continue; // skip certain non-copyable types 396 396 // type may involve type variables, so apply type substitution to get temporary variable's actual type … … 423 423 // level. Trying to pass that environment along. 424 424 callExpr->set_env( impCpCtorExpr->get_env()->clone() ); 425 Type * result = appExpr->get_result(); 426 if ( ! result->isVoid() ) { 427 // need to flatten result type and construct each 425 for ( Type * result : appExpr->get_results() ) { 428 426 result = result->clone(); 429 427 impCpCtorExpr->get_env()->apply( result ); … … 481 479 // know the result type of the assignment is the type of the LHS (minus the pointer), so 482 480 // add that onto the assignment expression so that later steps have the necessary information 483 assign-> set_result( returnDecl->get_type()->clone() );481 assign->add_result( returnDecl->get_type()->clone() ); 484 482 485 483 Expression * retExpr = new CommaExpr( assign, new VariableExpr( returnDecl ) ); 486 if ( callExpr->get_result ()->get_isLvalue() ) {484 if ( callExpr->get_results().front()->get_isLvalue() ) { 487 485 // lvalue returning functions are funny. Lvalue.cc inserts a *? in front of any lvalue returning 488 486 // non-intrinsic function. Add an AddressExpr to the call to negate the derefence and change the … … 502 500 UntypedExpr * deref = new UntypedExpr( new NameExpr( "*?" ) ); 503 501 deref->get_args().push_back( retExpr ); 504 deref-> set_result( resultType );502 deref->add_result( resultType ); 505 503 retExpr = deref; 506 504 } // if … … 941 939 Expression * FixCtorExprs::mutate( ConstructorExpr * ctorExpr ) { 942 940 static UniqueName tempNamer( "_tmp_ctor_expr" ); 943 assert( ctorExpr-> has_result() && ctorExpr->get_result()->size() == 1 );944 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, ctorExpr->get_result ()->clone(), nullptr );941 assert( ctorExpr->get_results().size() == 1 ); 942 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, ctorExpr->get_results().front()->clone(), nullptr ); 945 943 addDeclaration( tmp ); 946 944 … … 954 952 assign->get_args().push_back( new VariableExpr( tmp ) ); 955 953 assign->get_args().push_back( firstArg ); 956 assign->set_result( ctorExpr->get_result()->clone() );954 cloneAll( ctorExpr->get_results(), assign->get_results() ); 957 955 firstArg = assign; 958 956 -
src/InitTweak/InitTweak.cc
raa8f9df rfd782b2 340 340 return allofCtorDtor( stmt, []( Expression * callExpr ){ 341 341 if ( ApplicationExpr * appExpr = isIntrinsicCallExpr( callExpr ) ) { 342 FunctionType *funcType = GenPoly::getFunctionType( appExpr->get_function()->get_result() ); 342 assert( ! appExpr->get_function()->get_results().empty() ); 343 FunctionType *funcType = GenPoly::getFunctionType( appExpr->get_function()->get_results().front() ); 343 344 assert( funcType ); 344 345 return funcType->get_parameters().size() == 1; -
src/Makefile.in
raa8f9df rfd782b2 104 104 ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT) \ 105 105 ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT) \ 106 ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT) \ 106 107 GenPoly/driver_cfa_cpp-Box.$(OBJEXT) \ 107 108 GenPoly/driver_cfa_cpp-GenPoly.$(OBJEXT) \ … … 360 361 ControlStruct/LabelGenerator.cc ControlStruct/LabelFixer.cc \ 361 362 ControlStruct/MLEMutator.cc ControlStruct/Mutate.cc \ 362 ControlStruct/ForExprMutator.cc GenPoly/Box.cc \ 363 ControlStruct/ForExprMutator.cc \ 364 ControlStruct/LabelTypeChecker.cc GenPoly/Box.cc \ 363 365 GenPoly/GenPoly.cc GenPoly/PolyMutator.cc \ 364 366 GenPoly/ScrubTyVars.cc GenPoly/Lvalue.cc GenPoly/Specialize.cc \ … … 533 535 ControlStruct/$(DEPDIR)/$(am__dirstamp) 534 536 ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT): \ 537 ControlStruct/$(am__dirstamp) \ 538 ControlStruct/$(DEPDIR)/$(am__dirstamp) 539 ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT): \ 535 540 ControlStruct/$(am__dirstamp) \ 536 541 ControlStruct/$(DEPDIR)/$(am__dirstamp) … … 786 791 -rm -f ControlStruct/driver_cfa_cpp-LabelFixer.$(OBJEXT) 787 792 -rm -f ControlStruct/driver_cfa_cpp-LabelGenerator.$(OBJEXT) 793 -rm -f ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT) 788 794 -rm -f ControlStruct/driver_cfa_cpp-MLEMutator.$(OBJEXT) 789 795 -rm -f ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT) … … 890 896 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelFixer.Po@am__quote@ 891 897 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelGenerator.Po@am__quote@ 898 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Po@am__quote@ 892 899 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-MLEMutator.Po@am__quote@ 893 900 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-Mutate.Po@am__quote@ … … 1204 1211 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-ForExprMutator.obj `if test -f 'ControlStruct/ForExprMutator.cc'; then $(CYGPATH_W) 'ControlStruct/ForExprMutator.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/ForExprMutator.cc'; fi` 1205 1212 1213 ControlStruct/driver_cfa_cpp-LabelTypeChecker.o: ControlStruct/LabelTypeChecker.cc 1214 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ControlStruct/driver_cfa_cpp-LabelTypeChecker.o -MD -MP -MF ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Tpo -c -o ControlStruct/driver_cfa_cpp-LabelTypeChecker.o `test -f 'ControlStruct/LabelTypeChecker.cc' || echo '$(srcdir)/'`ControlStruct/LabelTypeChecker.cc 1215 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Tpo ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Po 1216 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='ControlStruct/LabelTypeChecker.cc' object='ControlStruct/driver_cfa_cpp-LabelTypeChecker.o' libtool=no @AMDEPBACKSLASH@ 1217 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1218 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-LabelTypeChecker.o `test -f 'ControlStruct/LabelTypeChecker.cc' || echo '$(srcdir)/'`ControlStruct/LabelTypeChecker.cc 1219 1220 ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj: ControlStruct/LabelTypeChecker.cc 1221 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj -MD -MP -MF ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Tpo -c -o ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj `if test -f 'ControlStruct/LabelTypeChecker.cc'; then $(CYGPATH_W) 'ControlStruct/LabelTypeChecker.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/LabelTypeChecker.cc'; fi` 1222 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Tpo ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Po 1223 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='ControlStruct/LabelTypeChecker.cc' object='ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj' libtool=no @AMDEPBACKSLASH@ 1224 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1225 @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj `if test -f 'ControlStruct/LabelTypeChecker.cc'; then $(CYGPATH_W) 'ControlStruct/LabelTypeChecker.cc'; else $(CYGPATH_W) '$(srcdir)/ControlStruct/LabelTypeChecker.cc'; fi` 1226 1206 1227 GenPoly/driver_cfa_cpp-Box.o: GenPoly/Box.cc 1207 1228 @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT GenPoly/driver_cfa_cpp-Box.o -MD -MP -MF GenPoly/$(DEPDIR)/driver_cfa_cpp-Box.Tpo -c -o GenPoly/driver_cfa_cpp-Box.o `test -f 'GenPoly/Box.cc' || echo '$(srcdir)/'`GenPoly/Box.cc -
src/ResolvExpr/Alternative.cc
raa8f9df rfd782b2 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Alternative.cc -- 7 // Alternative.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 12 12 // Last Modified On : Sat May 16 23:54:23 2015 13 13 // Update Count : 2 14 // 14 // 15 15 16 16 #include "Alternative.h" … … 54 54 expr->print( os, indent ); 55 55 os << "(types:" << std::endl; 56 os << std::string( indent+4, ' ' ); 57 expr->get_result()->print( os, indent + 4 ); 58 os << std::endl << ")" << std::endl; 56 printAll( expr->get_results(), os, indent + 4 ); 57 os << ")" << std::endl; 59 58 } else { 60 59 os << "Null expression!" << std::endl; -
src/ResolvExpr/AlternativeFinder.cc
raa8f9df rfd782b2 100 100 PruneStruct current( candidate ); 101 101 std::string mangleName; 102 {103 Type * newType = candidate->expr->get_result()->clone();102 for ( std::list< Type* >::const_iterator retType = candidate->expr->get_results().begin(); retType != candidate->expr->get_results().end(); ++retType ) { 103 Type *newType = (*retType)->clone(); 104 104 candidate->env.apply( newType ); 105 mangleName = SymTab::Mangler::mangle( newType );105 mangleName += SymTab::Mangler::mangle( newType ); 106 106 delete newType; 107 107 } … … 132 132 if ( ! target->second.isAmbiguous ) { 133 133 Alternative &alt = *target->second.candidate; 134 alt.env.applyFree( alt.expr->get_result() ); 134 for ( std::list< Type* >::iterator result = alt.expr->get_results().begin(); result != alt.expr->get_results().end(); ++result ) { 135 alt.env.applyFree( *result ); 136 } 135 137 *out++ = alt; 136 138 } 137 139 } 140 138 141 } 139 142 … … 146 149 147 150 void renameTypes( Expression *expr ) { 148 expr->get_result()->accept( global_renamer ); 151 for ( std::list< Type* >::iterator i = expr->get_results().begin(); i != expr->get_results().end(); ++i ) { 152 (*i)->accept( global_renamer ); 153 } 154 } 155 156 // flatten tuple type into list of types 157 template< typename OutputIterator > 158 void flatten( Type * type, OutputIterator out ) { 159 if ( TupleType * tupleType = dynamic_cast< TupleType * >( type ) ) { 160 for ( Type * t : *tupleType ) { 161 flatten( t, out ); 162 } 163 } else { 164 *out++ = type; 165 } 149 166 } 150 167 } … … 178 195 for ( AltList::iterator i = alternatives.begin(); i != alternatives.end(); ++i ) { 179 196 if ( adjust ) { 180 adjustExprType ( i->expr->get_result(), i->env, indexer );197 adjustExprTypeList( i->expr->get_results().begin(), i->expr->get_results().end(), i->env, indexer ); 181 198 } 182 199 } … … 248 265 Cost computeConversionCost( Alternative &alt, const SymTab::Indexer &indexer ) { 249 266 ApplicationExpr *appExpr = safe_dynamic_cast< ApplicationExpr* >( alt.expr ); 250 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result () );267 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_results().front() ); 251 268 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() ); 252 269 … … 265 282 (*actualExpr)->print( std::cerr, 8 ); 266 283 std::cerr << "--- results are" << std::endl; 267 (*actualExpr)->get_result()->print(std::cerr, 8 );284 printAll( (*actualExpr)->get_results(), std::cerr, 8 ); 268 285 ) 269 286 std::list< DeclarationWithType* >::iterator startFormal = formal; 270 287 Cost actualCost; 271 std::list< Type * > flatActualTypes; 272 flatten( (*actualExpr)->get_result(), back_inserter( flatActualTypes ) ); 273 for ( std::list< Type* >::iterator actualType = flatActualTypes.begin(); actualType != flatActualTypes.end(); ++actualType ) { 274 288 for ( std::list< Type* >::iterator actualType = (*actualExpr)->get_results().begin(); actualType != (*actualExpr)->get_results().end(); ++actualType ) { 275 289 276 290 // tuple handling code … … 385 399 386 400 for ( AltList::const_iterator actualExpr = actuals.begin(); actualExpr != actuals.end(); ++actualExpr ) { 387 std::list< Type * > flatActualTypes; 388 flatten( actualExpr->expr->get_result(), back_inserter( flatActualTypes ) ); 389 for ( std::list< Type* >::iterator actualType = flatActualTypes.begin(); actualType != flatActualTypes.end(); ++actualType, ++formalType ) { 401 std::list< Type* > & actualTypes = actualExpr->expr->get_results(); 402 for ( std::list< Type* >::iterator actualType = actualTypes.begin(); actualType != actualTypes.end(); ++actualType ) { 390 403 if ( formalType == formalTypes.end() ) { 391 404 // the type of the formal parameter may be a tuple type. To make this easier to work with, … … 403 416 PRINT( 404 417 std::cerr << "formal type is "; 405 (*formal Type)->print( std::cerr );418 (*formal)->get_type()->print( std::cerr ); 406 419 std::cerr << std::endl << "actual type is "; 407 420 (*actualType)->print( std::cerr ); … … 411 424 return false; 412 425 } 426 ++formalType; 413 427 } 414 428 } … … 518 532 //if ( newNeedParents[ curDecl->get_uniqueId() ][ candDecl->get_uniqueId() ]++ > recursionParentLimit ) continue; 519 533 Expression *varExpr = new VariableExpr( candDecl ); 520 delete varExpr->get_result(); 521 varExpr->set_result( adjType->clone() ); 534 deleteAll( varExpr->get_results() ); 535 varExpr->get_results().clear(); 536 varExpr->get_results().push_front( adjType->clone() ); 522 537 PRINT( 523 538 std::cerr << "satisfying assertion " << curDecl->get_uniqueId() << " "; … … 591 606 PointerType pt( Type::Qualifiers(), v.clone() ); 592 607 UntypedExpr *vexpr = untypedExpr->clone(); 593 vexpr-> set_result( pt.clone() );608 vexpr->get_results().push_front( pt.clone() ); 594 609 alternatives.push_back( Alternative( vexpr, env, Cost()) ); 595 610 return; … … 619 634 // check if the type is pointer to function 620 635 PointerType *pointer; 621 if ( ( pointer = dynamic_cast< PointerType* >( func->expr->get_result() ) ) ) {636 if ( func->expr->get_results().size() == 1 && ( pointer = dynamic_cast< PointerType* >( func->expr->get_results().front() ) ) ) { 622 637 if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) { 623 638 for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) { … … 655 670 // check if the type is pointer to function 656 671 PointerType *pointer; 657 if ( ( pointer = dynamic_cast< PointerType* >( funcOp->expr->get_result() ) ) ) { 672 if ( funcOp->expr->get_results().size() == 1 673 && ( pointer = dynamic_cast< PointerType* >( funcOp->expr->get_results().front() ) ) ) { 658 674 if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) { 659 675 for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) { … … 680 696 PRINT( 681 697 ApplicationExpr *appExpr = safe_dynamic_cast< ApplicationExpr* >( withFunc->expr ); 682 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result () );698 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_results().front() ); 683 699 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() ); 684 700 std::cerr << "Case +++++++++++++" << std::endl; … … 703 719 704 720 bool isLvalue( Expression *expr ) { 705 // xxx - recurse into tuples? 706 return expr->has_result() && expr->get_result()->get_isLvalue(); 721 for ( std::list< Type* >::const_iterator i = expr->get_results().begin(); i != expr->get_results().end(); ++i ) { 722 if ( !(*i)->get_isLvalue() ) return false; 723 } // for 724 return true; 707 725 } 708 726 … … 718 736 719 737 void AlternativeFinder::visit( CastExpr *castExpr ) { 720 Type *& toType = castExpr->get_result(); 721 toType = resolveTypeof( toType, indexer ); 722 SymTab::validateType( toType, &indexer ); 723 adjustExprType( toType, env, indexer ); 738 for ( std::list< Type* >::iterator i = castExpr->get_results().begin(); i != castExpr->get_results().end(); ++i ) { 739 *i = resolveTypeof( *i, indexer ); 740 SymTab::validateType( *i, &indexer ); 741 adjustExprType( *i, env, indexer ); 742 } // for 724 743 725 744 AlternativeFinder finder( indexer, env ); … … 735 754 // that are cast directly. The candidate is invalid if it has fewer results than there are types to cast 736 755 // to. 737 int discardedValues = (*i).expr->get_result ()->size() - castExpr->get_result()->size();756 int discardedValues = (*i).expr->get_results().size() - castExpr->get_results().size(); 738 757 if ( discardedValues < 0 ) continue; 739 // xxx - may need to go into tuple types and extract relavent types and use unifyList 758 std::list< Type* >::iterator candidate_end = (*i).expr->get_results().begin(); 759 std::advance( candidate_end, castExpr->get_results().size() ); 740 760 // unification run for side-effects 741 unify( castExpr->get_result(), (*i).expr->get_result(), i->env, needAssertions, haveAssertions, openVars, indexer ); 742 Cost thisCost = castCost( (*i).expr->get_result(), castExpr->get_result(), indexer, i->env ); 761 unifyList( castExpr->get_results().begin(), castExpr->get_results().end(), 762 (*i).expr->get_results().begin(), candidate_end, 763 i->env, needAssertions, haveAssertions, openVars, indexer ); 764 Cost thisCost = castCostList( (*i).expr->get_results().begin(), candidate_end, 765 castExpr->get_results().begin(), castExpr->get_results().end(), 766 indexer, i->env ); 743 767 if ( thisCost != Cost::infinity ) { 744 768 // count one safe conversion for each value that is thrown away … … 763 787 764 788 for ( AltList::const_iterator agg = funcFinder.alternatives.begin(); agg != funcFinder.alternatives.end(); ++agg ) { 765 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( agg->expr->get_result() ) ) { 766 addAggMembers( structInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() ); 767 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( agg->expr->get_result() ) ) { 768 addAggMembers( unionInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() ); 789 if ( agg->expr->get_results().size() == 1 ) { 790 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( agg->expr->get_results().front() ) ) { 791 addAggMembers( structInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() ); 792 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( agg->expr->get_results().front() ) ) { 793 addAggMembers( unionInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() ); 794 } // if 769 795 } // if 770 796 } // for … … 897 923 alternatives.push_back( Alternative( new AttrExpr( new VariableExpr( funcDecl ), argType->clone() ), env, Cost::zero ) ); 898 924 for ( std::list< DeclarationWithType* >::iterator i = function->get_returnVals().begin(); i != function->get_returnVals().end(); ++i ) { 899 alternatives.back().expr-> set_result( (*i)->get_type()->clone() );925 alternatives.back().expr->get_results().push_back( (*i)->get_type()->clone() ); 900 926 } // for 901 927 } // if … … 920 946 finder.find( attrExpr->get_expr() ); 921 947 for ( AltList::iterator choice = finder.alternatives.begin(); choice != finder.alternatives.end(); ++choice ) { 922 if ( choice->expr->get_result ()->size() == 1 ) {923 resolveAttr(*i, function, choice->expr->get_result (), choice->env );948 if ( choice->expr->get_results().size() == 1 ) { 949 resolveAttr(*i, function, choice->expr->get_results().front(), choice->env ); 924 950 } // fi 925 951 } // for … … 963 989 AssertionSet needAssertions, haveAssertions; 964 990 Alternative newAlt( 0, third->env, first->cost + second->cost + third->cost ); 965 Type* commonType;966 if ( unify ( second->expr->get_result(), third->expr->get_result(), newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType) ) {991 std::list< Type* > commonTypes; 992 if ( unifyList( second->expr->get_results().begin(), second->expr->get_results().end(), third->expr->get_results().begin(), third->expr->get_results().end(), newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonTypes ) ) { 967 993 ConditionalExpr *newExpr = new ConditionalExpr( first->expr->clone(), second->expr->clone(), third->expr->clone() ); 968 newExpr->set_result( commonType ? commonType : second->expr->get_result()->clone() ); 994 std::list< Type* >::const_iterator original = second->expr->get_results().begin(); 995 std::list< Type* >::const_iterator commonType = commonTypes.begin(); 996 for ( ; original != second->expr->get_results().end() && commonType != commonTypes.end(); ++original, ++commonType ) { 997 if ( *commonType ) { 998 newExpr->get_results().push_back( *commonType ); 999 } else { 1000 newExpr->get_results().push_back( (*original)->clone() ); 1001 } // if 1002 } // for 969 1003 newAlt.expr = newExpr; 970 1004 inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( alternatives ) ); … … 994 1028 TupleExpr *newExpr = new TupleExpr; 995 1029 makeExprList( *i, newExpr->get_exprs() ); 996 TupleType *tupleType = new TupleType( Type::Qualifiers(true, true, true, true, true, true) ); 997 Type::Qualifiers &qualifiers = tupleType->get_qualifiers(); 998 for ( Expression * resultExpr : newExpr->get_exprs() ) { 999 Type * type = resultExpr->get_result()->clone(); 1000 tupleType->get_types().push_back( type ); 1001 qualifiers &= type->get_qualifiers(); 1030 for ( std::list< Expression* >::const_iterator resultExpr = newExpr->get_exprs().begin(); resultExpr != newExpr->get_exprs().end(); ++resultExpr ) { 1031 for ( std::list< Type* >::const_iterator resultType = (*resultExpr)->get_results().begin(); resultType != (*resultExpr)->get_results().end(); ++resultType ) { 1032 newExpr->get_results().push_back( (*resultType)->clone() ); 1033 } // for 1002 1034 } // for 1003 newExpr->set_result( tupleType );1004 1035 1005 1036 TypeEnvironment compositeEnv; … … 1026 1057 alternatives.push_back( Alternative( tupleExpr->clone(), env, Cost::zero ) ); 1027 1058 } 1028 1029 void AlternativeFinder::visit( TupleAssignExpr *tupleAssignExpr ) {1030 alternatives.push_back( Alternative( tupleAssignExpr->clone(), env, Cost::zero ) );1031 }1032 1059 } // namespace ResolvExpr 1033 1060 -
src/ResolvExpr/AlternativeFinder.h
raa8f9df rfd782b2 68 68 virtual void visit( ConstructorExpr * ctorExpr ); 69 69 virtual void visit( TupleIndexExpr *tupleExpr ); 70 virtual void visit( TupleAssignExpr *tupleExpr );71 70 /// Runs a new alternative finder on each element in [begin, end) 72 71 /// and writes each alternative finder to out. -
src/ResolvExpr/AlternativePrinter.cc
raa8f9df rfd782b2 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // AlternativePrinter.cc -- 7 // AlternativePrinter.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 33 33 for ( AltList::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) { 34 34 os << "Alternative " << count++ << " ==============" << std::endl; 35 i->expr->get_result()->print(os );35 printAll( i->expr->get_results(), os ); 36 36 // i->print( os ); 37 37 os << std::endl; -
src/ResolvExpr/ResolveTypeof.cc
raa8f9df rfd782b2 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ResolveTypeof.cc -- 7 // ResolveTypeof.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 58 58 if ( typeofType->get_expr() ) { 59 59 Expression *newExpr = resolveInVoidContext( typeofType->get_expr(), indexer ); 60 assert( newExpr->has_result() && ! newExpr->get_result()->isVoid() ); 61 Type *newType = newExpr->get_result(); 60 assert( newExpr->get_results().size() > 0 ); 61 Type *newType; 62 if ( newExpr->get_results().size() > 1 ) { 63 TupleType *tupleType = new TupleType( Type::Qualifiers() ); 64 cloneAll( newExpr->get_results(), tupleType->get_types() ); 65 newType = tupleType; 66 } else { 67 newType = newExpr->get_results().front()->clone(); 68 } // if 62 69 delete typeofType; 63 70 return newType; -
src/ResolvExpr/Resolver.cc
raa8f9df rfd782b2 19 19 #include "RenameVars.h" 20 20 #include "ResolveTypeof.h" 21 #include "typeops.h"22 21 #include "SynTree/Statement.h" 23 22 #include "SynTree/Type.h" … … 68 67 void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator & ); 69 68 void fallbackInit( ConstructorInit * ctorInit ); 70 Type *functionReturn;69 std::list< Type * > functionReturn; 71 70 Type *initContext; 72 71 Type *switchType; … … 156 155 const TypeEnvironment *newEnv = 0; 157 156 for ( AltList::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) { 158 if ( i->expr->get_result ()->size() == 1 && isIntegralType( i->expr->get_result() ) ) {157 if ( i->expr->get_results().size() == 1 && isIntegralType( i->expr->get_results().front() ) ) { 159 158 if ( newExpr ) { 160 159 throw SemanticError( "Too many interpretations for case control expression", untyped ); … … 233 232 Type *new_type = resolveTypeof( functionDecl->get_type(), *this ); 234 233 functionDecl->set_type( new_type ); 235 ValueGuard< Type * > oldFunctionReturn( functionReturn ); 236 functionReturn = ResolvExpr::extractResultType( functionDecl->get_functionType() ); 234 std::list< Type * > oldFunctionReturn = functionReturn; 235 functionReturn.clear(); 236 for ( std::list< DeclarationWithType * >::const_iterator i = functionDecl->get_functionType()->get_returnVals().begin(); i != functionDecl->get_functionType()->get_returnVals().end(); ++i ) { 237 functionReturn.push_back( (*i)->get_type() ); 238 } // for 237 239 SymTab::Indexer::visit( functionDecl ); 240 functionReturn = oldFunctionReturn; 238 241 } 239 242 … … 333 336 void Resolver::visit( ReturnStmt *returnStmt ) { 334 337 if ( returnStmt->get_expr() ) { 335 CastExpr *castExpr = new CastExpr( returnStmt->get_expr(), functionReturn->clone() ); 338 CastExpr *castExpr = new CastExpr( returnStmt->get_expr() ); 339 cloneAll( functionReturn, castExpr->get_results() ); 336 340 Expression *newExpr = findSingleExpression( castExpr, *this ); 337 341 delete castExpr; … … 378 382 if ( isCharType( at->get_base() ) ) { 379 383 // check if the resolved type is char * 380 if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result () ) ) {384 if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_results().front() ) ) { 381 385 if ( isCharType( pt->get_base() ) ) { 382 386 // strip cast if we're initializing a char[] with a char *, e.g. char x[] = "hello"; -
src/ResolvExpr/Unify.cc
raa8f9df rfd782b2 588 588 } 589 589 590 // xxx - compute once and store in the FunctionType?591 Type * extractResultType( FunctionType * function ) {592 if ( function->get_returnVals().size() == 0 ) {593 return new VoidType( Type::Qualifiers() );594 } else if ( function->get_returnVals().size() == 1 ) {595 return function->get_returnVals().front()->get_type()->clone();596 } else {597 TupleType * tupleType = new TupleType( Type::Qualifiers() );598 for ( DeclarationWithType * decl : function->get_returnVals() ) {599 tupleType->get_types().push_back( decl->get_type()->clone() );600 } // for601 return tupleType;602 }603 }604 605 590 } // namespace ResolvExpr 606 591 -
src/ResolvExpr/typeops.h
raa8f9df rfd782b2 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // typeops.h -- 7 // typeops.h -- 8 8 // 9 9 // Author : Richard C. Bilson … … 30 30 typedef typename InputIterator::value_type SetType; 31 31 typedef typename std::list< typename SetType::value_type > ListType; 32 32 33 33 if ( begin == end ) { 34 34 *out++ = ListType(); 35 35 return; 36 36 } // if 37 37 38 38 InputIterator current = begin; 39 39 begin++; … … 41 41 std::list< ListType > recursiveResult; 42 42 combos( begin, end, back_inserter( recursiveResult ) ); 43 43 44 44 for ( typename std::list< ListType >::const_iterator i = recursiveResult.begin(); i != recursiveResult.end(); ++i ) { 45 45 for ( typename ListType::const_iterator j = current->begin(); j != current->end(); ++j ) { … … 52 52 } // for 53 53 } 54 54 55 55 // in AdjustExprType.cc 56 56 /// Replaces array types with the equivalent pointer, and function types with a pointer-to-function … … 144 144 } 145 145 146 /// creates the type represented by the list of returnVals in a FunctionType. The caller owns the return value.147 Type * extractResultType( FunctionType * functionType );148 149 146 // in CommonType.cc 150 147 Type *commonType( Type *type1, Type *type2, bool widenFirst, bool widenSecond, const SymTab::Indexer &indexer, TypeEnvironment &env, const OpenVarSet &openVars ); … … 155 152 // in Occurs.cc 156 153 bool occurs( Type *type, std::string varName, const TypeEnvironment &env ); 157 158 // flatten tuple type into list of types159 template< typename OutputIterator >160 void flatten( Type * type, OutputIterator out ) {161 if ( TupleType * tupleType = dynamic_cast< TupleType * >( type ) ) {162 for ( Type * t : tupleType->get_types() ) {163 flatten( t, out );164 }165 } else {166 *out++ = type;167 }168 }169 154 } // namespace ResolvExpr 170 155 -
src/SymTab/Autogen.cc
raa8f9df rfd782b2 116 116 // This happens before function pointer type conversion, so need to do it manually here 117 117 VariableExpr * assignVarExpr = new VariableExpr( assignDecl ); 118 Type * assignVarExprType = assignVarExpr->get_result();118 Type *& assignVarExprType = assignVarExpr->get_results().front(); 119 119 assignVarExprType = new PointerType( Type::Qualifiers(), assignVarExprType ); 120 assignVarExpr->set_result( assignVarExprType );121 120 ApplicationExpr * assignExpr = new ApplicationExpr( assignVarExpr ); 122 121 assignExpr->get_args().push_back( new VariableExpr( dstParam ) ); -
src/SymTab/Indexer.cc
raa8f9df rfd782b2 40 40 41 41 namespace SymTab { 42 template< typename TreeType, typename VisitorType >43 inline void accept NewScope( TreeType *tree, VisitorType &visitor ) {42 template< typename Container, typename VisitorType > 43 inline void acceptAllNewScope( Container &container, VisitorType &visitor ) { 44 44 visitor.enterScope(); 45 maybeAccept( tree, visitor );45 acceptAll( container, visitor ); 46 46 visitor.leaveScope(); 47 47 } … … 337 337 338 338 void Indexer::visit( ApplicationExpr *applicationExpr ) { 339 accept NewScope( applicationExpr->get_result(), *this );339 acceptAllNewScope( applicationExpr->get_results(), *this ); 340 340 maybeAccept( applicationExpr->get_function(), *this ); 341 341 acceptAll( applicationExpr->get_args(), *this ); … … 343 343 344 344 void Indexer::visit( UntypedExpr *untypedExpr ) { 345 accept NewScope( untypedExpr->get_result(), *this );345 acceptAllNewScope( untypedExpr->get_results(), *this ); 346 346 acceptAll( untypedExpr->get_args(), *this ); 347 347 } 348 348 349 349 void Indexer::visit( NameExpr *nameExpr ) { 350 accept NewScope( nameExpr->get_result(), *this );350 acceptAllNewScope( nameExpr->get_results(), *this ); 351 351 } 352 352 353 353 void Indexer::visit( AddressExpr *addressExpr ) { 354 accept NewScope( addressExpr->get_result(), *this );354 acceptAllNewScope( addressExpr->get_results(), *this ); 355 355 maybeAccept( addressExpr->get_arg(), *this ); 356 356 } 357 357 358 358 void Indexer::visit( LabelAddressExpr *labAddressExpr ) { 359 accept NewScope( labAddressExpr->get_result(), *this );359 acceptAllNewScope( labAddressExpr->get_results(), *this ); 360 360 maybeAccept( labAddressExpr->get_arg(), *this ); 361 361 } 362 362 363 363 void Indexer::visit( CastExpr *castExpr ) { 364 accept NewScope( castExpr->get_result(), *this );364 acceptAllNewScope( castExpr->get_results(), *this ); 365 365 maybeAccept( castExpr->get_arg(), *this ); 366 366 } 367 367 368 368 void Indexer::visit( UntypedMemberExpr *memberExpr ) { 369 accept NewScope( memberExpr->get_result(), *this );369 acceptAllNewScope( memberExpr->get_results(), *this ); 370 370 maybeAccept( memberExpr->get_aggregate(), *this ); 371 371 } 372 372 373 373 void Indexer::visit( MemberExpr *memberExpr ) { 374 accept NewScope( memberExpr->get_result(), *this );374 acceptAllNewScope( memberExpr->get_results(), *this ); 375 375 maybeAccept( memberExpr->get_aggregate(), *this ); 376 376 } 377 377 378 378 void Indexer::visit( VariableExpr *variableExpr ) { 379 accept NewScope( variableExpr->get_result(), *this );379 acceptAllNewScope( variableExpr->get_results(), *this ); 380 380 } 381 381 382 382 void Indexer::visit( ConstantExpr *constantExpr ) { 383 accept NewScope( constantExpr->get_result(), *this );383 acceptAllNewScope( constantExpr->get_results(), *this ); 384 384 maybeAccept( constantExpr->get_constant(), *this ); 385 385 } 386 386 387 387 void Indexer::visit( SizeofExpr *sizeofExpr ) { 388 accept NewScope( sizeofExpr->get_result(), *this );388 acceptAllNewScope( sizeofExpr->get_results(), *this ); 389 389 if ( sizeofExpr->get_isType() ) { 390 390 maybeAccept( sizeofExpr->get_type(), *this ); … … 395 395 396 396 void Indexer::visit( AlignofExpr *alignofExpr ) { 397 accept NewScope( alignofExpr->get_result(), *this );397 acceptAllNewScope( alignofExpr->get_results(), *this ); 398 398 if ( alignofExpr->get_isType() ) { 399 399 maybeAccept( alignofExpr->get_type(), *this ); … … 404 404 405 405 void Indexer::visit( UntypedOffsetofExpr *offsetofExpr ) { 406 accept NewScope( offsetofExpr->get_result(), *this );406 acceptAllNewScope( offsetofExpr->get_results(), *this ); 407 407 maybeAccept( offsetofExpr->get_type(), *this ); 408 408 } 409 409 410 410 void Indexer::visit( OffsetofExpr *offsetofExpr ) { 411 accept NewScope( offsetofExpr->get_result(), *this );411 acceptAllNewScope( offsetofExpr->get_results(), *this ); 412 412 maybeAccept( offsetofExpr->get_type(), *this ); 413 413 maybeAccept( offsetofExpr->get_member(), *this ); … … 415 415 416 416 void Indexer::visit( OffsetPackExpr *offsetPackExpr ) { 417 accept NewScope( offsetPackExpr->get_result(), *this );417 acceptAllNewScope( offsetPackExpr->get_results(), *this ); 418 418 maybeAccept( offsetPackExpr->get_type(), *this ); 419 419 } 420 420 421 421 void Indexer::visit( AttrExpr *attrExpr ) { 422 accept NewScope( attrExpr->get_result(), *this );422 acceptAllNewScope( attrExpr->get_results(), *this ); 423 423 if ( attrExpr->get_isType() ) { 424 424 maybeAccept( attrExpr->get_type(), *this ); … … 429 429 430 430 void Indexer::visit( LogicalExpr *logicalExpr ) { 431 accept NewScope( logicalExpr->get_result(), *this );431 acceptAllNewScope( logicalExpr->get_results(), *this ); 432 432 maybeAccept( logicalExpr->get_arg1(), *this ); 433 433 maybeAccept( logicalExpr->get_arg2(), *this ); … … 435 435 436 436 void Indexer::visit( ConditionalExpr *conditionalExpr ) { 437 accept NewScope( conditionalExpr->get_result(), *this );437 acceptAllNewScope( conditionalExpr->get_results(), *this ); 438 438 maybeAccept( conditionalExpr->get_arg1(), *this ); 439 439 maybeAccept( conditionalExpr->get_arg2(), *this ); … … 442 442 443 443 void Indexer::visit( CommaExpr *commaExpr ) { 444 accept NewScope( commaExpr->get_result(), *this );444 acceptAllNewScope( commaExpr->get_results(), *this ); 445 445 maybeAccept( commaExpr->get_arg1(), *this ); 446 446 maybeAccept( commaExpr->get_arg2(), *this ); … … 448 448 449 449 void Indexer::visit( TupleExpr *tupleExpr ) { 450 accept NewScope( tupleExpr->get_result(), *this );450 acceptAllNewScope( tupleExpr->get_results(), *this ); 451 451 acceptAll( tupleExpr->get_exprs(), *this ); 452 452 } 453 453 454 454 void Indexer::visit( TupleAssignExpr *tupleExpr ) { 455 accept NewScope( tupleExpr->get_result(), *this );455 acceptAllNewScope( tupleExpr->get_results(), *this ); 456 456 enterScope(); 457 457 acceptAll( tupleExpr->get_tempDecls(), *this ); … … 461 461 462 462 void Indexer::visit( TypeExpr *typeExpr ) { 463 accept NewScope( typeExpr->get_result(), *this );463 acceptAllNewScope( typeExpr->get_results(), *this ); 464 464 maybeAccept( typeExpr->get_type(), *this ); 465 465 } … … 472 472 473 473 void Indexer::visit( UntypedValofExpr *valofExpr ) { 474 accept NewScope( valofExpr->get_result(), *this );474 acceptAllNewScope( valofExpr->get_results(), *this ); 475 475 maybeAccept( valofExpr->get_body(), *this ); 476 476 } -
src/SynTree/AddressExpr.cc
raa8f9df rfd782b2 19 19 20 20 AddressExpr::AddressExpr( Expression *arg, Expression *_aname ) : Expression( _aname ), arg( arg ) { 21 if ( arg->has_result()) {22 set_result( new PointerType( Type::Qualifiers(), arg->get_result()->clone() ) );23 } 21 for ( std::list< Type* >::const_iterator i = arg->get_results().begin(); i != arg->get_results().end(); ++i ) { 22 get_results().push_back( new PointerType( Type::Qualifiers(), (*i)->clone() ) ); 23 } // for 24 24 } 25 25 … … 35 35 if ( arg ) { 36 36 os << std::string( indent+2, ' ' ); 37 arg->print( os, indent+2 );37 arg->print( os, indent+2 ); 38 38 } // if 39 39 } -
src/SynTree/ApplicationExpr.cc
raa8f9df rfd782b2 21 21 #include "TypeSubstitution.h" 22 22 #include "Common/utility.h" 23 #include "ResolvExpr/typeops.h" 23 24 24 25 25 ParamEntry::ParamEntry( const ParamEntry &other ) : … … 43 43 44 44 ApplicationExpr::ApplicationExpr( Expression *funcExpr ) : function( funcExpr ) { 45 PointerType *pointer = safe_dynamic_cast< PointerType* >( funcExpr->get_result() ); 46 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() ); 45 PointerType *pointer = dynamic_cast< PointerType* >( funcExpr->get_results().front() ); 46 assert( pointer ); 47 FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ); 48 assert( function ); 47 49 48 set_result( ResolvExpr::extractResultType( function ) );49 50 assert( has_result() );50 for ( std::list< DeclarationWithType* >::const_iterator i = function->get_returnVals().begin(); i != function->get_returnVals().end(); ++i ) { 51 get_results().push_back( (*i)->get_type()->clone() ); 52 } // for 51 53 } 52 54 -
src/SynTree/CommaExpr.cc
raa8f9df rfd782b2 23 23 // to false on all result types. Actually doing this causes some strange things 24 24 // to happen in later passes (particularly, Specialize, Lvalue, and Box). This needs to be looked into. 25 set_result( maybeClone( arg2->get_result() ) ); 26 // get_type->set_isLvalue( false ); 25 cloneAll( arg2->get_results(), get_results() ); 26 // for ( Type *& type : get_results() ) { 27 // type->set_isLvalue( false ); 28 // } 27 29 } 28 30 -
src/SynTree/Expression.cc
raa8f9df rfd782b2 31 31 32 32 33 Expression::Expression( Expression *_aname ) : result( 0 ), env( 0 ), argName( _aname ) {} 34 35 Expression::Expression( const Expression &other ) : result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ), extension( other.extension ) { 33 Expression::Expression( Expression *_aname ) : env( 0 ), argName( _aname ) {} 34 35 Expression::Expression( const Expression &other ) : env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ), extension( other.extension ) { 36 cloneAll( other.results, results ); 36 37 } 37 38 … … 39 40 delete env; 40 41 delete argName; // xxx -- there's a problem in cloning ConstantExpr I still don't know how to fix 41 delete result; 42 deleteAll( results ); 43 } 44 45 void Expression::add_result( Type *t ) { 46 if ( TupleType *tuple = dynamic_cast< TupleType* >( t ) ) { 47 std::copy( tuple->get_types().begin(), tuple->get_types().end(), back_inserter( results ) ); 48 } else { 49 results.push_back(t); 50 } // if 42 51 } 43 52 … … 59 68 60 69 ConstantExpr::ConstantExpr( Constant _c, Expression *_aname ) : Expression( _aname ), constant( _c ) { 61 set_result( constant.get_type()->clone() );70 add_result( constant.get_type()->clone() ); 62 71 } 63 72 … … 76 85 assert( var ); 77 86 assert( var->get_type() ); 78 Type * type = var->get_type()->clone(); 79 type->set_isLvalue( true ); 80 set_result( type ); 87 add_result( var->get_type()->clone() ); 88 for ( std::list< Type* >::iterator i = get_results().begin(); i != get_results().end(); ++i ) { 89 (*i)->set_isLvalue( true ); 90 } // for 81 91 } 82 92 … … 100 110 SizeofExpr::SizeofExpr( Expression *expr_, Expression *_aname ) : 101 111 Expression( _aname ), expr(expr_), type(0), isType(false) { 102 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );112 add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 103 113 } 104 114 105 115 SizeofExpr::SizeofExpr( Type *type_, Expression *_aname ) : 106 116 Expression( _aname ), expr(0), type(type_), isType(true) { 107 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );117 add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 108 118 } 109 119 … … 131 141 AlignofExpr::AlignofExpr( Expression *expr_, Expression *_aname ) : 132 142 Expression( _aname ), expr(expr_), type(0), isType(false) { 133 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );143 add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 134 144 } 135 145 136 146 AlignofExpr::AlignofExpr( Type *type_, Expression *_aname ) : 137 147 Expression( _aname ), expr(0), type(type_), isType(true) { 138 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );148 add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 139 149 } 140 150 … … 162 172 UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type_, const std::string &member_, Expression *_aname ) : 163 173 Expression( _aname ), type(type_), member(member_) { 164 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );174 add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 165 175 } 166 176 … … 187 197 OffsetofExpr::OffsetofExpr( Type *type_, DeclarationWithType *member_, Expression *_aname ) : 188 198 Expression( _aname ), type(type_), member(member_) { 189 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );199 add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 190 200 } 191 201 … … 219 229 220 230 OffsetPackExpr::OffsetPackExpr( StructInstType *type_, Expression *aname_ ) : Expression( aname_ ), type( type_ ) { 221 set_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );231 add_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) ); 222 232 } 223 233 … … 274 284 275 285 CastExpr::CastExpr( Expression *arg_, Type *toType, Expression *_aname ) : Expression( _aname ), arg(arg_) { 276 set_result(toType);286 add_result(toType); 277 287 } 278 288 279 289 CastExpr::CastExpr( Expression *arg_, Expression *_aname ) : Expression( _aname ), arg(arg_) { 280 set_result( new VoidType( Type::Qualifiers() ) );281 290 } 282 291 … … 294 303 arg->print(os, indent+2); 295 304 os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl; 296 os << std::string( indent+2, ' ' ); 297 if ( result->isVoid() ) { 298 os << "nothing"; 305 if ( results.empty() ) { 306 os << std::string( indent+2, ' ' ) << "nothing" << std::endl; 299 307 } else { 300 result->print( os, indent+2);308 printAll(results, os, indent+2); 301 309 } // if 302 os << std::endl;303 310 Expression::print( os, indent ); 304 311 } … … 334 341 MemberExpr::MemberExpr( DeclarationWithType *_member, Expression *_aggregate, Expression *_aname ) : 335 342 Expression( _aname ), member(_member), aggregate(_aggregate) { 336 set_result( member->get_type()->clone() ); 337 get_result()->set_isLvalue( true ); 343 add_result( member->get_type()->clone() ); 344 for ( std::list< Type* >::iterator i = get_results().begin(); i != get_results().end(); ++i ) { 345 (*i)->set_isLvalue( true ); 346 } // for 338 347 } 339 348 … … 410 419 LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp, Expression *_aname ) : 411 420 Expression( _aname ), arg1(arg1_), arg2(arg2_), isAnd(andp) { 412 set_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );421 add_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ); 413 422 } 414 423 … … 468 477 ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( ApplicationExpr * callExpr ) : callExpr( callExpr ) { 469 478 assert( callExpr ); 470 assert( callExpr->has_result() ); 471 set_result( callExpr->get_result()->clone() ); 479 cloneAll( callExpr->get_results(), results ); 472 480 } 473 481 … … 502 510 Expression * arg = InitTweak::getCallArg( callExpr, 0 ); 503 511 assert( arg ); 504 set_result( maybeClone( arg->get_result() ));512 cloneAll( arg->get_results(), results ); 505 513 } 506 514 … … 522 530 523 531 CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) { 524 set_result( type->clone() );532 add_result( type->clone() ); 525 533 } 526 534 … … 562 570 if ( ! body.empty() ) { 563 571 if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( body.back() ) ) { 564 set_result( maybeClone( exprStmt->get_expr()->get_result()) );572 cloneAll( exprStmt->get_expr()->get_results(), get_results() ); 565 573 } 566 574 } -
src/SynTree/Expression.h
raa8f9df rfd782b2 32 32 virtual ~Expression(); 33 33 34 Type *& get_result() { return result; } 35 void set_result( Type *newValue ) { result = newValue; } 36 bool has_result() const { return result != nullptr; } 34 std::list<Type *>& get_results() { return results; } 35 void add_result( Type *t ); 37 36 38 37 TypeSubstitution *get_env() const { return env; } … … 48 47 virtual void print( std::ostream &os, int indent = 0 ) const; 49 48 protected: 50 Type * result;49 std::list<Type *> results; 51 50 TypeSubstitution *env; 52 51 Expression* argName; // if expression is used as an argument, it can be "designated" by this name -
src/SynTree/Mutator.cc
raa8f9df rfd782b2 178 178 179 179 Expression *Mutator::mutate( ApplicationExpr *applicationExpr ) { 180 applicationExpr->set_result( maybeMutate( applicationExpr->get_result(), *this ));180 mutateAll( applicationExpr->get_results(), *this ); 181 181 applicationExpr->set_function( maybeMutate( applicationExpr->get_function(), *this ) ); 182 182 mutateAll( applicationExpr->get_args(), *this ); … … 185 185 186 186 Expression *Mutator::mutate( UntypedExpr *untypedExpr ) { 187 untypedExpr->set_result( maybeMutate( untypedExpr->get_result(), *this ));187 mutateAll( untypedExpr->get_results(), *this ); 188 188 mutateAll( untypedExpr->get_args(), *this ); 189 189 return untypedExpr; … … 191 191 192 192 Expression *Mutator::mutate( NameExpr *nameExpr ) { 193 nameExpr->set_result( maybeMutate( nameExpr->get_result(), *this ));193 mutateAll( nameExpr->get_results(), *this ); 194 194 return nameExpr; 195 195 } 196 196 197 197 Expression *Mutator::mutate( AddressExpr *addressExpr ) { 198 addressExpr->set_result( maybeMutate( addressExpr->get_result(), *this ));198 mutateAll( addressExpr->get_results(), *this ); 199 199 addressExpr->set_arg( maybeMutate( addressExpr->get_arg(), *this ) ); 200 200 return addressExpr; … … 202 202 203 203 Expression *Mutator::mutate( LabelAddressExpr *labelAddressExpr ) { 204 labelAddressExpr->set_result( maybeMutate( labelAddressExpr->get_result(), *this ));204 mutateAll( labelAddressExpr->get_results(), *this ); 205 205 labelAddressExpr->set_arg( maybeMutate( labelAddressExpr->get_arg(), *this ) ); 206 206 return labelAddressExpr; … … 208 208 209 209 Expression *Mutator::mutate( CastExpr *castExpr ) { 210 castExpr->set_result( maybeMutate( castExpr->get_result(), *this ));210 mutateAll( castExpr->get_results(), *this ); 211 211 castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) ); 212 212 return castExpr; … … 214 214 215 215 Expression *Mutator::mutate( UntypedMemberExpr *memberExpr ) { 216 m emberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ));216 mutateAll( memberExpr->get_results(), *this ); 217 217 memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) ); 218 218 memberExpr->set_member( maybeMutate( memberExpr->get_member(), *this ) ); … … 221 221 222 222 Expression *Mutator::mutate( MemberExpr *memberExpr ) { 223 m emberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ));223 mutateAll( memberExpr->get_results(), *this ); 224 224 memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) ); 225 225 return memberExpr; … … 227 227 228 228 Expression *Mutator::mutate( VariableExpr *variableExpr ) { 229 variableExpr->set_result( maybeMutate( variableExpr->get_result(), *this ));229 mutateAll( variableExpr->get_results(), *this ); 230 230 return variableExpr; 231 231 } 232 232 233 233 Expression *Mutator::mutate( ConstantExpr *constantExpr ) { 234 constantExpr->set_result( maybeMutate( constantExpr->get_result(), *this ));234 mutateAll( constantExpr->get_results(), *this ); 235 235 // maybeMutate( constantExpr->get_constant(), *this ) 236 236 return constantExpr; … … 238 238 239 239 Expression *Mutator::mutate( SizeofExpr *sizeofExpr ) { 240 sizeofExpr->set_result( maybeMutate( sizeofExpr->get_result(), *this ));240 mutateAll( sizeofExpr->get_results(), *this ); 241 241 if ( sizeofExpr->get_isType() ) { 242 242 sizeofExpr->set_type( maybeMutate( sizeofExpr->get_type(), *this ) ); … … 248 248 249 249 Expression *Mutator::mutate( AlignofExpr *alignofExpr ) { 250 alignofExpr->set_result( maybeMutate( alignofExpr->get_result(), *this ));250 mutateAll( alignofExpr->get_results(), *this ); 251 251 if ( alignofExpr->get_isType() ) { 252 252 alignofExpr->set_type( maybeMutate( alignofExpr->get_type(), *this ) ); … … 258 258 259 259 Expression *Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) { 260 offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ));260 mutateAll( offsetofExpr->get_results(), *this ); 261 261 offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) ); 262 262 return offsetofExpr; … … 264 264 265 265 Expression *Mutator::mutate( OffsetofExpr *offsetofExpr ) { 266 offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ));266 mutateAll( offsetofExpr->get_results(), *this ); 267 267 offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) ); 268 268 offsetofExpr->set_member( maybeMutate( offsetofExpr->get_member(), *this ) ); … … 271 271 272 272 Expression *Mutator::mutate( OffsetPackExpr *offsetPackExpr ) { 273 offsetPackExpr->set_result( maybeMutate( offsetPackExpr->get_result(), *this ));273 mutateAll( offsetPackExpr->get_results(), *this ); 274 274 offsetPackExpr->set_type( maybeMutate( offsetPackExpr->get_type(), *this ) ); 275 275 return offsetPackExpr; … … 277 277 278 278 Expression *Mutator::mutate( AttrExpr *attrExpr ) { 279 attrExpr->set_result( maybeMutate( attrExpr->get_result(), *this ));279 mutateAll( attrExpr->get_results(), *this ); 280 280 if ( attrExpr->get_isType() ) { 281 281 attrExpr->set_type( maybeMutate( attrExpr->get_type(), *this ) ); … … 287 287 288 288 Expression *Mutator::mutate( LogicalExpr *logicalExpr ) { 289 logicalExpr->set_result( maybeMutate( logicalExpr->get_result(), *this ));289 mutateAll( logicalExpr->get_results(), *this ); 290 290 logicalExpr->set_arg1( maybeMutate( logicalExpr->get_arg1(), *this ) ); 291 291 logicalExpr->set_arg2( maybeMutate( logicalExpr->get_arg2(), *this ) ); … … 294 294 295 295 Expression *Mutator::mutate( ConditionalExpr *conditionalExpr ) { 296 conditionalExpr->set_result( maybeMutate( conditionalExpr->get_result(), *this ));296 mutateAll( conditionalExpr->get_results(), *this ); 297 297 conditionalExpr->set_arg1( maybeMutate( conditionalExpr->get_arg1(), *this ) ); 298 298 conditionalExpr->set_arg2( maybeMutate( conditionalExpr->get_arg2(), *this ) ); … … 302 302 303 303 Expression *Mutator::mutate( CommaExpr *commaExpr ) { 304 commaExpr->set_result( maybeMutate( commaExpr->get_result(), *this ));304 mutateAll( commaExpr->get_results(), *this ); 305 305 commaExpr->set_arg1( maybeMutate( commaExpr->get_arg1(), *this ) ); 306 306 commaExpr->set_arg2( maybeMutate( commaExpr->get_arg2(), *this ) ); … … 309 309 310 310 Expression *Mutator::mutate( TypeExpr *typeExpr ) { 311 typeExpr->set_result( maybeMutate( typeExpr->get_result(), *this ));311 mutateAll( typeExpr->get_results(), *this ); 312 312 typeExpr->set_type( maybeMutate( typeExpr->get_type(), *this ) ); 313 313 return typeExpr; … … 329 329 330 330 Expression* Mutator::mutate( ConstructorExpr *ctorExpr ) { 331 ctorExpr->set_result( maybeMutate( ctorExpr->get_result(), *this ));331 mutateAll( ctorExpr->get_results(), *this ); 332 332 ctorExpr->set_callExpr( maybeMutate( ctorExpr->get_callExpr(), *this ) ); 333 333 return ctorExpr; … … 335 335 336 336 Expression *Mutator::mutate( CompoundLiteralExpr *compLitExpr ) { 337 compLitExpr->set_result( maybeMutate( compLitExpr->get_result(), *this ));337 mutateAll( compLitExpr->get_results(), *this ); 338 338 compLitExpr->set_type( maybeMutate( compLitExpr->get_type(), *this ) ); 339 339 compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) ); … … 342 342 343 343 Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) { 344 valofExpr->set_result( maybeMutate( valofExpr->get_result(), *this ));344 mutateAll( valofExpr->get_results(), *this ); 345 345 return valofExpr; 346 346 } … … 353 353 354 354 Expression *Mutator::mutate( TupleExpr *tupleExpr ) { 355 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ));355 mutateAll( tupleExpr->get_results(), *this ); 356 356 mutateAll( tupleExpr->get_exprs(), *this ); 357 357 return tupleExpr; … … 359 359 360 360 Expression *Mutator::mutate( TupleIndexExpr *tupleExpr ) { 361 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ));361 mutateAll( tupleExpr->get_results(), *this ); 362 362 tupleExpr->set_tuple( maybeMutate( tupleExpr->get_tuple(), *this ) ); 363 363 return tupleExpr; … … 365 365 366 366 Expression *Mutator::mutate( MemberTupleExpr *tupleExpr ) { 367 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ));367 mutateAll( tupleExpr->get_results(), *this ); 368 368 tupleExpr->set_member( maybeMutate( tupleExpr->get_member(), *this ) ); 369 369 tupleExpr->set_aggregate( maybeMutate( tupleExpr->get_aggregate(), *this ) ); … … 372 372 373 373 Expression *Mutator::mutate( TupleAssignExpr *assignExpr ) { 374 assignExpr->set_result( maybeMutate( assignExpr->get_result(), *this ));374 mutateAll( assignExpr->get_results(), *this ); 375 375 mutateAll( assignExpr->get_tempDecls(), *this ); 376 376 mutateAll( assignExpr->get_assigns(), *this ); … … 379 379 380 380 Expression *Mutator::mutate( StmtExpr *stmtExpr ) { 381 stmtExpr->set_result( maybeMutate( stmtExpr->get_result(), *this ));381 mutateAll( stmtExpr->get_results(), *this ); 382 382 stmtExpr->set_statements( maybeMutate( stmtExpr->get_statements(), *this ) ); 383 383 return stmtExpr; -
src/SynTree/TupleExpr.cc
raa8f9df rfd782b2 31 31 32 32 void TupleExpr::print( std::ostream &os, int indent ) const { 33 os << "Tuple:" << std::endl;33 os << std::string( indent, ' ' ) << "Tuple:" << std::endl; 34 34 printAll( exprs, os, indent+2 ); 35 35 Expression::print( os, indent ); … … 37 37 38 38 TupleIndexExpr::TupleIndexExpr( Expression * tuple, unsigned int index ) { 39 TupleType * type = safe_dynamic_cast< TupleType * >( tuple->get_result() );40 assert( t ype->size() >= index );41 set_result( *std::next( type->get_types().begin(), index ) );39 // TupleType * type = safe_dynamic_cast< TypeType * >( tuple->get_ ) 40 assert( tuple->get_results().size() >= index ); 41 add_result( *std::next( tuple->get_results().begin(), index ) ); 42 42 } 43 43 … … 50 50 51 51 void TupleIndexExpr::print( std::ostream &os, int indent ) const { 52 os << "Tuple Index Expression, with tuple:" << std::endl;52 os << std::string( indent, ' ' ) << "Tuple Index Expression, with tuple:" << std::endl; 53 53 tuple->print( os, indent+2 ); 54 54 os << std::string( indent+2, ' ' ) << "with index: " << index << std::endl; … … 57 57 58 58 MemberTupleExpr::MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname ) : Expression( _aname ) { 59 set_result( maybeClone( member->get_result()) ); // xxx - ???59 cloneAll( member->get_results(), get_results() ); // xxx - ??? 60 60 } 61 61 … … 69 69 70 70 void MemberTupleExpr::print( std::ostream &os, int indent ) const { 71 os << "Member Tuple Expression, with aggregate:" << std::endl;71 os << std::string( indent, ' ' ) << "Member Tuple Expression, with aggregate:" << std::endl; 72 72 aggregate->print( os, indent+2 ); 73 73 os << std::string( indent+2, ' ' ) << "with member: " << std::endl; … … 78 78 79 79 TupleAssignExpr::TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname ) : Expression( _aname ), assigns( assigns ), tempDecls( tempDecls ) { 80 TupleType * type = new TupleType( Type::Qualifiers() );81 80 for ( Expression * expr : assigns ) { 82 assert( expr->has_result() ); 83 type->get_types().push_back( expr->get_result()->clone() ); 81 cloneAll( expr->get_results(), get_results() ); 84 82 } 85 set_result( type );86 83 } 87 84 -
src/SynTree/Type.h
raa8f9df rfd782b2 27 27 Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic, bool isAttribute ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ), isAttribute( isAttribute ) {} 28 28 29 Qualifiers &operator&=( const Qualifiers &other );30 29 Qualifiers &operator+=( const Qualifiers &other ); 31 30 Qualifiers &operator-=( const Qualifiers &other ); … … 66 65 std::list<TypeDecl*>& get_forall() { return forall; } 67 66 68 /// How many elemental types are represented by this type69 virtual unsigned size() const { return 1; };70 virtual bool isVoid() const { return size() == 0; }71 72 67 virtual Type *clone() const = 0; 73 68 virtual void accept( Visitor &v ) = 0; … … 82 77 public: 83 78 VoidType( const Type::Qualifiers &tq ); 84 85 virtual unsigned size() const { return 0; };86 79 87 80 virtual VoidType *clone() const { return new VoidType( *this ); } … … 364 357 365 358 std::list<Type*>& get_types() { return types; } 366 virtual unsigned size() const { return types.size(); };367 359 368 360 iterator begin() { return types.begin(); } … … 433 425 }; 434 426 435 inline Type::Qualifiers &Type::Qualifiers::operator&=( const Type::Qualifiers &other ) {436 isConst &= other.isConst;437 isVolatile &= other.isVolatile;438 isRestrict &= other.isRestrict;439 isLvalue &= other.isLvalue;440 isAtomic &= other.isAtomic;441 return *this;442 }443 444 427 inline Type::Qualifiers &Type::Qualifiers::operator+=( const Type::Qualifiers &other ) { 445 428 isConst |= other.isConst; -
src/SynTree/Visitor.cc
raa8f9df rfd782b2 150 150 151 151 void Visitor::visit( ApplicationExpr *applicationExpr ) { 152 maybeAccept( applicationExpr->get_result(), *this );152 acceptAll( applicationExpr->get_results(), *this ); 153 153 maybeAccept( applicationExpr->get_function(), *this ); 154 154 acceptAll( applicationExpr->get_args(), *this ); … … 156 156 157 157 void Visitor::visit( UntypedExpr *untypedExpr ) { 158 maybeAccept( untypedExpr->get_result(), *this );158 acceptAll( untypedExpr->get_results(), *this ); 159 159 acceptAll( untypedExpr->get_args(), *this ); 160 160 } 161 161 162 162 void Visitor::visit( NameExpr *nameExpr ) { 163 maybeAccept( nameExpr->get_result(), *this );163 acceptAll( nameExpr->get_results(), *this ); 164 164 } 165 165 166 166 void Visitor::visit( AddressExpr *addressExpr ) { 167 maybeAccept( addressExpr->get_result(), *this );167 acceptAll( addressExpr->get_results(), *this ); 168 168 maybeAccept( addressExpr->get_arg(), *this ); 169 169 } 170 170 171 171 void Visitor::visit( LabelAddressExpr *labAddressExpr ) { 172 maybeAccept( labAddressExpr->get_result(), *this );172 acceptAll( labAddressExpr->get_results(), *this ); 173 173 maybeAccept( labAddressExpr->get_arg(), *this ); 174 174 } 175 175 176 176 void Visitor::visit( CastExpr *castExpr ) { 177 maybeAccept( castExpr->get_result(), *this );177 acceptAll( castExpr->get_results(), *this ); 178 178 maybeAccept( castExpr->get_arg(), *this ); 179 179 } 180 180 181 181 void Visitor::visit( UntypedMemberExpr *memberExpr ) { 182 maybeAccept( memberExpr->get_result(), *this );182 acceptAll( memberExpr->get_results(), *this ); 183 183 maybeAccept( memberExpr->get_aggregate(), *this ); 184 184 maybeAccept( memberExpr->get_member(), *this ); … … 186 186 187 187 void Visitor::visit( MemberExpr *memberExpr ) { 188 maybeAccept( memberExpr->get_result(), *this );188 acceptAll( memberExpr->get_results(), *this ); 189 189 maybeAccept( memberExpr->get_aggregate(), *this ); 190 190 } 191 191 192 192 void Visitor::visit( VariableExpr *variableExpr ) { 193 maybeAccept( variableExpr->get_result(), *this );193 acceptAll( variableExpr->get_results(), *this ); 194 194 } 195 195 196 196 void Visitor::visit( ConstantExpr *constantExpr ) { 197 maybeAccept( constantExpr->get_result(), *this );197 acceptAll( constantExpr->get_results(), *this ); 198 198 maybeAccept( constantExpr->get_constant(), *this ); 199 199 } 200 200 201 201 void Visitor::visit( SizeofExpr *sizeofExpr ) { 202 maybeAccept( sizeofExpr->get_result(), *this );202 acceptAll( sizeofExpr->get_results(), *this ); 203 203 if ( sizeofExpr->get_isType() ) { 204 204 maybeAccept( sizeofExpr->get_type(), *this ); … … 209 209 210 210 void Visitor::visit( AlignofExpr *alignofExpr ) { 211 maybeAccept( alignofExpr->get_result(), *this );211 acceptAll( alignofExpr->get_results(), *this ); 212 212 if ( alignofExpr->get_isType() ) { 213 213 maybeAccept( alignofExpr->get_type(), *this ); … … 218 218 219 219 void Visitor::visit( UntypedOffsetofExpr *offsetofExpr ) { 220 maybeAccept( offsetofExpr->get_result(), *this );220 acceptAll( offsetofExpr->get_results(), *this ); 221 221 maybeAccept( offsetofExpr->get_type(), *this ); 222 222 } 223 223 224 224 void Visitor::visit( OffsetofExpr *offsetofExpr ) { 225 maybeAccept( offsetofExpr->get_result(), *this );225 acceptAll( offsetofExpr->get_results(), *this ); 226 226 maybeAccept( offsetofExpr->get_type(), *this ); 227 227 maybeAccept( offsetofExpr->get_member(), *this ); … … 229 229 230 230 void Visitor::visit( OffsetPackExpr *offsetPackExpr ) { 231 maybeAccept( offsetPackExpr->get_result(), *this );231 acceptAll( offsetPackExpr->get_results(), *this ); 232 232 maybeAccept( offsetPackExpr->get_type(), *this ); 233 233 } 234 234 235 235 void Visitor::visit( AttrExpr *attrExpr ) { 236 maybeAccept( attrExpr->get_result(), *this );236 acceptAll( attrExpr->get_results(), *this ); 237 237 if ( attrExpr->get_isType() ) { 238 238 maybeAccept( attrExpr->get_type(), *this ); … … 243 243 244 244 void Visitor::visit( LogicalExpr *logicalExpr ) { 245 maybeAccept( logicalExpr->get_result(), *this );245 acceptAll( logicalExpr->get_results(), *this ); 246 246 maybeAccept( logicalExpr->get_arg1(), *this ); 247 247 maybeAccept( logicalExpr->get_arg2(), *this ); … … 249 249 250 250 void Visitor::visit( ConditionalExpr *conditionalExpr ) { 251 maybeAccept( conditionalExpr->get_result(), *this );251 acceptAll( conditionalExpr->get_results(), *this ); 252 252 maybeAccept( conditionalExpr->get_arg1(), *this ); 253 253 maybeAccept( conditionalExpr->get_arg2(), *this ); … … 256 256 257 257 void Visitor::visit( CommaExpr *commaExpr ) { 258 maybeAccept( commaExpr->get_result(), *this );258 acceptAll( commaExpr->get_results(), *this ); 259 259 maybeAccept( commaExpr->get_arg1(), *this ); 260 260 maybeAccept( commaExpr->get_arg2(), *this ); … … 262 262 263 263 void Visitor::visit( TypeExpr *typeExpr ) { 264 maybeAccept( typeExpr->get_result(), *this );264 acceptAll( typeExpr->get_results(), *this ); 265 265 maybeAccept( typeExpr->get_type(), *this ); 266 266 } … … 279 279 280 280 void Visitor::visit( ConstructorExpr * ctorExpr ) { 281 maybeAccept( ctorExpr->get_result(), *this );281 acceptAll( ctorExpr->get_results(), *this ); 282 282 maybeAccept( ctorExpr->get_callExpr(), *this ); 283 283 } 284 284 285 285 void Visitor::visit( CompoundLiteralExpr *compLitExpr ) { 286 maybeAccept( compLitExpr->get_result(), *this );286 acceptAll( compLitExpr->get_results(), *this ); 287 287 maybeAccept( compLitExpr->get_type(), *this ); 288 288 maybeAccept( compLitExpr->get_initializer(), *this ); … … 290 290 291 291 void Visitor::visit( UntypedValofExpr *valofExpr ) { 292 maybeAccept( valofExpr->get_result(), *this );292 acceptAll( valofExpr->get_results(), *this ); 293 293 maybeAccept( valofExpr->get_body(), *this ); 294 294 } … … 300 300 301 301 void Visitor::visit( TupleExpr *tupleExpr ) { 302 maybeAccept( tupleExpr->get_result(), *this );302 acceptAll( tupleExpr->get_results(), *this ); 303 303 acceptAll( tupleExpr->get_exprs(), *this ); 304 304 } 305 305 306 306 void Visitor::visit( TupleIndexExpr *tupleExpr ) { 307 maybeAccept( tupleExpr->get_result(), *this );307 acceptAll( tupleExpr->get_results(), *this ); 308 308 maybeAccept( tupleExpr->get_tuple(), *this ); 309 309 } 310 310 311 311 void Visitor::visit( MemberTupleExpr *tupleExpr ) { 312 maybeAccept( tupleExpr->get_result(), *this );312 acceptAll( tupleExpr->get_results(), *this ); 313 313 maybeAccept( tupleExpr->get_member(), *this ); 314 314 maybeAccept( tupleExpr->get_aggregate(), *this ); … … 316 316 317 317 void Visitor::visit( TupleAssignExpr *assignExpr ) { 318 maybeAccept( assignExpr->get_result(), *this );318 acceptAll( assignExpr->get_results(), *this ); 319 319 acceptAll( assignExpr->get_tempDecls(), *this ); 320 320 acceptAll( assignExpr->get_assigns(), *this ); … … 322 322 323 323 void Visitor::visit( StmtExpr *stmtExpr ) { 324 maybeAccept( stmtExpr->get_result(), *this );324 acceptAll( stmtExpr->get_results(), *this ); 325 325 maybeAccept( stmtExpr->get_statements(), *this ); 326 326 } -
src/Tuples/TupleAssignment.cc
raa8f9df rfd782b2 88 88 bool isTuple( Expression *expr ) { 89 89 if ( ! expr ) return false; 90 assert( expr->has_result() ); 90 91 91 // xxx - used to include cast to varExpr and call to isTupleVar, but this doesn't seem like it should be necessary 92 return dynamic_cast<TupleExpr *>(expr) || expr->get_result ()->size() > 1;92 return dynamic_cast<TupleExpr *>(expr) || expr->get_results().size() > 1; 93 93 } 94 94 … … 102 102 103 103 bool isTupleExpr( Expression *expr ) { 104 assert( expr->has_result() ); 105 return expr->get_result()->size() > 1; 104 return expr->get_results().size() > 1; 106 105 } 107 106 … … 192 191 193 192 ObjectDecl * newObject( UniqueName & namer, Expression * expr ) { 194 assert( expr->has_result() && ! expr->get_result()->isVoid() ); 195 return new ObjectDecl( namer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, expr->get_result()->clone(), new SingleInit( expr->clone() ) ); 193 Type * type; 194 assert( expr->get_results().size() >= 1 ); 195 if ( expr->get_results().size() > 1 ) { 196 TupleType * tt = new TupleType( Type::Qualifiers() ); 197 cloneAll( expr->get_results(), tt->get_types() ); 198 type = tt; 199 } else { 200 type = expr->get_results().front()->clone(); 201 } 202 return new ObjectDecl( namer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, type, new SingleInit( expr->clone() ) ); 196 203 } 197 204 -
src/Tuples/TupleExpansion.cc
raa8f9df rfd782b2 85 85 addDeclaration( decl ); 86 86 } 87 Type::Qualifiers qualifiers = newType->get_qualifiers();88 87 delete newType; 89 return new StructInstType( qualifiers, typeMap[mangleName] );88 return new StructInstType( newType->get_qualifiers(), typeMap[mangleName] ); 90 89 } 91 90
Note:
See TracChangeset
for help on using the changeset viewer.