Changes in src/ResolvExpr/PtrsCastable.cc [b0837e4:ea6332d]
- File:
-
- 1 edited
-
src/ResolvExpr/PtrsCastable.cc (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/PtrsCastable.cc
rb0837e4 rea6332d 50 50 }; 51 51 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 ) { 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 ) { 66 60 return -1; 67 61 } // if 62 } //if 63 } else if ( env.lookup( typeInst->get_name(), eqvClass ) ) { 64 if ( eqvClass.data.kind == TypeDecl::Ftype ) { 65 return -1; 68 66 } // if 69 } // if70 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 objectCast74 }67 } // if 68 } //if 69 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 objectCast 75 73 } 76 74 … … 95 93 } 96 94 97 void PtrsCastable::visit( VoidType *) {95 void PtrsCastable::visit( __attribute__((unused)) VoidType *voidType) { 98 96 result = objectCast( dest, env, indexer ); 99 97 } 100 98 101 void PtrsCastable::visit( BasicType *) {99 void PtrsCastable::visit( __attribute__((unused)) BasicType *basicType) { 102 100 result = objectCast( dest, env, indexer ); 103 101 } 104 102 105 void PtrsCastable::visit( PointerType *) {103 void PtrsCastable::visit( __attribute__((unused)) PointerType *pointerType) { 106 104 result = objectCast( dest, env, indexer ); 107 105 } 108 106 109 void PtrsCastable::visit( ArrayType *) {107 void PtrsCastable::visit( __attribute__((unused)) ArrayType *arrayType) { 110 108 result = objectCast( dest, env, indexer ); 111 109 } 112 110 113 void PtrsCastable::visit( FunctionType *) {111 void PtrsCastable::visit( __attribute__((unused)) FunctionType *functionType) { 114 112 // result = -1; 115 113 result = functionCast( dest, env, indexer ); 116 114 } 117 115 118 void PtrsCastable::visit( StructInstType *) {116 void PtrsCastable::visit( __attribute__((unused)) StructInstType *inst) { 119 117 result = objectCast( dest, env, indexer ); 120 118 } 121 119 122 void PtrsCastable::visit( UnionInstType *) {120 void PtrsCastable::visit( __attribute__((unused)) UnionInstType *inst) { 123 121 result = objectCast( dest, env, indexer ); 124 122 } 125 123 126 void PtrsCastable::visit( EnumInstType *) {124 void PtrsCastable::visit( __attribute__((unused)) EnumInstType *inst) { 127 125 if ( dynamic_cast< EnumInstType* >( dest ) ) { 128 126 result = 1; … … 138 136 } 139 137 140 void PtrsCastable::visit( TraitInstType *) {}138 void PtrsCastable::visit( __attribute__((unused)) TraitInstType *inst ) {} 141 139 142 140 void PtrsCastable::visit(TypeInstType *inst) { … … 145 143 } 146 144 147 void PtrsCastable::visit( TupleType *) {145 void PtrsCastable::visit( __attribute__((unused)) TupleType *tupleType) { 148 146 result = objectCast( dest, env, indexer ); 149 147 } 150 148 151 void PtrsCastable::visit( VarArgsType *) {149 void PtrsCastable::visit( __attribute__((unused)) VarArgsType *varArgsType) { 152 150 result = objectCast( dest, env, indexer ); 153 151 } 154 152 155 void PtrsCastable::visit( ZeroType *) {153 void PtrsCastable::visit( __attribute__((unused)) ZeroType *zeroType) { 156 154 result = objectCast( dest, env, indexer ); 157 155 } 158 156 159 void PtrsCastable::visit( OneType *) {157 void PtrsCastable::visit( __attribute__((unused)) OneType *oneType) { 160 158 result = objectCast( dest, env, indexer ); 161 159 }
Note:
See TracChangeset
for help on using the changeset viewer.