source: src/GenPoly/DeclMutator.h @ d1969a6

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 d1969a6 was 5f98ce5, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

hoist non-constexpr array dimension into const variable in case of side effects

  • Property mode set to 100644
File size: 2.5 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// DeclMutator.h --
8//
9// Author           : Aaron B. Moss
10// Created On       : Fri Nov 27 14:44:00 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Tue Jul 12 17:39:01 2016
13// Update Count     : 2
14//
15
16#ifndef _DECLMUTATOR_H
17#define _DECLMUTATOR_H
18
19#include <list>
20#include <vector>
21
22#include "SynTree/SynTree.h"
23#include "SynTree/Declaration.h"
24#include "SynTree/Mutator.h"
25
26namespace GenPoly {
27        /// Mutates a list of declarations, providing a means of adding new declarations into the list
28        class DeclMutator : public Mutator {
29        public:
30                typedef Mutator Parent;
31
32                DeclMutator();
33                virtual ~DeclMutator();
34
35                using Parent::mutate;
36                virtual CompoundStmt* mutate(CompoundStmt *compoundStmt);
37                virtual Statement* mutate(IfStmt *ifStmt);
38                virtual Statement* mutate(WhileStmt *whileStmt);
39                virtual Statement* mutate(ForStmt *forStmt);
40                virtual Statement* mutate(SwitchStmt *switchStmt);
41                virtual Statement* mutate(CaseStmt *caseStmt);
42                virtual Statement* mutate(TryStmt *tryStmt);
43                virtual Statement* mutate(CatchStmt *catchStmt);
44
45                /// Mutates a list of declarations with this visitor
46                void mutateDeclarationList(std::list< Declaration* >& decls);
47
48                /// Called on entry to a new scope; overriders should call this as a super-class call
49                virtual void doBeginScope();
50                /// Called on exit from a scope; overriders should call this as a super-class call
51                virtual void doEndScope();
52        protected:
53                /// Mutate a statement that forms its own scope
54                Statement* mutateStatement( Statement *stmt );
55                /// Mutate a list of statements that form a scope
56                void mutateStatementList( std::list< Statement* > &stmts );
57                /// Add a declaration to the list to be added before the current position
58                void addDeclaration( Declaration* decl );
59                /// Add a declaration to the list to be added after the current position
60                void addDeclarationAfter( Declaration* decl );
61        private:
62                /// A stack of declarations to add before the current declaration or statement
63                std::vector< std::list< Declaration* > > declsToAdd;
64                /// A stack of declarations to add after the current declaration or statement
65                std::vector< std::list< Declaration* > > declsToAddAfter;
66        };
67} // namespace
68
69#endif // _DECLMUTATOR_H
70
71// Local Variables: //
72// tab-width: 4 //
73// mode: c++ //
74// compile-command: "make install" //
75// End: //
Note: See TracBrowser for help on using the repository browser.