[b0b958a] | 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
|
---|
[4e06c1e] | 11 | // Last Modified By : Peter A. Buhr
|
---|
[6b0b624] | 12 | // Last Modified On : Sat Jul 22 09:21:12 2017
|
---|
| 13 | // Update Count : 4
|
---|
[b0b958a] | 14 | //
|
---|
| 15 |
|
---|
[6b0b624] | 16 | #pragma once
|
---|
[b0b958a] | 17 |
|
---|
[08fc48f] | 18 | #include <list> // for list
|
---|
| 19 | #include <vector> // for vector
|
---|
[b0b958a] | 20 |
|
---|
[08fc48f] | 21 | #include "SynTree/Mutator.h" // for Mutator
|
---|
| 22 | #include "SynTree/SynTree.h" // for Visitor Nodes
|
---|
[b0b958a] | 23 |
|
---|
| 24 | namespace GenPoly {
|
---|
| 25 | /// Mutates a list of declarations, providing a means of adding new declarations into the list
|
---|
| 26 | class DeclMutator : public Mutator {
|
---|
[6b0b624] | 27 | public:
|
---|
[5f98ce5] | 28 | typedef Mutator Parent;
|
---|
| 29 |
|
---|
[b0b958a] | 30 | DeclMutator();
|
---|
| 31 | virtual ~DeclMutator();
|
---|
[5f98ce5] | 32 |
|
---|
| 33 | using Parent::mutate;
|
---|
[b0b958a] | 34 | virtual CompoundStmt* mutate(CompoundStmt *compoundStmt);
|
---|
| 35 | virtual Statement* mutate(IfStmt *ifStmt);
|
---|
| 36 | virtual Statement* mutate(WhileStmt *whileStmt);
|
---|
| 37 | virtual Statement* mutate(ForStmt *forStmt);
|
---|
| 38 | virtual Statement* mutate(SwitchStmt *switchStmt);
|
---|
| 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);
|
---|
[5f98ce5] | 45 |
|
---|
[b0b958a] | 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();
|
---|
[6b0b624] | 50 | protected:
|
---|
[b0b958a] | 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 );
|
---|
[dbd8652] | 57 | /// Add a declaration to the list to be added after the current position
|
---|
| 58 | void addDeclarationAfter( Declaration* decl );
|
---|
[6b0b624] | 59 | private:
|
---|
[b0b958a] | 60 | /// A stack of declarations to add before the current declaration or statement
|
---|
| 61 | std::vector< std::list< Declaration* > > declsToAdd;
|
---|
[dbd8652] | 62 | /// A stack of declarations to add after the current declaration or statement
|
---|
| 63 | std::vector< std::list< Declaration* > > declsToAddAfter;
|
---|
[b0b958a] | 64 | };
|
---|
| 65 | } // namespace
|
---|
| 66 |
|
---|
| 67 | // Local Variables: //
|
---|
| 68 | // tab-width: 4 //
|
---|
| 69 | // mode: c++ //
|
---|
| 70 | // compile-command: "make install" //
|
---|
| 71 | // End: //
|
---|