Ignore:
Timestamp:
May 7, 2019, 1:39:08 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
cedb545
Parents:
0c0f548
Message:

Added WithConstTypeSubstitution? accessory on pass visitor.
Mostly exploratory work, figuring out what can be const

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/TypeSubstitution.h

    r0c0f548 r02fdb8e  
    3939        TypeSubstitution &operator=( const TypeSubstitution &other );
    4040
    41         template< typename SynTreeClass > int apply( SynTreeClass *&input );
    42         template< typename SynTreeClass > int applyFree( SynTreeClass *&input );
     41        template< typename SynTreeClass > int apply( SynTreeClass *&input ) const;
     42        template< typename SynTreeClass > int applyFree( SynTreeClass *&input ) const;
    4343
    4444        void add( std::string formalType, Type *actualType );
     
    5656
    5757        /// create a new TypeSubstitution using bindings from env containing all of the type variables in expr
    58         static TypeSubstitution * newFromExpr( Expression * expr, TypeSubstitution * env );
     58        static TypeSubstitution * newFromExpr( Expression * expr, const TypeSubstitution * env );
    5959
    6060        void normalize();
     
    130130// definitition must happen after PassVisitor is included so that WithGuards can be used
    131131struct TypeSubstitution::Substituter : public WithGuards, public WithVisitorRef<Substituter> {
    132                 Substituter( TypeSubstitution & sub, bool freeOnly ) : sub( sub ), freeOnly( freeOnly ) {}
     132                Substituter( const TypeSubstitution & sub, bool freeOnly ) : sub( sub ), freeOnly( freeOnly ) {}
    133133
    134134                Type * postmutate( TypeInstType * aggregateUseType );
     
    143143                void premutate( UnionInstType * aggregateUseType );
    144144
    145                 TypeSubstitution & sub;
     145                const TypeSubstitution & sub;
    146146                int subCount = 0;
    147147                bool freeOnly;
     
    151151
    152152template< typename SynTreeClass >
    153 int TypeSubstitution::apply( SynTreeClass *&input ) {
     153int TypeSubstitution::apply( SynTreeClass *&input ) const {
    154154        assert( input );
    155155        PassVisitor<Substituter> sub( *this, false );
     
    163163
    164164template< typename SynTreeClass >
    165 int TypeSubstitution::applyFree( SynTreeClass *&input ) {
     165int TypeSubstitution::applyFree( SynTreeClass *&input ) const {
    166166        assert( input );
    167167        PassVisitor<Substituter> sub( *this, true );
Note: See TracChangeset for help on using the changeset viewer.