Changeset f07c1e6 for src


Ignore:
Timestamp:
Jan 15, 2018, 3:40:34 PM (6 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:
ad51cc2
Parents:
12145b9
Message:

Convert PtrsAssignable? to PassVisitor?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/PtrsAssignable.cc

    r12145b9 rf07c1e6  
    1414//
    1515
     16#include "Common/PassVisitor.h"
    1617#include "ResolvExpr/TypeEnvironment.h"  // for EqvClass, TypeEnvironment
    1718#include "SynTree/Type.h"                // for TypeInstType, Type, BasicType
     
    2021
    2122namespace ResolvExpr {
    22         class PtrsAssignable : public Visitor {
    23           public:
     23        struct PtrsAssignable : public WithShortCircuiting {
    2424                PtrsAssignable( Type *dest, const TypeEnvironment &env );
    2525
    2626                int get_result() const { return result; }
    2727
    28                 virtual void visit( VoidType *voidType );
    29                 virtual void visit( BasicType *basicType );
    30                 virtual void visit( PointerType *pointerType );
    31                 virtual void visit( ArrayType *arrayType );
    32                 virtual void visit( FunctionType *functionType );
    33                 virtual void visit( StructInstType *inst );
    34                 virtual void visit( UnionInstType *inst );
    35                 virtual void visit( EnumInstType *inst );
    36                 virtual void visit( TraitInstType *inst );
    37                 virtual void visit( TypeInstType *inst );
    38                 virtual void visit( TupleType *tupleType );
    39                 virtual void visit( VarArgsType *varArgsType );
    40                 virtual void visit( ZeroType *zeroType );
    41                 virtual void visit( OneType *oneType );
     28                void previsit( Type * ) { visit_children = false; }
     29
     30                void postvisit( VoidType * voidType );
     31                void postvisit( BasicType * basicType );
     32                void postvisit( PointerType * pointerType );
     33                void postvisit( ArrayType * arrayType );
     34                void postvisit( FunctionType * functionType );
     35                void postvisit( StructInstType * inst );
     36                void postvisit( UnionInstType * inst );
     37                void postvisit( EnumInstType * inst );
     38                void postvisit( TraitInstType * inst );
     39                void postvisit( TypeInstType * inst );
     40                void postvisit( TupleType * tupleType );
     41                void postvisit( VarArgsType * varArgsType );
     42                void postvisit( ZeroType * zeroType );
     43                void postvisit( OneType * oneType );
    4244          private:
    4345                Type *dest;
     
    5961                        return -1;
    6062                } else {
    61                         PtrsAssignable ptrs( dest, env );
     63                        PassVisitor<PtrsAssignable> ptrs( dest, env );
    6264                        src->accept( ptrs );
    63                         return ptrs.get_result();
     65                        return ptrs.pass.get_result();
    6466                } // if
    6567        }
     
    6769        PtrsAssignable::PtrsAssignable( Type *dest, const TypeEnvironment &env ) : dest( dest ), result( 0 ), env( env ) {}
    6870
    69         void PtrsAssignable::visit( VoidType * ) {
     71        void PtrsAssignable::postvisit( VoidType * ) {
    7072                // T * = void * is disallowed - this is a change from C, where any
    7173                // void * can be assigned or passed to a non-void pointer without a cast.
    7274        }
    7375
    74         void PtrsAssignable::visit( __attribute__((unused)) BasicType *basicType ) {}
    75         void PtrsAssignable::visit( __attribute__((unused)) PointerType *pointerType ) {}
    76         void PtrsAssignable::visit( __attribute__((unused)) ArrayType *arrayType ) {}
    77         void PtrsAssignable::visit( __attribute__((unused)) FunctionType *functionType ) {}
     76        void PtrsAssignable::postvisit( __attribute__((unused)) BasicType *basicType ) {}
     77        void PtrsAssignable::postvisit( __attribute__((unused)) PointerType *pointerType ) {}
     78        void PtrsAssignable::postvisit( __attribute__((unused)) ArrayType *arrayType ) {}
     79        void PtrsAssignable::postvisit( __attribute__((unused)) FunctionType *functionType ) {}
    7880
    79         void PtrsAssignable::visit(  __attribute__((unused)) StructInstType *inst ) {}
    80         void PtrsAssignable::visit(  __attribute__((unused)) UnionInstType *inst ) {}
     81        void PtrsAssignable::postvisit(  __attribute__((unused)) StructInstType *inst ) {}
     82        void PtrsAssignable::postvisit(  __attribute__((unused)) UnionInstType *inst ) {}
    8183
    82         void PtrsAssignable::visit( EnumInstType * ) {
     84        void PtrsAssignable::postvisit( EnumInstType * ) {
    8385                if ( dynamic_cast< BasicType* >( dest ) ) {
    8486                        // int * = E *, etc. is safe. This isn't technically correct, as each
     
    9193        }
    9294
    93         void PtrsAssignable::visit(  __attribute__((unused)) TraitInstType *inst ) {}
    94         void PtrsAssignable::visit( TypeInstType *inst ) {
     95        void PtrsAssignable::postvisit(  __attribute__((unused)) TraitInstType *inst ) {}
     96        void PtrsAssignable::postvisit( TypeInstType *inst ) {
    9597                EqvClass eqvClass;
    9698                if ( env.lookup( inst->get_name(), eqvClass ) && eqvClass.type ) {
     
    100102        }
    101103
    102         void PtrsAssignable::visit(  __attribute__((unused)) TupleType *tupleType ) {}
    103         void PtrsAssignable::visit(  __attribute__((unused)) VarArgsType *varArgsType ) {}
    104         void PtrsAssignable::visit(  __attribute__((unused)) ZeroType *zeroType ) {}
    105         void PtrsAssignable::visit(  __attribute__((unused)) OneType *oneType ) {}
     104        void PtrsAssignable::postvisit(  __attribute__((unused)) TupleType *tupleType ) {}
     105        void PtrsAssignable::postvisit(  __attribute__((unused)) VarArgsType *varArgsType ) {}
     106        void PtrsAssignable::postvisit(  __attribute__((unused)) ZeroType *zeroType ) {}
     107        void PtrsAssignable::postvisit(  __attribute__((unused)) OneType *oneType ) {}
    106108
    107109} // namespace ResolvExpr
Note: See TracChangeset for help on using the changeset viewer.