Changeset 6b224a52 for src/ResolvExpr/CastCost.cc
- Timestamp:
- Aug 25, 2017, 12:11:53 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:
- bf7b9da7
- Parents:
- 135b431 (diff), f676b84 (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
-
src/ResolvExpr/CastCost.cc (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CastCost.cc
r135b431 r6b224a52 49 49 assert( type ); 50 50 if ( type->get_base() ) { 51 return castCost( src, type->get_base(), indexer, env ) + Cost ( 0, 0, 1 );51 return castCost( src, type->get_base(), indexer, env ) + Cost::safe; 52 52 } // if 53 53 } // if 54 54 } // if 55 55 if ( typesCompatibleIgnoreQualifiers( src, dest, indexer, env ) ) { 56 return Cost ( 0, 0, 0 );56 return Cost::zero; 57 57 } else if ( dynamic_cast< VoidType* >( dest ) ) { 58 return Cost( 0, 0, 1 ); 58 return Cost::safe; 59 } else if ( ReferenceType * refType = dynamic_cast< ReferenceType * > ( dest ) ) { 60 return convertToReferenceCost( src, refType, indexer, env ); 59 61 } else { 60 62 CastCost converter( dest, indexer, env ); … … 64 66 } else { 65 67 // xxx - why are we adding cost 0 here? 66 return converter.get_cost() + Cost ( 0, 0, 0 );68 return converter.get_cost() + Cost::zero; 67 69 } // if 68 70 } // if … … 77 79 if ( destAsPointer && basicType->isInteger() ) { 78 80 // necessary for, e.g. unsigned long => void* 79 cost = Cost ( 1, 0, 0 );81 cost = Cost::unsafe; 80 82 } else { 81 ConversionCost::visit( basicType);83 cost = conversionCost( basicType, dest, indexer, env ); 82 84 } // if 83 85 } … … 86 88 if ( PointerType *destAsPtr = dynamic_cast< PointerType* >( dest ) ) { 87 89 if ( pointerType->get_qualifiers() <= destAsPtr->get_qualifiers() && typesCompatibleIgnoreQualifiers( pointerType->get_base(), destAsPtr->get_base(), indexer, env ) ) { 88 cost = Cost ( 0, 0, 1 );90 cost = Cost::safe; 89 91 } else { 90 92 TypeEnvironment newEnv( env ); … … 93 95 int castResult = ptrsCastable( pointerType->get_base(), destAsPtr->get_base(), newEnv, indexer ); 94 96 if ( castResult > 0 ) { 95 cost = Cost ( 0, 0, 1 );97 cost = Cost::safe; 96 98 } else if ( castResult < 0 ) { 97 99 cost = Cost::infinity; … … 101 103 if ( destAsBasic->isInteger() ) { 102 104 // necessary for, e.g. void* => unsigned long 103 cost = Cost ( 1, 0, 0 );105 cost = Cost::unsafe; 104 106 } // if 105 107 }
Note:
See TracChangeset
for help on using the changeset viewer.