source: src/ControlStruct/ChooseMutator.cc @ 09a9a8b

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 09a9a8b 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
RevLine 
[51587aa]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//
[a08ba92]7// ChooseMutator.cc --
[51587aa]8//
[843054c2]9// Author           : Rodolfo G. Esteves
[51587aa]10// Created On       : Mon May 18 07:44:20 2015
[a08ba92]11// Last Modified By : Peter A. Buhr
12// Last Modified On : Tue May 19 15:31:39 2015
13// Update Count     : 2
[51587aa]14//
[a08ba92]15
[51b7345]16#include <list>
17
18#include "SynTree/Statement.h"
19#include "ChooseMutator.h"
20
21namespace ControlStruct {
[a08ba92]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        }
[51b7345]29
[a08ba92]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        }
[51b7345]37
[a08ba92]38        Statement *ChooseMutator::mutate( FallthruStmt *fallthruStmt ) {
39                delete fallthruStmt;
40                return new NullStmt();
41        }
[51b7345]42
[a08ba92]43        Statement* ChooseMutator::mutate( CaseStmt *caseStmt ) {
44                std::list< Statement * > &stmts = caseStmt->get_statements();
[d9a0e76]45
[a08ba92]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
[d9a0e76]56
[a08ba92]57                mutateAll ( stmts, *this );
58                return caseStmt;
59        }
[51b7345]60} // namespace ControlStruct
[a08ba92]61
[51587aa]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.