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