source: src/GenPoly/DeclMutator.h @ 6b0b624

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since 6b0b624 was 6b0b624, checked in by Peter A. Buhr <pabuhr@…>, 4 years ago

change #ifndef to #pragma once

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