Changeset 23b6643f for src/ResolvExpr/ConversionCost.cc
- Timestamp:
- Sep 20, 2016, 4:47:34 PM (8 years ago)
- 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:
- 1132b62
- Parents:
- aefcc3b (diff), db46512 (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/ConversionCost.cc
raefcc3b r23b6643f 160 160 // xxx - not positive this is correct, but appears to allow casting int => enum 161 161 cost = Cost( 1, 0, 0 ); 162 } // if 162 } else if ( dynamic_cast< ZeroType* >( dest ) != nullptr || dynamic_cast< OneType* >( dest ) != nullptr ) { 163 cost = Cost( 1, 0, 0 ); 164 } // if 163 165 } 164 166 … … 175 177 } // if 176 178 } // if 179 } else if ( dynamic_cast< ZeroType* >( dest ) != nullptr || dynamic_cast< OneType* >( dest ) != nullptr ) { 180 cost = Cost( 1, 0, 0 ); 177 181 } // if 178 182 } … … 256 260 } 257 261 } 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 conversions 268 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 conversions 284 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 } 258 292 } // namespace ResolvExpr 259 293
Note: See TracChangeset
for help on using the changeset viewer.