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