source: src/ControlStruct/MLEMutator.h @ bff09c8

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since bff09c8 was d180746, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

Big header cleaning pass - commit 2

  • Property mode set to 100644
File size: 3.1 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 : Sat Jul 22 09:19:59 2017
13// Update Count     : 35
14//
15
16#pragma once
17
18#include <list>                    // for list
19#include <map>                     // for map
20#include <string>                  // for string
21
22#include "Common/SemanticError.h"  // for SemanticError
23#include "SynTree/Label.h"         // for Label
24#include "SynTree/Mutator.h"       // for Mutator
25#include "SynTree/SynTree.h"       // for Visitor Nodes
26
27namespace ControlStruct {
28class LabelGenerator;
29
30        class MLEMutator : public Mutator {
31                class Entry;
32
33                typedef Mutator Parent;
34          public:
35                MLEMutator( std::map<Label, Statement *> *t, LabelGenerator *gen = 0 ) : targetTable( t ), breakLabel(std::string("")), generator( gen ) {}
36                ~MLEMutator();
37
38                virtual CompoundStmt *mutate( CompoundStmt *cmpndStmt ) override;
39                virtual Statement *mutate( WhileStmt *whileStmt ) override;
40                virtual Statement *mutate( ForStmt *forStmt ) override;
41                virtual Statement *mutate( BranchStmt *branchStmt ) throw ( SemanticError ) override;
42                virtual Statement *mutate( CaseStmt *caseStmt ) override;
43                virtual Statement *mutate( IfStmt *ifStmt ) override;
44                virtual Statement *mutate( SwitchStmt *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// Local Variables: //
93// tab-width: 4 //
94// mode: c++ //
95// compile-command: "make install" //
96// End: //
Note: See TracBrowser for help on using the repository browser.