Changeset 908cc83 for src/Tuples
- Timestamp:
- Sep 10, 2016, 1:31:37 PM (8 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:
- 8f7cea1
- Parents:
- 5af62f1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Tuples/TupleAssignment.cc
r5af62f1 r908cc83 56 56 virtual ~Matcher() {} 57 57 virtual void match( std::list< Expression * > &out ) = 0; 58 virtual void solve( std::list< Expression * > &assigns) = 0;58 virtual void solve() = 0; 59 59 static UntypedExpr *createAssgn( Expression *left, Expression *right ); 60 60 protected: … … 69 69 } 70 70 virtual void match( std::list< Expression * > &out ); 71 virtual void solve( std::list< Expression * > &assigns);71 virtual void solve(); 72 72 }; 73 73 … … 76 76 MultipleAssignMatcher( TupleAssignSpotter &spot, Expression *lhs, Expression *rhs ); 77 77 virtual void match( std::list< Expression * > &out ); 78 virtual void solve( std::list< Expression * > &assigns);78 virtual void solve(); 79 79 }; 80 80 … … 150 150 if ( new_assigns.empty() ) return; 151 151 std::list< Expression * > solved_assigns; 152 ResolvExpr::AltList solved_alts;153 152 ResolvExpr::AltList current; 154 153 // now resolve new assignments … … 160 159 assert( alts.size() == 1 ); 161 160 assert( alts.front().expr != 0 ); 162 current.push_back( finder.get_alternatives().front() ); 163 solved_assigns.push_back( alts.front().expr->clone() ); 161 current.push_back( alts.front() ); 164 162 } 165 163 options.options.push_back( current ); 166 164 167 matcher->solve( new_assigns);165 matcher->solve(); 168 166 } 169 167 … … 197 195 } 198 196 199 void TupleAssignSpotter::MassAssignMatcher::solve( std::list< Expression * > &assigns) {197 void TupleAssignSpotter::MassAssignMatcher::solve() { 200 198 assert( ! spotter.options.empty() ); 201 ResolvExpr::AltList winners;202 199 for ( std::list< ResolvExpr::AltList >::iterator i = spotter.options.begin(); i != spotter.options.end(); ++i ) { 203 findMinCost( i->begin(), i->end(), back_inserter(winners) );204 }205 206 std::list< Expression *> solved_assigns;207 for ( ResolvExpr::AltList::iterator i = winners.begin(); i != winners.end(); ++i ) {208 solved_assigns.push_back( i->expr );209 }210 spotter.currentFinder.get_alternatives().push_front( ResolvExpr::Alternative(new SolvedTupleExpr(solved_assigns), spotter.currentFinder.get_environ(), ResolvExpr::Cost() ) );200 // extract expressions from the alternatives to produce a list of assignments that 201 // together form a single alternative 202 std::list< Expression *> solved_assigns; 203 for ( ResolvExpr::Alternative & alt : *i ) { 204 solved_assigns.push_back( alt.expr ); 205 } 206 spotter.currentFinder.get_alternatives().push_front( ResolvExpr::Alternative(new SolvedTupleExpr(solved_assigns), spotter.currentFinder.get_environ(), ResolvExpr::sumCost( *i ) ) ); 207 } 211 208 } 212 209 … … 218 215 } 219 216 220 void TupleAssignSpotter::MultipleAssignMatcher::solve( std::list< Expression * > &assigns) {217 void TupleAssignSpotter::MultipleAssignMatcher::solve() { 221 218 // options.print( std::cerr ); 222 219 std::list< ResolvExpr::AltList > best = spotter.options.get_best();
Note: See TracChangeset
for help on using the changeset viewer.