Changes in src/ResolvExpr/Candidate.hpp [99d4584:432ce7a]
- File:
-
- 1 edited
-
src/ResolvExpr/Candidate.hpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Candidate.hpp
r99d4584 r432ce7a 30 30 /// A list of unresolved assertions 31 31 using AssertionList = std::vector<AssertionSet::value_type>; 32 33 /// Convenience to merge AssertionList into AssertionSet 34 static inline void mergeAssertionSet( AssertionSet & dst, const AssertionList & src ) { 35 for ( const auto & s : src ) { dst.emplace( s ); } 36 } 32 37 } 33 38 … … 42 47 ast::OpenVarSet open; ///< Open variables for environment 43 48 ast::AssertionList need; ///< Assertions which need to be resolved 49 50 Candidate() : expr(), cost( Cost::zero ), cvtCost( Cost::zero ), env(), open(), need() {} 51 52 Candidate( const ast::Expr * x, const ast::TypeEnvironment & e ) 53 : expr( x ), cost( Cost::zero ), cvtCost( Cost::zero ), env( e ), open(), need() {} 54 55 Candidate( const Candidate & o, const ast::Expr * x ) 56 : expr( x ), cost( o.cost ), cvtCost( Cost::zero ), env( o.env ), open( o.open ), 57 need( o.need ) {} 58 59 Candidate( 60 const ast::Expr * x, ast::TypeEnvironment && e, ast::OpenVarSet && o, 61 ast::AssertionSet && n, const Cost & c ) 62 : expr( x ), cost( c ), cvtCost( Cost::zero ), env( std::move( e ) ), open( std::move( o ) ), 63 need( n.begin(), n.end() ) {} 44 64 }; 45 65 … … 49 69 /// List of candidates 50 70 using CandidateList = std::vector< CandidateRef >; 71 72 /// Splice src after dst, clearing src 73 static inline void splice( CandidateList & dst, CandidateList & src ) { 74 dst.reserve( dst.size() + src.size() ); 75 for ( CandidateRef & r : src ) { dst.emplace_back( std::move( r ) ); } 76 src.clear(); 77 } 78 79 /// Splice src before dst 80 static inline void spliceBegin( CandidateList & dst, CandidateList & src ) { 81 splice( src, dst ); 82 dst.swap( src ); 83 } 84 85 /// Sum the cost of a list of candidates 86 static inline Cost sumCost( const CandidateList & candidates ) { 87 Cost total = Cost::zero; 88 for ( const CandidateRef & r : candidates ) { total += r->cost; } 89 return total; 90 } 91 92 /// Holdover behaviour from old `findMinCost` -- xxx -- can maybe be eliminated? 93 static inline void promoteCvtCost( CandidateList & candidates ) { 94 for ( CandidateRef & r : candidates ) { 95 r->cost = r->cvtCost; 96 } 97 } 51 98 52 99 void print( std::ostream & os, const Candidate & cand, Indenter indent = {} );
Note:
See TracChangeset
for help on using the changeset viewer.