Changeset ff29f08 for src/ResolvExpr
- Timestamp:
- May 18, 2018, 2:09:21 PM (6 years ago)
- Branches:
- new-env, with_gc
- Children:
- 2472a19
- Parents:
- f6f0cca3 (diff), c7d8100c (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/ResolvExpr
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
rf6f0cca3 rff29f08 453 453 /// Adds type variables to the open variable set and marks their assertions 454 454 void makeUnifiableVars( Type *type, OpenVarSet &unifiableVars, AssertionSet &needAssertions ) { 455 for ( Type::ForallList::const_iterator tyvar = type-> get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {455 for ( Type::ForallList::const_iterator tyvar = type->forall.begin(); tyvar != type->forall.end(); ++tyvar ) { 456 456 unifiableVars[ (*tyvar)->get_name() ] = TypeDecl::Data{ *tyvar }; 457 for ( std::list< DeclarationWithType* >::iterator assert = (*tyvar)-> get_assertions().begin(); assert != (*tyvar)->get_assertions().end(); ++assert ) {457 for ( std::list< DeclarationWithType* >::iterator assert = (*tyvar)->assertions.begin(); assert != (*tyvar)->assertions.end(); ++assert ) { 458 458 needAssertions[ *assert ].isUsed = true; 459 459 } -
src/ResolvExpr/AlternativeFinder.h
rf6f0cca3 rff29f08 126 126 void printAlts( const AltList &list, std::ostream &os, unsigned int indentAmt = 0 ); 127 127 128 /// Adds type variables to the open variable set and marks their assertions 129 void makeUnifiableVars( Type *type, OpenVarSet &unifiableVars, AssertionSet &needAssertions ); 130 128 131 template< typename InputIterator > 129 132 void simpleCombineEnvironments( InputIterator begin, InputIterator end, TypeEnvironment &result ) { -
src/ResolvExpr/Resolver.cc
rf6f0cca3 rff29f08 493 493 } 494 494 495 if(clause.target.arguments.empty()) { 496 SemanticError( stmt->location, "Waitfor clause must have at least one mutex parameter"); 497 } 498 495 499 // Find all alternatives for all arguments in canonical form 496 500 std::vector< AlternativeFinder > argAlternatives; … … 541 545 OpenVarSet openVars; 542 546 AssertionSet resultNeed, resultHave; 543 TypeEnvironment resultEnv; 547 TypeEnvironment resultEnv( func.env ); 548 makeUnifiableVars( function, openVars, resultNeed ); 549 // add all type variables as open variables now so that those not used in the parameter 550 // list are still considered open. 551 resultEnv.add( function->forall ); 544 552 545 553 // Load type variables from arguemnts into one shared space … … 557 565 auto param_end = function->parameters.end(); 558 566 567 int n_mutex_arg = 0; 568 559 569 // For every arguments of its set, check if it matches one of the parameter 560 570 // The order is important … … 565 575 // We ran out of parameters but still have arguments 566 576 // this function doesn't match 567 SemanticError( function, "candidate function not viable: too many mutex arguments\n");577 SemanticError( function, toString("candidate function not viable: too many mutex arguments, expected ", n_mutex_arg, "\n" )); 568 578 } 569 579 580 n_mutex_arg++; 581 570 582 // Check if the argument matches the parameter type in the current scope 571 if( ! unify( (*param)->get_type(), arg.expr->get_result(), resultEnv, resultNeed, resultHave, openVars, this->indexer ) ) {583 if( ! unify( arg.expr->get_result(), (*param)->get_type(), resultEnv, resultNeed, resultHave, openVars, this->indexer ) ) { 572 584 // Type doesn't match 573 585 stringstream ss; 574 586 ss << "candidate function not viable: no known convertion from '"; 587 (*param)->get_type()->print( ss ); 588 ss << "' to '"; 575 589 arg.expr->get_result()->print( ss ); 576 ss << "' to'";577 (*param)->get_type()->print( ss);590 ss << "' with env '"; 591 resultEnv.print(ss); 578 592 ss << "'\n"; 579 593 SemanticError( function, ss.str() ); … … 589 603 // We ran out of arguments but still have parameters left 590 604 // this function doesn't match 591 SemanticError( function, "candidate function not viable: too few mutex arguments\n");605 SemanticError( function, toString("candidate function not viable: too few mutex arguments, expected ", n_mutex_arg, "\n" )); 592 606 } 593 607
Note: See TracChangeset
for help on using the changeset viewer.