Changeset ff29f08 for src/ResolvExpr


Ignore:
Timestamp:
May 18, 2018, 2:09:21 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
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.
Message:

Merge remote-tracking branch 'origin/master' into with_gc

Location:
src/ResolvExpr
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    rf6f0cca3 rff29f08  
    453453        /// Adds type variables to the open variable set and marks their assertions
    454454        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 ) {
    456456                        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 ) {
    458458                                needAssertions[ *assert ].isUsed = true;
    459459                        }
  • src/ResolvExpr/AlternativeFinder.h

    rf6f0cca3 rff29f08  
    126126        void printAlts( const AltList &list, std::ostream &os, unsigned int indentAmt = 0 );
    127127
     128        /// Adds type variables to the open variable set and marks their assertions
     129        void makeUnifiableVars( Type *type, OpenVarSet &unifiableVars, AssertionSet &needAssertions );
     130
    128131        template< typename InputIterator >
    129132        void simpleCombineEnvironments( InputIterator begin, InputIterator end, TypeEnvironment &result ) {
  • src/ResolvExpr/Resolver.cc

    rf6f0cca3 rff29f08  
    493493                        }
    494494
     495                        if(clause.target.arguments.empty()) {
     496                                SemanticError( stmt->location, "Waitfor clause must have at least one mutex parameter");
     497                        }
     498
    495499                        // Find all alternatives for all arguments in canonical form
    496500                        std::vector< AlternativeFinder > argAlternatives;
     
    541545                                                        OpenVarSet openVars;
    542546                                                        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 );
    544552
    545553                                                        // Load type variables from arguemnts into one shared space
     
    557565                                                        auto param_end = function->parameters.end();
    558566
     567                                                        int n_mutex_arg = 0;
     568
    559569                                                        // For every arguments of its set, check if it matches one of the parameter
    560570                                                        // The order is important
     
    565575                                                                        // We ran out of parameters but still have arguments
    566576                                                                        // 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" ));
    568578                                                                }
    569579
     580                                                                n_mutex_arg++;
     581
    570582                                                                // 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 ) ) {
    572584                                                                        // Type doesn't match
    573585                                                                        stringstream ss;
    574586                                                                        ss << "candidate function not viable: no known convertion from '";
     587                                                                        (*param)->get_type()->print( ss );
     588                                                                        ss << "' to '";
    575589                                                                        arg.expr->get_result()->print( ss );
    576                                                                         ss << "' to '";
    577                                                                         (*param)->get_type()->print( ss );
     590                                                                        ss << "' with env '";
     591                                                                        resultEnv.print(ss);
    578592                                                                        ss << "'\n";
    579593                                                                        SemanticError( function, ss.str() );
     
    589603                                                                // We ran out of arguments but still have parameters left
    590604                                                                // 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" ));
    592606                                                        }
    593607
Note: See TracChangeset for help on using the changeset viewer.