Changeset 2f42718 for src/ResolvExpr
- Timestamp:
- Feb 22, 2019, 10:43:29 AM (7 years ago)
- Branches:
- no_list
- Parents:
- 43e0949
- Location:
- src/ResolvExpr
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
r43e0949 r2f42718 434 434 435 435 Cost convCost = Cost::zero; 436 std::list< DeclarationWithType* >& formals = function->parameters;437 std::list< DeclarationWithType* >::iterator formal= formals.begin();438 std::list< Expression* >& actuals = appExpr->args;436 auto & formals = function->parameters; 437 auto formal = formals.begin(); 438 auto & actuals = appExpr->args; 439 439 440 440 for ( Expression*& actualExpr : actuals ) { … … 493 493 /// Adds type variables to the open variable set and marks their assertions 494 494 void makeUnifiableVars( Type *type, OpenVarSet &unifiableVars, AssertionSet &needAssertions ) { 495 for ( Type::ForallList::const_iterator tyvar = type->forall.begin(); tyvar != type->forall.end(); ++tyvar) {496 unifiableVars[ (*tyvar)->get_name() ] = TypeDecl::Data{ *tyvar };497 for ( std::list< DeclarationWithType* >::iterator assert = (*tyvar)->assertions.begin(); assert != (*tyvar)->assertions.end(); ++assert) {498 needAssertions[ *assert ].isUsed = true;495 for ( auto tyvar : type->forall ) { 496 unifiableVars[ tyvar->get_name() ] = TypeDecl::Data{ tyvar }; 497 for ( auto assert : tyvar->assertions ) { 498 needAssertions[ assert ].isUsed = true; 499 499 } 500 500 } … … 1407 1407 // assume no polymorphism 1408 1408 // assume no implicit conversions 1409 assert( function-> get_parameters().size() == 1 );1409 assert( function->parameters.size() == 1 ); 1410 1410 PRINT( 1411 1411 std::cerr << "resolvAttr: funcDecl is "; … … 1417 1417 const SymTab::Indexer & indexer = finder.get_indexer(); 1418 1418 AltList & alternatives = finder.get_alternatives(); 1419 if ( typesCompatibleIgnoreQualifiers( argType, function-> get_parameters().front()->get_type(), indexer, env ) ) {1419 if ( typesCompatibleIgnoreQualifiers( argType, function->parameters.front()->get_type(), indexer, env ) ) { 1420 1420 Cost cost = Cost::zero; 1421 1421 Expression * newExpr = data.combine( cost ); … … 1442 1442 if ( FunctionType *function = dynamic_cast< FunctionType* >( id->get_type() ) ) { 1443 1443 // assume exactly one parameter 1444 if ( function-> get_parameters().size() == 1 ) {1444 if ( function->parameters.size() == 1 ) { 1445 1445 if ( attrExpr->get_isType() ) { 1446 1446 resolveAttr( data, function, attrExpr->get_type(), env, altFinder); -
src/ResolvExpr/ConversionCost.cc
r43e0949 r2f42718 388 388 Cost c = Cost::zero; 389 389 if ( TupleType * destAsTuple = dynamic_cast< TupleType * >( dest ) ) { 390 std:: list< Type * >::const_iterator srcIt = tupleType->types.begin();391 std:: list< Type * >::const_iterator destIt = destAsTuple->types.begin();390 std::vector< Type * >::const_iterator srcIt = tupleType->types.begin(); 391 std::vector< Type * >::const_iterator destIt = destAsTuple->types.begin(); 392 392 while ( srcIt != tupleType->types.end() && destIt != destAsTuple->types.end() ) { 393 393 Cost newCost = costFunc( *srcIt++, *destIt++, indexer, env ); -
src/ResolvExpr/FindOpenVars.cc
r43e0949 r2f42718 50 50 void FindOpenVars::common_action( Type *type ) { 51 51 if ( nextIsOpen ) { 52 for ( Type::ForallList::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i) {53 openVars[ (*i)->get_name() ] = TypeDecl::Data{ (*i)};54 for ( std::list< DeclarationWithType* >::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert) {55 needAssertions[ *assert ].isUsed = false;52 for ( const auto i : type->get_forall() ) { 53 openVars[ i->get_name() ] = TypeDecl::Data{ i }; 54 for ( const auto assert : i->assertions ) { 55 needAssertions[ assert ].isUsed = false; 56 56 } 57 /// cloneAll( (*i)->get_assertions(), needAssertions );58 /// needAssertions.insert( needAssertions.end(), (*i)->get_assertions().begin(), (*i)->get_assertions().end() );59 57 } 60 58 } else { 61 for ( Type::ForallList::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i) {62 closedVars[ (*i)->get_name() ] = TypeDecl::Data{ (*i)};63 for ( std::list< DeclarationWithType* >::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert) {64 haveAssertions[ *assert ].isUsed = false;59 for ( const auto i : type->get_forall() ) { 60 closedVars[ i->get_name() ] = TypeDecl::Data{ i }; 61 for ( const auto assert : i->assertions ) { 62 haveAssertions[ assert ].isUsed = false; 65 63 } 66 /// cloneAll( (*i)->get_assertions(), haveAssertions );67 /// haveAssertions.insert( haveAssertions.end(), (*i)->get_assertions().begin(), (*i)->get_assertions().end() );68 64 } // for 69 65 } // if 70 /// std::cerr << "type is ";71 /// type->print( std::cerr );72 /// std::cerr << std::endl << "need is" << std::endl;73 /// printAssertionSet( needAssertions, std::cerr );74 /// std::cerr << std::endl << "have is" << std::endl;75 /// printAssertionSet( haveAssertions, std::cerr );76 66 } 77 67 -
src/ResolvExpr/SpecCost.cc
r43e0949 r2f42718 42 42 private: 43 43 // takes minimum non-negative count over parameter/return list 44 void takeminover( int& mincount, std:: list<DeclarationWithType*>& dwts ) {44 void takeminover( int& mincount, std::vector<DeclarationWithType*> & dwts ) { 45 45 for ( DeclarationWithType* dwt : dwts ) { 46 46 count = -1; … … 61 61 visit_children = false; 62 62 } 63 63 64 64 private: 65 65 // returns minimum non-negative count + 1 over type parameters (-1 if none such) … … 80 80 visit_children = false; 81 81 } 82 82 83 83 // look for polymorphic parameters 84 84 void previsit(UnionInstType* uty) { -
src/ResolvExpr/Unify.cc
r43e0949 r2f42718 283 283 void markAssertions( AssertionSet &assertion1, AssertionSet &assertion2, Type *type ) { 284 284 for ( auto tyvar : type->get_forall() ) { 285 for ( auto assert : tyvar-> get_assertions()) {285 for ( auto assert : tyvar->assertions ) { 286 286 markAssertionSet( assertion1, assert ); 287 287 markAssertionSet( assertion2, assert ); … … 336 336 template< typename Iterator, typename Func > 337 337 std::unique_ptr<Type> combineTypes( Iterator begin, Iterator end, Func & toType ) { 338 std:: list< Type * > types;338 std::vector< Type * > types; 339 339 for ( ; begin != end; ++begin ) { 340 340 // it's guaranteed that a ttype variable will be bound to a flat tuple, so ensure that this results in a flat tuple … … 404 404 /// flattens a list of declarations, so that each tuple type has a single declaration. 405 405 /// makes use of TtypeExpander to ensure ttypes are flat as well. 406 void flattenList( std:: list< DeclarationWithType * > src, std::list< DeclarationWithType * > & dst, TypeEnvironment & env ) {406 void flattenList( std::vector< DeclarationWithType * > src, std::vector< DeclarationWithType * > & dst, TypeEnvironment & env ) { 407 407 dst.clear(); 408 408 for ( DeclarationWithType * dcl : src ) { … … 429 429 std::unique_ptr<FunctionType> flatFunc( functionType->clone() ); 430 430 std::unique_ptr<FunctionType> flatOther( otherFunction->clone() ); 431 flattenList( flatFunc ->get_parameters(), flatFunc->get_parameters(), env );432 flattenList( flatOther-> get_parameters(), flatOther->get_parameters(), env );431 flattenList( flatFunc ->parameters, flatFunc ->parameters, env ); 432 flattenList( flatOther->parameters, flatOther->parameters, env ); 433 433 434 434 // sizes don't have to match if ttypes are involved; need to be more precise wrt where the ttype is to prevent errors … … 481 481 } else if ( tupleParam ) { 482 482 // bundle other parameters into tuple to match 483 std:: list< Type * > binderTypes;483 std::vector< Type * > binderTypes; 484 484 485 485 do { … … 497 497 } else if ( otherTupleParam ) { 498 498 // bundle parameters into tuple to match other 499 std:: list< Type * > binderTypes;499 std::vector< Type * > binderTypes; 500 500 501 501 do { … … 626 626 // xxx - compute once and store in the FunctionType? 627 627 Type * extractResultType( FunctionType * function ) { 628 if ( function-> get_returnVals().size() == 0 ) {628 if ( function->returnVals.size() == 0 ) { 629 629 return new VoidType( Type::Qualifiers() ); 630 } else if ( function-> get_returnVals().size() == 1 ) {631 return function-> get_returnVals().front()->get_type()->clone();630 } else if ( function->returnVals.size() == 1 ) { 631 return function->returnVals.front()->get_type()->clone(); 632 632 } else { 633 std:: list< Type * > types;634 for ( DeclarationWithType * decl : function-> get_returnVals()) {633 std::vector< Type * > types; 634 for ( DeclarationWithType * decl : function->returnVals ) { 635 635 types.push_back( decl->get_type()->clone() ); 636 636 } // for -
src/ResolvExpr/typeops.h
r43e0949 r2f42718 73 73 74 74 // in AlternativeFinder.cc 75 Cost computeConversionCost( Type *actualType, Type *formalType, 75 Cost computeConversionCost( Type *actualType, Type *formalType, 76 76 const SymTab::Indexer &indexer, const TypeEnvironment &env ); 77 77 … … 112 112 bool occurs( Type *type, std::string varName, const TypeEnvironment &env ); 113 113 114 template<typename Iter> 114 template<typename Iter> 115 115 bool occursIn( Type* ty, Iter begin, Iter end, const TypeEnvironment &env ) { 116 116 while ( begin != end ) { … … 128 128 void flatten( Type * type, OutputIterator out ) { 129 129 if ( TupleType * tupleType = dynamic_cast< TupleType * >( type ) ) { 130 for ( Type * t : tupleType-> get_types()) {130 for ( Type * t : tupleType->types ) { 131 131 flatten( t, out ); 132 132 }
Note:
See TracChangeset
for help on using the changeset viewer.