Changeset 90152a4 for src/GenPoly/ScrubTyVars.cc
- Timestamp:
- Aug 27, 2018, 4:40:34 PM (7 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- b7c89aa
- Parents:
- f9feab8 (diff), 305581d (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.cc (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/ScrubTyVars.cc
rf9feab8 r90152a4 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; … … 50 50 delete typeInst; 51 51 return new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ); 52 default: 53 assertf(false, "Unhandled tyvar kind: %d", tyVar->second.kind); 52 54 } // switch 53 55 } // if … … 55 57 } 56 58 57 Type * ScrubTyVars::mutateAggregateType( Type * ty ) {59 Type * ScrubTyVars::mutateAggregateType( Type * ty ) { 58 60 if ( shouldScrub( ty ) ) { 59 PointerType * ret = new PointerType( Type::Qualifiers(), new VoidType( ty->get_qualifiers() ) );61 PointerType * ret = new PointerType( Type::Qualifiers(), new VoidType( ty->get_qualifiers() ) ); 60 62 delete ty; 61 63 return ret; … … 64 66 } 65 67 66 Type * ScrubTyVars:: mutate( StructInstType *structInst ) {68 Type * ScrubTyVars::postmutate( StructInstType * structInst ) { 67 69 return mutateAggregateType( structInst ); 68 70 } 69 71 70 Type * ScrubTyVars:: mutate( UnionInstType *unionInst ) {72 Type * ScrubTyVars::postmutate( UnionInstType * unionInst ) { 71 73 return mutateAggregateType( unionInst ); 72 74 } 73 75 74 Expression * ScrubTyVars::mutate( SizeofExpr *szeof ) { 76 void ScrubTyVars::primeBaseScrub( Type * type ) { 77 // need to determine whether type needs to be scrubbed to determine whether 78 // automatic recursion is necessary 79 if ( Type * t = shouldScrub( type ) ) { 80 visit_children = false; 81 GuardValue( dynType ); 82 dynType = t; 83 } 84 } 85 86 Expression * ScrubTyVars::postmutate( SizeofExpr * szeof ) { 75 87 // sizeof( T ) => _sizeof_T parameter, which is the size of T 76 if ( Type *dynType = shouldScrub( szeof->get_type() )) {88 if ( dynType ) { 77 89 Expression *expr = new NameExpr( sizeofName( mangleType( dynType ) ) ); 78 90 return expr; 79 } else {80 return Mutator::mutate( szeof );81 91 } // if 92 return szeof; 82 93 } 83 94 84 Expression * ScrubTyVars:: mutate( AlignofExpr *algnof ) {95 Expression * ScrubTyVars::postmutate( AlignofExpr * algnof ) { 85 96 // alignof( T ) => _alignof_T parameter, which is the alignment of T 86 if ( Type *dynType = shouldScrub( algnof->get_type() )) {97 if ( dynType ) { 87 98 Expression *expr = new NameExpr( alignofName( mangleType( dynType ) ) ); 88 99 return expr; 89 } else {90 return Mutator::mutate( algnof );91 100 } // if 101 return algnof; 92 102 } 93 103 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 ); 104 Type * ScrubTyVars::postmutate( PointerType * pointer ) { 105 if ( dynType ) { 106 Type * ret = dynType->acceptMutator( *visitor ); 110 107 ret->get_qualifiers() |= pointer->get_qualifiers(); 111 pointer-> set_base( 0 );108 pointer->base = nullptr; 112 109 delete pointer; 113 110 return ret; 114 111 } 115 return Mutator::mutate( pointer );112 return pointer; 116 113 } 117 114 } // namespace GenPoly
Note:
See TracChangeset
for help on using the changeset viewer.