Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    r3233b91 r3b0c8cb  
    131131
    132132        void printAlts( const AltList &list, std::ostream &os, unsigned int indentAmt ) {
    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;
     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;
    145137                }
    146138        }
     
    259251                        SemanticError( expr, "No reasonable alternatives for expression " );
    260252                }
    261                 if ( mode.prune ) {
     253                if ( mode.satisfyAssns || mode.prune ) {
    262254                        // trim candidates just to those where the assertions resolve
    263255                        // - necessary pre-requisite to pruning
     
    12241216                        unify( castExpr->result, alt.expr->result, alt.env, needAssertions,
    12251217                                haveAssertions, openVars, indexer );
    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 );
     1218                        Cost thisCost = castCost( alt.expr->result, castExpr->result, alt.expr->get_lvalue(),
     1219                                indexer, alt.env );
    12301220                        PRINT(
    12311221                                std::cerr << "working on cast with result: " << castExpr->result << std::endl;
     
    13021292
    13031293                try {
    1304                         // Attempt 1 : turn (thread&)X into ($thread&)X.__thrd
     1294                        // Attempt 1 : turn (thread&)X into (thread_desc&)X.__thrd
    13051295                        // Clone is purely for memory management
    13061296                        std::unique_ptr<Expression> tech1 { new UntypedMemberExpr(new NameExpr(castExpr->concrete_target.field), castExpr->arg->clone()) };
     
    13131303                } catch(SemanticErrorException & ) {}
    13141304
    1315                 // Fallback : turn (thread&)X into ($thread&)get_thread(X)
     1305                // Fallback : turn (thread&)X into (thread_desc&)get_thread(X)
    13161306                std::unique_ptr<Expression> fallback { UntypedExpr::createDeref( new UntypedExpr(new NameExpr(castExpr->concrete_target.getter), { castExpr->arg->clone() })) };
    13171307                // don't prune here, since it's guaranteed all alternatives will have the same type
     
    17081698
    17091699                                // unification run for side-effects
    1710                                 bool canUnify = unify( toType, alt.expr->result, newEnv, need, have, openVars, indexer );
    1711                                 (void) canUnify;
     1700                                unify( toType, alt.expr->result, newEnv, need, have, openVars, indexer );
    17121701                                // xxx - do some inspecting on this line... why isn't result bound to initAlt.type?
    17131702
    1714                                 Cost thisCost = computeConversionCost( alt.expr->result, toType, alt.expr->get_lvalue(),
     1703                                Cost thisCost = castCost( alt.expr->result, toType, alt.expr->get_lvalue(),
    17151704                                        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 
    17291705                                if ( thisCost != Cost::infinity ) {
    17301706                                        // count one safe conversion for each value that is thrown away
Note: See TracChangeset for help on using the changeset viewer.