[51587aa] | 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 | // |
---|
[01aeade] | 7 | // ScrubTyVars.h -- |
---|
[51587aa] | 8 | // |
---|
| 9 | // Author : Richard C. Bilson |
---|
| 10 | // Created On : Mon May 18 07:44:20 2015 |
---|
[01aeade] | 11 | // Last Modified By : Peter A. Buhr |
---|
| 12 | // Last Modified On : Tue May 19 07:48:14 2015 |
---|
| 13 | // Update Count : 1 |
---|
[51587aa] | 14 | // |
---|
[01aeade] | 15 | |
---|
| 16 | #ifndef _SCRUBTYVARS_H |
---|
| 17 | #define _SCRUBTYVARS_H |
---|
[51b7345] | 18 | |
---|
| 19 | #include "GenPoly.h" |
---|
| 20 | |
---|
| 21 | #include "SynTree/SynTree.h" |
---|
| 22 | #include "SynTree/Mutator.h" |
---|
| 23 | |
---|
| 24 | namespace GenPoly { |
---|
[01aeade] | 25 | class ScrubTyVars : public Mutator { |
---|
| 26 | public: |
---|
| 27 | ScrubTyVars( bool doAll, const TyVarMap &tyVars ): doAll( doAll ), tyVars( tyVars ) {} |
---|
| 28 | |
---|
| 29 | template< typename SynTreeClass > |
---|
| 30 | static SynTreeClass *scrub( SynTreeClass *target, const TyVarMap &tyVars ); |
---|
| 31 | template< typename SynTreeClass > |
---|
| 32 | static SynTreeClass *scrub( SynTreeClass *target ); |
---|
[51b7345] | 33 | |
---|
[01aeade] | 34 | virtual Type* mutate( TypeInstType *typeInst ); |
---|
| 35 | Expression* mutate( SizeofExpr *szeof ); |
---|
| 36 | virtual Type* mutate( PointerType *pointer ); |
---|
| 37 | private: |
---|
| 38 | bool doAll; |
---|
| 39 | const TyVarMap &tyVars; |
---|
| 40 | }; |
---|
| 41 | |
---|
| 42 | /* static class method */ |
---|
[bdd516a] | 43 | template< typename SynTreeClass > |
---|
[01aeade] | 44 | SynTreeClass * ScrubTyVars::scrub( SynTreeClass *target, const TyVarMap &tyVars ) { |
---|
| 45 | ScrubTyVars scrubber( false, tyVars ); |
---|
| 46 | return static_cast< SynTreeClass * >( target->acceptMutator( scrubber ) ); |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | /* static class method */ |
---|
[bdd516a] | 50 | template< typename SynTreeClass > |
---|
[01aeade] | 51 | SynTreeClass * ScrubTyVars::scrub( SynTreeClass *target ) { |
---|
| 52 | TyVarMap tyVars; |
---|
| 53 | ScrubTyVars scrubber( true, tyVars ); |
---|
| 54 | return static_cast< SynTreeClass* >( target->acceptMutator( scrubber ) ); |
---|
| 55 | } |
---|
[51b7345] | 56 | } // namespace GenPoly |
---|
| 57 | |
---|
[01aeade] | 58 | #endif // _SCRUBTYVARS_H |
---|
| 59 | |
---|
[51587aa] | 60 | // Local Variables: // |
---|
| 61 | // tab-width: 4 // |
---|
| 62 | // mode: c++ // |
---|
| 63 | // compile-command: "make install" // |
---|
| 64 | // End: // |
---|