[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 | |
---|
| 13 | namespace ControlStruct { |
---|
| 14 | |
---|
| 15 | class MLEMutator : public Mutator { |
---|
| 16 | class Entry; |
---|
| 17 | |
---|
| 18 | public: |
---|
| 19 | MLEMutator( std::map <Label, Statement *> *t, LabelGenerator *gen = 0 ) : targetTable( t ), breakLabel(std::string("")), generator( gen ) {} |
---|
| 20 | ~MLEMutator(); |
---|
| 21 | |
---|
| 22 | CompoundStmt *mutate( CompoundStmt *cmpndStmt ); |
---|
| 23 | Statement *mutate( WhileStmt *whileStmt ); |
---|
| 24 | Statement *mutate( ForStmt *forStmt ); |
---|
| 25 | Statement *mutate( BranchStmt *branchStmt ) throw ( SemanticError ); |
---|
| 26 | |
---|
| 27 | Statement *mutate( SwitchStmt *switchStmt ); |
---|
| 28 | Statement *mutate( ChooseStmt *switchStmt ); |
---|
| 29 | |
---|
| 30 | Statement *mutateLoop( Statement *bodyLoop, Entry &e ); |
---|
| 31 | |
---|
| 32 | Label &get_breakLabel() { return breakLabel; } |
---|
| 33 | void set_breakLabel( Label newValue ) { breakLabel = newValue; } |
---|
| 34 | |
---|
| 35 | private: |
---|
| 36 | class Entry { |
---|
| 37 | public: |
---|
| 38 | explicit Entry( Statement *_loop = 0, Label _contExit = Label(""), Label _breakExit = Label("") ) : |
---|
| 39 | loop( _loop ), contExit( _contExit ), breakExit( _breakExit ), contExitUsed( false ), breakExitUsed( false ) {} |
---|
| 40 | |
---|
| 41 | bool operator==( const Statement *stmt ) { return ( loop == stmt ) ; } |
---|
| 42 | bool operator!=( const Statement *stmt ) { return ( loop != stmt ) ; } |
---|
| 43 | |
---|
| 44 | bool operator==( const Entry &other ) { return ( loop == other.get_loop() ) ; } |
---|
| 45 | |
---|
| 46 | Statement *get_loop() const { return loop; } |
---|
| 47 | |
---|
| 48 | Label get_contExit() const { return contExit; } |
---|
| 49 | void set_contExit( Label ); |
---|
| 50 | |
---|
| 51 | Label get_breakExit() const { return breakExit; } |
---|
| 52 | void set_breakExit( Label ); |
---|
| 53 | |
---|
| 54 | private: |
---|
| 55 | Statement *loop; |
---|
| 56 | Label contExit, breakExit; |
---|
| 57 | public: // hack, provide proper [sg]etters |
---|
| 58 | bool contExitUsed, breakExitUsed; |
---|
| 59 | }; |
---|
| 60 | |
---|
| 61 | std::map <Label, Statement *> *targetTable; |
---|
| 62 | std::list < Entry > enclosingBlocks,enclosingLoops,enclosingSwitches; |
---|
| 63 | Label breakLabel; |
---|
| 64 | LabelGenerator *generator; |
---|
| 65 | }; |
---|
| 66 | |
---|
| 67 | } // namespace ControlStruct |
---|
| 68 | |
---|
| 69 | #endif |
---|
| 70 | |
---|
| 71 | /* |
---|
| 72 | Local Variables: |
---|
| 73 | mode: c++ |
---|
| 74 | End: |
---|
| 75 | */ |
---|