Changeset 58fe85a for src/ResolvExpr/AlternativeFinder.cc
- Timestamp:
- Jan 7, 2021, 3:27:00 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 2b4daf2, 64aeca0
- Parents:
- 3c64c668 (diff), eef8dfb (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
r3c64c668 r58fe85a 131 131 132 132 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; 137 145 } 138 146 } … … 251 259 SemanticError( expr, "No reasonable alternatives for expression " ); 252 260 } 253 if ( mode. satisfyAssns || mode.prune ) {261 if ( mode.prune ) { 254 262 // trim candidates just to those where the assertions resolve 255 263 // - necessary pre-requisite to pruning … … 1216 1224 unify( castExpr->result, alt.expr->result, alt.env, needAssertions, 1217 1225 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 ); 1220 1230 PRINT( 1221 1231 std::cerr << "working on cast with result: " << castExpr->result << std::endl; … … 1698 1708 1699 1709 // 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; 1701 1712 // xxx - do some inspecting on this line... why isn't result bound to initAlt.type? 1702 1713 1703 Cost thisCost = c astCost( alt.expr->result, toType, alt.expr->get_lvalue(),1714 Cost thisCost = computeConversionCost( alt.expr->result, toType, alt.expr->get_lvalue(), 1704 1715 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 1705 1729 if ( thisCost != Cost::infinity ) { 1706 1730 // count one safe conversion for each value that is thrown away
Note:
See TracChangeset
for help on using the changeset viewer.