- File:
-
- 1 edited
-
src/ResolvExpr/AlternativeFinder.cc (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
r3233b91 r3b0c8cb 131 131 132 132 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; 145 137 } 146 138 } … … 259 251 SemanticError( expr, "No reasonable alternatives for expression " ); 260 252 } 261 if ( mode. prune ) {253 if ( mode.satisfyAssns || mode.prune ) { 262 254 // trim candidates just to those where the assertions resolve 263 255 // - necessary pre-requisite to pruning … … 1224 1216 unify( castExpr->result, alt.expr->result, alt.env, needAssertions, 1225 1217 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 ); 1230 1220 PRINT( 1231 1221 std::cerr << "working on cast with result: " << castExpr->result << std::endl; … … 1302 1292 1303 1293 try { 1304 // Attempt 1 : turn (thread&)X into ( $thread&)X.__thrd1294 // Attempt 1 : turn (thread&)X into (thread_desc&)X.__thrd 1305 1295 // Clone is purely for memory management 1306 1296 std::unique_ptr<Expression> tech1 { new UntypedMemberExpr(new NameExpr(castExpr->concrete_target.field), castExpr->arg->clone()) }; … … 1313 1303 } catch(SemanticErrorException & ) {} 1314 1304 1315 // Fallback : turn (thread&)X into ( $thread&)get_thread(X)1305 // Fallback : turn (thread&)X into (thread_desc&)get_thread(X) 1316 1306 std::unique_ptr<Expression> fallback { UntypedExpr::createDeref( new UntypedExpr(new NameExpr(castExpr->concrete_target.getter), { castExpr->arg->clone() })) }; 1317 1307 // don't prune here, since it's guaranteed all alternatives will have the same type … … 1708 1698 1709 1699 // 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 ); 1712 1701 // xxx - do some inspecting on this line... why isn't result bound to initAlt.type? 1713 1702 1714 Cost thisCost = c omputeConversionCost( alt.expr->result, toType, alt.expr->get_lvalue(),1703 Cost thisCost = castCost( alt.expr->result, toType, alt.expr->get_lvalue(), 1715 1704 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 1729 1705 if ( thisCost != Cost::infinity ) { 1730 1706 // count one safe conversion for each value that is thrown away
Note:
See TracChangeset
for help on using the changeset viewer.