Changeset aa8f9df
- Timestamp:
- Sep 15, 2016, 3:22:50 PM (6 years ago)
- Branches:
- aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 4ab9536
- Parents:
- fd782b2 (diff), 906e24d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src
- Files:
-
- 2 deleted
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
rfd782b2 raa8f9df 309 309 UntypedExpr * newExpr = new UntypedExpr( new NameExpr( "*?" ) ); 310 310 newExpr->get_args().push_back( *arg ); 311 assert( (*arg)->get_results().size() == 1 ); 312 Type * type = InitTweak::getPointerBase( (*arg)->get_results().front() ); 311 Type * type = InitTweak::getPointerBase( (*arg)->get_result() ); 313 312 assert( type ); 314 newExpr-> get_results().push_back( type->clone() );313 newExpr->set_result( type->clone() ); 315 314 *arg = newExpr; 316 315 } // if … … 527 526 extension( castExpr ); 528 527 output << "("; 529 if ( castExpr->get_result s().empty() ) {528 if ( castExpr->get_result()->isVoid() ) { 530 529 output << "(void)" ; 531 } else if ( ! castExpr->get_result s().front()->get_isLvalue() ) {530 } else if ( ! castExpr->get_result()->get_isLvalue() ) { 532 531 // at least one result type of cast, but not an lvalue 533 532 output << "("; 534 output << genType( castExpr->get_result s().front(), "" );533 output << genType( castExpr->get_result(), "" ); 535 534 output << ")"; 536 535 } else { -
src/ControlStruct/Mutate.cc
rfd782b2 raa8f9df 23 23 #include "MLEMutator.h" 24 24 #include "ForExprMutator.h" 25 #include "LabelTypeChecker.h"26 25 //#include "ExceptMutator.h" 27 26 … … 41 40 42 41 //ExceptMutator exc; 43 // LabelTypeChecker lbl;44 42 45 43 mutateAll( translationUnit, formut ); 46 44 acceptAll( translationUnit, lfix ); 47 45 //mutateAll( translationUnit, exc ); 48 //acceptAll( translationUnit, lbl );49 46 } 50 47 } // namespace CodeGen -
src/ControlStruct/module.mk
rfd782b2 raa8f9df 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 \ 22 ControlStruct/LabelTypeChecker.cc 21 ControlStruct/ForExprMutator.cc 23 22 -
src/GenPoly/Box.cc
rfd782b2 raa8f9df 782 782 783 783 // add size/align for generic types to parameter list 784 if ( appExpr->get_function()->get_results().empty() ) return;785 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() ); 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 || fnArgBase->get_results().empty() ) continue;802 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 ); 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 ) ); 892 appExpr->set_function( new NameExpr( adapterName ) ); // xxx - result is never set on NameExpr 893 893 894 894 return ret; … … 896 896 897 897 void Pass1::boxParam( Type *param, Expression *&arg, const TyVarMap &exprTyVars ) { 898 assert( ! arg->get_results().empty() );898 assert( arg->has_result() ); 899 899 if ( isPolyType( param, exprTyVars ) ) { 900 if ( isPolyType( arg->get_result s().front() ) ) {900 if ( isPolyType( arg->get_result() ) ) { 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 s().front()->get_isLvalue() ) {903 } else if ( arg->get_result()->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-> get_results().push_back( arg->get_type()->clone() );989 deref->set_result( 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-> get_results().front() = appExpr->get_results().front()->clone();1126 addAssign->set_result( appExpr->get_result()->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->get_results().empty() );1140 assert( appExpr->has_result() ); 1141 1141 assert( appExpr->get_args().size() == 2 ); 1142 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result s().front(), scopeTyVars, env );1143 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 ); 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-> get_results().push_front( appExpr->get_results().front()->clone() );1163 ret->set_result( appExpr->get_result()->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->get_results().empty() );1173 assert( appExpr->has_result() ); 1174 1174 assert( ! appExpr->get_args().empty() ); 1175 if ( isPolyType( appExpr->get_result s().front(), scopeTyVars, env ) ) {1175 if ( isPolyType( appExpr->get_result(), scopeTyVars, env ) ) { 1176 1176 Expression *ret = appExpr->get_args().front(); 1177 delete ret->get_result s().front();1178 ret-> get_results().front() = appExpr->get_results().front()->clone();1177 delete ret->get_result(); 1178 ret->set_result( appExpr->get_result()->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->get_results().empty() );1188 assert( appExpr->has_result() ); 1189 1189 assert( appExpr->get_args().size() == 1 ); 1190 if ( Type *baseType = isPolyPtr( appExpr->get_result s().front(), scopeTyVars, env ) ) {1191 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(); 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->get_results().empty() );1208 assert( appExpr->has_result() ); 1209 1209 assert( appExpr->get_args().size() == 1 ); 1210 if ( Type *baseType = isPolyPtr( appExpr->get_result s().front(), scopeTyVars, env ) ) {1210 if ( Type *baseType = isPolyPtr( appExpr->get_result(), 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->get_results().empty() );1214 assert( appExpr->has_result() ); 1215 1215 assert( appExpr->get_args().size() == 2 ); 1216 Type *baseType1 = isPolyPtr( appExpr->get_args().front()->get_result s().front(), scopeTyVars, env );1217 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 ); 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-> get_results().push_front( appExpr->get_results().front()->clone() );1222 divide->set_result( appExpr->get_result()->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->get_results().empty() );1240 assert( appExpr->has_result() ); 1241 1241 assert( appExpr->get_args().size() == 2 ); 1242 Type *baseType = isPolyPtr( appExpr->get_result s().front(), scopeTyVars, env );1242 Type *baseType = isPolyPtr( appExpr->get_result(), 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()->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 ); 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() ); 1273 1271 1274 1272 if ( Expression *newExpr = handleIntrinsics( appExpr ) ) { … … 1308 1306 1309 1307 Expression *Pass1::mutate( UntypedExpr *expr ) { 1310 if ( ! expr->get_results().empty() && isPolyType( expr->get_results().front(), scopeTyVars, env ) ) {1308 if ( expr->has_result() && isPolyType( expr->get_result(), scopeTyVars, env ) ) { 1311 1309 if ( NameExpr *name = dynamic_cast< NameExpr *>( expr->get_function() ) ) { 1312 1310 if ( name->get_name() == "*?" ) { … … 1322 1320 1323 1321 Expression *Pass1::mutate( AddressExpr *addrExpr ) { 1324 assert( ! addrExpr->get_arg()->get_results().empty() );1322 assert( addrExpr->get_arg()->has_result() && ! addrExpr->get_arg()->get_result()->isVoid() ); 1325 1323 1326 1324 bool needs = false; 1327 1325 if ( UntypedExpr *expr = dynamic_cast< UntypedExpr *>( addrExpr->get_arg() ) ) { 1328 if ( ! expr->get_results().empty() && isPolyType( expr->get_results().front(), scopeTyVars, env ) ) {1326 if ( expr->has_result() && isPolyType( expr->get_result(), scopeTyVars, env ) ) { 1329 1327 if ( NameExpr *name = dynamic_cast< NameExpr *>( expr->get_function() ) ) { 1330 1328 if ( name->get_name() == "*?" ) { 1331 1329 if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr->get_args().front() ) ) { 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 ); 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() ); 1337 1333 needs = needsAdapter( function, scopeTyVars ); 1338 1334 } // if … … 1343 1339 // isPolyType check needs to happen before mutating addrExpr arg, so pull it forward 1344 1340 // out of the if condition. 1345 bool polytype = isPolyType( addrExpr->get_arg()->get_result s().front(), scopeTyVars, env );1341 bool polytype = isPolyType( addrExpr->get_arg()->get_result(), scopeTyVars, env ); 1346 1342 addrExpr->set_arg( mutateExpression( addrExpr->get_arg() ) ); 1347 1343 if ( polytype || needs ) { 1348 1344 Expression *ret = addrExpr->get_arg(); 1349 delete ret->get_result s().front();1350 ret-> get_results().front() = addrExpr->get_results().front()->clone();1345 delete ret->get_result(); 1346 ret->set_result( addrExpr->get_result()->clone() ); 1351 1347 addrExpr->set_arg( 0 ); 1352 1348 delete addrExpr; … … 1386 1382 Statement * Pass1::mutate( ReturnStmt *returnStmt ) { 1387 1383 if ( retval && returnStmt->get_expr() ) { 1388 assert( ! returnStmt->get_expr()->get_results().empty() );1384 assert( returnStmt->get_expr()->has_result() && ! returnStmt->get_expr()->get_result()->isVoid() ); 1389 1385 // ***** Code Removal ***** After introducing a temporary variable for all return expressions, the following code appears superfluous. 1390 1386 // if ( returnStmt->get_expr()->get_results().front()->get_isLvalue() ) { … … 1466 1462 // replace return statement with appropriate assignment to out parameter 1467 1463 Expression *retParm = new NameExpr( retval->get_name() ); 1468 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() ) ); 1469 1465 assignExpr->get_args().push_back( retParm ); 1470 1466 assignExpr->get_args().push_back( returnStmt->get_expr() ); -
src/GenPoly/Lvalue.cc
rfd782b2 raa8f9df 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() );103 101 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 ); 102 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() ); 103 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() ); 108 104 109 105 Type *funType = isLvalueRet( function ); 110 106 if ( funType && ! isIntrinsicApp( appExpr ) ) { 111 107 Expression *expr = appExpr; 112 Type *appType = appExpr->get_result s().front();108 Type *appType = appExpr->get_result(); 113 109 if ( isPolyType( funType ) && ! isPolyType( appType ) ) { 114 110 // make sure cast for polymorphic type is inside dereference … … 116 112 } 117 113 UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) ); 118 deref-> get_results().push_back( appType->clone() );119 appExpr-> get_results().front() = new PointerType( Type::Qualifiers(), appType);114 deref->set_result( appType->clone() ); 115 appExpr->set_result( new PointerType( Type::Qualifiers(), appType ) ); 120 116 deref->get_args().push_back( expr ); 121 117 return deref; … … 127 123 Statement * Pass1::mutate(ReturnStmt *retStmt) { 128 124 if ( retval && retStmt->get_expr() ) { 129 assert( ! retStmt->get_expr()->get_results().empty() ); 130 if ( retStmt->get_expr()->get_results().front()->get_isLvalue() ) { 125 if ( retStmt->get_expr()->get_result()->get_isLvalue() ) { 131 126 // ***** Code Removal ***** because casts may be stripped already 132 127 … … 155 150 retParm->set_type( new PointerType( Type::Qualifiers(), retParm->get_type() ) ); 156 151 } // if 157 152 158 153 Visitor::visit( funType ); 159 154 } -
src/GenPoly/Specialize.cc
rfd782b2 raa8f9df 147 147 148 148 Expression * Specialize::doSpecialization( Type *formalType, Expression *actual, InferredParams *inferParams ) { 149 assert( ! actual->get_results().empty() ); // using front, should have this assert150 if ( needsSpecialization( formalType, actual->get_result s().front(), env ) ) {149 assert( actual->has_result() ); 150 if ( needsSpecialization( formalType, actual->get_result(), 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()->get_results().empty() );174 FunctionType *function = getFunctionType( appExpr->get_function()->get_result s().front() );173 assert( appExpr->get_function()->has_result() ); 174 FunctionType *function = getFunctionType( appExpr->get_function()->get_result() ); 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->get_results().empty() );203 addrExpr->set_arg( doSpecialization( addrExpr->get_result s().front(), addrExpr->get_arg() ) );202 assert( addrExpr->has_result() ); 203 addrExpr->set_arg( doSpecialization( addrExpr->get_result(), 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 s().empty() ) {209 if ( castExpr->get_result()->isVoid() ) { 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 s().front(), castExpr->get_arg() );213 Expression *specialized = doSpecialization( castExpr->get_result(), castExpr->get_arg() ); 214 214 if ( specialized != castExpr->get_arg() ) { 215 215 // assume here that the specialization incorporates the cast -
src/InitTweak/FixInit.cc
rfd782b2 raa8f9df 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->get_results().empty() );394 Type * result = arg->get_result s().front();393 assert( arg->has_result() ); 394 Type * result = arg->get_result(); 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 for ( Type * result : appExpr->get_results() ) { 425 Type * result = appExpr->get_result(); 426 if ( ! result->isVoid() ) { 427 // need to flatten result type and construct each 426 428 result = result->clone(); 427 429 impCpCtorExpr->get_env()->apply( result ); … … 479 481 // know the result type of the assignment is the type of the LHS (minus the pointer), so 480 482 // add that onto the assignment expression so that later steps have the necessary information 481 assign-> add_result( returnDecl->get_type()->clone() );483 assign->set_result( returnDecl->get_type()->clone() ); 482 484 483 485 Expression * retExpr = new CommaExpr( assign, new VariableExpr( returnDecl ) ); 484 if ( callExpr->get_result s().front()->get_isLvalue() ) {486 if ( callExpr->get_result()->get_isLvalue() ) { 485 487 // lvalue returning functions are funny. Lvalue.cc inserts a *? in front of any lvalue returning 486 488 // non-intrinsic function. Add an AddressExpr to the call to negate the derefence and change the … … 500 502 UntypedExpr * deref = new UntypedExpr( new NameExpr( "*?" ) ); 501 503 deref->get_args().push_back( retExpr ); 502 deref-> add_result( resultType );504 deref->set_result( resultType ); 503 505 retExpr = deref; 504 506 } // if … … 939 941 Expression * FixCtorExprs::mutate( ConstructorExpr * ctorExpr ) { 940 942 static UniqueName tempNamer( "_tmp_ctor_expr" ); 941 assert( ctorExpr-> get_results().size() == 1 );942 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, ctorExpr->get_result s().front()->clone(), nullptr );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 ); 943 945 addDeclaration( tmp ); 944 946 … … 952 954 assign->get_args().push_back( new VariableExpr( tmp ) ); 953 955 assign->get_args().push_back( firstArg ); 954 cloneAll( ctorExpr->get_results(), assign->get_results() );956 assign->set_result( ctorExpr->get_result()->clone() ); 955 957 firstArg = assign; 956 958 -
src/InitTweak/InitTweak.cc
rfd782b2 raa8f9df 340 340 return allofCtorDtor( stmt, []( Expression * callExpr ){ 341 341 if ( ApplicationExpr * appExpr = isIntrinsicCallExpr( callExpr ) ) { 342 assert( ! appExpr->get_function()->get_results().empty() ); 343 FunctionType *funcType = GenPoly::getFunctionType( appExpr->get_function()->get_results().front() ); 342 FunctionType *funcType = GenPoly::getFunctionType( appExpr->get_function()->get_result() ); 344 343 assert( funcType ); 345 344 return funcType->get_parameters().size() == 1; -
src/Makefile.in
rfd782b2 raa8f9df 104 104 ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT) \ 105 105 ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT) \ 106 ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT) \107 106 GenPoly/driver_cfa_cpp-Box.$(OBJEXT) \ 108 107 GenPoly/driver_cfa_cpp-GenPoly.$(OBJEXT) \ … … 361 360 ControlStruct/LabelGenerator.cc ControlStruct/LabelFixer.cc \ 362 361 ControlStruct/MLEMutator.cc ControlStruct/Mutate.cc \ 363 ControlStruct/ForExprMutator.cc \ 364 ControlStruct/LabelTypeChecker.cc GenPoly/Box.cc \ 362 ControlStruct/ForExprMutator.cc GenPoly/Box.cc \ 365 363 GenPoly/GenPoly.cc GenPoly/PolyMutator.cc \ 366 364 GenPoly/ScrubTyVars.cc GenPoly/Lvalue.cc GenPoly/Specialize.cc \ … … 535 533 ControlStruct/$(DEPDIR)/$(am__dirstamp) 536 534 ControlStruct/driver_cfa_cpp-ForExprMutator.$(OBJEXT): \ 537 ControlStruct/$(am__dirstamp) \538 ControlStruct/$(DEPDIR)/$(am__dirstamp)539 ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT): \540 535 ControlStruct/$(am__dirstamp) \ 541 536 ControlStruct/$(DEPDIR)/$(am__dirstamp) … … 791 786 -rm -f ControlStruct/driver_cfa_cpp-LabelFixer.$(OBJEXT) 792 787 -rm -f ControlStruct/driver_cfa_cpp-LabelGenerator.$(OBJEXT) 793 -rm -f ControlStruct/driver_cfa_cpp-LabelTypeChecker.$(OBJEXT)794 788 -rm -f ControlStruct/driver_cfa_cpp-MLEMutator.$(OBJEXT) 795 789 -rm -f ControlStruct/driver_cfa_cpp-Mutate.$(OBJEXT) … … 896 890 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelFixer.Po@am__quote@ 897 891 @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@899 892 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-MLEMutator.Po@am__quote@ 900 893 @AMDEP_TRUE@@am__include@ @am__quote@ControlStruct/$(DEPDIR)/driver_cfa_cpp-Mutate.Po@am__quote@ … … 1211 1204 @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` 1212 1205 1213 ControlStruct/driver_cfa_cpp-LabelTypeChecker.o: ControlStruct/LabelTypeChecker.cc1214 @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.cc1215 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Tpo ControlStruct/$(DEPDIR)/driver_cfa_cpp-LabelTypeChecker.Po1216 @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.cc1219 1220 ControlStruct/driver_cfa_cpp-LabelTypeChecker.obj: ControlStruct/LabelTypeChecker.cc1221 @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.Po1223 @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 1227 1206 GenPoly/driver_cfa_cpp-Box.o: GenPoly/Box.cc 1228 1207 @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
rfd782b2 raa8f9df 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 printAll( expr->get_results(), os, indent + 4 ); 57 os << ")" << std::endl; 56 os << std::string( indent+4, ' ' ); 57 expr->get_result()->print( os, indent + 4 ); 58 os << std::endl << ")" << std::endl; 58 59 } else { 59 60 os << "Null expression!" << std::endl; -
src/ResolvExpr/AlternativeFinder.cc
rfd782b2 raa8f9df 100 100 PruneStruct current( candidate ); 101 101 std::string mangleName; 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();102 { 103 Type * newType = candidate->expr->get_result()->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 for ( std::list< Type* >::iterator result = alt.expr->get_results().begin(); result != alt.expr->get_results().end(); ++result ) { 135 alt.env.applyFree( *result ); 136 } 134 alt.env.applyFree( alt.expr->get_result() ); 137 135 *out++ = alt; 138 136 } 139 137 } 140 141 138 } 142 139 … … 149 146 150 147 void renameTypes( Expression *expr ) { 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 } 148 expr->get_result()->accept( global_renamer ); 166 149 } 167 150 } … … 195 178 for ( AltList::iterator i = alternatives.begin(); i != alternatives.end(); ++i ) { 196 179 if ( adjust ) { 197 adjustExprType List( i->expr->get_results().begin(), i->expr->get_results().end(), i->env, indexer );180 adjustExprType( i->expr->get_result(), i->env, indexer ); 198 181 } 199 182 } … … 265 248 Cost computeConversionCost( Alternative &alt, const SymTab::Indexer &indexer ) { 266 249 ApplicationExpr *appExpr = safe_dynamic_cast< ApplicationExpr* >( alt.expr ); 267 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result s().front() );250 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() ); 268 251 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() ); 269 252 … … 282 265 (*actualExpr)->print( std::cerr, 8 ); 283 266 std::cerr << "--- results are" << std::endl; 284 printAll( (*actualExpr)->get_results(),std::cerr, 8 );267 (*actualExpr)->get_result()->print( std::cerr, 8 ); 285 268 ) 286 269 std::list< DeclarationWithType* >::iterator startFormal = formal; 287 270 Cost actualCost; 288 for ( std::list< Type* >::iterator actualType = (*actualExpr)->get_results().begin(); actualType != (*actualExpr)->get_results().end(); ++actualType ) { 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 289 275 290 276 // tuple handling code … … 399 385 400 386 for ( AltList::const_iterator actualExpr = actuals.begin(); actualExpr != actuals.end(); ++actualExpr ) { 401 std::list< Type* > & actualTypes = actualExpr->expr->get_results(); 402 for ( std::list< Type* >::iterator actualType = actualTypes.begin(); actualType != actualTypes.end(); ++actualType ) { 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 ) { 403 390 if ( formalType == formalTypes.end() ) { 404 391 // the type of the formal parameter may be a tuple type. To make this easier to work with, … … 416 403 PRINT( 417 404 std::cerr << "formal type is "; 418 (*formal )->get_type()->print( std::cerr );405 (*formalType)->print( std::cerr ); 419 406 std::cerr << std::endl << "actual type is "; 420 407 (*actualType)->print( std::cerr ); … … 424 411 return false; 425 412 } 426 ++formalType;427 413 } 428 414 } … … 532 518 //if ( newNeedParents[ curDecl->get_uniqueId() ][ candDecl->get_uniqueId() ]++ > recursionParentLimit ) continue; 533 519 Expression *varExpr = new VariableExpr( candDecl ); 534 deleteAll( varExpr->get_results() ); 535 varExpr->get_results().clear(); 536 varExpr->get_results().push_front( adjType->clone() ); 520 delete varExpr->get_result(); 521 varExpr->set_result( adjType->clone() ); 537 522 PRINT( 538 523 std::cerr << "satisfying assertion " << curDecl->get_uniqueId() << " "; … … 606 591 PointerType pt( Type::Qualifiers(), v.clone() ); 607 592 UntypedExpr *vexpr = untypedExpr->clone(); 608 vexpr-> get_results().push_front( pt.clone() );593 vexpr->set_result( pt.clone() ); 609 594 alternatives.push_back( Alternative( vexpr, env, Cost()) ); 610 595 return; … … 634 619 // check if the type is pointer to function 635 620 PointerType *pointer; 636 if ( func->expr->get_results().size() == 1 && ( pointer = dynamic_cast< PointerType* >( func->expr->get_results().front() ) ) ) {621 if ( ( pointer = dynamic_cast< PointerType* >( func->expr->get_result() ) ) ) { 637 622 if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) { 638 623 for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) { … … 670 655 // check if the type is pointer to function 671 656 PointerType *pointer; 672 if ( funcOp->expr->get_results().size() == 1 673 && ( pointer = dynamic_cast< PointerType* >( funcOp->expr->get_results().front() ) ) ) { 657 if ( ( pointer = dynamic_cast< PointerType* >( funcOp->expr->get_result() ) ) ) { 674 658 if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) { 675 659 for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) { … … 696 680 PRINT( 697 681 ApplicationExpr *appExpr = safe_dynamic_cast< ApplicationExpr* >( withFunc->expr ); 698 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result s().front() );682 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() ); 699 683 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() ); 700 684 std::cerr << "Case +++++++++++++" << std::endl; … … 719 703 720 704 bool isLvalue( Expression *expr ) { 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; 705 // xxx - recurse into tuples? 706 return expr->has_result() && expr->get_result()->get_isLvalue(); 725 707 } 726 708 … … 736 718 737 719 void AlternativeFinder::visit( CastExpr *castExpr ) { 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 720 Type *& toType = castExpr->get_result(); 721 toType = resolveTypeof( toType, indexer ); 722 SymTab::validateType( toType, &indexer ); 723 adjustExprType( toType, env, indexer ); 743 724 744 725 AlternativeFinder finder( indexer, env ); … … 754 735 // that are cast directly. The candidate is invalid if it has fewer results than there are types to cast 755 736 // to. 756 int discardedValues = (*i).expr->get_result s().size() - castExpr->get_results().size();737 int discardedValues = (*i).expr->get_result()->size() - castExpr->get_result()->size(); 757 738 if ( discardedValues < 0 ) continue; 758 std::list< Type* >::iterator candidate_end = (*i).expr->get_results().begin(); 759 std::advance( candidate_end, castExpr->get_results().size() ); 739 // xxx - may need to go into tuple types and extract relavent types and use unifyList 760 740 // unification run for side-effects 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 ); 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 ); 767 743 if ( thisCost != Cost::infinity ) { 768 744 // count one safe conversion for each value that is thrown away … … 787 763 788 764 for ( AltList::const_iterator agg = funcFinder.alternatives.begin(); agg != funcFinder.alternatives.end(); ++agg ) { 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 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() ); 795 769 } // if 796 770 } // for … … 923 897 alternatives.push_back( Alternative( new AttrExpr( new VariableExpr( funcDecl ), argType->clone() ), env, Cost::zero ) ); 924 898 for ( std::list< DeclarationWithType* >::iterator i = function->get_returnVals().begin(); i != function->get_returnVals().end(); ++i ) { 925 alternatives.back().expr-> get_results().push_back( (*i)->get_type()->clone() );899 alternatives.back().expr->set_result( (*i)->get_type()->clone() ); 926 900 } // for 927 901 } // if … … 946 920 finder.find( attrExpr->get_expr() ); 947 921 for ( AltList::iterator choice = finder.alternatives.begin(); choice != finder.alternatives.end(); ++choice ) { 948 if ( choice->expr->get_result s().size() == 1 ) {949 resolveAttr(*i, function, choice->expr->get_result s().front(), choice->env );922 if ( choice->expr->get_result()->size() == 1 ) { 923 resolveAttr(*i, function, choice->expr->get_result(), choice->env ); 950 924 } // fi 951 925 } // for … … 989 963 AssertionSet needAssertions, haveAssertions; 990 964 Alternative newAlt( 0, third->env, first->cost + second->cost + third->cost ); 991 std::list< Type* > commonTypes;992 if ( unify List( 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) ) {965 Type* commonType; 966 if ( unify( second->expr->get_result(), third->expr->get_result(), newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) { 993 967 ConditionalExpr *newExpr = new ConditionalExpr( first->expr->clone(), second->expr->clone(), third->expr->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 968 newExpr->set_result( commonType ? commonType : second->expr->get_result()->clone() ); 1003 969 newAlt.expr = newExpr; 1004 970 inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( alternatives ) ); … … 1028 994 TupleExpr *newExpr = new TupleExpr; 1029 995 makeExprList( *i, newExpr->get_exprs() ); 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 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(); 1034 1002 } // for 1003 newExpr->set_result( tupleType ); 1035 1004 1036 1005 TypeEnvironment compositeEnv; … … 1057 1026 alternatives.push_back( Alternative( tupleExpr->clone(), env, Cost::zero ) ); 1058 1027 } 1028 1029 void AlternativeFinder::visit( TupleAssignExpr *tupleAssignExpr ) { 1030 alternatives.push_back( Alternative( tupleAssignExpr->clone(), env, Cost::zero ) ); 1031 } 1059 1032 } // namespace ResolvExpr 1060 1033 -
src/ResolvExpr/AlternativeFinder.h
rfd782b2 raa8f9df 68 68 virtual void visit( ConstructorExpr * ctorExpr ); 69 69 virtual void visit( TupleIndexExpr *tupleExpr ); 70 virtual void visit( TupleAssignExpr *tupleExpr ); 70 71 /// Runs a new alternative finder on each element in [begin, end) 71 72 /// and writes each alternative finder to out. -
src/ResolvExpr/AlternativePrinter.cc
rfd782b2 raa8f9df 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 printAll( i->expr->get_results(),os );35 i->expr->get_result()->print( os ); 36 36 // i->print( os ); 37 37 os << std::endl; -
src/ResolvExpr/ResolveTypeof.cc
rfd782b2 raa8f9df 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->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 60 assert( newExpr->has_result() && ! newExpr->get_result()->isVoid() ); 61 Type *newType = newExpr->get_result(); 69 62 delete typeofType; 70 63 return newType; -
src/ResolvExpr/Resolver.cc
rfd782b2 raa8f9df 19 19 #include "RenameVars.h" 20 20 #include "ResolveTypeof.h" 21 #include "typeops.h" 21 22 #include "SynTree/Statement.h" 22 23 #include "SynTree/Type.h" … … 67 68 void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator & ); 68 69 void fallbackInit( ConstructorInit * ctorInit ); 69 std::list< Type * >functionReturn;70 Type * functionReturn; 70 71 Type *initContext; 71 72 Type *switchType; … … 155 156 const TypeEnvironment *newEnv = 0; 156 157 for ( AltList::const_iterator i = finder.get_alternatives().begin(); i != finder.get_alternatives().end(); ++i ) { 157 if ( i->expr->get_result s().size() == 1 && isIntegralType( i->expr->get_results().front() ) ) {158 if ( i->expr->get_result()->size() == 1 && isIntegralType( i->expr->get_result() ) ) { 158 159 if ( newExpr ) { 159 160 throw SemanticError( "Too many interpretations for case control expression", untyped ); … … 232 233 Type *new_type = resolveTypeof( functionDecl->get_type(), *this ); 233 234 functionDecl->set_type( new_type ); 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 235 ValueGuard< Type * > oldFunctionReturn( functionReturn ); 236 functionReturn = ResolvExpr::extractResultType( functionDecl->get_functionType() ); 239 237 SymTab::Indexer::visit( functionDecl ); 240 functionReturn = oldFunctionReturn;241 238 } 242 239 … … 336 333 void Resolver::visit( ReturnStmt *returnStmt ) { 337 334 if ( returnStmt->get_expr() ) { 338 CastExpr *castExpr = new CastExpr( returnStmt->get_expr() ); 339 cloneAll( functionReturn, castExpr->get_results() ); 335 CastExpr *castExpr = new CastExpr( returnStmt->get_expr(), functionReturn->clone() ); 340 336 Expression *newExpr = findSingleExpression( castExpr, *this ); 341 337 delete castExpr; … … 382 378 if ( isCharType( at->get_base() ) ) { 383 379 // check if the resolved type is char * 384 if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result s().front() ) ) {380 if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result() ) ) { 385 381 if ( isCharType( pt->get_base() ) ) { 386 382 // strip cast if we're initializing a char[] with a char *, e.g. char x[] = "hello"; -
src/ResolvExpr/Unify.cc
rfd782b2 raa8f9df 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 } // for 601 return tupleType; 602 } 603 } 604 590 605 } // namespace ResolvExpr 591 606 -
src/ResolvExpr/typeops.h
rfd782b2 raa8f9df 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 146 149 // in CommonType.cc 147 150 Type *commonType( Type *type1, Type *type2, bool widenFirst, bool widenSecond, const SymTab::Indexer &indexer, TypeEnvironment &env, const OpenVarSet &openVars ); … … 152 155 // in Occurs.cc 153 156 bool occurs( Type *type, std::string varName, const TypeEnvironment &env ); 157 158 // flatten tuple type into list of types 159 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 } 154 169 } // namespace ResolvExpr 155 170 -
src/SymTab/Autogen.cc
rfd782b2 raa8f9df 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_results().front();118 Type * assignVarExprType = assignVarExpr->get_result(); 119 119 assignVarExprType = new PointerType( Type::Qualifiers(), assignVarExprType ); 120 assignVarExpr->set_result( assignVarExprType ); 120 121 ApplicationExpr * assignExpr = new ApplicationExpr( assignVarExpr ); 121 122 assignExpr->get_args().push_back( new VariableExpr( dstParam ) ); -
src/SymTab/Indexer.cc
rfd782b2 raa8f9df 40 40 41 41 namespace SymTab { 42 template< typename Container, typename VisitorType >43 inline void accept AllNewScope( Container &container, VisitorType &visitor ) {42 template< typename TreeType, typename VisitorType > 43 inline void acceptNewScope( TreeType *tree, VisitorType &visitor ) { 44 44 visitor.enterScope(); 45 acceptAll( container, visitor );45 maybeAccept( tree, visitor ); 46 46 visitor.leaveScope(); 47 47 } … … 337 337 338 338 void Indexer::visit( ApplicationExpr *applicationExpr ) { 339 accept AllNewScope( applicationExpr->get_results(), *this );339 acceptNewScope( applicationExpr->get_result(), *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 AllNewScope( untypedExpr->get_results(), *this );345 acceptNewScope( untypedExpr->get_result(), *this ); 346 346 acceptAll( untypedExpr->get_args(), *this ); 347 347 } 348 348 349 349 void Indexer::visit( NameExpr *nameExpr ) { 350 accept AllNewScope( nameExpr->get_results(), *this );350 acceptNewScope( nameExpr->get_result(), *this ); 351 351 } 352 352 353 353 void Indexer::visit( AddressExpr *addressExpr ) { 354 accept AllNewScope( addressExpr->get_results(), *this );354 acceptNewScope( addressExpr->get_result(), *this ); 355 355 maybeAccept( addressExpr->get_arg(), *this ); 356 356 } 357 357 358 358 void Indexer::visit( LabelAddressExpr *labAddressExpr ) { 359 accept AllNewScope( labAddressExpr->get_results(), *this );359 acceptNewScope( labAddressExpr->get_result(), *this ); 360 360 maybeAccept( labAddressExpr->get_arg(), *this ); 361 361 } 362 362 363 363 void Indexer::visit( CastExpr *castExpr ) { 364 accept AllNewScope( castExpr->get_results(), *this );364 acceptNewScope( castExpr->get_result(), *this ); 365 365 maybeAccept( castExpr->get_arg(), *this ); 366 366 } 367 367 368 368 void Indexer::visit( UntypedMemberExpr *memberExpr ) { 369 accept AllNewScope( memberExpr->get_results(), *this );369 acceptNewScope( memberExpr->get_result(), *this ); 370 370 maybeAccept( memberExpr->get_aggregate(), *this ); 371 371 } 372 372 373 373 void Indexer::visit( MemberExpr *memberExpr ) { 374 accept AllNewScope( memberExpr->get_results(), *this );374 acceptNewScope( memberExpr->get_result(), *this ); 375 375 maybeAccept( memberExpr->get_aggregate(), *this ); 376 376 } 377 377 378 378 void Indexer::visit( VariableExpr *variableExpr ) { 379 accept AllNewScope( variableExpr->get_results(), *this );379 acceptNewScope( variableExpr->get_result(), *this ); 380 380 } 381 381 382 382 void Indexer::visit( ConstantExpr *constantExpr ) { 383 accept AllNewScope( constantExpr->get_results(), *this );383 acceptNewScope( constantExpr->get_result(), *this ); 384 384 maybeAccept( constantExpr->get_constant(), *this ); 385 385 } 386 386 387 387 void Indexer::visit( SizeofExpr *sizeofExpr ) { 388 accept AllNewScope( sizeofExpr->get_results(), *this );388 acceptNewScope( sizeofExpr->get_result(), *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 AllNewScope( alignofExpr->get_results(), *this );397 acceptNewScope( alignofExpr->get_result(), *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 AllNewScope( offsetofExpr->get_results(), *this );406 acceptNewScope( offsetofExpr->get_result(), *this ); 407 407 maybeAccept( offsetofExpr->get_type(), *this ); 408 408 } 409 409 410 410 void Indexer::visit( OffsetofExpr *offsetofExpr ) { 411 accept AllNewScope( offsetofExpr->get_results(), *this );411 acceptNewScope( offsetofExpr->get_result(), *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 AllNewScope( offsetPackExpr->get_results(), *this );417 acceptNewScope( offsetPackExpr->get_result(), *this ); 418 418 maybeAccept( offsetPackExpr->get_type(), *this ); 419 419 } 420 420 421 421 void Indexer::visit( AttrExpr *attrExpr ) { 422 accept AllNewScope( attrExpr->get_results(), *this );422 acceptNewScope( attrExpr->get_result(), *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 AllNewScope( logicalExpr->get_results(), *this );431 acceptNewScope( logicalExpr->get_result(), *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 AllNewScope( conditionalExpr->get_results(), *this );437 acceptNewScope( conditionalExpr->get_result(), *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 AllNewScope( commaExpr->get_results(), *this );444 acceptNewScope( commaExpr->get_result(), *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 AllNewScope( tupleExpr->get_results(), *this );450 acceptNewScope( tupleExpr->get_result(), *this ); 451 451 acceptAll( tupleExpr->get_exprs(), *this ); 452 452 } 453 453 454 454 void Indexer::visit( TupleAssignExpr *tupleExpr ) { 455 accept AllNewScope( tupleExpr->get_results(), *this );455 acceptNewScope( tupleExpr->get_result(), *this ); 456 456 enterScope(); 457 457 acceptAll( tupleExpr->get_tempDecls(), *this ); … … 461 461 462 462 void Indexer::visit( TypeExpr *typeExpr ) { 463 accept AllNewScope( typeExpr->get_results(), *this );463 acceptNewScope( typeExpr->get_result(), *this ); 464 464 maybeAccept( typeExpr->get_type(), *this ); 465 465 } … … 472 472 473 473 void Indexer::visit( UntypedValofExpr *valofExpr ) { 474 accept AllNewScope( valofExpr->get_results(), *this );474 acceptNewScope( valofExpr->get_result(), *this ); 475 475 maybeAccept( valofExpr->get_body(), *this ); 476 476 } -
src/SynTree/AddressExpr.cc
rfd782b2 raa8f9df 19 19 20 20 AddressExpr::AddressExpr( Expression *arg, Expression *_aname ) : Expression( _aname ), arg( arg ) { 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 } // for21 if ( arg->has_result() ) { 22 set_result( new PointerType( Type::Qualifiers(), arg->get_result()->clone() ) ); 23 } 24 24 } 25 25 … … 35 35 if ( arg ) { 36 36 os << std::string( indent+2, ' ' ); 37 37 arg->print( os, indent+2 ); 38 38 } // if 39 39 } -
src/SynTree/ApplicationExpr.cc
rfd782b2 raa8f9df 21 21 #include "TypeSubstitution.h" 22 22 #include "Common/utility.h" 23 23 #include "ResolvExpr/typeops.h" 24 24 25 25 ParamEntry::ParamEntry( const ParamEntry &other ) : … … 43 43 44 44 ApplicationExpr::ApplicationExpr( Expression *funcExpr ) : function( funcExpr ) { 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 ); 45 PointerType *pointer = safe_dynamic_cast< PointerType* >( funcExpr->get_result() ); 46 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() ); 49 47 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 } // for48 set_result( ResolvExpr::extractResultType( function ) ); 49 50 assert( has_result() ); 53 51 } 54 52 -
src/SynTree/CommaExpr.cc
rfd782b2 raa8f9df 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 cloneAll( arg2->get_results(), get_results() ); 26 // for ( Type *& type : get_results() ) { 27 // type->set_isLvalue( false ); 28 // } 25 set_result( maybeClone( arg2->get_result() ) ); 26 // get_type->set_isLvalue( false ); 29 27 } 30 28 -
src/SynTree/Expression.cc
rfd782b2 raa8f9df 31 31 32 32 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 ); 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 ) { 37 36 } 38 37 … … 40 39 delete env; 41 40 delete argName; // xxx -- there's a problem in cloning ConstantExpr I still don't know how to fix 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 41 delete result; 51 42 } 52 43 … … 68 59 69 60 ConstantExpr::ConstantExpr( Constant _c, Expression *_aname ) : Expression( _aname ), constant( _c ) { 70 add_result( constant.get_type()->clone() );61 set_result( constant.get_type()->clone() ); 71 62 } 72 63 … … 85 76 assert( var ); 86 77 assert( var->get_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 78 Type * type = var->get_type()->clone(); 79 type->set_isLvalue( true ); 80 set_result( type ); 91 81 } 92 82 … … 110 100 SizeofExpr::SizeofExpr( Expression *expr_, Expression *_aname ) : 111 101 Expression( _aname ), expr(expr_), type(0), isType(false) { 112 add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );102 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 113 103 } 114 104 115 105 SizeofExpr::SizeofExpr( Type *type_, Expression *_aname ) : 116 106 Expression( _aname ), expr(0), type(type_), isType(true) { 117 add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );107 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 118 108 } 119 109 … … 141 131 AlignofExpr::AlignofExpr( Expression *expr_, Expression *_aname ) : 142 132 Expression( _aname ), expr(expr_), type(0), isType(false) { 143 add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );133 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 144 134 } 145 135 146 136 AlignofExpr::AlignofExpr( Type *type_, Expression *_aname ) : 147 137 Expression( _aname ), expr(0), type(type_), isType(true) { 148 add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );138 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 149 139 } 150 140 … … 172 162 UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type_, const std::string &member_, Expression *_aname ) : 173 163 Expression( _aname ), type(type_), member(member_) { 174 add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );164 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 175 165 } 176 166 … … 197 187 OffsetofExpr::OffsetofExpr( Type *type_, DeclarationWithType *member_, Expression *_aname ) : 198 188 Expression( _aname ), type(type_), member(member_) { 199 add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );189 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 200 190 } 201 191 … … 229 219 230 220 OffsetPackExpr::OffsetPackExpr( StructInstType *type_, Expression *aname_ ) : Expression( aname_ ), type( type_ ) { 231 add_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );221 set_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) ); 232 222 } 233 223 … … 284 274 285 275 CastExpr::CastExpr( Expression *arg_, Type *toType, Expression *_aname ) : Expression( _aname ), arg(arg_) { 286 add_result(toType);276 set_result(toType); 287 277 } 288 278 289 279 CastExpr::CastExpr( Expression *arg_, Expression *_aname ) : Expression( _aname ), arg(arg_) { 280 set_result( new VoidType( Type::Qualifiers() ) ); 290 281 } 291 282 … … 303 294 arg->print(os, indent+2); 304 295 os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl; 305 if ( results.empty() ) { 306 os << std::string( indent+2, ' ' ) << "nothing" << std::endl; 296 os << std::string( indent+2, ' ' ); 297 if ( result->isVoid() ) { 298 os << "nothing"; 307 299 } else { 308 printAll(results, os, indent+2);300 result->print( os, indent+2 ); 309 301 } // if 302 os << std::endl; 310 303 Expression::print( os, indent ); 311 304 } … … 341 334 MemberExpr::MemberExpr( DeclarationWithType *_member, Expression *_aggregate, Expression *_aname ) : 342 335 Expression( _aname ), member(_member), aggregate(_aggregate) { 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 336 set_result( member->get_type()->clone() ); 337 get_result()->set_isLvalue( true ); 347 338 } 348 339 … … 419 410 LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp, Expression *_aname ) : 420 411 Expression( _aname ), arg1(arg1_), arg2(arg2_), isAnd(andp) { 421 add_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );412 set_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ); 422 413 } 423 414 … … 477 468 ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( ApplicationExpr * callExpr ) : callExpr( callExpr ) { 478 469 assert( callExpr ); 479 cloneAll( callExpr->get_results(), results ); 470 assert( callExpr->has_result() ); 471 set_result( callExpr->get_result()->clone() ); 480 472 } 481 473 … … 510 502 Expression * arg = InitTweak::getCallArg( callExpr, 0 ); 511 503 assert( arg ); 512 cloneAll( arg->get_results(), results);504 set_result( maybeClone( arg->get_result() ) ); 513 505 } 514 506 … … 530 522 531 523 CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) { 532 add_result( type->clone() );524 set_result( type->clone() ); 533 525 } 534 526 … … 570 562 if ( ! body.empty() ) { 571 563 if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( body.back() ) ) { 572 cloneAll( exprStmt->get_expr()->get_results(), get_results() );564 set_result( maybeClone( exprStmt->get_expr()->get_result() ) ); 573 565 } 574 566 } -
src/SynTree/Expression.h
rfd782b2 raa8f9df 32 32 virtual ~Expression(); 33 33 34 std::list<Type *>& get_results() { return results; } 35 void add_result( Type *t ); 34 Type *& get_result() { return result; } 35 void set_result( Type *newValue ) { result = newValue; } 36 bool has_result() const { return result != nullptr; } 36 37 37 38 TypeSubstitution *get_env() const { return env; } … … 47 48 virtual void print( std::ostream &os, int indent = 0 ) const; 48 49 protected: 49 std::list<Type *> results;50 Type * result; 50 51 TypeSubstitution *env; 51 52 Expression* argName; // if expression is used as an argument, it can be "designated" by this name -
src/SynTree/Mutator.cc
rfd782b2 raa8f9df 178 178 179 179 Expression *Mutator::mutate( ApplicationExpr *applicationExpr ) { 180 mutateAll( applicationExpr->get_results(), *this);180 applicationExpr->set_result( maybeMutate( applicationExpr->get_result(), *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 mutateAll( untypedExpr->get_results(), *this);187 untypedExpr->set_result( maybeMutate( untypedExpr->get_result(), *this ) ); 188 188 mutateAll( untypedExpr->get_args(), *this ); 189 189 return untypedExpr; … … 191 191 192 192 Expression *Mutator::mutate( NameExpr *nameExpr ) { 193 mutateAll( nameExpr->get_results(), *this);193 nameExpr->set_result( maybeMutate( nameExpr->get_result(), *this ) ); 194 194 return nameExpr; 195 195 } 196 196 197 197 Expression *Mutator::mutate( AddressExpr *addressExpr ) { 198 mutateAll( addressExpr->get_results(), *this);198 addressExpr->set_result( maybeMutate( addressExpr->get_result(), *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 mutateAll( labelAddressExpr->get_results(), *this);204 labelAddressExpr->set_result( maybeMutate( labelAddressExpr->get_result(), *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 mutateAll( castExpr->get_results(), *this);210 castExpr->set_result( maybeMutate( castExpr->get_result(), *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 utateAll( memberExpr->get_results(), *this);216 memberExpr->set_result( maybeMutate( memberExpr->get_result(), *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 utateAll( memberExpr->get_results(), *this);223 memberExpr->set_result( maybeMutate( memberExpr->get_result(), *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 mutateAll( variableExpr->get_results(), *this);229 variableExpr->set_result( maybeMutate( variableExpr->get_result(), *this ) ); 230 230 return variableExpr; 231 231 } 232 232 233 233 Expression *Mutator::mutate( ConstantExpr *constantExpr ) { 234 mutateAll( constantExpr->get_results(), *this);234 constantExpr->set_result( maybeMutate( constantExpr->get_result(), *this ) ); 235 235 // maybeMutate( constantExpr->get_constant(), *this ) 236 236 return constantExpr; … … 238 238 239 239 Expression *Mutator::mutate( SizeofExpr *sizeofExpr ) { 240 mutateAll( sizeofExpr->get_results(), *this);240 sizeofExpr->set_result( maybeMutate( sizeofExpr->get_result(), *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 mutateAll( alignofExpr->get_results(), *this);250 alignofExpr->set_result( maybeMutate( alignofExpr->get_result(), *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 mutateAll( offsetofExpr->get_results(), *this);260 offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *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 mutateAll( offsetofExpr->get_results(), *this);266 offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *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 mutateAll( offsetPackExpr->get_results(), *this);273 offsetPackExpr->set_result( maybeMutate( offsetPackExpr->get_result(), *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 mutateAll( attrExpr->get_results(), *this);279 attrExpr->set_result( maybeMutate( attrExpr->get_result(), *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 mutateAll( logicalExpr->get_results(), *this);289 logicalExpr->set_result( maybeMutate( logicalExpr->get_result(), *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 mutateAll( conditionalExpr->get_results(), *this);296 conditionalExpr->set_result( maybeMutate( conditionalExpr->get_result(), *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 mutateAll( commaExpr->get_results(), *this);304 commaExpr->set_result( maybeMutate( commaExpr->get_result(), *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 mutateAll( typeExpr->get_results(), *this);311 typeExpr->set_result( maybeMutate( typeExpr->get_result(), *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 mutateAll( ctorExpr->get_results(), *this);331 ctorExpr->set_result( maybeMutate( ctorExpr->get_result(), *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 mutateAll( compLitExpr->get_results(), *this);337 compLitExpr->set_result( maybeMutate( compLitExpr->get_result(), *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 mutateAll( valofExpr->get_results(), *this);344 valofExpr->set_result( maybeMutate( valofExpr->get_result(), *this ) ); 345 345 return valofExpr; 346 346 } … … 353 353 354 354 Expression *Mutator::mutate( TupleExpr *tupleExpr ) { 355 mutateAll( tupleExpr->get_results(), *this);355 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) ); 356 356 mutateAll( tupleExpr->get_exprs(), *this ); 357 357 return tupleExpr; … … 359 359 360 360 Expression *Mutator::mutate( TupleIndexExpr *tupleExpr ) { 361 mutateAll( tupleExpr->get_results(), *this);361 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *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 mutateAll( tupleExpr->get_results(), *this);367 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *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 mutateAll( assignExpr->get_results(), *this);374 assignExpr->set_result( maybeMutate( assignExpr->get_result(), *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 mutateAll( stmtExpr->get_results(), *this);381 stmtExpr->set_result( maybeMutate( stmtExpr->get_result(), *this ) ); 382 382 stmtExpr->set_statements( maybeMutate( stmtExpr->get_statements(), *this ) ); 383 383 return stmtExpr; -
src/SynTree/TupleExpr.cc
rfd782b2 raa8f9df 31 31 32 32 void TupleExpr::print( std::ostream &os, int indent ) const { 33 os << std::string( indent, ' ' ) <<"Tuple:" << std::endl;33 os << "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< TypeType * >( tuple->get_ )40 assert( t uple->get_results().size() >= index );41 add_result( *std::next( tuple->get_results().begin(), index ) );39 TupleType * type = safe_dynamic_cast< TupleType * >( tuple->get_result() ); 40 assert( type->size() >= index ); 41 set_result( *std::next( type->get_types().begin(), index ) ); 42 42 } 43 43 … … 50 50 51 51 void TupleIndexExpr::print( std::ostream &os, int indent ) const { 52 os << std::string( indent, ' ' ) <<"Tuple Index Expression, with tuple:" << std::endl;52 os << "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 cloneAll( member->get_results(), get_results() ); // xxx - ???59 set_result( maybeClone( member->get_result() ) ); // xxx - ??? 60 60 } 61 61 … … 69 69 70 70 void MemberTupleExpr::print( std::ostream &os, int indent ) const { 71 os << std::string( indent, ' ' ) <<"Member Tuple Expression, with aggregate:" << std::endl;71 os << "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() ); 80 81 for ( Expression * expr : assigns ) { 81 cloneAll( expr->get_results(), get_results() ); 82 assert( expr->has_result() ); 83 type->get_types().push_back( expr->get_result()->clone() ); 82 84 } 85 set_result( type ); 83 86 } 84 87 -
src/SynTree/Type.h
rfd782b2 raa8f9df 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 ); 29 30 Qualifiers &operator+=( const Qualifiers &other ); 30 31 Qualifiers &operator-=( const Qualifiers &other ); … … 65 66 std::list<TypeDecl*>& get_forall() { return forall; } 66 67 68 /// How many elemental types are represented by this type 69 virtual unsigned size() const { return 1; }; 70 virtual bool isVoid() const { return size() == 0; } 71 67 72 virtual Type *clone() const = 0; 68 73 virtual void accept( Visitor &v ) = 0; … … 77 82 public: 78 83 VoidType( const Type::Qualifiers &tq ); 84 85 virtual unsigned size() const { return 0; }; 79 86 80 87 virtual VoidType *clone() const { return new VoidType( *this ); } … … 357 364 358 365 std::list<Type*>& get_types() { return types; } 366 virtual unsigned size() const { return types.size(); }; 359 367 360 368 iterator begin() { return types.begin(); } … … 425 433 }; 426 434 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 427 444 inline Type::Qualifiers &Type::Qualifiers::operator+=( const Type::Qualifiers &other ) { 428 445 isConst |= other.isConst; -
src/SynTree/Visitor.cc
rfd782b2 raa8f9df 150 150 151 151 void Visitor::visit( ApplicationExpr *applicationExpr ) { 152 acceptAll( applicationExpr->get_results(), *this );152 maybeAccept( applicationExpr->get_result(), *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 acceptAll( untypedExpr->get_results(), *this );158 maybeAccept( untypedExpr->get_result(), *this ); 159 159 acceptAll( untypedExpr->get_args(), *this ); 160 160 } 161 161 162 162 void Visitor::visit( NameExpr *nameExpr ) { 163 acceptAll( nameExpr->get_results(), *this );163 maybeAccept( nameExpr->get_result(), *this ); 164 164 } 165 165 166 166 void Visitor::visit( AddressExpr *addressExpr ) { 167 acceptAll( addressExpr->get_results(), *this );167 maybeAccept( addressExpr->get_result(), *this ); 168 168 maybeAccept( addressExpr->get_arg(), *this ); 169 169 } 170 170 171 171 void Visitor::visit( LabelAddressExpr *labAddressExpr ) { 172 acceptAll( labAddressExpr->get_results(), *this );172 maybeAccept( labAddressExpr->get_result(), *this ); 173 173 maybeAccept( labAddressExpr->get_arg(), *this ); 174 174 } 175 175 176 176 void Visitor::visit( CastExpr *castExpr ) { 177 acceptAll( castExpr->get_results(), *this );177 maybeAccept( castExpr->get_result(), *this ); 178 178 maybeAccept( castExpr->get_arg(), *this ); 179 179 } 180 180 181 181 void Visitor::visit( UntypedMemberExpr *memberExpr ) { 182 acceptAll( memberExpr->get_results(), *this );182 maybeAccept( memberExpr->get_result(), *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 acceptAll( memberExpr->get_results(), *this );188 maybeAccept( memberExpr->get_result(), *this ); 189 189 maybeAccept( memberExpr->get_aggregate(), *this ); 190 190 } 191 191 192 192 void Visitor::visit( VariableExpr *variableExpr ) { 193 acceptAll( variableExpr->get_results(), *this );193 maybeAccept( variableExpr->get_result(), *this ); 194 194 } 195 195 196 196 void Visitor::visit( ConstantExpr *constantExpr ) { 197 acceptAll( constantExpr->get_results(), *this );197 maybeAccept( constantExpr->get_result(), *this ); 198 198 maybeAccept( constantExpr->get_constant(), *this ); 199 199 } 200 200 201 201 void Visitor::visit( SizeofExpr *sizeofExpr ) { 202 acceptAll( sizeofExpr->get_results(), *this );202 maybeAccept( sizeofExpr->get_result(), *this ); 203 203 if ( sizeofExpr->get_isType() ) { 204 204 maybeAccept( sizeofExpr->get_type(), *this ); … … 209 209 210 210 void Visitor::visit( AlignofExpr *alignofExpr ) { 211 acceptAll( alignofExpr->get_results(), *this );211 maybeAccept( alignofExpr->get_result(), *this ); 212 212 if ( alignofExpr->get_isType() ) { 213 213 maybeAccept( alignofExpr->get_type(), *this ); … … 218 218 219 219 void Visitor::visit( UntypedOffsetofExpr *offsetofExpr ) { 220 acceptAll( offsetofExpr->get_results(), *this );220 maybeAccept( offsetofExpr->get_result(), *this ); 221 221 maybeAccept( offsetofExpr->get_type(), *this ); 222 222 } 223 223 224 224 void Visitor::visit( OffsetofExpr *offsetofExpr ) { 225 acceptAll( offsetofExpr->get_results(), *this );225 maybeAccept( offsetofExpr->get_result(), *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 acceptAll( offsetPackExpr->get_results(), *this );231 maybeAccept( offsetPackExpr->get_result(), *this ); 232 232 maybeAccept( offsetPackExpr->get_type(), *this ); 233 233 } 234 234 235 235 void Visitor::visit( AttrExpr *attrExpr ) { 236 acceptAll( attrExpr->get_results(), *this );236 maybeAccept( attrExpr->get_result(), *this ); 237 237 if ( attrExpr->get_isType() ) { 238 238 maybeAccept( attrExpr->get_type(), *this ); … … 243 243 244 244 void Visitor::visit( LogicalExpr *logicalExpr ) { 245 acceptAll( logicalExpr->get_results(), *this );245 maybeAccept( logicalExpr->get_result(), *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 acceptAll( conditionalExpr->get_results(), *this );251 maybeAccept( conditionalExpr->get_result(), *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 acceptAll( commaExpr->get_results(), *this );258 maybeAccept( commaExpr->get_result(), *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 acceptAll( typeExpr->get_results(), *this );264 maybeAccept( typeExpr->get_result(), *this ); 265 265 maybeAccept( typeExpr->get_type(), *this ); 266 266 } … … 279 279 280 280 void Visitor::visit( ConstructorExpr * ctorExpr ) { 281 acceptAll( ctorExpr->get_results(), *this );281 maybeAccept( ctorExpr->get_result(), *this ); 282 282 maybeAccept( ctorExpr->get_callExpr(), *this ); 283 283 } 284 284 285 285 void Visitor::visit( CompoundLiteralExpr *compLitExpr ) { 286 acceptAll( compLitExpr->get_results(), *this );286 maybeAccept( compLitExpr->get_result(), *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 acceptAll( valofExpr->get_results(), *this );292 maybeAccept( valofExpr->get_result(), *this ); 293 293 maybeAccept( valofExpr->get_body(), *this ); 294 294 } … … 300 300 301 301 void Visitor::visit( TupleExpr *tupleExpr ) { 302 acceptAll( tupleExpr->get_results(), *this );302 maybeAccept( tupleExpr->get_result(), *this ); 303 303 acceptAll( tupleExpr->get_exprs(), *this ); 304 304 } 305 305 306 306 void Visitor::visit( TupleIndexExpr *tupleExpr ) { 307 acceptAll( tupleExpr->get_results(), *this );307 maybeAccept( tupleExpr->get_result(), *this ); 308 308 maybeAccept( tupleExpr->get_tuple(), *this ); 309 309 } 310 310 311 311 void Visitor::visit( MemberTupleExpr *tupleExpr ) { 312 acceptAll( tupleExpr->get_results(), *this );312 maybeAccept( tupleExpr->get_result(), *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 acceptAll( assignExpr->get_results(), *this );318 maybeAccept( assignExpr->get_result(), *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 acceptAll( stmtExpr->get_results(), *this );324 maybeAccept( stmtExpr->get_result(), *this ); 325 325 maybeAccept( stmtExpr->get_statements(), *this ); 326 326 } -
src/Tuples/TupleAssignment.cc
rfd782b2 raa8f9df 88 88 bool isTuple( Expression *expr ) { 89 89 if ( ! expr ) return false; 90 90 assert( expr->has_result() ); 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 s().size() > 1;92 return dynamic_cast<TupleExpr *>(expr) || expr->get_result()->size() > 1; 93 93 } 94 94 … … 102 102 103 103 bool isTupleExpr( Expression *expr ) { 104 return expr->get_results().size() > 1; 104 assert( expr->has_result() ); 105 return expr->get_result()->size() > 1; 105 106 } 106 107 … … 191 192 192 193 ObjectDecl * newObject( UniqueName & namer, Expression * expr ) { 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() ) ); 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() ) ); 203 196 } 204 197 -
src/Tuples/TupleExpansion.cc
rfd782b2 raa8f9df 85 85 addDeclaration( decl ); 86 86 } 87 Type::Qualifiers qualifiers = newType->get_qualifiers(); 87 88 delete newType; 88 return new StructInstType( newType->get_qualifiers(), typeMap[mangleName] );89 return new StructInstType( qualifiers, typeMap[mangleName] ); 89 90 } 90 91
Note: See TracChangeset
for help on using the changeset viewer.