Changes in src/ControlStruct/MLEMutator.h [720a007:a16764a6]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ControlStruct/MLEMutator.h
r720a007 ra16764a6 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 8 16:42:32 201813 // Update Count : 4112 // Last Modified On : Sat Jul 22 09:19:59 2017 13 // Update Count : 35 14 14 // 15 15 … … 19 19 #include <map> // for map 20 20 #include <string> // for string 21 #include <set> // for unordered_set22 21 23 22 #include "Common/PassVisitor.h" … … 30 29 class LabelGenerator; 31 30 32 class MLEMutator : public WithVisitorRef<MLEMutator>, public WithShortCircuiting, public WithGuards { 31 class MLEMutator : public WithVisitorRef<MLEMutator>, public WithShortCircuiting { 32 class Entry; 33 33 34 public: 34 class Entry;35 35 MLEMutator( std::map<Label, Statement *> *t, LabelGenerator *gen = 0 ) : targetTable( t ), breakLabel(std::string("")), generator( gen ) {} 36 36 ~MLEMutator(); … … 52 52 Label &get_breakLabel() { return breakLabel; } 53 53 void set_breakLabel( Label newValue ) { breakLabel = newValue; } 54 54 private: 55 55 class Entry { 56 56 public: 57 // specialized constructors for each combination of statement with labelled break/continue/fallthrough that is valid to cleanup the use cases 58 explicit Entry( ForStmt *stmt, Label breakExit, Label contExit ) : 59 stmt( stmt ), breakExit( breakExit ), contExit( contExit ) {} 57 explicit Entry( Statement *_loop, Label _breakExit, Label _contExit = Label("") ) : 58 loop( _loop ), breakExit( _breakExit ), contExit( _contExit ), breakUsed(false), contUsed(false) {} 60 59 61 explicit Entry( WhileStmt *stmt, Label breakExit, Label contExit ) :62 stmt( stmt ), breakExit( breakExit ), contExit( contExit ) {}60 bool operator==( const Statement *stmt ) { return loop == stmt; } 61 bool operator!=( const Statement *stmt ) { return loop != stmt; } 63 62 64 explicit Entry( CompoundStmt *stmt, Label breakExit ) : 65 stmt( stmt ), breakExit( breakExit ) {} 63 bool operator==( const Entry &other ) { return loop == other.get_controlStructure(); } 66 64 67 explicit Entry( IfStmt *stmt, Label breakExit ) : 68 stmt( stmt ), breakExit( breakExit ) {} 69 70 explicit Entry( CaseStmt *stmt, Label fallExit ) : 71 stmt( stmt ), fallExit( fallExit ) {} 72 73 explicit Entry( SwitchStmt *stmt, Label breakExit, Label fallDefaultExit ) : 74 stmt( stmt ), breakExit( breakExit ), fallDefaultExit( fallDefaultExit ) {} 75 76 bool operator==( const Statement *other ) { return stmt == other; } 77 bool operator!=( const Statement *other ) { return stmt != other; } 78 79 bool operator==( const Entry &other ) { return stmt == other.get_controlStructure(); } 80 81 Statement *get_controlStructure() const { return stmt; } 65 Statement *get_controlStructure() const { return loop; } 82 66 83 67 Label useContExit() { contUsed = true; return contExit; } 84 68 Label useBreakExit() { breakUsed = true; return breakExit; } 85 Label useFallExit() { fallUsed = true; return fallExit; }86 Label useFallDefaultExit() { fallDefaultUsed = true; return fallDefaultExit; }87 69 88 70 bool isContUsed() const { return contUsed; } 89 71 bool isBreakUsed() const { return breakUsed; } 90 bool isFallUsed() const { return fallUsed; }91 bool isFallDefaultUsed() const { return fallDefaultUsed; }92 void seenDefault() { fallDefaultValid = false; }93 bool isFallDefaultValid() const { return fallDefaultValid; }94 72 private: 95 Statement *stmt; 96 Label breakExit, contExit, fallExit, fallDefaultExit; 97 bool breakUsed = false, contUsed = false, fallUsed = false, fallDefaultUsed = false; 98 bool fallDefaultValid = true; 73 Statement *loop; 74 Label breakExit, contExit; 75 bool breakUsed, contUsed; 99 76 }; 100 77 101 private:102 78 std::map< Label, Statement * > *targetTable; 103 std::set< Label > fallthroughLabels;104 79 std::list< Entry > enclosingControlStructures; 105 80 Label breakLabel; … … 112 87 Statement * posthandleLoopStmt( LoopClass * loopStmt ); 113 88 114 void fixBlock( std::list< Statement * > &kids , bool caseClause = false);89 void fixBlock( std::list< Statement * > &kids ); 115 90 }; 116 91 } // namespace ControlStruct
Note: See TracChangeset
for help on using the changeset viewer.