Changes in src/ResolvExpr/CastCost.cc [89be1c68:0b150ec]
- File:
-
- 1 edited
-
src/ResolvExpr/CastCost.cc (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CastCost.cc
r89be1c68 r0b150ec 46 46 assert( type ); 47 47 if ( type->get_base() ) { 48 return castCost( src, type->get_base(), indexer, env ) + Cost ::safe;48 return castCost( src, type->get_base(), indexer, env ) + Cost( 0, 0, 1 ); 49 49 } // if 50 50 } // if 51 51 } // if 52 52 if ( typesCompatibleIgnoreQualifiers( src, dest, indexer, env ) ) { 53 return Cost ::zero;53 return Cost( 0, 0, 0 ); 54 54 } else if ( dynamic_cast< VoidType* >( dest ) ) { 55 return Cost::safe; 56 } else if ( ReferenceType * refType = dynamic_cast< ReferenceType * > ( dest ) ) { 57 return convertToReferenceCost( src, refType, indexer, env ); 55 return Cost( 0, 0, 1 ); 58 56 } else { 59 57 CastCost converter( dest, indexer, env ); … … 63 61 } else { 64 62 // xxx - why are we adding cost 0 here? 65 return converter.get_cost() + Cost ::zero;63 return converter.get_cost() + Cost( 0, 0, 0 ); 66 64 } // if 67 65 } // if … … 76 74 if ( destAsPointer && basicType->isInteger() ) { 77 75 // necessary for, e.g. unsigned long => void* 78 cost = Cost ::unsafe;76 cost = Cost( 1, 0, 0 ); 79 77 } else { 80 cost = conversionCost( basicType, dest, indexer, env);78 ConversionCost::visit( basicType ); 81 79 } // if 82 80 } … … 85 83 if ( PointerType *destAsPtr = dynamic_cast< PointerType* >( dest ) ) { 86 84 if ( pointerType->get_qualifiers() <= destAsPtr->get_qualifiers() && typesCompatibleIgnoreQualifiers( pointerType->get_base(), destAsPtr->get_base(), indexer, env ) ) { 87 cost = Cost ::safe;85 cost = Cost( 0, 0, 1 ); 88 86 } else { 89 87 TypeEnvironment newEnv( env ); … … 92 90 int castResult = ptrsCastable( pointerType->get_base(), destAsPtr->get_base(), newEnv, indexer ); 93 91 if ( castResult > 0 ) { 94 cost = Cost ::safe;92 cost = Cost( 0, 0, 1 ); 95 93 } else if ( castResult < 0 ) { 96 94 cost = Cost::infinity; … … 100 98 if ( destAsBasic->isInteger() ) { 101 99 // necessary for, e.g. void* => unsigned long 102 cost = Cost ::unsafe;100 cost = Cost( 1, 0, 0 ); 103 101 } // if 104 102 }
Note:
See TracChangeset
for help on using the changeset viewer.