source: src/GenPoly/ScrubTyVars.h @ b18b0b5

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since b18b0b5 was b18b0b5, checked in by Aaron Moss <a3moss@…>, 8 years ago

Replace generic type function parameters with void*

  • Property mode set to 100644
File size: 2.3 KB
Line 
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 <string>
20
21#include "GenPoly.h"
22
23#include "SynTree/SynTree.h"
24#include "SynTree/Mutator.h"
25
26namespace GenPoly {
27        class ScrubTyVars : public Mutator {
28          public:
29                ScrubTyVars( bool doAll, const TyVarMap &tyVars ): doAll( doAll ), tyVars( tyVars ) {}
30
31                /// Like scrub( SynTreeClass* ), but only applies to type variables in `tyVars`
32                template< typename SynTreeClass >
33                static SynTreeClass *scrub( SynTreeClass *target, const TyVarMap &tyVars );
34                /// Replaces dtypes and ftypes with the appropriate void type, and sizeof expressions of polymorphic types with the proper variable
35                template< typename SynTreeClass >
36                static SynTreeClass *scrub( SynTreeClass *target );
37
38                virtual Type* mutate( TypeInstType *typeInst );
39                virtual Type* mutate( StructInstType *structInst );
40                virtual Type* mutate( UnionInstType *unionInst );
41                virtual Expression* mutate( SizeofExpr *szeof );
42                virtual Expression* mutate( AlignofExpr *algnof );
43                virtual Type* mutate( PointerType *pointer );
44
45          private:
46                /// Mutates (possibly generic) aggregate types appropriately
47                Type* mutateAggregateType( Type *ty );
48               
49                bool doAll;
50                const TyVarMap &tyVars;
51        };
52
53        /* static class method */
54        template< typename SynTreeClass >
55        SynTreeClass * ScrubTyVars::scrub( SynTreeClass *target, const TyVarMap &tyVars ) {
56                ScrubTyVars scrubber( false, tyVars );
57                return static_cast< SynTreeClass * >( target->acceptMutator( scrubber ) );
58        }
59
60        /* static class method */
61        template< typename SynTreeClass >
62        SynTreeClass * ScrubTyVars::scrub( SynTreeClass *target ) {
63                TyVarMap tyVars;
64                ScrubTyVars scrubber( true, tyVars );
65                return static_cast< SynTreeClass* >( target->acceptMutator( scrubber ) );
66        }
67} // namespace GenPoly
68
69#endif // _SCRUBTYVARS_H
70
71// Local Variables: //
72// tab-width: 4 //
73// mode: c++ //
74// compile-command: "make install" //
75// End: //
Note: See TracBrowser for help on using the repository browser.