source: src/ControlStruct/ChooseMutator.cc@ 2bae7307

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay gc_noraii jacob/cs343-translation jenkins-sandbox memory new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new string with_gc
Last change on this file since 2bae7307 was 843054c2, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

licencing: seventh groups of files

  • Property mode set to 100644
File size: 1.9 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// ChooseMutator.cc --
8//
9// Author : Rodolfo G. Esteves
10// Created On : Mon May 18 07:44:20 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Tue May 19 15:31:39 2015
13// Update Count : 2
14//
15
16#include <list>
17
18#include "SynTree/Statement.h"
19#include "ChooseMutator.h"
20
21namespace ControlStruct {
22 Statement *ChooseMutator::mutate( ChooseStmt *chooseStmt ) {
23 bool enclosingChoose = insideChoose;
24 insideChoose = true;
25 mutateAll( chooseStmt->get_branches(), *this );
26 insideChoose = enclosingChoose;
27 return new SwitchStmt( chooseStmt->get_labels(), chooseStmt->get_condition(), chooseStmt->get_branches() );
28 }
29
30 Statement *ChooseMutator::mutate( SwitchStmt *switchStmt ) {
31 bool enclosingChoose = insideChoose;
32 insideChoose = false;
33 mutateAll( switchStmt->get_branches(), *this );
34 insideChoose = enclosingChoose;
35 return switchStmt;
36 }
37
38 Statement *ChooseMutator::mutate( FallthruStmt *fallthruStmt ) {
39 delete fallthruStmt;
40 return new NullStmt();
41 }
42
43 Statement* ChooseMutator::mutate( CaseStmt *caseStmt ) {
44 std::list< Statement * > &stmts = caseStmt->get_statements();
45
46 if ( insideChoose ) {
47 BranchStmt *posBrk;
48 if ( (( posBrk = dynamic_cast< BranchStmt * > ( stmts.back() ) ) &&
49 ( posBrk->get_type() == BranchStmt::Break )) // last statement in the list is a (superfluous) 'break'
50 || dynamic_cast< FallthruStmt * > ( stmts.back() ) )
51 ;
52 else {
53 stmts.push_back( new BranchStmt( std::list< Label >(), "", BranchStmt::Break ) );
54 } // if
55 } // if
56
57 mutateAll ( stmts, *this );
58 return caseStmt;
59 }
60} // namespace ControlStruct
61
62// Local Variables: //
63// tab-width: 4 //
64// mode: c++ //
65// compile-command: "make install" //
66// End: //
Note: See TracBrowser for help on using the repository browser.