source: src/GenPoly/DeclMutator.h @ be945ac

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since be945ac was dbd8652, checked in by Aaron Moss <a3moss@…>, 9 years ago

Add capability to add declarations after current one to DeclMutator?

  • 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 : Aaron B. Moss
12// Last Modified On : Fri Nov 27 14:44:00 2015
13// Update Count     : 1
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                DeclMutator();
31                virtual ~DeclMutator();
32               
33                virtual CompoundStmt* mutate(CompoundStmt *compoundStmt);
34                virtual Statement* mutate(IfStmt *ifStmt);
35                virtual Statement* mutate(WhileStmt *whileStmt);
36                virtual Statement* mutate(ForStmt *forStmt);
37                virtual Statement* mutate(SwitchStmt *switchStmt);
38                virtual Statement* mutate(ChooseStmt *chooseStmt);
39                virtual Statement* mutate(CaseStmt *caseStmt);
40                virtual Statement* mutate(TryStmt *tryStmt);
41                virtual Statement* mutate(CatchStmt *catchStmt);
42
43                /// Mutates a list of declarations with this visitor
44                void mutateDeclarationList(std::list< Declaration* >& decls);
45               
46                /// Called on entry to a new scope; overriders should call this as a super-class call
47                virtual void doBeginScope();
48                /// Called on exit from a scope; overriders should call this as a super-class call
49                virtual void doEndScope();
50        protected:
51                /// Mutate a statement that forms its own scope
52                Statement* mutateStatement( Statement *stmt );
53                /// Mutate a list of statements that form a scope
54                void mutateStatementList( std::list< Statement* > &stmts );
55                /// Add a declaration to the list to be added before the current position
56                void addDeclaration( Declaration* decl );
57                /// Add a declaration to the list to be added after the current position
58                void addDeclarationAfter( Declaration* decl );
59        private:
60                /// A stack of declarations to add before the current declaration or statement
61                std::vector< std::list< Declaration* > > declsToAdd;
62                /// A stack of declarations to add after the current declaration or statement
63                std::vector< std::list< Declaration* > > declsToAddAfter;
64        };
65} // namespace
66
67#endif // _DECLMUTATOR_H
68
69// Local Variables: //
70// tab-width: 4 //
71// mode: c++ //
72// compile-command: "make install" //
73// End: //
Note: See TracBrowser for help on using the repository browser.