ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change
on this file since d11f789 was
51b7345,
checked in by Peter A. Buhr <pabuhr@…>, 10 years ago
|
initial commit
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Rev | Line | |
---|
[51b7345] | 1 | #include <list> |
---|
| 2 | |
---|
| 3 | #include "SynTree/Statement.h" |
---|
| 4 | #include "ChooseMutator.h" |
---|
| 5 | |
---|
| 6 | namespace ControlStruct { |
---|
| 7 | |
---|
| 8 | Statement* ChooseMutator::mutate(ChooseStmt *chooseStmt) |
---|
| 9 | { |
---|
| 10 | bool enclosingChoose = insideChoose; |
---|
| 11 | insideChoose = true; |
---|
| 12 | mutateAll( chooseStmt->get_branches(), *this ); |
---|
| 13 | insideChoose = enclosingChoose; |
---|
| 14 | |
---|
| 15 | return new SwitchStmt( chooseStmt->get_labels(), chooseStmt->get_condition(), chooseStmt->get_branches() ); |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | Statement* ChooseMutator::mutate(SwitchStmt *switchStmt) |
---|
| 19 | { |
---|
| 20 | bool enclosingChoose = insideChoose; |
---|
| 21 | insideChoose = false; |
---|
| 22 | mutateAll( switchStmt->get_branches(), *this ); |
---|
| 23 | insideChoose = enclosingChoose; |
---|
| 24 | |
---|
| 25 | return switchStmt; |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | Statement* ChooseMutator::mutate(FallthruStmt *fallthruStmt) |
---|
| 29 | { |
---|
| 30 | delete fallthruStmt; |
---|
| 31 | return new NullStmt(); |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | Statement* ChooseMutator::mutate(CaseStmt *caseStmt) |
---|
| 35 | { |
---|
| 36 | |
---|
| 37 | std::list< Statement * > &stmts = caseStmt->get_statements(); |
---|
| 38 | |
---|
| 39 | if ( insideChoose ) { |
---|
| 40 | BranchStmt *posBrk; |
---|
| 41 | if ( (( posBrk = dynamic_cast< BranchStmt * > ( stmts.back() ) ) && |
---|
| 42 | ( posBrk->get_type() == BranchStmt::Break )) // last statement in the list is a (superfluous) 'break' |
---|
| 43 | || dynamic_cast< FallthruStmt * > ( stmts.back() ) ) |
---|
| 44 | ; |
---|
| 45 | else { |
---|
| 46 | stmts.push_back( new BranchStmt( std::list< Label >(), "", BranchStmt::Break ) ); |
---|
| 47 | } |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | mutateAll ( stmts, *this ); |
---|
| 51 | |
---|
| 52 | return caseStmt; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | } // namespace ControlStruct |
---|
Note: See
TracBrowser
for help on using the repository browser.