Changeset ebe9b3a for src/GenPoly
- Timestamp:
- Jan 12, 2016, 3:56:30 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- aadc9a4
- Parents:
- 36874e4
- Location:
- src/GenPoly
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/ScrubTyVars.cc
r36874e4 rebe9b3a 27 27 Type * ScrubTyVars::mutate( TypeInstType *typeInst ) { 28 28 TyVarMap::const_iterator tyVar = tyVars.find( typeInst->get_name() ); 29 if ( doAll ||tyVar != tyVars.end() ) {29 if ( tyVar != tyVars.end() ) { 30 30 switch ( tyVar->second ) { 31 31 case TypeDecl::Any: … … 45 45 46 46 Type * ScrubTyVars::mutateAggregateType( Type *ty ) { 47 if ( doAll ? isPolyType( ty ) :isPolyType( ty, tyVars ) ) {47 if ( isPolyType( ty, tyVars ) ) { 48 48 PointerType *ret = new PointerType( Type::Qualifiers(), new VoidType( ty->get_qualifiers() ) ); 49 49 delete ty; … … 83 83 Type * ScrubTyVars::mutate( PointerType *pointer ) { 84 84 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( pointer->get_base() ) ) { 85 if ( doAll ||tyVars.find( typeInst->get_name() ) != tyVars.end() ) {85 if ( tyVars.find( typeInst->get_name() ) != tyVars.end() ) { 86 86 Type *ret = mutate( typeInst ); 87 87 ret->get_qualifiers() += pointer->get_qualifiers(); -
src/GenPoly/ScrubTyVars.h
r36874e4 rebe9b3a 27 27 class ScrubTyVars : public Mutator { 28 28 public: 29 ScrubTyVars( bool doAll, const TyVarMap &tyVars ): doAll( doAll ),tyVars( tyVars ) {}29 ScrubTyVars( const TyVarMap &tyVars ): tyVars( tyVars ) {} 30 30 31 /// Like scrub( SynTreeClass* ), but only applies to type variables in `tyVars` 31 /// For all polymorphic types with type variables in `tyVars`, replaces generic types, dtypes, and ftypes with the appropriate void type, 32 /// and sizeof/alignof expressions with the proper variable 32 33 template< typename SynTreeClass > 33 34 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 variable35 template< typename SynTreeClass >36 static SynTreeClass *scrub( SynTreeClass *target );37 35 38 36 virtual Type* mutate( TypeInstType *typeInst ); … … 47 45 Type* mutateAggregateType( Type *ty ); 48 46 49 bool doAll;50 47 const TyVarMap &tyVars; 51 48 }; … … 54 51 template< typename SynTreeClass > 55 52 SynTreeClass * ScrubTyVars::scrub( SynTreeClass *target, const TyVarMap &tyVars ) { 56 ScrubTyVars scrubber( false,tyVars );53 ScrubTyVars scrubber( tyVars ); 57 54 return static_cast< SynTreeClass * >( target->acceptMutator( scrubber ) ); 58 55 } 59 56 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 57 } // namespace GenPoly 68 58
Note: See TracChangeset
for help on using the changeset viewer.