Ignore:
Timestamp:
Aug 27, 2018, 4:40:34 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
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.
Message:

Merge branch 'master' into cleanup-dtors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/ScrubTyVars.cc

    rf9feab8 r90152a4  
    2525
    2626namespace GenPoly {
    27         Type * ScrubTyVars::mutate( TypeInstType *typeInst ) {
     27        Type * ScrubTyVars::postmutate( TypeInstType * typeInst ) {
    2828                if ( ! tyVars ) {
    2929                        if ( typeInst->get_isFtype() ) {
     
    3131                                return new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) );
    3232                        } 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() ) );
    3434                                delete typeInst;
    3535                                return ret;
     
    3737                }
    3838
    39                 TyVarMap::const_iterator tyVar = tyVars->find( typeInst->get_name() );
     39                TyVarMap::const_iterator tyVar = tyVars->find( typeInst->name );
    4040                if ( tyVar != tyVars->end() ) {
    4141                        switch ( tyVar->second.kind ) {
     
    4343                          case TypeDecl::Ttype:
    4444                                {
    45                                         PointerType *ret = new PointerType( Type::Qualifiers(), new VoidType( typeInst->get_qualifiers() ) );
     45                                        PointerType * ret = new PointerType( Type::Qualifiers(), new VoidType( typeInst->get_qualifiers() ) );
    4646                                        delete typeInst;
    4747                                        return ret;
     
    5050                                delete typeInst;
    5151                                return new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) );
     52                          default:
     53                                assertf(false, "Unhandled tyvar kind: %d", tyVar->second.kind);
    5254                        } // switch
    5355                } // if
     
    5557        }
    5658
    57         Type * ScrubTyVars::mutateAggregateType( Type *ty ) {
     59        Type * ScrubTyVars::mutateAggregateType( Type * ty ) {
    5860                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() ) );
    6062                        delete ty;
    6163                        return ret;
     
    6466        }
    6567
    66         Type * ScrubTyVars::mutate( StructInstType *structInst ) {
     68        Type * ScrubTyVars::postmutate( StructInstType * structInst ) {
    6769                return mutateAggregateType( structInst );
    6870        }
    6971
    70         Type * ScrubTyVars::mutate( UnionInstType *unionInst ) {
     72        Type * ScrubTyVars::postmutate( UnionInstType * unionInst ) {
    7173                return mutateAggregateType( unionInst );
    7274        }
    7375
    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 ) {
    7587                // sizeof( T ) => _sizeof_T parameter, which is the size of T
    76                 if ( Type *dynType = shouldScrub( szeof->get_type() ) ) {
     88                if ( dynType ) {
    7789                        Expression *expr = new NameExpr( sizeofName( mangleType( dynType ) ) );
    7890                        return expr;
    79                 } else {
    80                         return Mutator::mutate( szeof );
    8191                } // if
     92                return szeof;
    8293        }
    8394
    84         Expression * ScrubTyVars::mutate( AlignofExpr *algnof ) {
     95        Expression * ScrubTyVars::postmutate( AlignofExpr * algnof ) {
    8596                // alignof( T ) => _alignof_T parameter, which is the alignment of T
    86                 if ( Type *dynType = shouldScrub( algnof->get_type() ) ) {
     97                if ( dynType ) {
    8798                        Expression *expr = new NameExpr( alignofName( mangleType( dynType ) ) );
    8899                        return expr;
    89                 } else {
    90                         return Mutator::mutate( algnof );
    91100                } // if
     101                return algnof;
    92102        }
    93103
    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 );
    110107                        ret->get_qualifiers() |= pointer->get_qualifiers();
    111                         pointer->set_base( 0 );
     108                        pointer->base = nullptr;
    112109                        delete pointer;
    113110                        return ret;
    114111                }
    115                 return Mutator::mutate( pointer );
     112                return pointer;
    116113        }
    117114} // namespace GenPoly
Note: See TracChangeset for help on using the changeset viewer.