Changeset 5af62f1 for src/ResolvExpr
- Timestamp:
- Sep 10, 2016, 12:53:36 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, 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
- Location:
- src/ResolvExpr
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/ResolvExpr/AlternativeFinder.cc ¶
radd7117 r5af62f1 142 142 } 143 143 144 template< typename InputIterator, typename OutputIterator >145 void findMinCost( InputIterator begin, InputIterator end, OutputIterator out ) {146 AltList alternatives;147 148 // select the alternatives that have the minimum parameter cost149 Cost minCost = Cost::infinity;150 for ( AltList::iterator i = begin; i != end; ++i ) {151 if ( i->cost < minCost ) {152 minCost = i->cost;153 i->cost = i->cvtCost;154 alternatives.clear();155 alternatives.push_back( *i );156 } else if ( i->cost == minCost ) {157 i->cost = i->cvtCost;158 alternatives.push_back( *i );159 }160 }161 std::copy( alternatives.begin(), alternatives.end(), out );162 }163 164 144 template< typename InputIterator > 165 145 void simpleCombineEnvironments( InputIterator begin, InputIterator end, TypeEnvironment &result ) { … … 254 234 template< typename StructOrUnionType > 255 235 void AlternativeFinder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ) { 236 237 // // member must be either a tuple expression or a name expr 238 // if ( NameExpr * nameExpr = dynamic_cast< NameExpr * >( memberExpr->get_member() ) ) { 239 // addAggMembers( structInst, agg->expr, agg->cost, nameExpr->get_name() ); 240 // } else { 241 // TupleExpr * tupleExpr = safe_dynamic_cast< TupleExpr * >( memberExpr->get_member() ); 242 // // xxx - ... 243 // assert( false ); 244 // } 245 // if ( TupleExpr * tupleExpr = dynamic_cast< TupleExpr * >( memberExpr->get_member() ) ) { 246 247 // } 256 248 NameExpr * nameExpr = safe_dynamic_cast< NameExpr * >( member ); 257 249 const std::string & name = nameExpr->get_name(); … … 639 631 combos( argAlternatives.begin(), argAlternatives.end(), back_inserter( possibilities ) ); 640 632 641 Tuples::TupleAssignSpotter tassign( this ); 642 if ( tassign.isTupleAssignment( untypedExpr, possibilities ) ) { 643 // take care of possible tuple assignments, or discard expression 644 return; 645 } // else ... 633 // take care of possible tuple assignments 634 // if not tuple assignment, assignment is taken care of as a normal function call 635 Tuples::handleTupleAssignment( *this, untypedExpr, possibilities ); 646 636 647 637 AltList candidates; -
TabularUnified 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.