Ignore:
Timestamp:
Jan 7, 2021, 2:55:57 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:
58fe85a
Parents:
bdfc032 (diff), 44e37ef (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' into dkobets-vector

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    rbdfc032 reef8dfb  
    131131
    132132        void printAlts( const AltList &list, std::ostream &os, unsigned int indentAmt ) {
    133                 Indenter indent = { indentAmt };
    134                 for ( AltList::const_iterator i = list.begin(); i != list.end(); ++i ) {
    135                         i->print( os, indent );
    136                         os << std::endl;
     133                std::vector<std::string> sorted;
     134                sorted.reserve(list.size());
     135                for(const auto & c : list) {
     136                        std::stringstream ss;
     137                        c.print( ss, indentAmt );
     138                        sorted.push_back(ss.str());
     139                }
     140
     141                std::sort(sorted.begin(), sorted.end());
     142
     143                for ( const auto & s : sorted ) {
     144                        os << s << std::endl;
    137145                }
    138146        }
     
    251259                        SemanticError( expr, "No reasonable alternatives for expression " );
    252260                }
    253                 if ( mode.satisfyAssns || mode.prune ) {
     261                if ( mode.prune ) {
    254262                        // trim candidates just to those where the assertions resolve
    255263                        // - necessary pre-requisite to pruning
     
    12161224                        unify( castExpr->result, alt.expr->result, alt.env, needAssertions,
    12171225                                haveAssertions, openVars, indexer );
    1218                         Cost thisCost = castCost( alt.expr->result, castExpr->result, alt.expr->get_lvalue(),
    1219                                 indexer, alt.env );
     1226                        Cost thisCost =
     1227                                castExpr->isGenerated
     1228                                ? conversionCost( alt.expr->result, castExpr->result, alt.expr->get_lvalue(),   indexer, alt.env )
     1229                                : castCost( alt.expr->result, castExpr->result, alt.expr->get_lvalue(), indexer, alt.env );
    12201230                        PRINT(
    12211231                                std::cerr << "working on cast with result: " << castExpr->result << std::endl;
     
    12921302
    12931303                try {
    1294                         // Attempt 1 : turn (thread&)X into (thread_desc&)X.__thrd
     1304                        // Attempt 1 : turn (thread&)X into ($thread&)X.__thrd
    12951305                        // Clone is purely for memory management
    12961306                        std::unique_ptr<Expression> tech1 { new UntypedMemberExpr(new NameExpr(castExpr->concrete_target.field), castExpr->arg->clone()) };
     
    13031313                } catch(SemanticErrorException & ) {}
    13041314
    1305                 // Fallback : turn (thread&)X into (thread_desc&)get_thread(X)
     1315                // Fallback : turn (thread&)X into ($thread&)get_thread(X)
    13061316                std::unique_ptr<Expression> fallback { UntypedExpr::createDeref( new UntypedExpr(new NameExpr(castExpr->concrete_target.getter), { castExpr->arg->clone() })) };
    13071317                // don't prune here, since it's guaranteed all alternatives will have the same type
     
    16981708
    16991709                                // unification run for side-effects
    1700                                 unify( toType, alt.expr->result, newEnv, need, have, openVars, indexer );
     1710                                bool canUnify = unify( toType, alt.expr->result, newEnv, need, have, openVars, indexer );
     1711                                (void) canUnify;
    17011712                                // xxx - do some inspecting on this line... why isn't result bound to initAlt.type?
    17021713
    1703                                 Cost thisCost = castCost( alt.expr->result, toType, alt.expr->get_lvalue(),
     1714                                Cost thisCost = computeConversionCost( alt.expr->result, toType, alt.expr->get_lvalue(),
    17041715                                        indexer, newEnv );
     1716
     1717                                PRINT(
     1718                                        Cost legacyCost = castCost( alt.expr->result, toType, alt.expr->get_lvalue(),
     1719                                                indexer, newEnv );
     1720                                        std::cerr << "Considering initialization:";
     1721                                        std::cerr << std::endl << "  FROM: "; alt.expr->result->print(std::cerr);
     1722                                        std::cerr << std::endl << "  TO: ";   toType          ->print(std::cerr);
     1723                                        std::cerr << std::endl << "  Unification " << (canUnify ? "succeeded" : "failed");
     1724                                        std::cerr << std::endl << "  Legacy cost " << legacyCost;
     1725                                        std::cerr << std::endl << "  New cost " << thisCost;
     1726                                        std::cerr << std::endl;
     1727                                )
     1728
    17051729                                if ( thisCost != Cost::infinity ) {
    17061730                                        // count one safe conversion for each value that is thrown away
Note: See TracChangeset for help on using the changeset viewer.