Changeset b3bd772
- Timestamp:
- Dec 14, 2018, 5:12:48 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 8deaf2b
- Parents:
- 9aaacc27
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/ResolveAssertions.cc
r9aaacc27 rb3bd772 16 16 #include "ResolveAssertions.h" 17 17 18 #include <algorithm> // for sort 18 19 #include <cassert> // for assertf 19 20 #include <list> // for list 21 #include <memory> // for unique_ptr 20 22 #include <unordered_map> // for unordered_map, unordered_multimap 21 23 #include <utility> // for move … … 27 29 #include "ResolvExpr/RenameVars.h" // for renameTyVars 28 30 #include "SymTab/Indexer.h" // for Indexer 31 #include "SymTab/Mangler.h" // for Mangler 29 32 #include "SynTree/Expression.h" // for InferredParams 30 33 #include "TypeEnvironment.h" // for TypeEnvironment, etc. … … 370 373 } 371 374 } else { 372 // resolve deferred assertions by mutual compatibility and sort by cost375 // resolve deferred assertions by mutual compatibility 373 376 std::vector<CandidateEnvMerger::OutType> compatible = filterCombos( 374 377 resn.deferred, 375 378 CandidateEnvMerger{ resn.alt.env, resn.alt.openVars, resn.indexer } ); 376 auto lmin = sort_mins( compatible.begin(), compatible.end(), 377 CandidateCost{resn.indexer} ); 378 379 for ( auto it = compatible.begin(); it != lmin ; ++it ) { 380 auto& compat = *it; 379 // sort by cost 380 CandidateCost coster{ resn.indexer }; 381 std::sort( compatible.begin(), compatible.end(), coster ); 382 // // sort by cost if pruning 383 // if ( pruneAssertions ) { 384 // auto lmin = sort_mins( compatible.begin(), compatible.end(), 385 // CandidateCost{resn.indexer} ); 386 // compatible.erase( lmin, compatible.end() ); 387 // } 388 389 // keep map of detected options 390 std::unordered_map<std::string, Cost> found; 391 for ( auto& compat : compatible ) { 392 // filter by environment-adjusted result type, keep only cheapest option 393 Type* resType = alt.expr->result->clone(); 394 compat.env.apply( resType ); 395 // skip if cheaper alternative already processed with same result type 396 Cost resCost = coster.get( compat ); 397 auto it = found.emplace( SymTab::Mangler::mangleType( resType ), resCost ); 398 if ( it.second == false && it.first->second < resCost ) continue; 399 400 // proceed with resolution step 381 401 ResnState new_resn = resn; 382 402
Note: See TracChangeset
for help on using the changeset viewer.