source: translator/ControlStruct/MLEMutator.h @ 01aeade

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 01aeade was 51587aa, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

licencing: fourth groups of files

  • Property mode set to 100644
File size: 2.5 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// XXX.cc --
8//
9// Author           : Richard C. Bilson
10// Created On       : Mon May 18 07:44:20 2015
11// Last Modified By :
12// Last Modified On :
13// Update Count     : 0
14//
15#ifndef MLE_MUTATOR_H
16#define MLE_MUTATOR_H
17
18#include <map>
19#include <list>
20
21#include "utility.h"
22#include "SynTree/SynTree.h"
23#include "SynTree/Mutator.h"
24
25#include "LabelGenerator.h"
26
27namespace ControlStruct {
28    class MLEMutator : public Mutator {
29        class Entry;
30      public:
31        MLEMutator( std::map<Label, Statement *> *t, LabelGenerator *gen = 0 ) : targetTable( t ), breakLabel(std::string("")), generator( gen ) {}
32        ~MLEMutator();
33
34        CompoundStmt *mutate( CompoundStmt *cmpndStmt );
35        Statement *mutate( WhileStmt *whileStmt );
36        Statement *mutate( ForStmt *forStmt );
37        Statement *mutate( BranchStmt *branchStmt ) throw ( SemanticError );
38
39        Statement *mutate( SwitchStmt *switchStmt );
40        Statement *mutate( ChooseStmt *switchStmt );
41
42        Statement *mutateLoop( Statement *bodyLoop, Entry &e );
43
44        Label &get_breakLabel() { return breakLabel; }
45        void set_breakLabel( Label newValue ) { breakLabel = newValue; }
46      private:
47        class Entry {
48          public:
49            explicit Entry( Statement *_loop = 0, Label _contExit = Label(""), Label _breakExit = Label("") ) :
50                loop( _loop ), contExit( _contExit ), breakExit( _breakExit ), contExitUsed( false ), breakExitUsed( false ) {}
51
52            bool operator==( const Statement *stmt ) { return ( loop == stmt ); }
53            bool operator!=( const Statement *stmt ) { return ( loop != stmt ); }
54
55            bool operator==( const Entry &other ) { return ( loop == other.get_loop() ); }
56
57            Statement *get_loop() const { return loop; }
58
59            Label get_contExit() const { return contExit; }
60            void set_contExit( Label );
61
62            Label get_breakExit() const { return breakExit; }
63            void set_breakExit( Label );
64
65          private:
66            Statement *loop;
67            Label contExit, breakExit;
68          public: // hack, provide proper [sg]etters
69            bool contExitUsed, breakExitUsed;
70        };
71
72        std::map< Label, Statement * > *targetTable;
73        std::list< Entry > enclosingBlocks, enclosingLoops, enclosingSwitches;
74        Label breakLabel;
75        LabelGenerator *generator;
76    };
77
78} // namespace ControlStruct
79
80#endif
81
82/*
83  Local Variables:
84  mode: c++
85  End:
86*/
87// Local Variables: //
88// tab-width: 4 //
89// mode: c++ //
90// compile-command: "make install" //
91// End: //
Note: See TracBrowser for help on using the repository browser.