Ignore:
Timestamp:
Jun 11, 2019, 3:42:10 PM (5 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
432ce7a
Parents:
3da7c19
Message:

Fill in CandidateFinder? boilerplate in resolver port

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Candidate.hpp

    r3da7c19 r4b7cce6  
    3030        /// A list of unresolved assertions
    3131        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        }
    3237}
    3338
     
    4348        ast::AssertionList need;   ///< Assertions which need to be resolved
    4449
    45         Candidate() = default;
     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() ) {}
    4664};
    4765
     
    5169/// List of candidates
    5270using CandidateList = std::vector< CandidateRef >;
     71
     72/// Sum the cost of a list of candidates
     73static inline Cost sumCost( const CandidateList & candidates ) {
     74        Cost total = Cost::zero;
     75        for ( const CandidateRef & r : candidates ) { total += r->cost; }
     76        return total;
     77}
    5378
    5479/// Holdover behaviour from old `findMinCost` -- xxx -- can maybe be eliminated?
Note: See TracChangeset for help on using the changeset viewer.