Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CastCost.cc

    r89be1c68 r0b150ec  
    4646                                assert( type );
    4747                                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 );
    4949                                } // if
    5050                        } // if
    5151                } // if
    5252                if ( typesCompatibleIgnoreQualifiers( src, dest, indexer, env ) ) {
    53                         return Cost::zero;
     53                        return Cost( 0, 0, 0 );
    5454                } 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 );
    5856                } else {
    5957                        CastCost converter( dest, indexer, env );
     
    6361                        } else {
    6462                                // xxx - why are we adding cost 0 here?
    65                                 return converter.get_cost() + Cost::zero;
     63                                return converter.get_cost() + Cost( 0, 0, 0 );
    6664                        } // if
    6765                } // if
     
    7674                if ( destAsPointer && basicType->isInteger() ) {
    7775                        // necessary for, e.g. unsigned long => void*
    78                         cost = Cost::unsafe;
     76                        cost = Cost( 1, 0, 0 );
    7977                } else {
    80                         cost = conversionCost( basicType, dest, indexer, env );
     78                        ConversionCost::visit( basicType );
    8179                } // if
    8280        }
     
    8583                if ( PointerType *destAsPtr = dynamic_cast< PointerType* >( dest ) ) {
    8684                        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 );
    8886                        } else {
    8987                                TypeEnvironment newEnv( env );
     
    9290                                int castResult = ptrsCastable( pointerType->get_base(), destAsPtr->get_base(), newEnv, indexer );
    9391                                if ( castResult > 0 ) {
    94                                         cost = Cost::safe;
     92                                        cost = Cost( 0, 0, 1 );
    9593                                } else if ( castResult < 0 ) {
    9694                                        cost = Cost::infinity;
     
    10098                        if ( destAsBasic->isInteger() ) {
    10199                                // necessary for, e.g. void* => unsigned long
    102                                 cost = Cost::unsafe;
     100                                cost = Cost( 1, 0, 0 );
    103101                        } // if
    104102                }
Note: See TracChangeset for help on using the changeset viewer.