source: translator/ControlStruct/MLEMutator.h @ 0dd3a2f

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 0dd3a2f was 6c3744e, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

add list initializer, formatting changes

  • Property mode set to 100644
File size: 2.0 KB
RevLine 
[51b7345]1#ifndef MLE_MUTATOR_H
2#define MLE_MUTATOR_H
3
4#include <map>
5#include <list>
6
7#include "utility.h"
8#include "SynTree/SynTree.h"
9#include "SynTree/Mutator.h"
10
11#include "LabelGenerator.h"
12
13namespace ControlStruct {
[d9a0e76]14    class MLEMutator : public Mutator {
15        class Entry;
16      public:
[6c3744e]17        MLEMutator( std::map<Label, Statement *> *t, LabelGenerator *gen = 0 ) : targetTable( t ), breakLabel(std::string("")), generator( gen ) {}
[d9a0e76]18        ~MLEMutator();
19
20        CompoundStmt *mutate( CompoundStmt *cmpndStmt );
21        Statement *mutate( WhileStmt *whileStmt );
22        Statement *mutate( ForStmt *forStmt );
23        Statement *mutate( BranchStmt *branchStmt ) throw ( SemanticError );
24
25        Statement *mutate( SwitchStmt *switchStmt );
26        Statement *mutate( ChooseStmt *switchStmt );
27
28        Statement *mutateLoop( Statement *bodyLoop, Entry &e );
29
30        Label &get_breakLabel() { return breakLabel; }
31        void set_breakLabel( Label newValue ) { breakLabel = newValue; }
32      private:
33        class Entry {
34          public:
35            explicit Entry( Statement *_loop = 0, Label _contExit = Label(""), Label _breakExit = Label("") ) :
36                loop( _loop ), contExit( _contExit ), breakExit( _breakExit ), contExitUsed( false ), breakExitUsed( false ) {}
37
38            bool operator==( const Statement *stmt ) { return ( loop == stmt ); }
39            bool operator!=( const Statement *stmt ) { return ( loop != stmt ); }
40
41            bool operator==( const Entry &other ) { return ( loop == other.get_loop() ); }
42
43            Statement *get_loop() const { return loop; }
44
45            Label get_contExit() const { return contExit; }
46            void set_contExit( Label );
47
48            Label get_breakExit() const { return breakExit; }
49            void set_breakExit( Label );
50
51          private:
52            Statement *loop;
53            Label contExit, breakExit;
54          public: // hack, provide proper [sg]etters
55            bool contExitUsed, breakExitUsed;
56        };
57
[6c3744e]58        std::map< Label, Statement * > *targetTable;
59        std::list< Entry > enclosingBlocks, enclosingLoops, enclosingSwitches;
[d9a0e76]60        Label breakLabel;
61        LabelGenerator *generator;
[51b7345]62    };
63
64} // namespace ControlStruct
65
66#endif
67
68/*
69  Local Variables:
70  mode: c++
71  End:
72*/
Note: See TracBrowser for help on using the repository browser.