Changes in src/ResolvExpr/PtrsCastable.cc [12145b9:b0837e4]
- File:
-
- 1 edited
-
src/ResolvExpr/PtrsCastable.cc (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/PtrsCastable.cc
r12145b9 rb0837e4 14 14 // 15 15 16 #include "Common/PassVisitor.h"17 16 #include "ResolvExpr/TypeEnvironment.h" // for EqvClass, TypeEnvironment 18 17 #include "SymTab/Indexer.h" // for Indexer … … 22 21 #include "typeops.h" // for ptrsAssignable 23 22 23 24 24 namespace ResolvExpr { 25 struct PtrsCastable : public WithShortCircuiting{25 class PtrsCastable : public Visitor { 26 26 public: 27 27 PtrsCastable( Type *dest, const TypeEnvironment &env, const SymTab::Indexer &indexer ); … … 29 29 int get_result() const { return result; } 30 30 31 void previsit( Type * ) { visit_children = false; } 32 33 void postvisit( VoidType * voidType ); 34 void postvisit( BasicType * basicType ); 35 void postvisit( PointerType * pointerType ); 36 void postvisit( ArrayType * arrayType ); 37 void postvisit( FunctionType * functionType ); 38 void postvisit( StructInstType * inst ); 39 void postvisit( UnionInstType * inst ); 40 void postvisit( EnumInstType * inst ); 41 void postvisit( TraitInstType * inst ); 42 void postvisit( TypeInstType * inst ); 43 void postvisit( TupleType * tupleType ); 44 void postvisit( VarArgsType * varArgsType ); 45 void postvisit( ZeroType * zeroType ); 46 void postvisit( OneType * oneType ); 31 virtual void visit(VoidType *voidType); 32 virtual void visit(BasicType *basicType); 33 virtual void visit(PointerType *pointerType); 34 virtual void visit(ArrayType *arrayType); 35 virtual void visit(FunctionType *functionType); 36 virtual void visit(StructInstType *inst); 37 virtual void visit(UnionInstType *inst); 38 virtual void visit(EnumInstType *inst); 39 virtual void visit(TraitInstType *inst); 40 virtual void visit(TypeInstType *inst); 41 virtual void visit(TupleType *tupleType); 42 virtual void visit(VarArgsType *varArgsType); 43 virtual void visit(ZeroType *zeroType); 44 virtual void visit(OneType *oneType); 47 45 private: 48 46 Type *dest; … … 81 79 EqvClass eqvClass; 82 80 if ( env.lookup( destAsTypeInst->get_name(), eqvClass ) ) { 83 // xxx - should this be ptrsCastable?84 81 return ptrsAssignable( src, eqvClass.type, env ); 85 82 } // if … … 88 85 return objectCast( src, env, indexer ); 89 86 } else { 90 P assVisitor<PtrsCastable>ptrs( dest, env, indexer );87 PtrsCastable ptrs( dest, env, indexer ); 91 88 src->accept( ptrs ); 92 return ptrs. pass.get_result();89 return ptrs.get_result(); 93 90 } // if 94 91 } … … 98 95 } 99 96 100 void PtrsCastable:: postvisit( VoidType * ) {97 void PtrsCastable::visit( VoidType * ) { 101 98 result = objectCast( dest, env, indexer ); 102 99 } 103 100 104 void PtrsCastable:: postvisit( BasicType * ) {101 void PtrsCastable::visit( BasicType * ) { 105 102 result = objectCast( dest, env, indexer ); 106 103 } 107 104 108 void PtrsCastable:: postvisit( PointerType * ) {105 void PtrsCastable::visit( PointerType * ) { 109 106 result = objectCast( dest, env, indexer ); 110 107 } 111 108 112 void PtrsCastable:: postvisit( ArrayType * ) {109 void PtrsCastable::visit( ArrayType * ) { 113 110 result = objectCast( dest, env, indexer ); 114 111 } 115 112 116 void PtrsCastable:: postvisit( FunctionType * ) {113 void PtrsCastable::visit( FunctionType * ) { 117 114 // result = -1; 118 115 result = functionCast( dest, env, indexer ); 119 116 } 120 117 121 void PtrsCastable:: postvisit( StructInstType * ) {118 void PtrsCastable::visit( StructInstType * ) { 122 119 result = objectCast( dest, env, indexer ); 123 120 } 124 121 125 void PtrsCastable:: postvisit( UnionInstType * ) {122 void PtrsCastable::visit( UnionInstType * ) { 126 123 result = objectCast( dest, env, indexer ); 127 124 } 128 125 129 void PtrsCastable:: postvisit( EnumInstType * ) {126 void PtrsCastable::visit( EnumInstType * ) { 130 127 if ( dynamic_cast< EnumInstType* >( dest ) ) { 131 128 result = 1; … … 141 138 } 142 139 143 void PtrsCastable:: postvisit( TraitInstType * ) {}140 void PtrsCastable::visit( TraitInstType * ) {} 144 141 145 void PtrsCastable:: postvisit(TypeInstType *inst) {142 void PtrsCastable::visit(TypeInstType *inst) { 146 143 //result = objectCast( inst, env, indexer ) > 0 && objectCast( dest, env, indexer ) > 0 ? 1 : -1; 147 144 result = objectCast( inst, env, indexer ) == objectCast( dest, env, indexer ) ? 1 : -1; 148 145 } 149 146 150 void PtrsCastable:: postvisit( TupleType * ) {147 void PtrsCastable::visit( TupleType * ) { 151 148 result = objectCast( dest, env, indexer ); 152 149 } 153 150 154 void PtrsCastable:: postvisit( VarArgsType * ) {151 void PtrsCastable::visit( VarArgsType * ) { 155 152 result = objectCast( dest, env, indexer ); 156 153 } 157 154 158 void PtrsCastable:: postvisit( ZeroType * ) {155 void PtrsCastable::visit( ZeroType * ) { 159 156 result = objectCast( dest, env, indexer ); 160 157 } 161 158 162 void PtrsCastable:: postvisit( OneType * ) {159 void PtrsCastable::visit( OneType * ) { 163 160 result = objectCast( dest, env, indexer ); 164 161 }
Note:
See TracChangeset
for help on using the changeset viewer.