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 02e9ae2 was
d9a0e76,
checked in by Peter A. Buhr <pabuhr@…>, 10 years ago
|
remove Parser.old, add -XCFA to driver, copy ptrdiff_t from stddef.h in preclude, remove casts from initialization constants, adjust formatting
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | #include <list> |
---|
2 | |
---|
3 | #include "SynTree/Statement.h" |
---|
4 | #include "ChooseMutator.h" |
---|
5 | |
---|
6 | namespace ControlStruct { |
---|
7 | Statement *ChooseMutator::mutate( ChooseStmt *chooseStmt) { |
---|
8 | bool enclosingChoose = insideChoose; |
---|
9 | insideChoose = true; |
---|
10 | mutateAll( chooseStmt->get_branches(), *this ); |
---|
11 | insideChoose = enclosingChoose; |
---|
12 | return new SwitchStmt( chooseStmt->get_labels(), chooseStmt->get_condition(), chooseStmt->get_branches() ); |
---|
13 | } |
---|
14 | |
---|
15 | Statement *ChooseMutator::mutate( SwitchStmt *switchStmt ) { |
---|
16 | bool enclosingChoose = insideChoose; |
---|
17 | insideChoose = false; |
---|
18 | mutateAll( switchStmt->get_branches(), *this ); |
---|
19 | insideChoose = enclosingChoose; |
---|
20 | return switchStmt; |
---|
21 | } |
---|
22 | |
---|
23 | Statement *ChooseMutator::mutate( FallthruStmt *fallthruStmt ) { |
---|
24 | delete fallthruStmt; |
---|
25 | return new NullStmt(); |
---|
26 | } |
---|
27 | |
---|
28 | Statement* ChooseMutator::mutate(CaseStmt *caseStmt) { |
---|
29 | std::list< Statement * > &stmts = caseStmt->get_statements(); |
---|
30 | |
---|
31 | if ( insideChoose ) { |
---|
32 | BranchStmt *posBrk; |
---|
33 | if ( (( posBrk = dynamic_cast< BranchStmt * > ( stmts.back() ) ) && |
---|
34 | ( posBrk->get_type() == BranchStmt::Break )) // last statement in the list is a (superfluous) 'break' |
---|
35 | || dynamic_cast< FallthruStmt * > ( stmts.back() ) ) |
---|
36 | ; |
---|
37 | else { |
---|
38 | stmts.push_back( new BranchStmt( std::list< Label >(), "", BranchStmt::Break ) ); |
---|
39 | } // if |
---|
40 | } // if |
---|
41 | |
---|
42 | mutateAll ( stmts, *this ); |
---|
43 | return caseStmt; |
---|
44 | } |
---|
45 | } // namespace ControlStruct |
---|
Note: See
TracBrowser
for help on using the repository browser.