Changeset 906e24d
- Timestamp:
- Sep 15, 2016, 10:17:16 AM (7 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:
- aa8f9df
- Parents:
- 96a10cd
- git-author:
- Rob Schluntz <rschlunt@…> (09/14/16 22:32:34)
- git-committer:
- Rob Schluntz <rschlunt@…> (09/15/16 10:17:16)
- Location:
- src
- Files:
-
- 2 deleted
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r96a10cd r906e24d 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
r96a10cd r906e24d 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
r96a10cd r906e24d 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
r96a10cd r906e24d 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
r96a10cd r906e24d 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
r96a10cd r906e24d 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
r96a10cd r906e24d 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
r96a10cd r906e24d 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
r96a10cd r906e24d 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
r96a10cd r906e24d 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
r96a10cd r906e24d 101 101 PruneStruct current( candidate ); 102 102 std::string mangleName; 103 for ( std::list< Type* >::const_iterator retType = candidate->expr->get_results().begin(); retType != candidate->expr->get_results().end(); ++retType ){104 Type * newType = (*retType)->clone();103 { 104 Type * newType = candidate->expr->get_result()->clone(); 105 105 candidate->env.apply( newType ); 106 mangleName += SymTab::Mangler::mangle( newType );106 mangleName = SymTab::Mangler::mangle( newType ); 107 107 delete newType; 108 108 } … … 133 133 if ( ! target->second.isAmbiguous ) { 134 134 Alternative &alt = *target->second.candidate; 135 for ( std::list< Type* >::iterator result = alt.expr->get_results().begin(); result != alt.expr->get_results().end(); ++result ) { 136 alt.env.applyFree( *result ); 137 } 135 alt.env.applyFree( alt.expr->get_result() ); 138 136 *out++ = alt; 139 137 } 140 138 } 141 142 139 } 143 140 … … 170 167 171 168 void renameTypes( Expression *expr ) { 172 for ( std::list< Type* >::iterator i = expr->get_results().begin(); i != expr->get_results().end(); ++i ) { 173 (*i)->accept( global_renamer ); 174 } 169 expr->get_result()->accept( global_renamer ); 175 170 } 176 171 } … … 204 199 for ( AltList::iterator i = alternatives.begin(); i != alternatives.end(); ++i ) { 205 200 if ( adjust ) { 206 adjustExprType List( i->expr->get_results().begin(), i->expr->get_results().end(), i->env, indexer );201 adjustExprType( i->expr->get_result(), i->env, indexer ); 207 202 } 208 203 } … … 259 254 260 255 Cost computeConversionCost( Alternative &alt, const SymTab::Indexer &indexer ) { 261 ApplicationExpr *appExpr = dynamic_cast< ApplicationExpr* >( alt.expr ); 262 assert( appExpr ); 263 PointerType *pointer = dynamic_cast< PointerType* >( appExpr->get_function()->get_results().front() ); 264 assert( pointer ); 265 FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ); 266 assert( function ); 256 ApplicationExpr *appExpr = safe_dynamic_cast< ApplicationExpr* >( alt.expr ); 257 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() ); 258 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() ); 267 259 268 260 Cost convCost( 0, 0, 0 ); … … 275 267 (*actualExpr)->print( std::cerr, 8 ); 276 268 std::cerr << "--- results are" << std::endl; 277 printAll( (*actualExpr)->get_results(),std::cerr, 8 );269 (*actualExpr)->get_result()->print( std::cerr, 8 ); 278 270 ) 279 271 std::list< DeclarationWithType* >::iterator startFormal = formal; 280 272 Cost actualCost; 281 for ( std::list< Type* >::iterator actual = (*actualExpr)->get_results().begin(); actual != (*actualExpr)->get_results().end(); ++actual ) { 273 // xxx - tuple type matching 274 std::list< Type * > flatActualTypes; 275 flatten( (*actualExpr)->get_result(), back_inserter( flatActualTypes ) ); 276 for ( std::list< Type* >::iterator actual = flatActualTypes.begin(); actual != flatActualTypes.end(); ++actual ) { 282 277 if ( formal == formals.end() ) { 283 278 if ( function->get_isVarArgs() ) { … … 383 378 std::list< DeclarationWithType* >::iterator formal = formals.begin(); 384 379 for ( AltList::const_iterator actualExpr = actuals.begin(); actualExpr != actuals.end(); ++actualExpr ) { 385 for ( std::list< Type* >::iterator actual = actualExpr->expr->get_results().begin(); actual != actualExpr->expr->get_results().end(); ++actual ) { 380 std::list< Type * > flatActualTypes; 381 flatten( actualExpr->expr->get_result(), back_inserter( flatActualTypes ) ); 382 for ( std::list< Type* >::iterator actual = flatActualTypes.begin(); actual != flatActualTypes.end(); ++actual ) { 386 383 if ( formal == formals.end() ) { 387 384 return isVarArgs; … … 500 497 //if ( newNeedParents[ curDecl->get_uniqueId() ][ candDecl->get_uniqueId() ]++ > recursionParentLimit ) continue; 501 498 Expression *varExpr = new VariableExpr( candDecl ); 502 deleteAll( varExpr->get_results() ); 503 varExpr->get_results().clear(); 504 varExpr->get_results().push_front( adjType->clone() ); 499 delete varExpr->get_result(); 500 varExpr->set_result( adjType->clone() ); 505 501 PRINT( 506 502 std::cerr << "satisfying assertion " << curDecl->get_uniqueId() << " "; … … 574 570 PointerType pt( Type::Qualifiers(), v.clone() ); 575 571 UntypedExpr *vexpr = untypedExpr->clone(); 576 vexpr-> get_results().push_front( pt.clone() );572 vexpr->set_result( pt.clone() ); 577 573 alternatives.push_back( Alternative( vexpr, env, Cost()) ); 578 574 return; … … 604 600 // check if the type is pointer to function 605 601 PointerType *pointer; 606 if ( func->expr->get_results().size() == 1 && ( pointer = dynamic_cast< PointerType* >( func->expr->get_results().front() ) ) ) {602 if ( ( pointer = dynamic_cast< PointerType* >( func->expr->get_result() ) ) ) { 607 603 if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) { 608 604 for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) { … … 640 636 // check if the type is pointer to function 641 637 PointerType *pointer; 642 if ( funcOp->expr->get_results().size() == 1 643 && ( pointer = dynamic_cast< PointerType* >( funcOp->expr->get_results().front() ) ) ) { 638 if ( ( pointer = dynamic_cast< PointerType* >( funcOp->expr->get_result() ) ) ) { 644 639 if ( FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ) ) { 645 640 for ( std::list< AltList >::iterator actualAlt = possibilities.begin(); actualAlt != possibilities.end(); ++actualAlt ) { … … 665 660 666 661 PRINT( 667 ApplicationExpr *appExpr = dynamic_cast< ApplicationExpr* >( withFunc->expr ); 668 assert( appExpr ); 669 PointerType *pointer = dynamic_cast< PointerType* >( appExpr->get_function()->get_results().front() ); 670 assert( pointer ); 671 FunctionType *function = dynamic_cast< FunctionType* >( pointer->get_base() ); 672 assert( function ); 662 ApplicationExpr *appExpr = safe_dynamic_cast< ApplicationExpr* >( withFunc->expr ); 663 PointerType *pointer = safe_dynamic_cast< PointerType* >( appExpr->get_function()->get_result() ); 664 FunctionType *function = safe_dynamic_cast< FunctionType* >( pointer->get_base() ); 673 665 std::cerr << "Case +++++++++++++" << std::endl; 674 666 std::cerr << "formals are:" << std::endl; … … 692 684 693 685 bool isLvalue( Expression *expr ) { 694 for ( std::list< Type* >::const_iterator i = expr->get_results().begin(); i != expr->get_results().end(); ++i ) { 695 if ( !(*i)->get_isLvalue() ) return false; 696 } // for 697 return true; 686 // xxx - recurse into tuples? 687 return expr->has_result() && expr->get_result()->get_isLvalue(); 698 688 } 699 689 … … 709 699 710 700 void AlternativeFinder::visit( CastExpr *castExpr ) { 711 for ( std::list< Type* >::iterator i = castExpr->get_results().begin(); i != castExpr->get_results().end(); ++i ) { 712 *i = resolveTypeof( *i, indexer ); 713 SymTab::validateType( *i, &indexer ); 714 adjustExprType( *i, env, indexer ); 715 } // for 701 Type *& toType = castExpr->get_result(); 702 toType = resolveTypeof( toType, indexer ); 703 SymTab::validateType( toType, &indexer ); 704 adjustExprType( toType, env, indexer ); 716 705 717 706 AlternativeFinder finder( indexer, env ); … … 727 716 // that are cast directly. The candidate is invalid if it has fewer results than there are types to cast 728 717 // to. 729 int discardedValues = (*i).expr->get_result s().size() - castExpr->get_results().size();718 int discardedValues = (*i).expr->get_result()->size() - castExpr->get_result()->size(); 730 719 if ( discardedValues < 0 ) continue; 731 std::list< Type* >::iterator candidate_end = (*i).expr->get_results().begin(); 732 std::advance( candidate_end, castExpr->get_results().size() ); 720 // xxx - may need to go into tuple types and extract relavent types and use unifyList 733 721 // unification run for side-effects 734 unifyList( castExpr->get_results().begin(), castExpr->get_results().end(), 735 (*i).expr->get_results().begin(), candidate_end, 736 i->env, needAssertions, haveAssertions, openVars, indexer ); 737 Cost thisCost = castCostList( (*i).expr->get_results().begin(), candidate_end, 738 castExpr->get_results().begin(), castExpr->get_results().end(), 739 indexer, i->env ); 722 unify( castExpr->get_result(), (*i).expr->get_result(), i->env, needAssertions, haveAssertions, openVars, indexer ); 723 Cost thisCost = castCost( (*i).expr->get_result(), castExpr->get_result(), indexer, i->env ); 740 724 if ( thisCost != Cost::infinity ) { 741 725 // count one safe conversion for each value that is thrown away … … 760 744 761 745 for ( AltList::const_iterator agg = funcFinder.alternatives.begin(); agg != funcFinder.alternatives.end(); ++agg ) { 762 if ( agg->expr->get_results().size() == 1 ) { 763 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( agg->expr->get_results().front() ) ) { 764 addAggMembers( structInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() ); 765 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( agg->expr->get_results().front() ) ) { 766 addAggMembers( unionInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() ); 767 } // if 746 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( agg->expr->get_result() ) ) { 747 addAggMembers( structInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() ); 748 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( agg->expr->get_result() ) ) { 749 addAggMembers( unionInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() ); 768 750 } // if 769 751 } // for … … 894 876 alternatives.push_back( Alternative( new AttrExpr( new VariableExpr( funcDecl ), argType->clone() ), env, Cost::zero ) ); 895 877 for ( std::list< DeclarationWithType* >::iterator i = function->get_returnVals().begin(); i != function->get_returnVals().end(); ++i ) { 896 alternatives.back().expr-> get_results().push_back( (*i)->get_type()->clone() );878 alternatives.back().expr->set_result( (*i)->get_type()->clone() ); 897 879 } // for 898 880 } // if … … 917 899 finder.find( attrExpr->get_expr() ); 918 900 for ( AltList::iterator choice = finder.alternatives.begin(); choice != finder.alternatives.end(); ++choice ) { 919 if ( choice->expr->get_result s().size() == 1 ) {920 resolveAttr(*i, function, choice->expr->get_result s().front(), choice->env );901 if ( choice->expr->get_result()->size() == 1 ) { 902 resolveAttr(*i, function, choice->expr->get_result(), choice->env ); 921 903 } // fi 922 904 } // for … … 960 942 AssertionSet needAssertions, haveAssertions; 961 943 Alternative newAlt( 0, third->env, first->cost + second->cost + third->cost ); 962 std::list< Type* > commonTypes;963 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) ) {944 Type* commonType; 945 if ( unify( second->expr->get_result(), third->expr->get_result(), newAlt.env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) { 964 946 ConditionalExpr *newExpr = new ConditionalExpr( first->expr->clone(), second->expr->clone(), third->expr->clone() ); 965 std::list< Type* >::const_iterator original = second->expr->get_results().begin(); 966 std::list< Type* >::const_iterator commonType = commonTypes.begin(); 967 for ( ; original != second->expr->get_results().end() && commonType != commonTypes.end(); ++original, ++commonType ) { 968 if ( *commonType ) { 969 newExpr->get_results().push_back( *commonType ); 970 } else { 971 newExpr->get_results().push_back( (*original)->clone() ); 972 } // if 973 } // for 947 newExpr->set_result( commonType ? commonType : second->expr->get_result()->clone() ); 974 948 newAlt.expr = newExpr; 975 949 inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( alternatives ) ); … … 999 973 TupleExpr *newExpr = new TupleExpr; 1000 974 makeExprList( *i, newExpr->get_exprs() ); 1001 for ( std::list< Expression* >::const_iterator resultExpr = newExpr->get_exprs().begin(); resultExpr != newExpr->get_exprs().end(); ++resultExpr ) { 1002 for ( std::list< Type* >::const_iterator resultType = (*resultExpr)->get_results().begin(); resultType != (*resultExpr)->get_results().end(); ++resultType ) { 1003 newExpr->get_results().push_back( (*resultType)->clone() ); 1004 } // for 975 for ( Expression * resultExpr : newExpr->get_exprs() ) { 976 newExpr->set_result( resultExpr->get_result()->clone() ); 1005 977 } // for 1006 978 -
src/ResolvExpr/AlternativePrinter.cc
r96a10cd r906e24d 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
r96a10cd r906e24d 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
r96a10cd r906e24d 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
r96a10cd r906e24d 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
r96a10cd r906e24d 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
r96a10cd r906e24d 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
r96a10cd r906e24d 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( SolvedTupleExpr *tupleExpr ) { 455 accept AllNewScope( tupleExpr->get_results(), *this );455 acceptNewScope( tupleExpr->get_result(), *this ); 456 456 acceptAll( tupleExpr->get_exprs(), *this ); 457 457 } 458 458 459 459 void Indexer::visit( TypeExpr *typeExpr ) { 460 accept AllNewScope( typeExpr->get_results(), *this );460 acceptNewScope( typeExpr->get_result(), *this ); 461 461 maybeAccept( typeExpr->get_type(), *this ); 462 462 } … … 469 469 470 470 void Indexer::visit( UntypedValofExpr *valofExpr ) { 471 accept AllNewScope( valofExpr->get_results(), *this );471 acceptNewScope( valofExpr->get_result(), *this ); 472 472 maybeAccept( valofExpr->get_body(), *this ); 473 473 } -
src/SynTree/AddressExpr.cc
r96a10cd r906e24d 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
r96a10cd r906e24d 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
r96a10cd r906e24d 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
r96a10cd r906e24d 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 } … … 338 331 MemberExpr::MemberExpr( DeclarationWithType *_member, Expression *_aggregate, Expression *_aname ) : 339 332 Expression( _aname ), member(_member), aggregate(_aggregate) { 340 add_result( member->get_type()->clone() ); 341 for ( std::list< Type* >::iterator i = get_results().begin(); i != get_results().end(); ++i ) { 342 (*i)->set_isLvalue( true ); 343 } // for 333 set_result( member->get_type()->clone() ); 334 get_result()->set_isLvalue( true ); 344 335 } 345 336 … … 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 -
src/SynTree/Expression.h
r96a10cd r906e24d 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
r96a10cd r906e24d 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 return memberExpr; … … 220 220 221 221 Expression *Mutator::mutate( MemberExpr *memberExpr ) { 222 m utateAll( memberExpr->get_results(), *this);222 memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) ); 223 223 memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) ); 224 224 return memberExpr; … … 226 226 227 227 Expression *Mutator::mutate( VariableExpr *variableExpr ) { 228 mutateAll( variableExpr->get_results(), *this);228 variableExpr->set_result( maybeMutate( variableExpr->get_result(), *this ) ); 229 229 return variableExpr; 230 230 } 231 231 232 232 Expression *Mutator::mutate( ConstantExpr *constantExpr ) { 233 mutateAll( constantExpr->get_results(), *this);233 constantExpr->set_result( maybeMutate( constantExpr->get_result(), *this ) ); 234 234 // maybeMutate( constantExpr->get_constant(), *this ) 235 235 return constantExpr; … … 237 237 238 238 Expression *Mutator::mutate( SizeofExpr *sizeofExpr ) { 239 mutateAll( sizeofExpr->get_results(), *this);239 sizeofExpr->set_result( maybeMutate( sizeofExpr->get_result(), *this ) ); 240 240 if ( sizeofExpr->get_isType() ) { 241 241 sizeofExpr->set_type( maybeMutate( sizeofExpr->get_type(), *this ) ); … … 247 247 248 248 Expression *Mutator::mutate( AlignofExpr *alignofExpr ) { 249 mutateAll( alignofExpr->get_results(), *this);249 alignofExpr->set_result( maybeMutate( alignofExpr->get_result(), *this ) ); 250 250 if ( alignofExpr->get_isType() ) { 251 251 alignofExpr->set_type( maybeMutate( alignofExpr->get_type(), *this ) ); … … 257 257 258 258 Expression *Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) { 259 mutateAll( offsetofExpr->get_results(), *this);259 offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) ); 260 260 offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) ); 261 261 return offsetofExpr; … … 263 263 264 264 Expression *Mutator::mutate( OffsetofExpr *offsetofExpr ) { 265 mutateAll( offsetofExpr->get_results(), *this);265 offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) ); 266 266 offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) ); 267 267 offsetofExpr->set_member( maybeMutate( offsetofExpr->get_member(), *this ) ); … … 270 270 271 271 Expression *Mutator::mutate( OffsetPackExpr *offsetPackExpr ) { 272 mutateAll( offsetPackExpr->get_results(), *this);272 offsetPackExpr->set_result( maybeMutate( offsetPackExpr->get_result(), *this ) ); 273 273 offsetPackExpr->set_type( maybeMutate( offsetPackExpr->get_type(), *this ) ); 274 274 return offsetPackExpr; … … 276 276 277 277 Expression *Mutator::mutate( AttrExpr *attrExpr ) { 278 mutateAll( attrExpr->get_results(), *this);278 attrExpr->set_result( maybeMutate( attrExpr->get_result(), *this ) ); 279 279 if ( attrExpr->get_isType() ) { 280 280 attrExpr->set_type( maybeMutate( attrExpr->get_type(), *this ) ); … … 286 286 287 287 Expression *Mutator::mutate( LogicalExpr *logicalExpr ) { 288 mutateAll( logicalExpr->get_results(), *this);288 logicalExpr->set_result( maybeMutate( logicalExpr->get_result(), *this ) ); 289 289 logicalExpr->set_arg1( maybeMutate( logicalExpr->get_arg1(), *this ) ); 290 290 logicalExpr->set_arg2( maybeMutate( logicalExpr->get_arg2(), *this ) ); … … 293 293 294 294 Expression *Mutator::mutate( ConditionalExpr *conditionalExpr ) { 295 mutateAll( conditionalExpr->get_results(), *this);295 conditionalExpr->set_result( maybeMutate( conditionalExpr->get_result(), *this ) ); 296 296 conditionalExpr->set_arg1( maybeMutate( conditionalExpr->get_arg1(), *this ) ); 297 297 conditionalExpr->set_arg2( maybeMutate( conditionalExpr->get_arg2(), *this ) ); … … 301 301 302 302 Expression *Mutator::mutate( CommaExpr *commaExpr ) { 303 mutateAll( commaExpr->get_results(), *this);303 commaExpr->set_result( maybeMutate( commaExpr->get_result(), *this ) ); 304 304 commaExpr->set_arg1( maybeMutate( commaExpr->get_arg1(), *this ) ); 305 305 commaExpr->set_arg2( maybeMutate( commaExpr->get_arg2(), *this ) ); … … 308 308 309 309 Expression *Mutator::mutate( TupleExpr *tupleExpr ) { 310 mutateAll( tupleExpr->get_results(), *this);310 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) ); 311 311 mutateAll( tupleExpr->get_exprs(), *this ); 312 312 return tupleExpr; … … 314 314 315 315 Expression *Mutator::mutate( SolvedTupleExpr *tupleExpr ) { 316 mutateAll( tupleExpr->get_results(), *this);316 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) ); 317 317 mutateAll( tupleExpr->get_exprs(), *this ); 318 318 return tupleExpr; … … 320 320 321 321 Expression *Mutator::mutate( TypeExpr *typeExpr ) { 322 mutateAll( typeExpr->get_results(), *this);322 typeExpr->set_result( maybeMutate( typeExpr->get_result(), *this ) ); 323 323 typeExpr->set_type( maybeMutate( typeExpr->get_type(), *this ) ); 324 324 return typeExpr; … … 340 340 341 341 Expression* Mutator::mutate( ConstructorExpr *ctorExpr ) { 342 mutateAll( ctorExpr->get_results(), *this);342 ctorExpr->set_result( maybeMutate( ctorExpr->get_result(), *this ) ); 343 343 ctorExpr->set_callExpr( maybeMutate( ctorExpr->get_callExpr(), *this ) ); 344 344 return ctorExpr; … … 346 346 347 347 Expression *Mutator::mutate( CompoundLiteralExpr *compLitExpr ) { 348 mutateAll( compLitExpr->get_results(), *this);348 compLitExpr->set_result( maybeMutate( compLitExpr->get_result(), *this ) ); 349 349 compLitExpr->set_type( maybeMutate( compLitExpr->get_type(), *this ) ); 350 350 compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) ); … … 353 353 354 354 Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) { 355 mutateAll( valofExpr->get_results(), *this);355 valofExpr->set_result( maybeMutate( valofExpr->get_result(), *this ) ); 356 356 return valofExpr; 357 357 } -
src/SynTree/Type.h
r96a10cd r906e24d 65 65 std::list<TypeDecl*>& get_forall() { return forall; } 66 66 67 /// How many elemental types are represented by this type 68 virtual unsigned size() const { return 1; }; 69 virtual bool isVoid() const { return size() == 0; } 70 67 71 virtual Type *clone() const = 0; 68 72 virtual void accept( Visitor &v ) = 0; … … 77 81 public: 78 82 VoidType( const Type::Qualifiers &tq ); 83 84 virtual unsigned size() const { return 0; }; 79 85 80 86 virtual VoidType *clone() const { return new VoidType( *this ); } … … 353 359 354 360 std::list<Type*>& get_types() { return types; } 361 virtual unsigned size() const { return types.size(); }; 355 362 356 363 virtual TupleType *clone() const { return new TupleType( *this ); } -
src/SynTree/Visitor.cc
r96a10cd r906e24d 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 } 185 185 186 186 void Visitor::visit( MemberExpr *memberExpr ) { 187 acceptAll( memberExpr->get_results(), *this );187 maybeAccept( memberExpr->get_result(), *this ); 188 188 maybeAccept( memberExpr->get_aggregate(), *this ); 189 189 } 190 190 191 191 void Visitor::visit( VariableExpr *variableExpr ) { 192 acceptAll( variableExpr->get_results(), *this );192 maybeAccept( variableExpr->get_result(), *this ); 193 193 } 194 194 195 195 void Visitor::visit( ConstantExpr *constantExpr ) { 196 acceptAll( constantExpr->get_results(), *this );196 maybeAccept( constantExpr->get_result(), *this ); 197 197 maybeAccept( constantExpr->get_constant(), *this ); 198 198 } 199 199 200 200 void Visitor::visit( SizeofExpr *sizeofExpr ) { 201 acceptAll( sizeofExpr->get_results(), *this );201 maybeAccept( sizeofExpr->get_result(), *this ); 202 202 if ( sizeofExpr->get_isType() ) { 203 203 maybeAccept( sizeofExpr->get_type(), *this ); … … 208 208 209 209 void Visitor::visit( AlignofExpr *alignofExpr ) { 210 acceptAll( alignofExpr->get_results(), *this );210 maybeAccept( alignofExpr->get_result(), *this ); 211 211 if ( alignofExpr->get_isType() ) { 212 212 maybeAccept( alignofExpr->get_type(), *this ); … … 217 217 218 218 void Visitor::visit( UntypedOffsetofExpr *offsetofExpr ) { 219 acceptAll( offsetofExpr->get_results(), *this );219 maybeAccept( offsetofExpr->get_result(), *this ); 220 220 maybeAccept( offsetofExpr->get_type(), *this ); 221 221 } 222 222 223 223 void Visitor::visit( OffsetofExpr *offsetofExpr ) { 224 acceptAll( offsetofExpr->get_results(), *this );224 maybeAccept( offsetofExpr->get_result(), *this ); 225 225 maybeAccept( offsetofExpr->get_type(), *this ); 226 226 maybeAccept( offsetofExpr->get_member(), *this ); … … 228 228 229 229 void Visitor::visit( OffsetPackExpr *offsetPackExpr ) { 230 acceptAll( offsetPackExpr->get_results(), *this );230 maybeAccept( offsetPackExpr->get_result(), *this ); 231 231 maybeAccept( offsetPackExpr->get_type(), *this ); 232 232 } 233 233 234 234 void Visitor::visit( AttrExpr *attrExpr ) { 235 acceptAll( attrExpr->get_results(), *this );235 maybeAccept( attrExpr->get_result(), *this ); 236 236 if ( attrExpr->get_isType() ) { 237 237 maybeAccept( attrExpr->get_type(), *this ); … … 242 242 243 243 void Visitor::visit( LogicalExpr *logicalExpr ) { 244 acceptAll( logicalExpr->get_results(), *this );244 maybeAccept( logicalExpr->get_result(), *this ); 245 245 maybeAccept( logicalExpr->get_arg1(), *this ); 246 246 maybeAccept( logicalExpr->get_arg2(), *this ); … … 248 248 249 249 void Visitor::visit( ConditionalExpr *conditionalExpr ) { 250 acceptAll( conditionalExpr->get_results(), *this );250 maybeAccept( conditionalExpr->get_result(), *this ); 251 251 maybeAccept( conditionalExpr->get_arg1(), *this ); 252 252 maybeAccept( conditionalExpr->get_arg2(), *this ); … … 255 255 256 256 void Visitor::visit( CommaExpr *commaExpr ) { 257 acceptAll( commaExpr->get_results(), *this );257 maybeAccept( commaExpr->get_result(), *this ); 258 258 maybeAccept( commaExpr->get_arg1(), *this ); 259 259 maybeAccept( commaExpr->get_arg2(), *this ); … … 261 261 262 262 void Visitor::visit( TupleExpr *tupleExpr ) { 263 acceptAll( tupleExpr->get_results(), *this );263 maybeAccept( tupleExpr->get_result(), *this ); 264 264 acceptAll( tupleExpr->get_exprs(), *this ); 265 265 } 266 266 267 267 void Visitor::visit( SolvedTupleExpr *tupleExpr ) { 268 acceptAll( tupleExpr->get_results(), *this );268 maybeAccept( tupleExpr->get_result(), *this ); 269 269 acceptAll( tupleExpr->get_exprs(), *this ); 270 270 } 271 271 272 272 void Visitor::visit( TypeExpr *typeExpr ) { 273 acceptAll( typeExpr->get_results(), *this );273 maybeAccept( typeExpr->get_result(), *this ); 274 274 maybeAccept( typeExpr->get_type(), *this ); 275 275 } … … 288 288 289 289 void Visitor::visit( ConstructorExpr * ctorExpr ) { 290 acceptAll( ctorExpr->get_results(), *this );290 maybeAccept( ctorExpr->get_result(), *this ); 291 291 maybeAccept( ctorExpr->get_callExpr(), *this ); 292 292 } 293 293 294 294 void Visitor::visit( CompoundLiteralExpr *compLitExpr ) { 295 acceptAll( compLitExpr->get_results(), *this );295 maybeAccept( compLitExpr->get_result(), *this ); 296 296 maybeAccept( compLitExpr->get_type(), *this ); 297 297 maybeAccept( compLitExpr->get_initializer(), *this ); … … 299 299 300 300 void Visitor::visit( UntypedValofExpr *valofExpr ) { 301 acceptAll( valofExpr->get_results(), *this );301 maybeAccept( valofExpr->get_result(), *this ); 302 302 maybeAccept( valofExpr->get_body(), *this ); 303 303 } -
src/Tuples/TupleAssignment.cc
r96a10cd r906e24d 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // TupleAssignment.cc -- 7 // TupleAssignment.cc -- 8 8 // 9 9 // Author : Rodolfo G. Esteves … … 125 125 126 126 bool TupleAssignSpotter::isMVR( Expression *expr ) { 127 if ( expr->get_results().size() > 1 ) { 128 // MVR processing 129 return true; 130 } 131 return false; 127 return isTuple( expr ); 132 128 } 133 129 -
src/Tuples/TupleAssignment.h
r96a10cd r906e24d 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // TupleAssignment.h -- 7 // TupleAssignment.h -- 8 8 // 9 9 // Author : Rodolfo G. Esteves
Note: See TracChangeset
for help on using the changeset viewer.