- File:
-
- 1 edited
-
src/ResolvExpr/ConversionCost.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/ConversionCost.cc
r89e6ffc ra436947 160 160 // xxx - not positive this is correct, but appears to allow casting int => enum 161 161 cost = Cost( 1, 0, 0 ); 162 } else if ( dynamic_cast< ZeroType* >( dest ) != nullptr || dynamic_cast< OneType* >( dest ) != nullptr ) { 163 cost = Cost( 1, 0, 0 ); 164 } // if 162 } // if 165 163 } 166 164 … … 177 175 } // if 178 176 } // if 179 } else if ( dynamic_cast< ZeroType* >( dest ) != nullptr || dynamic_cast< OneType* >( dest ) != nullptr ) {180 cost = Cost( 1, 0, 0 );181 177 } // if 182 178 } … … 260 256 } 261 257 } 262 263 void ConversionCost::visit(ZeroType *zeroType) {264 if ( dynamic_cast< ZeroType* >( dest ) ) {265 cost = Cost::zero;266 } else if ( BasicType *destAsBasic = dynamic_cast< BasicType* >( dest ) ) {267 // copied from visit(BasicType*) for signed int, but +1 for safe conversions268 int tableResult = costMatrix[ BasicType::SignedInt ][ destAsBasic->get_kind() ];269 if ( tableResult == -1 ) {270 cost = Cost( 1, 0, 0 );271 } else {272 cost = Cost( 0, 0, tableResult + 1 );273 }274 } else if ( dynamic_cast< PointerType* >( dest ) ) {275 cost = Cost( 0, 0, 1 );276 }277 }278 279 void ConversionCost::visit(OneType *oneType) {280 if ( dynamic_cast< OneType* >( dest ) ) {281 cost = Cost::zero;282 } else if ( BasicType *destAsBasic = dynamic_cast< BasicType* >( dest ) ) {283 // copied from visit(BasicType*) for signed int, but +1 for safe conversions284 int tableResult = costMatrix[ BasicType::SignedInt ][ destAsBasic->get_kind() ];285 if ( tableResult == -1 ) {286 cost = Cost( 1, 0, 0 );287 } else {288 cost = Cost( 0, 0, tableResult + 1 );289 }290 }291 }292 258 } // namespace ResolvExpr 293 259
Note:
See TracChangeset
for help on using the changeset viewer.