[51b7345] | 1 | /* |
---|
| 2 | * This file is part of the Cforall project |
---|
| 3 | * |
---|
| 4 | * $Id: PolyMutator.h,v 1.8 2005/08/29 20:14:13 rcbilson Exp $ |
---|
| 5 | * |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #ifndef GENPOLY_POLYMUTATOR_H |
---|
| 9 | #define GENPOLY_POLYMUTATOR_H |
---|
| 10 | |
---|
| 11 | #include <map> |
---|
| 12 | #include <string> |
---|
| 13 | #include <list> |
---|
| 14 | |
---|
| 15 | #include "GenPoly.h" |
---|
| 16 | |
---|
| 17 | #include "SynTree/SynTree.h" |
---|
| 18 | #include "SynTree/Declaration.h" |
---|
| 19 | #include "SynTree/Mutator.h" |
---|
| 20 | |
---|
| 21 | namespace GenPoly { |
---|
| 22 | |
---|
| 23 | class PolyMutator : public Mutator |
---|
| 24 | { |
---|
| 25 | public: |
---|
| 26 | PolyMutator(); |
---|
| 27 | |
---|
| 28 | virtual CompoundStmt* mutate(CompoundStmt *compoundStmt); |
---|
| 29 | virtual Statement* mutate(IfStmt *ifStmt); |
---|
| 30 | virtual Statement* mutate(WhileStmt *whileStmt); |
---|
| 31 | virtual Statement* mutate(ForStmt *forStmt); |
---|
| 32 | virtual Statement* mutate(SwitchStmt *switchStmt); |
---|
| 33 | virtual Statement* mutate(ChooseStmt *chooseStmt); |
---|
| 34 | virtual Statement* mutate(CaseStmt *caseStmt); |
---|
| 35 | virtual Statement* mutate(TryStmt *returnStmt); |
---|
| 36 | virtual Statement* mutate(CatchStmt *catchStmt); |
---|
| 37 | virtual Statement* mutate(ExprStmt *catchStmt); |
---|
| 38 | virtual Statement* mutate(ReturnStmt *catchStmt); |
---|
| 39 | |
---|
| 40 | virtual Expression* mutate(UntypedExpr *untypedExpr); |
---|
| 41 | |
---|
| 42 | // template method |
---|
[b1a6d6b] | 43 | virtual void doBeginScope() {} |
---|
[51b7345] | 44 | virtual void doEndScope() {} |
---|
| 45 | |
---|
| 46 | protected: |
---|
| 47 | void mutateStatementList( std::list< Statement* > &statements ); |
---|
| 48 | Statement* mutateStatement( Statement *stmt ); |
---|
| 49 | Expression* mutateExpression( Expression *expr ); |
---|
| 50 | static void makeTyVarMap( Type *type, TyVarMap &tyVarMap ); |
---|
| 51 | |
---|
| 52 | TyVarMap scopeTyVars; |
---|
| 53 | TypeSubstitution *env; |
---|
| 54 | std::list< Statement* > stmtsToAdd; |
---|
| 55 | std::list< Statement* > stmtsToAddAfter; |
---|
| 56 | }; |
---|
| 57 | |
---|
| 58 | } // namespace |
---|
| 59 | |
---|
| 60 | #endif /* #ifndef GENPOLY_POLYMUTATOR_H */ |
---|