// // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo // // The contents of this file are covered under the licence agreement in the // file "LICENCE" distributed with Cforall. // // MLEMutator.h -- // // Author : Rodolfo G. Esteves // Created On : Mon May 18 07:44:20 2015 // Last Modified By : Rob Schluntz // Last Modified On : Tue May 26 15:04:21 2015 // Update Count : 7 // #ifndef MLE_MUTATOR_H #define MLE_MUTATOR_H #include #include #include "utility.h" #include "SynTree/SynTree.h" #include "SynTree/Mutator.h" #include "LabelGenerator.h" namespace ControlStruct { class MLEMutator : public Mutator { class Entry; public: MLEMutator( std::map *t, LabelGenerator *gen = 0 ) : targetTable( t ), breakLabel(std::string("")), generator( gen ) {} ~MLEMutator(); CompoundStmt *mutate( CompoundStmt *cmpndStmt ); Statement *mutate( WhileStmt *whileStmt ); Statement *mutate( ForStmt *forStmt ); Statement *mutate( BranchStmt *branchStmt ) throw ( SemanticError ); Statement *mutate( SwitchStmt *switchStmt ); Statement *mutate( ChooseStmt *switchStmt ); Statement *mutateLoop( Statement *bodyLoop, Entry &e ); Label &get_breakLabel() { return breakLabel; } void set_breakLabel( Label newValue ) { breakLabel = newValue; } private: class Entry { public: explicit Entry( Statement *_loop = 0, Label _contExit = Label(""), Label _breakExit = Label("") ) : loop( _loop ), contExit( _contExit ), breakExit( _breakExit ), contExitUsed( false ), breakExitUsed( false ) {} bool operator==( const Statement *stmt ) { return ( loop == stmt ); } bool operator!=( const Statement *stmt ) { return ( loop != stmt ); } bool operator==( const Entry &other ) { return ( loop == other.get_loop() ); } Statement *get_loop() const { return loop; } Label get_contExit() const { return contExit; } void set_contExit( Label ); Label get_breakExit() const { return breakExit; } void set_breakExit( Label ); private: Statement *loop; Label contExit, breakExit; public: // hack, provide proper [sg]etters bool contExitUsed, breakExitUsed; }; std::map< Label, Statement * > *targetTable; std::list< Entry > enclosingBlocks, enclosingLoops, enclosingSwitches; Label breakLabel; LabelGenerator *generator; template< typename SwitchClass > friend Statement *handleSwitchStmt( SwitchClass *switchStmt, MLEMutator &mutator ); }; } // namespace ControlStruct #endif // MLE_MUTATOR_H // Local Variables: // // tab-width: 4 // // mode: c++ // // compile-command: "make install" // // End: //