Changeset 447c356


Ignore:
Timestamp:
Oct 19, 2017, 11:15:35 AM (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:
6fc5c14
Parents:
84733c1
git-author:
Rob Schluntz <rschlunt@…> (10/17/17 10:25:17)
git-committer:
Rob Schluntz <rschlunt@…> (10/19/17 11:15:35)
Message:

Add support for TypeSubstitution? in PassVisitor?

Location:
src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/Common/PassVisitor.h

    r84733c1 r447c356  
    238238        virtual Attribute * mutate( Attribute * attribute ) override final;
    239239
     240        virtual TypeSubstitution * mutate( TypeSubstitution * sub ) final;
     241
    240242private:
    241243        template<typename pass_t> friend void acceptAll( std::list< Declaration* > &decls, PassVisitor< pass_t >& visitor );
  • src/Common/PassVisitor.impl.h

    r84733c1 r447c356  
    21272127        MUTATE_BODY( Attribute, node );
    21282128}
     2129
     2130template< typename pass_type >
     2131TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) {
     2132        MUTATE_START( node );
     2133
     2134        for ( auto & p : node->typeEnv ) {
     2135                indexerScopedMutate( p.second, *this );
     2136        }
     2137        for ( auto & p : node->varEnv ) {
     2138                indexerScopedMutate( p.second, *this );
     2139        }
     2140
     2141        MUTATE_END( TypeSubstitution, node );
     2142}
  • src/SynTree/Mutator.cc

    r84733c1 r447c356  
    626626}
    627627
     628TypeSubstitution * Mutator::mutate( TypeSubstitution * sub ) {
     629        for ( auto & p : sub->typeEnv ) {
     630                p.second = maybeMutate( p.second, *this );
     631        }
     632        for ( auto & p : sub->varEnv ) {
     633                p.second = maybeMutate( p.second, *this );
     634        }
     635        return sub;
     636}
     637
    628638// Local Variables: //
    629639// tab-width: 4 //
  • src/SynTree/Mutator.h

    r84733c1 r447c356  
    117117
    118118        virtual Attribute * mutate( Attribute * attribute );
     119
     120        virtual TypeSubstitution * mutate( TypeSubstitution * sub );
    119121  private:
    120122        virtual Declaration * handleAggregateDecl(AggregateDecl * aggregateDecl );
  • src/SynTree/TypeSubstitution.cc

    r84733c1 r447c356  
    148148template< typename TypeClass >
    149149Type *TypeSubstitution::handleType( TypeClass *type ) {
    150         BoundVarsType oldBoundVars( boundVars );
     150        ValueGuard<BoundVarsType> oldBoundVars( boundVars );
    151151        // bind type variables from forall-qualifiers
    152152        if ( freeOnly ) {
     
    156156        } // if
    157157        Type *ret = Mutator::mutate( type );
    158         boundVars = oldBoundVars;
    159158        return ret;
    160159}
     
    162161template< typename TypeClass >
    163162Type *TypeSubstitution::handleAggregateType( TypeClass *type ) {
    164         BoundVarsType oldBoundVars( boundVars );
     163        ValueGuard<BoundVarsType> oldBoundVars( boundVars );
    165164        // bind type variables from forall-qualifiers
    166165        if ( freeOnly ) {
     
    177176        } // if
    178177        Type *ret = Mutator::mutate( type );
    179         boundVars = oldBoundVars;
    180178        return ret;
    181179}
     
    231229Type * TypeSubstitution::mutate( OneType *oneType ) {
    232230        return handleType( oneType );
    233 }
    234 
    235 TypeSubstitution * TypeSubstitution::acceptMutator( Mutator & mutator ) {
    236         for ( auto & p : typeEnv ) {
    237                 p.second = maybeMutate( p.second, mutator );
    238         }
    239         for ( auto & p : varEnv ) {
    240                 p.second = maybeMutate( p.second, mutator );
    241         }
    242         return this;
    243231}
    244232
  • src/SynTree/TypeSubstitution.h

    r84733c1 r447c356  
    5959        void normalize();
    6060
    61         TypeSubstitution * acceptMutator( Mutator & mutator );
     61        TypeSubstitution * acceptMutator( Mutator & m ) { return m.mutate( this ); }
    6262
    6363        void print( std::ostream &os, Indenter indent = {} ) const;
     
    8989
    9090        void initialize( const TypeSubstitution &src, TypeSubstitution &dest );
     91
     92        friend class Mutator;
     93
     94        template<typename pass_type>
     95        friend class PassVisitor;
    9196
    9297        typedef std::map< std::string, Type* > TypeEnvType;
Note: See TracChangeset for help on using the changeset viewer.