Changes in src/GenPoly/ScrubTyVars.h [5a3ac84:3bb195cb]
- File:
-
- 1 edited
-
src/GenPoly/ScrubTyVars.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/ScrubTyVars.h
r5a3ac84 r3bb195cb 26 26 namespace GenPoly { 27 27 class ScrubTyVars : public Mutator { 28 /// Whether to scrub all type variables from the provided map, dynamic type variables from the provided map, or all type variables29 enum ScrubMode { FromMap, DynamicFromMap, All };28 public: 29 ScrubTyVars( const TyVarMap &tyVars, bool dynamicOnly = false ): tyVars( tyVars ), dynamicOnly( dynamicOnly ) {} 30 30 31 ScrubTyVars() : tyVars(nullptr), mode( All ) {}32 33 ScrubTyVars( const TyVarMap &tyVars, ScrubMode mode = FromMap ): tyVars( &tyVars ), mode( mode ) {}34 35 public:36 31 /// For all polymorphic types with type variables in `tyVars`, replaces generic types, dtypes, and ftypes with the appropriate void type, 37 32 /// and sizeof/alignof expressions with the proper variable … … 43 38 template< typename SynTreeClass > 44 39 static SynTreeClass *scrubDynamic( SynTreeClass *target, const TyVarMap &tyVars ); 45 46 /// For all polymorphic types, replaces generic types, dtypes, and ftypes with the appropriate void type,47 /// and sizeof/alignof expressions with the proper variable48 template< typename SynTreeClass >49 static SynTreeClass *scrubAll( SynTreeClass *target );50 40 51 41 virtual Type* mutate( TypeInstType *typeInst ); … … 59 49 /// Returns the type if it should be scrubbed, NULL otherwise. 60 50 Type* shouldScrub( Type *ty ) { 61 switch ( mode ) { 62 case FromMap: return isPolyType( ty, *tyVars ); 63 case DynamicFromMap: return isDynType( ty, *tyVars ); 64 case All: return isPolyType( ty ); 65 } 66 assert(false); return nullptr; // unreachable 67 // return dynamicOnly ? isDynType( ty, tyVars ) : isPolyType( ty, tyVars ); 51 return dynamicOnly ? isDynType( ty, tyVars ) : isPolyType( ty, tyVars ); 52 // if ( ! dynamicOnly ) return isPolyType( ty, tyVars ); 53 // 54 // if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( ty ) ) { 55 // return tyVars.find( typeInst->get_name() ) != tyVars.end() ? ty : 0; 56 // } 57 // 58 // return isDynType( ty, tyVars ); 68 59 } 69 60 … … 71 62 Type* mutateAggregateType( Type *ty ); 72 63 73 const TyVarMap *tyVars; ///< Type variables to scrub74 ScrubMode mode; ///< which type variables to scrub? [FromMap]64 const TyVarMap &tyVars; ///< Type variables to scrub 65 bool dynamicOnly; ///< only scrub the types with dynamic layout? [false] 75 66 }; 76 67 … … 83 74 template< typename SynTreeClass > 84 75 SynTreeClass * ScrubTyVars::scrubDynamic( SynTreeClass *target, const TyVarMap &tyVars ) { 85 ScrubTyVars scrubber( tyVars, ScrubTyVars::DynamicFromMap ); 86 return static_cast< SynTreeClass * >( target->acceptMutator( scrubber ) ); 87 } 88 89 template< typename SynTreeClass > 90 SynTreeClass * ScrubTyVars::scrubAll( SynTreeClass *target ) { 91 ScrubTyVars scrubber; 76 ScrubTyVars scrubber( tyVars, true ); 92 77 return static_cast< SynTreeClass * >( target->acceptMutator( scrubber ) ); 93 78 }
Note:
See TracChangeset
for help on using the changeset viewer.