- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.h
rb6fe7e6 r8f7cea1 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 69 virtual void visit( TupleIndexExpr *tupleExpr ); 70 /// Runs a new alternative finder on each element in [begin, end) 71 /// and writes each alternative finder to out. 70 72 template< typename InputIterator, typename OutputIterator > 71 73 void findSubExprs( InputIterator begin, InputIterator end, OutputIterator out ); 72 74 73 private:74 75 /// Adds alternatives for member expressions, given the aggregate, conversion cost for that aggregate, and name of the member 75 template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, const std::string &name);76 template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ); 76 77 /// Adds alternatives for offsetof expressions, given the base type and name of the member 77 78 template< typename StructOrUnionType > void addOffsetof( StructOrUnionType *aggInst, const std::string &name ); … … 89 90 90 91 Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer, TypeEnvironment &env ); 92 93 template< typename InputIterator, typename OutputIterator > 94 void findMinCost( InputIterator begin, InputIterator end, OutputIterator out ) { 95 AltList alternatives; 96 97 // select the alternatives that have the minimum parameter cost 98 Cost minCost = Cost::infinity; 99 for ( InputIterator i = begin; i != end; ++i ) { 100 if ( i->cost < minCost ) { 101 minCost = i->cost; 102 i->cost = i->cvtCost; 103 alternatives.clear(); 104 alternatives.push_back( *i ); 105 } else if ( i->cost == minCost ) { 106 i->cost = i->cvtCost; 107 alternatives.push_back( *i ); 108 } 109 } 110 std::copy( alternatives.begin(), alternatives.end(), out ); 111 } 112 113 Cost sumCost( const AltList &in ); 91 114 } // namespace ResolvExpr 92 115
Note: See TracChangeset
for help on using the changeset viewer.