Changeset 136ccd7 for src/ResolvExpr/PtrsCastable.cc
- Timestamp:
- Nov 3, 2017, 3:01:31 PM (6 years ago)
- 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:
- 4ee36bf0
- Parents:
- 4ee1efb (diff), 760ba67 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/PtrsCastable.cc
r4ee1efb r136ccd7 50 50 }; 51 51 52 int objectCast( Type *src, const TypeEnvironment &env, const SymTab::Indexer &indexer ) { 53 if ( dynamic_cast< FunctionType* >( src ) ) { 54 return -1; 55 } else if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( src ) ) { 56 EqvClass eqvClass; 57 if ( NamedTypeDecl *ntDecl = indexer.lookupType( typeInst->get_name() ) ) { 58 if ( TypeDecl *tyDecl = dynamic_cast< TypeDecl* >( ntDecl ) ) { 59 if ( tyDecl->get_kind() == TypeDecl::Ftype ) { 52 namespace { 53 int objectCast( Type *src, const TypeEnvironment &env, const SymTab::Indexer &indexer ) { 54 if ( dynamic_cast< FunctionType* >( src ) ) { 55 return -1; 56 } else if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( src ) ) { 57 EqvClass eqvClass; 58 if ( NamedTypeDecl *ntDecl = indexer.lookupType( typeInst->get_name() ) ) { 59 if ( TypeDecl *tyDecl = dynamic_cast< TypeDecl* >( ntDecl ) ) { 60 if ( tyDecl->get_kind() == TypeDecl::Ftype ) { 61 return -1; 62 } // if 63 } //if 64 } else if ( env.lookup( typeInst->get_name(), eqvClass ) ) { 65 if ( eqvClass.data.kind == TypeDecl::Ftype ) { 60 66 return -1; 61 67 } // if 62 } //if63 } else if ( env.lookup( typeInst->get_name(), eqvClass ) ) {64 if ( eqvClass.data.kind == TypeDecl::Ftype ) {65 return -1;66 68 } // if 67 } // 68 } //if69 return 1;70 }71 int functionCast( Type *src, const TypeEnvironment &env, const SymTab::Indexer &indexer ) {72 return -1 * objectCast( src, env, indexer ); // reverse the sense of objectCast69 } //if 70 return 1; 71 } 72 int functionCast( Type *src, const TypeEnvironment &env, const SymTab::Indexer &indexer ) { 73 return -1 * objectCast( src, env, indexer ); // reverse the sense of objectCast 74 } 73 75 } 74 76 … … 93 95 } 94 96 95 void PtrsCastable::visit( __attribute__((unused)) VoidType *voidType) {97 void PtrsCastable::visit( VoidType * ) { 96 98 result = objectCast( dest, env, indexer ); 97 99 } 98 100 99 void PtrsCastable::visit( __attribute__((unused)) BasicType *basicType) {101 void PtrsCastable::visit( BasicType * ) { 100 102 result = objectCast( dest, env, indexer ); 101 103 } 102 104 103 void PtrsCastable::visit( __attribute__((unused)) PointerType *pointerType) {105 void PtrsCastable::visit( PointerType * ) { 104 106 result = objectCast( dest, env, indexer ); 105 107 } 106 108 107 void PtrsCastable::visit( __attribute__((unused)) ArrayType *arrayType) {109 void PtrsCastable::visit( ArrayType * ) { 108 110 result = objectCast( dest, env, indexer ); 109 111 } 110 112 111 void PtrsCastable::visit( __attribute__((unused)) FunctionType *functionType) {113 void PtrsCastable::visit( FunctionType * ) { 112 114 // result = -1; 113 115 result = functionCast( dest, env, indexer ); 114 116 } 115 117 116 void PtrsCastable::visit( __attribute__((unused)) StructInstType *inst) {118 void PtrsCastable::visit( StructInstType * ) { 117 119 result = objectCast( dest, env, indexer ); 118 120 } 119 121 120 void PtrsCastable::visit( __attribute__((unused)) UnionInstType *inst) {122 void PtrsCastable::visit( UnionInstType * ) { 121 123 result = objectCast( dest, env, indexer ); 122 124 } 123 125 124 void PtrsCastable::visit( __attribute__((unused)) EnumInstType *inst) {126 void PtrsCastable::visit( EnumInstType * ) { 125 127 if ( dynamic_cast< EnumInstType* >( dest ) ) { 126 128 result = 1; … … 136 138 } 137 139 138 void PtrsCastable::visit( __attribute__((unused)) TraitInstType *inst) {}140 void PtrsCastable::visit( TraitInstType * ) {} 139 141 140 142 void PtrsCastable::visit(TypeInstType *inst) { … … 143 145 } 144 146 145 void PtrsCastable::visit( __attribute__((unused)) TupleType *tupleType) {147 void PtrsCastable::visit( TupleType * ) { 146 148 result = objectCast( dest, env, indexer ); 147 149 } 148 150 149 void PtrsCastable::visit( __attribute__((unused)) VarArgsType *varArgsType) {151 void PtrsCastable::visit( VarArgsType * ) { 150 152 result = objectCast( dest, env, indexer ); 151 153 } 152 154 153 void PtrsCastable::visit( __attribute__((unused)) ZeroType *zeroType) {155 void PtrsCastable::visit( ZeroType * ) { 154 156 result = objectCast( dest, env, indexer ); 155 157 } 156 158 157 void PtrsCastable::visit( __attribute__((unused)) OneType *oneType) {159 void PtrsCastable::visit( OneType * ) { 158 160 result = objectCast( dest, env, indexer ); 159 161 }
Note: See TracChangeset
for help on using the changeset viewer.