Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CastCost.cc

    r0c6596f rea6332d  
    4949                                assert( type );
    5050                                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 );
    5252                                } // if
    5353                        } // if
    5454                } // if
    5555                if ( typesCompatibleIgnoreQualifiers( src, dest, indexer, env ) ) {
    56                         return Cost::zero;
     56                        return Cost( 0, 0, 0 );
    5757                } 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 );
    6359                } else {
    6460                        CastCost converter( dest, indexer, env );
     
    6864                        } else {
    6965                                // xxx - why are we adding cost 0 here?
    70                                 return converter.get_cost() + Cost::zero;
     66                                return converter.get_cost() + Cost( 0, 0, 0 );
    7167                        } // if
    7268                } // if
     
    8177                if ( destAsPointer && basicType->isInteger() ) {
    8278                        // necessary for, e.g. unsigned long => void*
    83                         cost = Cost::unsafe;
     79                        cost = Cost( 1, 0, 0 );
    8480                } else {
    85                         cost = conversionCost( basicType, dest, indexer, env );
     81                        ConversionCost::visit( basicType );
    8682                } // if
    8783        }
     
    9086                if ( PointerType *destAsPtr = dynamic_cast< PointerType* >( dest ) ) {
    9187                        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 );
    9389                        } else {
    9490                                TypeEnvironment newEnv( env );
     
    9793                                int castResult = ptrsCastable( pointerType->get_base(), destAsPtr->get_base(), newEnv, indexer );
    9894                                if ( castResult > 0 ) {
    99                                         cost = Cost::safe;
     95                                        cost = Cost( 0, 0, 1 );
    10096                                } else if ( castResult < 0 ) {
    10197                                        cost = Cost::infinity;
     
    105101                        if ( destAsBasic->isInteger() ) {
    106102                                // necessary for, e.g. void* => unsigned long
    107                                 cost = Cost::unsafe;
     103                                cost = Cost( 1, 0, 0 );
    108104                        } // if
    109105                }
Note: See TracChangeset for help on using the changeset viewer.