Ignore:
Timestamp:
Jul 31, 2019, 3:23:04 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
ae265b55, f49b3fc
Parents:
504eb72
Message:

Startup.cfa now compiles with new ast

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/TypeSubstitution.hpp

    r504eb72 r2890212  
    4444        TypeSubstitution &operator=( const TypeSubstitution &other );
    4545
    46         template< typename SynTreeClass > int apply( const SynTreeClass *& input ) const;
    47         template< typename SynTreeClass > int applyFree( const SynTreeClass *& input ) const;
     46        template< typename SynTreeClass >
     47        struct ApplyResult {
     48                const SynTreeClass * node;
     49                int count;
     50        };
     51
     52        template< typename SynTreeClass > ApplyResult<SynTreeClass> apply( const SynTreeClass * input ) const;
     53        template< typename SynTreeClass > ApplyResult<SynTreeClass> applyFree( const SynTreeClass * input ) const;
    4854
    4955        template< typename node_t, enum Node::ref_type ref_t >
    5056        int apply( ptr_base< node_t, ref_t > & input ) const {
    5157                const node_t * p = input.get();
    52                 int ret = apply(p);
    53                 input = p;
    54                 return ret;
     58                auto ret = apply(p);
     59                input = ret.node;
     60                return ret.count;
    5561        }
    5662
     
    5864        int applyFree( ptr_base< node_t, ref_t > & input ) const {
    5965                const node_t * p = input.get();
    60                 int ret = applyFree(p);
    61                 input = p;
    62                 return ret;
     66                auto ret = applyFree(p);
     67                input = ret.node;
     68                return ret.count;
    6369        }
    6470
     
    175181
    176182template< typename SynTreeClass >
    177 int TypeSubstitution::apply( const SynTreeClass *& input ) const {
     183TypeSubstitution::ApplyResult<SynTreeClass> TypeSubstitution::apply( const SynTreeClass * input ) const {
    178184        assert( input );
    179185        Pass<Substituter> sub( *this, false );
    180186        input = strict_dynamic_cast< const SynTreeClass * >( input->accept( sub ) );
    181 ///     std::cerr << "substitution result is: ";
    182 ///     newType->print( std::cerr );
    183 ///     std::cerr << std::endl;
    184         return sub.pass.subCount;
     187        return { input, sub.pass.subCount };
    185188}
    186189
    187190template< typename SynTreeClass >
    188 int TypeSubstitution::applyFree( const SynTreeClass *& input ) const {
     191TypeSubstitution::ApplyResult<SynTreeClass> TypeSubstitution::applyFree( const SynTreeClass * input ) const {
    189192        assert( input );
    190193        Pass<Substituter> sub( *this, true );
    191194        input = strict_dynamic_cast< const SynTreeClass * >( input->accept( sub ) );
    192 ///     std::cerr << "substitution result is: ";
    193 ///     newType->print( std::cerr );
    194 ///     std::cerr << std::endl;
    195         return sub.pass.subCount;
     195        return { input, sub.pass.subCount };
    196196}
    197197
Note: See TracChangeset for help on using the changeset viewer.