Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CastCost.cc

    r543159b r9fd97126  
    1010// Created On       : Sun May 17 06:57:43 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May 17 06:59:10 2015
    13 // Update Count     : 2
     12// Last Modified On : Tue Feb  2 15:34:36 2016
     13// Update Count     : 7
    1414//
    1515
     
    5656                                return Cost::infinity;
    5757                        } else {
     58                                // xxx - why are we adding cost 0 here?
    5859                                return converter.get_cost() + Cost( 0, 0, 0 );
    5960                        } // if
     
    6869                PointerType *destAsPointer = dynamic_cast< PointerType* >( dest );
    6970                if ( destAsPointer && basicType->isInteger() ) {
     71                        // necessary for, e.g. unsigned long => void*
    7072                        cost = Cost( 1, 0, 0 );
    7173                } else {
     
    8284                                newEnv.add( pointerType->get_forall() );
    8385                                newEnv.add( pointerType->get_base()->get_forall() );
    84                                 int assignResult = ptrsCastable( pointerType->get_base(), destAsPtr->get_base(), newEnv, indexer );
    85                                 if ( assignResult > 0 ) {
     86                                int castResult = ptrsCastable( pointerType->get_base(), destAsPtr->get_base(), newEnv, indexer );
     87                                if ( castResult > 0 ) {
    8688                                        cost = Cost( 0, 0, 1 );
    87                                 } else if ( assignResult < 0 ) {
    88                                         cost = Cost( 1, 0, 0 );
     89                                } else if ( castResult < 0 ) {
     90                                        cost = Cost::infinity;
    8991                                } // if
    9092                        } // if
    9193                } else if ( BasicType *destAsBasic = dynamic_cast< BasicType* >( dest ) ) {
    9294                        if ( destAsBasic->isInteger() ) {
     95                                // necessary for, e.g. void* => unsigned long
    9396                                cost = Cost( 1, 0, 0 );
    9497                        } // if
Note: See TracChangeset for help on using the changeset viewer.