source: src/GenPoly/DeclMutator.h @ 4e06c1e

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

changes for switch and choose statements

  • 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 : 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                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(CaseStmt *caseStmt);
39                virtual Statement* mutate(TryStmt *tryStmt);
40                virtual Statement* mutate(CatchStmt *catchStmt);
41
42                /// Mutates a list of declarations with this visitor
43                void mutateDeclarationList(std::list< Declaration* >& decls);
44               
45                /// Called on entry to a new scope; overriders should call this as a super-class call
46                virtual void doBeginScope();
47                /// Called on exit from a scope; overriders should call this as a super-class call
48                virtual void doEndScope();
49        protected:
50                /// Mutate a statement that forms its own scope
51                Statement* mutateStatement( Statement *stmt );
52                /// Mutate a list of statements that form a scope
53                void mutateStatementList( std::list< Statement* > &stmts );
54                /// Add a declaration to the list to be added before the current position
55                void addDeclaration( Declaration* decl );
56                /// Add a declaration to the list to be added after the current position
57                void addDeclarationAfter( Declaration* decl );
58        private:
59                /// A stack of declarations to add before the current declaration or statement
60                std::vector< std::list< Declaration* > > declsToAdd;
61                /// A stack of declarations to add after the current declaration or statement
62                std::vector< std::list< Declaration* > > declsToAddAfter;
63        };
64} // namespace
65
66#endif // _DECLMUTATOR_H
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.