Changeset 9cdfb4d0 for src/GenPoly/ScrubTyVars.cc
- Timestamp:
- Jan 22, 2018, 3:09:01 PM (6 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:
- e23d20b
- Parents:
- 326cd2b (diff), 4bf3b2b (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.cc
r326cd2b r9cdfb4d0 25 25 26 26 namespace GenPoly { 27 Type * ScrubTyVars:: mutate( TypeInstType *typeInst ) {27 Type * ScrubTyVars::postmutate( TypeInstType * typeInst ) { 28 28 if ( ! tyVars ) { 29 29 if ( typeInst->get_isFtype() ) { … … 31 31 return new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ); 32 32 } else { 33 PointerType * ret = new PointerType( Type::Qualifiers(), new VoidType( typeInst->get_qualifiers() ) );33 PointerType * ret = new PointerType( Type::Qualifiers(), new VoidType( typeInst->get_qualifiers() ) ); 34 34 delete typeInst; 35 35 return ret; … … 37 37 } 38 38 39 TyVarMap::const_iterator tyVar = tyVars->find( typeInst-> get_name());39 TyVarMap::const_iterator tyVar = tyVars->find( typeInst->name ); 40 40 if ( tyVar != tyVars->end() ) { 41 41 switch ( tyVar->second.kind ) { … … 43 43 case TypeDecl::Ttype: 44 44 { 45 PointerType * ret = new PointerType( Type::Qualifiers(), new VoidType( typeInst->get_qualifiers() ) );45 PointerType * ret = new PointerType( Type::Qualifiers(), new VoidType( typeInst->get_qualifiers() ) ); 46 46 delete typeInst; 47 47 return ret; … … 55 55 } 56 56 57 Type * ScrubTyVars::mutateAggregateType( Type * ty ) {57 Type * ScrubTyVars::mutateAggregateType( Type * ty ) { 58 58 if ( shouldScrub( ty ) ) { 59 PointerType * ret = new PointerType( Type::Qualifiers(), new VoidType( ty->get_qualifiers() ) );59 PointerType * ret = new PointerType( Type::Qualifiers(), new VoidType( ty->get_qualifiers() ) ); 60 60 delete ty; 61 61 return ret; … … 64 64 } 65 65 66 Type * ScrubTyVars:: mutate( StructInstType *structInst ) {66 Type * ScrubTyVars::postmutate( StructInstType * structInst ) { 67 67 return mutateAggregateType( structInst ); 68 68 } 69 69 70 Type * ScrubTyVars:: mutate( UnionInstType *unionInst ) {70 Type * ScrubTyVars::postmutate( UnionInstType * unionInst ) { 71 71 return mutateAggregateType( unionInst ); 72 72 } 73 73 74 Expression * ScrubTyVars::mutate( SizeofExpr *szeof ) { 74 void ScrubTyVars::primeBaseScrub( Type * type ) { 75 // need to determine whether type needs to be scrubbed to determine whether 76 // automatic recursion is necessary 77 if ( Type * t = shouldScrub( type ) ) { 78 visit_children = false; 79 GuardValue( dynType ); 80 dynType = t; 81 } 82 } 83 84 Expression * ScrubTyVars::postmutate( SizeofExpr * szeof ) { 75 85 // sizeof( T ) => _sizeof_T parameter, which is the size of T 76 if ( Type *dynType = shouldScrub( szeof->get_type() )) {86 if ( dynType ) { 77 87 Expression *expr = new NameExpr( sizeofName( mangleType( dynType ) ) ); 78 88 return expr; 79 } else {80 return Mutator::mutate( szeof );81 89 } // if 90 return szeof; 82 91 } 83 92 84 Expression * ScrubTyVars:: mutate( AlignofExpr *algnof ) {93 Expression * ScrubTyVars::postmutate( AlignofExpr * algnof ) { 85 94 // alignof( T ) => _alignof_T parameter, which is the alignment of T 86 if ( Type *dynType = shouldScrub( algnof->get_type() )) {95 if ( dynType ) { 87 96 Expression *expr = new NameExpr( alignofName( mangleType( dynType ) ) ); 88 97 return expr; 89 } else {90 return Mutator::mutate( algnof );91 98 } // if 99 return algnof; 92 100 } 93 101 94 Type * ScrubTyVars::mutate( PointerType *pointer ) { 95 // // special case of shouldScrub that takes all TypeInstType pointer bases, even if they're not dynamic 96 // Type *base = pointer->get_base(); 97 // Type *dynType = 0; 98 // if ( dynamicOnly ) { 99 // if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( base ) ) { 100 // if ( tyVars.find( typeInst->get_name() ) != tyVars.end() ) { dynType = typeInst; } 101 // } else { 102 // dynType = isDynType( base, tyVars ); 103 // } 104 // } else { 105 // dynType = isPolyType( base, tyVars ); 106 // } 107 // if ( dynType ) { 108 if ( Type *dynType = shouldScrub( pointer->get_base() ) ) { 109 Type *ret = dynType->acceptMutator( *this ); 102 Type * ScrubTyVars::postmutate( PointerType * pointer ) { 103 if ( dynType ) { 104 Type * ret = dynType->acceptMutator( *visitor ); 110 105 ret->get_qualifiers() |= pointer->get_qualifiers(); 111 pointer-> set_base( 0 );106 pointer->base = nullptr; 112 107 delete pointer; 113 108 return ret; 114 109 } 115 return Mutator::mutate( pointer );110 return pointer; 116 111 } 117 112 } // namespace GenPoly
Note: See TracChangeset
for help on using the changeset viewer.