Changes in src/ControlStruct/MLEMutator.cc [d939274:be5aa1b]
- File:
-
- 1 edited
-
src/ControlStruct/MLEMutator.cc (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/MLEMutator.cc
rd939274 rbe5aa1b 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Jun 02 13:43:01201513 // Update Count : 9212 // Last Modified On : Wed May 27 16:19:32 2015 13 // Update Count : 44 14 14 // 15 15 … … 33 33 } // if 34 34 35 // a child statement may set the break label36 // - if they do, attach it to the next statement37 35 std::list< Statement * > &kids = cmpndStmt->get_kids(); 38 36 for ( std::list< Statement * >::iterator k = kids.begin(); k != kids.end(); k++ ) { … … 40 38 41 39 if ( ! get_breakLabel().empty() ) { 42 std::list< Statement * >::iterator next = k +1;40 std::list< Statement * >::iterator next = k; next++; 43 41 if ( next == kids.end() ) { 44 42 std::list<Label> ls; ls.push_back( get_breakLabel() ); … … 60 58 } // if 61 59 60 //mutateAll( cmpndStmt->get_kids(), *this ); 62 61 return cmpndStmt; 63 62 } … … 77 76 Statement *MLEMutator::mutate( ForStmt *forStmt ) { 78 77 enclosingLoops.push_back( Entry( forStmt ) ); 79 forStmt->set_body( maybeMutate( forStmt->get_body(), *this ));78 maybeMutate( forStmt->get_body(), *this ); 80 79 81 80 Entry &e = enclosingLoops.back(); … … 155 154 Label brkLabel = generator->newLabel(); 156 155 enclosingSwitches.push_back( Entry(switchStmt, "", brkLabel) ); 157 mutateAll( switchStmt->get_branches(), mutator ); 158 { 156 mutateAll( switchStmt->get_branches(), mutator ); { 159 157 // check if this is necessary (if there is a break to this point, otherwise do not generate 160 161 // for the purposes of keeping switch statements uniform (i.e. all statements that are 162 // direct children of a switch should be CastStmts), append the exit label + break to the 163 // last case statement; create a default case if there are no cases 164 std::list< Statement * > &branches = switchStmt->get_branches(); 165 if ( branches.empty() ) { 166 branches.push_back( CaseStmt::makeDefault() ); 167 } 168 169 if ( CaseStmt * c = dynamic_cast< CaseStmt * >( branches.back() ) ) { 170 std::list<Label> temp; temp.push_back( brkLabel ); 171 c->get_statements().push_back( new BranchStmt( temp, Label(""), BranchStmt::Break ) ); 172 } else assert(0); 158 std::list<Label> temp; temp.push_back( brkLabel ); 159 switchStmt->get_branches().push_back( new BranchStmt( temp, Label(""), BranchStmt::Break ) ); 173 160 } 174 161 assert ( enclosingSwitches.back() == switchStmt ); … … 186 173 187 174 Statement *MLEMutator::mutateLoop( Statement *bodyLoop, Entry &e ) { 188 // ensure loop body is a block189 175 CompoundStmt *newBody; 190 176 if ( ! (newBody = dynamic_cast<CompoundStmt *>( bodyLoop )) ) { … … 218 204 } 219 205 220 //*** Entry's methods - ensure these labels can be set at most once206 //*** Entry's methods 221 207 void MLEMutator::Entry::set_contExit( Label l ) { 222 208 assert ( contExit == "" || contExit == l );
Note:
See TracChangeset
for help on using the changeset viewer.