source: src/GenPoly/ScrubTyVars.h @ db0b3ce

aaron-thesisarm-ehcleanup-dtorsctordeferred_resndemanglergc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newstringwith_gc
Last change on this file since db0b3ce was db0b3ce, checked in by Aaron Moss <a3moss@…>, 6 years ago

Initial draft of switch-over of size/align names

  • Property mode set to 100644
File size: 2.0 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 "GenPoly.h"
20
21#include "SynTree/SynTree.h"
22#include "SynTree/Mutator.h"
23
24namespace 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                Expression* mutate( AlignofExpr *algnof );
39                virtual Type* mutate( PointerType *pointer );
40          private:
41                bool doAll;
42                const TyVarMap &tyVars;
43        };
44
45        /* static class method */
46        template< typename SynTreeClass >
47        SynTreeClass * ScrubTyVars::scrub( SynTreeClass *target, const TyVarMap &tyVars ) {
48                ScrubTyVars scrubber( false, tyVars );
49                return static_cast< SynTreeClass * >( target->acceptMutator( scrubber ) );
50        }
51
52        /* static class method */
53        template< typename SynTreeClass >
54        SynTreeClass * ScrubTyVars::scrub( SynTreeClass *target ) {
55                TyVarMap tyVars;
56                ScrubTyVars scrubber( true, tyVars );
57                return static_cast< SynTreeClass* >( target->acceptMutator( scrubber ) );
58        }
59} // namespace GenPoly
60
61#endif // _SCRUBTYVARS_H
62
63// Local Variables: //
64// tab-width: 4 //
65// mode: c++ //
66// compile-command: "make install" //
67// End: //
Note: See TracBrowser for help on using the repository browser.