[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 | |
---|
[78dd0da] | 19 | #include <string> |
---|
| 20 | |
---|
[51b7345] | 21 | #include "GenPoly.h" |
---|
| 22 | |
---|
| 23 | #include "SynTree/SynTree.h" |
---|
| 24 | #include "SynTree/Mutator.h" |
---|
| 25 | |
---|
| 26 | namespace GenPoly { |
---|
[01aeade] | 27 | class ScrubTyVars : public Mutator { |
---|
| 28 | public: |
---|
[ebe9b3a] | 29 | ScrubTyVars( const TyVarMap &tyVars ): tyVars( tyVars ) {} |
---|
[f8b961b] | 30 | |
---|
[ebe9b3a] | 31 | /// For all polymorphic types with type variables in `tyVars`, replaces generic types, dtypes, and ftypes with the appropriate void type, |
---|
| 32 | /// and sizeof/alignof expressions with the proper variable |
---|
[01aeade] | 33 | template< typename SynTreeClass > |
---|
| 34 | static SynTreeClass *scrub( SynTreeClass *target, const TyVarMap &tyVars ); |
---|
[b18b0b5] | 35 | |
---|
[01aeade] | 36 | virtual Type* mutate( TypeInstType *typeInst ); |
---|
[b18b0b5] | 37 | virtual Type* mutate( StructInstType *structInst ); |
---|
| 38 | virtual Type* mutate( UnionInstType *unionInst ); |
---|
| 39 | virtual Expression* mutate( SizeofExpr *szeof ); |
---|
| 40 | virtual Expression* mutate( AlignofExpr *algnof ); |
---|
[01aeade] | 41 | virtual Type* mutate( PointerType *pointer ); |
---|
[b18b0b5] | 42 | |
---|
[01aeade] | 43 | private: |
---|
[b18b0b5] | 44 | /// Mutates (possibly generic) aggregate types appropriately |
---|
| 45 | Type* mutateAggregateType( Type *ty ); |
---|
| 46 | |
---|
[01aeade] | 47 | const TyVarMap &tyVars; |
---|
| 48 | }; |
---|
| 49 | |
---|
| 50 | /* static class method */ |
---|
[bdd516a] | 51 | template< typename SynTreeClass > |
---|
[01aeade] | 52 | SynTreeClass * ScrubTyVars::scrub( SynTreeClass *target, const TyVarMap &tyVars ) { |
---|
[ebe9b3a] | 53 | ScrubTyVars scrubber( tyVars ); |
---|
[01aeade] | 54 | return static_cast< SynTreeClass * >( target->acceptMutator( scrubber ) ); |
---|
| 55 | } |
---|
| 56 | |
---|
[51b7345] | 57 | } // namespace GenPoly |
---|
| 58 | |
---|
[01aeade] | 59 | #endif // _SCRUBTYVARS_H |
---|
| 60 | |
---|
[51587aa] | 61 | // Local Variables: // |
---|
| 62 | // tab-width: 4 // |
---|
| 63 | // mode: c++ // |
---|
| 64 | // compile-command: "make install" // |
---|
| 65 | // End: // |
---|