Changeset 7416d46a for src/GenPoly/ScrubTyVars.h
- Timestamp:
- Jan 30, 2018, 3:54:32 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 633a642
- Parents:
- f792cb8 (diff), 42be3c3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/ScrubTyVars.h
rf792cb8 r7416d46a 18 18 #include <cassert> // for assert 19 19 20 #include "Common/PassVisitor.h" 20 21 #include "GenPoly.h" // for TyVarMap, isPolyType, isDynType 21 22 #include "SynTree/Mutator.h" // for Mutator … … 27 28 28 29 namespace GenPoly { 29 class ScrubTyVars : public Mutator{30 struct ScrubTyVars : public WithVisitorRef<ScrubTyVars>, public WithShortCircuiting, public WithGuards { 30 31 /// Whether to scrub all type variables from the provided map, dynamic type variables from the provided map, or all type variables 31 32 enum ScrubMode { FromMap, DynamicFromMap, All }; … … 51 52 static SynTreeClass *scrubAll( SynTreeClass *target ); 52 53 53 virtual Type* mutate( TypeInstType *typeInst ); 54 virtual Type* mutate( StructInstType *structInst ); 55 virtual Type* mutate( UnionInstType *unionInst ); 56 virtual Expression* mutate( SizeofExpr *szeof ); 57 virtual Expression* mutate( AlignofExpr *algnof ); 58 virtual Type* mutate( PointerType *pointer ); 54 /// determine if children should be visited based on whether base type should be scrubbed. 55 void primeBaseScrub( Type * ); 56 57 void premutate( TypeInstType * ) { visit_children = false; } 58 void premutate( StructInstType * ) { visit_children = false; } 59 void premutate( UnionInstType * ) { visit_children = false; } 60 void premutate( SizeofExpr * szeof ) { primeBaseScrub( szeof->type ); } 61 void premutate( AlignofExpr * algnof ) { primeBaseScrub( algnof->type ); } 62 void premutate( PointerType * pointer ) { primeBaseScrub( pointer->base ); } 63 64 Type * postmutate( TypeInstType * typeInst ); 65 Type * postmutate( StructInstType * structInst ); 66 Type * postmutate( UnionInstType * unionInst ); 67 Expression * postmutate( SizeofExpr * szeof ); 68 Expression * postmutate( AlignofExpr * algnof ); 69 Type * postmutate( PointerType * pointer ); 59 70 60 71 private: … … 75 86 const TyVarMap *tyVars; ///< Type variables to scrub 76 87 ScrubMode mode; ///< which type variables to scrub? [FromMap] 88 89 Type * dynType = nullptr; ///< result of shouldScrub 77 90 }; 78 91 79 92 template< typename SynTreeClass > 80 93 SynTreeClass * ScrubTyVars::scrub( SynTreeClass *target, const TyVarMap &tyVars ) { 81 ScrubTyVarsscrubber( tyVars );94 PassVisitor<ScrubTyVars> scrubber( tyVars ); 82 95 return static_cast< SynTreeClass * >( target->acceptMutator( scrubber ) ); 83 96 } … … 85 98 template< typename SynTreeClass > 86 99 SynTreeClass * ScrubTyVars::scrubDynamic( SynTreeClass *target, const TyVarMap &tyVars ) { 87 ScrubTyVarsscrubber( tyVars, ScrubTyVars::DynamicFromMap );100 PassVisitor<ScrubTyVars> scrubber( tyVars, ScrubTyVars::DynamicFromMap ); 88 101 return static_cast< SynTreeClass * >( target->acceptMutator( scrubber ) ); 89 102 } … … 91 104 template< typename SynTreeClass > 92 105 SynTreeClass * ScrubTyVars::scrubAll( SynTreeClass *target ) { 93 ScrubTyVarsscrubber;106 PassVisitor<ScrubTyVars> scrubber; 94 107 return static_cast< SynTreeClass * >( target->acceptMutator( scrubber ) ); 95 108 }
Note:
See TracChangeset
for help on using the changeset viewer.