Changeset 5af62f1 for src/ResolvExpr/AlternativeFinder.h
- Timestamp:
- Sep 10, 2016, 12:53:36 PM (7 years ago)
- Branches:
- aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 908cc83
- Parents:
- add7117
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.h
radd7117 r5af62f1 67 67 virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr ); 68 68 virtual void visit( ConstructorExpr * ctorExpr ); 69 public: // xxx - temporary hack - should make Tuples::TupleAssignment a friend 70 /// Runs a new alternative finder on each element in [begin, end) 71 /// and writes each alternative finder to out. 69 /// Runs a new alternative finder on each element in [begin, end) 70 /// and writes each alternative finder to out. 72 71 template< typename InputIterator, typename OutputIterator > 73 72 void findSubExprs( InputIterator begin, InputIterator end, OutputIterator out ); 74 73 75 private:76 74 /// Adds alternatives for member expressions, given the aggregate, conversion cost for that aggregate, and name of the member 77 75 template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ); … … 91 89 92 90 Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer, TypeEnvironment &env ); 91 92 template< typename InputIterator, typename OutputIterator > 93 void findMinCost( InputIterator begin, InputIterator end, OutputIterator out ) { 94 AltList alternatives; 95 96 // select the alternatives that have the minimum parameter cost 97 Cost minCost = Cost::infinity; 98 for ( InputIterator i = begin; i != end; ++i ) { 99 if ( i->cost < minCost ) { 100 minCost = i->cost; 101 i->cost = i->cvtCost; 102 alternatives.clear(); 103 alternatives.push_back( *i ); 104 } else if ( i->cost == minCost ) { 105 i->cost = i->cvtCost; 106 alternatives.push_back( *i ); 107 } 108 } 109 std::copy( alternatives.begin(), alternatives.end(), out ); 110 } 93 111 } // namespace ResolvExpr 94 112
Note: See TracChangeset
for help on using the changeset viewer.