source: src/ControlStruct/MLEMutator.h @ 888cbe4

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 888cbe4 was 0f8e4ac, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

change Label from a string typedef to a class

  • Property mode set to 100644
File size: 2.7 KB
RevLine 
[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//
[0f8e4ac]7// MLEMutator.h --
[51587aa]8//
[843054c2]9// Author           : Rodolfo G. Esteves
[51587aa]10// Created On       : Mon May 18 07:44:20 2015
[be5aa1b]11// Last Modified By : Rob Schluntz
[27de955]12// Last Modified On : Wed Jun 03 15:06:36 2015
13// Update Count     : 25
[51587aa]14//
[a08ba92]15
[51b7345]16#ifndef MLE_MUTATOR_H
17#define MLE_MUTATOR_H
18
19#include <map>
20#include <list>
21
[d3b7937]22#include "Common/utility.h"
[51b7345]23#include "SynTree/SynTree.h"
24#include "SynTree/Mutator.h"
[0f8e4ac]25#include "SynTree/Label.h"
[51b7345]26
27#include "LabelGenerator.h"
28
29namespace ControlStruct {
[a08ba92]30        class MLEMutator : public Mutator {
31                class Entry;
[d9a0e76]32          public:
[a08ba92]33                MLEMutator( std::map<Label, Statement *> *t, LabelGenerator *gen = 0 ) : targetTable( t ), breakLabel(std::string("")), generator( gen ) {}
34                ~MLEMutator();
[d9a0e76]35
[a08ba92]36                CompoundStmt *mutate( CompoundStmt *cmpndStmt );
37                Statement *mutate( WhileStmt *whileStmt );
38                Statement *mutate( ForStmt *forStmt );
39                Statement *mutate( BranchStmt *branchStmt ) throw ( SemanticError );
[d9a0e76]40
[0f8e4ac]41                Statement *mutate( CaseStmt *caseStmt );
[a08ba92]42                Statement *mutate( SwitchStmt *switchStmt );
43                Statement *mutate( ChooseStmt *switchStmt );
[d9a0e76]44
[a08ba92]45                Statement *mutateLoop( Statement *bodyLoop, Entry &e );
[d9a0e76]46
[a08ba92]47                Label &get_breakLabel() { return breakLabel; }
48                void set_breakLabel( Label newValue ) { breakLabel = newValue; }
49          private:
50                class Entry {
51                  public:
[27de955]52                        explicit Entry( Statement *_loop, Label _breakExit, Label _contExit = Label("") ) :
53                                loop( _loop ), breakExit( _breakExit ), contExit( _contExit ), breakUsed(false), contUsed(false) {}
[d9a0e76]54
[a08ba92]55                        bool operator==( const Statement *stmt ) { return ( loop == stmt ); }
56                        bool operator!=( const Statement *stmt ) { return ( loop != stmt ); }
[d9a0e76]57
[a08ba92]58                        bool operator==( const Entry &other ) { return ( loop == other.get_loop() ); }
[d9a0e76]59
[a08ba92]60                        Statement *get_loop() const { return loop; }
[51b7345]61
[27de955]62                        Label useContExit() { contUsed = true; return contExit; }
63                        Label useBreakExit() { breakUsed = true; return breakExit; }
[a08ba92]64
[27de955]65                        bool isContUsed() const { return contUsed; }
66                        bool isBreakUsed() const { return breakUsed; }
[a08ba92]67
68                  private:
69                        Statement *loop;
[27de955]70                        Label breakExit, contExit;
71                        bool breakUsed, contUsed;
[a08ba92]72                };
73
74                std::map< Label, Statement * > *targetTable;
75                std::list< Entry > enclosingBlocks, enclosingLoops, enclosingSwitches;
76                Label breakLabel;
77                LabelGenerator *generator;
[be5aa1b]78
[27de955]79                template< typename LoopClass >
80                Statement *handleLoopStmt( LoopClass *loopStmt );
81
[0f8e4ac]82                template< typename SwitchClass >
[27de955]83                Statement *handleSwitchStmt( SwitchClass *switchStmt );
84
85                void fixBlock( std::list< Statement * > &kids );
[a08ba92]86        };
[51b7345]87} // namespace ControlStruct
88
[a08ba92]89#endif // MLE_MUTATOR_H
[51b7345]90
[51587aa]91// Local Variables: //
92// tab-width: 4 //
93// mode: c++ //
94// compile-command: "make install" //
95// End: //
Note: See TracBrowser for help on using the repository browser.