source: src/ControlStruct/MLEMutator.h @ a01f7c94

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 a01f7c94 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
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
[6b0b624]12// Last Modified On : Sat Jul 22 09:19:59 2017
13// Update Count     : 35
[51587aa]14//
[a08ba92]15
[6b0b624]16#pragma once
[51b7345]17
[d180746]18#include <list>                    // for list
19#include <map>                     // for map
20#include <string>                  // for string
[51b7345]21
[d180746]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
[51b7345]26
27namespace ControlStruct {
[d180746]28class LabelGenerator;
29
[a08ba92]30        class MLEMutator : public Mutator {
31                class Entry;
[d180746]32
[adcc065]33                typedef Mutator Parent;
[d9a0e76]34          public:
[a08ba92]35                MLEMutator( std::map<Label, Statement *> *t, LabelGenerator *gen = 0 ) : targetTable( t ), breakLabel(std::string("")), generator( gen ) {}
36                ~MLEMutator();
[d9a0e76]37
[6a37d13]38                virtual CompoundStmt *mutate( CompoundStmt *cmpndStmt ) override;
[adcc065]39                virtual Statement *mutate( WhileStmt *whileStmt ) override;
40                virtual Statement *mutate( ForStmt *forStmt ) override;
41                virtual Statement *mutate( BranchStmt *branchStmt ) throw ( SemanticError ) override;
[99f11dd]42                virtual Statement *mutate( CaseStmt *caseStmt ) override;
[adcc065]43                virtual Statement *mutate( IfStmt *ifStmt ) override;
44                virtual Statement *mutate( SwitchStmt *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; }
[51b7345]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        };
[51b7345]90} // namespace ControlStruct
91
[51587aa]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.