Ignore:
Timestamp:
May 22, 2019, 5:34:17 PM (6 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:
0b8bf27
Parents:
5902625 (diff), 722c4831 (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/AST/TypeSubstitution.hpp

    r5902625 rf23de79d  
    2525#include "Fwd.hpp"        // for UniqueId
    2626#include "ParseNode.hpp"
    27 #include "Type.hpp"       // for ptr<Type>
     27#include "Type.hpp"       
    2828#include "Common/SemanticError.h"  // for SemanticError
    2929#include "Visitor.hpp"
    3030#include "Decl.hpp"
    3131#include "Expr.hpp"
     32#include "Node.hpp"
    3233
    3334namespace ast {
     
    4344        TypeSubstitution &operator=( const TypeSubstitution &other );
    4445
    45         template< typename SynTreeClass > int apply( SynTreeClass *&input ) const;
    46         template< typename SynTreeClass > int applyFree( SynTreeClass *&input ) const;
     46        template< typename SynTreeClass > int apply( const SynTreeClass *& input ) const;
     47        template< typename SynTreeClass > int applyFree( const SynTreeClass *& input ) const;
     48
     49        template< typename node_t, enum Node::ref_type ref_t >
     50        int apply( ptr_base< node_t, ref_t > & input ) const {
     51                const node_t * p = input.get();
     52                int ret = apply(p);
     53                input = p;
     54                return ret;
     55        }
     56
     57        template< typename node_t, enum Node::ref_type ref_t >
     58        int applyFree( ptr_base< node_t, ref_t > & input ) const {
     59                const node_t * p = input.get();
     60                int ret = applyFree(p);
     61                input = p;
     62                return ret;
     63        }
    4764
    4865        void add( std::string formalType, const Type *actualType );
     
    162179
    163180template< typename SynTreeClass >
    164 int TypeSubstitution::apply( SynTreeClass *&input ) const {
     181int TypeSubstitution::apply( const SynTreeClass *& input ) const {
    165182        assert( input );
    166183        Pass<Substituter> sub( *this, false );
    167         input = dynamic_cast< SynTreeClass * >( input->acceptMutator( sub ) );
    168         assert( input );
     184        input = strict_dynamic_cast< const SynTreeClass * >( input->accept( sub ) );
    169185///     std::cerr << "substitution result is: ";
    170186///     newType->print( std::cerr );
     
    174190
    175191template< typename SynTreeClass >
    176 int TypeSubstitution::applyFree( SynTreeClass *&input ) const {
     192int TypeSubstitution::applyFree( const SynTreeClass *& input ) const {
    177193        assert( input );
    178194        Pass<Substituter> sub( *this, true );
    179         input = dynamic_cast< SynTreeClass * >( input->acceptMutator( sub ) );
    180         assert( input );
     195        input = strict_dynamic_cast< const SynTreeClass * >( input->accept( sub ) );
    181196///     std::cerr << "substitution result is: ";
    182197///     newType->print( std::cerr );
Note: See TracChangeset for help on using the changeset viewer.