Changeset ed1a6374 for src


Ignore:
Timestamp:
Jan 5, 2021, 2:51:58 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
f03209d3
Parents:
c4241b6 (diff), 95eec2c (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 branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/ResolvExpr
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/RenameVars.cc

    rc4241b6 red1a6374  
    186186}
    187187
    188 const ast::Type * renameTyVars( const ast::Type * t, RenameMode mode ) {
     188const ast::Type * renameTyVars( const ast::Type * t, RenameMode mode, bool reset ) {
    189189        // ast::Type *tc = ast::deepCopy(t);
    190190        ast::Pass<RenameVars_new> renamer;
    191191        renamer.core.mode = mode;
    192         if (mode == GEN_USAGE) {
     192        if (mode == GEN_USAGE && reset) {
    193193                renaming.nextUsage();
    194194        }
     
    198198void resetTyVarRenaming() {
    199199        renaming.reset();
     200        renaming.nextUsage();
    200201}
    201202
  • src/ResolvExpr/RenameVars.h

    rc4241b6 red1a6374  
    3535                GEN_EXPR_ID // for type in decl
    3636        };
    37         const ast::Type * renameTyVars( const ast::Type *, RenameMode mode = GEN_USAGE );
     37        const ast::Type * renameTyVars( const ast::Type *, RenameMode mode = GEN_USAGE, bool reset = true );
     38       
    3839
    3940        /// resets internal state of renamer to avoid overflow
  • src/ResolvExpr/Resolver.cc

    rc4241b6 red1a6374  
    11511151                        const ast::Expr * untyped, const ast::SymbolTable & symtab
    11521152                ) {
    1153                         resetTyVarRenaming();
    11541153                        ast::TypeEnvironment env;
    11551154                        ast::ptr< ast::Expr > newExpr = resolveInVoidContext( untyped, symtab, env );
  • src/ResolvExpr/SatisfyAssertions.cpp

    rc4241b6 red1a6374  
    202202                        ast::ptr< ast::Type > toType = assn.first->result;
    203203                        ast::ptr< ast::Type > adjType =
    204                                 renameTyVars( adjustExprType( candidate->get_type(), newEnv, sat.symtab ) );
     204                                renameTyVars( adjustExprType( candidate->get_type(), newEnv, sat.symtab ), GEN_USAGE, false );
    205205
    206206                        // only keep candidates which unify
     
    385385
    386386        /// Limit to depth of recursion of assertion satisfaction
    387         static const int recursionLimit = 4;
     387        static const int recursionLimit = 8;
    388388        /// Maximum number of simultaneously-deferred assertions to attempt concurrent satisfaction of
    389389        static const int deferLimit = 10;
     
    417417                        if ( it != thresholds.end() && it->second < sat.costs ) goto nextSat;
    418418
    419                         // make initial pass at matching assertions
    420                         for ( auto & assn : sat.need ) {
    421                                 // fail early if any assertion is not satisfiable
    422                                 if ( ! satisfyAssertion( assn, sat ) ) {
     419                        // should a limit be imposed? worst case here is O(n^2) but very unlikely to happen.
     420                        for (unsigned resetCount = 0; ; ++resetCount) {
     421                                ast::AssertionList next;
     422                                resetTyVarRenaming();
     423                                // make initial pass at matching assertions
     424                                for ( auto & assn : sat.need ) {
     425                                        // fail early if any assertion is not satisfiable
     426                                        if ( ! satisfyAssertion( assn, sat ) ) {
     427                                                next.emplace_back(assn);
     428                                                // goto nextSat;
     429                                        }
     430                                }
     431                                // success
     432                                if (next.empty()) break;
     433                                // fail if nothing resolves
     434                                else if (next.size() == sat.need.size()) {
    423435                                        Indenter tabs{ 3 };
    424436                                        std::ostringstream ss;
     
    426438                                        print( ss, *sat.cand, ++tabs );
    427439                                        ss << (tabs-1) << "Could not satisfy assertion:\n";
    428                                         ast::print( ss, assn.first, tabs );
     440                                        ast::print( ss, next[0].first, tabs );
    429441
    430442                                        errors.emplace_back( ss.str() );
    431443                                        goto nextSat;
    432444                                }
     445                                sat.need = std::move(next);
    433446                        }
    434447
Note: See TracChangeset for help on using the changeset viewer.