Changeset d9a0e76 for translator/ControlStruct/ChooseMutator.cc
- Timestamp:
- Dec 16, 2014, 9:41:50 PM (10 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 17cd4eb
- Parents:
- 3848e0e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
translator/ControlStruct/ChooseMutator.cc
r3848e0e rd9a0e76 5 5 6 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 } 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() ); 48 13 } 49 14 50 mutateAll ( stmts, *this ); 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 } 51 22 52 return caseStmt; 53 } 23 Statement *ChooseMutator::mutate( FallthruStmt *fallthruStmt ) { 24 delete fallthruStmt; 25 return new NullStmt(); 26 } 54 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 } 55 45 } // namespace ControlStruct
Note: See TracChangeset
for help on using the changeset viewer.