source: src/ControlStruct/MLEMutator.h@ 540b275

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 540b275 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
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
[adcc065]11// Last Modified By : Peter A. Buhr
[99f11dd]12// Last Modified On : Wed Jul 6 18:16:26 2016
13// Update Count : 33
[51587aa]14//
[a08ba92]15
[51b73452]16#ifndef MLE_MUTATOR_H
17#define MLE_MUTATOR_H
18
19#include <map>
20#include <list>
21
[d3b7937]22#include "Common/utility.h"
[51b73452]23#include "SynTree/SynTree.h"
24#include "SynTree/Mutator.h"
[0f8e4ac]25#include "SynTree/Label.h"
[51b73452]26
27#include "LabelGenerator.h"
28
29namespace ControlStruct {
[a08ba92]30 class MLEMutator : public Mutator {
31 class Entry;
[adcc065]32 typedef Mutator Parent;
[d9a0e76]33 public:
[a08ba92]34 MLEMutator( std::map<Label, Statement *> *t, LabelGenerator *gen = 0 ) : targetTable( t ), breakLabel(std::string("")), generator( gen ) {}
35 ~MLEMutator();
[d9a0e76]36
[6a37d13]37 virtual CompoundStmt *mutate( CompoundStmt *cmpndStmt ) override;
[adcc065]38 virtual Statement *mutate( WhileStmt *whileStmt ) override;
39 virtual Statement *mutate( ForStmt *forStmt ) override;
40 virtual Statement *mutate( BranchStmt *branchStmt ) throw ( SemanticError ) override;
[99f11dd]41 virtual Statement *mutate( CaseStmt *caseStmt ) override;
[adcc065]42 virtual Statement *mutate( IfStmt *ifStmt ) override;
43 virtual Statement *mutate( SwitchStmt *switchStmt ) override;
44 virtual Statement *mutate( ChooseStmt *switchStmt ) override;
[d9a0e76]45
[a08ba92]46 Statement *mutateLoop( Statement *bodyLoop, Entry &e );
[d9a0e76]47
[a08ba92]48 Label &get_breakLabel() { return breakLabel; }
49 void set_breakLabel( Label newValue ) { breakLabel = newValue; }
50 private:
51 class Entry {
52 public:
[27de955]53 explicit Entry( Statement *_loop, Label _breakExit, Label _contExit = Label("") ) :
54 loop( _loop ), breakExit( _breakExit ), contExit( _contExit ), breakUsed(false), contUsed(false) {}
[d9a0e76]55
[a08ba92]56 bool operator==( const Statement *stmt ) { return ( loop == stmt ); }
57 bool operator!=( const Statement *stmt ) { return ( loop != stmt ); }
[d9a0e76]58
[e39aa0f]59 bool operator==( const Entry &other ) { return ( loop == other.get_controlStructure() ); }
[d9a0e76]60
[e39aa0f]61 Statement *get_controlStructure() const { return loop; }
[51b73452]62
[27de955]63 Label useContExit() { contUsed = true; return contExit; }
64 Label useBreakExit() { breakUsed = true; return breakExit; }
[a08ba92]65
[27de955]66 bool isContUsed() const { return contUsed; }
67 bool isBreakUsed() const { return breakUsed; }
[a08ba92]68 private:
69 Statement *loop;
[27de955]70 Label breakExit, contExit;
71 bool breakUsed, contUsed;
[a08ba92]72 };
73
74 std::map< Label, Statement * > *targetTable;
[e39aa0f]75 std::list< Entry > enclosingControlStructures;
[a08ba92]76 Label breakLabel;
77 LabelGenerator *generator;
[be5aa1b]78
[27de955]79 template< typename LoopClass >
80 Statement *handleLoopStmt( LoopClass *loopStmt );
81
[adcc065]82 template< typename IfClass >
83 Statement *handleIfStmt( IfClass *switchStmt );
84
[0f8e4ac]85 template< typename SwitchClass >
[27de955]86 Statement *handleSwitchStmt( SwitchClass *switchStmt );
87
88 void fixBlock( std::list< Statement * > &kids );
[a08ba92]89 };
[51b73452]90} // namespace ControlStruct
91
[a08ba92]92#endif // MLE_MUTATOR_H
[51b73452]93
[51587aa]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.