Ignore:
Timestamp:
Aug 16, 2016, 3:20:06 PM (10 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, stuck-waitfor-destruct, with_gc
Children:
1f6d4624
Parents:
950f7a7 (diff), 7880579 (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:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/ScrubTyVars.h

    r950f7a7 r7527e63  
    2727        class ScrubTyVars : public Mutator {
    2828          public:
    29                 ScrubTyVars( const TyVarMap &tyVars ): tyVars( tyVars ) {}
     29                ScrubTyVars( const TyVarMap &tyVars, bool dynamicOnly = false ): tyVars( tyVars ), dynamicOnly( dynamicOnly ) {}
    3030
    3131                /// For all polymorphic types with type variables in `tyVars`, replaces generic types, dtypes, and ftypes with the appropriate void type,
     
    3333                template< typename SynTreeClass >
    3434                static SynTreeClass *scrub( SynTreeClass *target, const TyVarMap &tyVars );
     35
     36                /// For all dynamic-layout types with type variables in `tyVars`, replaces generic types, dtypes, and ftypes with the appropriate void type,
     37                /// and sizeof/alignof expressions with the proper variable
     38                template< typename SynTreeClass >
     39                static SynTreeClass *scrubDynamic( SynTreeClass *target, const TyVarMap &tyVars );
    3540
    3641                virtual Type* mutate( TypeInstType *typeInst );
     
    4247
    4348          private:
     49                /// Returns the type if it should be scrubbed, NULL otherwise.
     50                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 );
     59                }
     60               
    4461                /// Mutates (possibly generic) aggregate types appropriately
    4562                Type* mutateAggregateType( Type *ty );
    4663               
    47                 const TyVarMap &tyVars;
     64                const TyVarMap &tyVars;  ///< Type variables to scrub
     65                bool dynamicOnly;        ///< only scrub the types with dynamic layout? [false]
    4866        };
    4967
    50         /* static class method */
    5168        template< typename SynTreeClass >
    5269        SynTreeClass * ScrubTyVars::scrub( SynTreeClass *target, const TyVarMap &tyVars ) {
    5370                ScrubTyVars scrubber( tyVars );
     71                return static_cast< SynTreeClass * >( target->acceptMutator( scrubber ) );
     72        }
     73
     74        template< typename SynTreeClass >
     75        SynTreeClass * ScrubTyVars::scrubDynamic( SynTreeClass *target, const TyVarMap &tyVars ) {
     76                ScrubTyVars scrubber( tyVars, true );
    5477                return static_cast< SynTreeClass * >( target->acceptMutator( scrubber ) );
    5578        }
Note: See TracChangeset for help on using the changeset viewer.