Changeset 7527e63 for src/GenPoly/ScrubTyVars.h
- Timestamp:
- Aug 16, 2016, 3:20:06 PM (10 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, stuck-waitfor-destruct, with_gc
- Children:
- 1f6d4624
- Parents:
- 950f7a7 (diff), 7880579 (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
-
src/GenPoly/ScrubTyVars.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/ScrubTyVars.h
r950f7a7 r7527e63 27 27 class ScrubTyVars : public Mutator { 28 28 public: 29 ScrubTyVars( const TyVarMap &tyVars ): tyVars( tyVars) {}29 ScrubTyVars( const TyVarMap &tyVars, bool dynamicOnly = false ): tyVars( tyVars ), dynamicOnly( dynamicOnly ) {} 30 30 31 31 /// For all polymorphic types with type variables in `tyVars`, replaces generic types, dtypes, and ftypes with the appropriate void type, … … 33 33 template< typename SynTreeClass > 34 34 static SynTreeClass *scrub( SynTreeClass *target, const TyVarMap &tyVars ); 35 36 /// For all dynamic-layout types with type variables in `tyVars`, replaces generic types, dtypes, and ftypes with the appropriate void type, 37 /// and sizeof/alignof expressions with the proper variable 38 template< typename SynTreeClass > 39 static SynTreeClass *scrubDynamic( SynTreeClass *target, const TyVarMap &tyVars ); 35 40 36 41 virtual Type* mutate( TypeInstType *typeInst ); … … 42 47 43 48 private: 49 /// Returns the type if it should be scrubbed, NULL otherwise. 50 Type* shouldScrub( Type *ty ) { 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 ); 59 } 60 44 61 /// Mutates (possibly generic) aggregate types appropriately 45 62 Type* mutateAggregateType( Type *ty ); 46 63 47 const TyVarMap &tyVars; 64 const TyVarMap &tyVars; ///< Type variables to scrub 65 bool dynamicOnly; ///< only scrub the types with dynamic layout? [false] 48 66 }; 49 67 50 /* static class method */51 68 template< typename SynTreeClass > 52 69 SynTreeClass * ScrubTyVars::scrub( SynTreeClass *target, const TyVarMap &tyVars ) { 53 70 ScrubTyVars scrubber( tyVars ); 71 return static_cast< SynTreeClass * >( target->acceptMutator( scrubber ) ); 72 } 73 74 template< typename SynTreeClass > 75 SynTreeClass * ScrubTyVars::scrubDynamic( SynTreeClass *target, const TyVarMap &tyVars ) { 76 ScrubTyVars scrubber( tyVars, true ); 54 77 return static_cast< SynTreeClass * >( target->acceptMutator( scrubber ) ); 55 78 }
Note:
See TracChangeset
for help on using the changeset viewer.