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