source: src/ControlStruct/MLEMutator.h@ 6f72453

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox memory new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 6f72453 was 99f11dd, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

add deleted line when fixing conflict

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