Ignore:
Timestamp:
Mar 16, 2017, 4:50:08 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
395fc37, 64ac636, ef42b143
Parents:
2f26687a (diff), d6d747d (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' of plg.uwaterloo.ca:/u/cforall/software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/ScrubTyVars.h

    r2f26687a r1fbab5a  
    2626namespace GenPoly {
    2727        class ScrubTyVars : public Mutator {
    28           public:
    29                 ScrubTyVars( const TyVarMap &tyVars, bool dynamicOnly = false ): tyVars( tyVars ), dynamicOnly( dynamicOnly ) {}
     28                /// Whether to scrub all type variables from the provided map, dynamic type variables from the provided map, or all type variables
     29                enum ScrubMode { FromMap, DynamicFromMap, All };
    3030
     31                ScrubTyVars() : tyVars(nullptr), mode( All ) {}
     32
     33                ScrubTyVars( const TyVarMap &tyVars, ScrubMode mode = FromMap ): tyVars( &tyVars ), mode( mode ) {}
     34
     35        public:
    3136                /// For all polymorphic types with type variables in `tyVars`, replaces generic types, dtypes, and ftypes with the appropriate void type,
    3237                /// and sizeof/alignof expressions with the proper variable
     
    3843                template< typename SynTreeClass >
    3944                static SynTreeClass *scrubDynamic( SynTreeClass *target, const TyVarMap &tyVars );
     45
     46                /// For all polymorphic types, replaces generic types, dtypes, and ftypes with the appropriate void type,
     47                /// and sizeof/alignof expressions with the proper variable
     48                template< typename SynTreeClass >
     49                static SynTreeClass *scrubAll( SynTreeClass *target );
    4050
    4151                virtual Type* mutate( TypeInstType *typeInst );
     
    4959                /// Returns the type if it should be scrubbed, NULL otherwise.
    5060                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 );
     61                        switch ( mode ) {
     62                        case FromMap: return isPolyType( ty, *tyVars );
     63                        case DynamicFromMap: return isDynType( ty, *tyVars );
     64                        case All: return isPolyType( ty );
     65                        }
     66                        assert(false); return nullptr; // unreachable
     67                        // return dynamicOnly ? isDynType( ty, tyVars ) : isPolyType( ty, tyVars );
    5968                }
    6069               
     
    6271                Type* mutateAggregateType( Type *ty );
    6372               
    64                 const TyVarMap &tyVars;  ///< Type variables to scrub
    65                 bool dynamicOnly;        ///< only scrub the types with dynamic layout? [false]
     73                const TyVarMap *tyVars;  ///< Type variables to scrub
     74                ScrubMode mode;          ///< which type variables to scrub? [FromMap]
    6675        };
    6776
     
    7483        template< typename SynTreeClass >
    7584        SynTreeClass * ScrubTyVars::scrubDynamic( SynTreeClass *target, const TyVarMap &tyVars ) {
    76                 ScrubTyVars scrubber( tyVars, true );
     85                ScrubTyVars scrubber( tyVars, ScrubTyVars::DynamicFromMap );
     86                return static_cast< SynTreeClass * >( target->acceptMutator( scrubber ) );
     87        }
     88
     89        template< typename SynTreeClass >
     90        SynTreeClass * ScrubTyVars::scrubAll( SynTreeClass *target ) {
     91                ScrubTyVars scrubber;
    7792                return static_cast< SynTreeClass * >( target->acceptMutator( scrubber ) );
    7893        }
Note: See TracChangeset for help on using the changeset viewer.