Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/ConversionCost.cc

    r89e6ffc ra436947  
    160160                        // xxx - not positive this is correct, but appears to allow casting int => enum
    161161                        cost = Cost( 1, 0, 0 );
    162                 } else if ( dynamic_cast< ZeroType* >( dest ) != nullptr || dynamic_cast< OneType* >( dest ) != nullptr ) {
    163                         cost = Cost( 1, 0, 0 );
    164                 } // if
     162    } // if
    165163        }
    166164
     
    177175                                } // if
    178176                        } // if
    179                 } else if ( dynamic_cast< ZeroType* >( dest ) != nullptr || dynamic_cast< OneType* >( dest ) != nullptr ) {
    180                         cost = Cost( 1, 0, 0 );
    181177                } // if
    182178        }
     
    260256                }
    261257        }
    262 
    263         void ConversionCost::visit(ZeroType *zeroType) {
    264                 if ( dynamic_cast< ZeroType* >( dest ) ) {
    265                         cost = Cost::zero;
    266                 } else if ( BasicType *destAsBasic = dynamic_cast< BasicType* >( dest ) ) {
    267                         // copied from visit(BasicType*) for signed int, but +1 for safe conversions
    268                         int tableResult = costMatrix[ BasicType::SignedInt ][ destAsBasic->get_kind() ];
    269                         if ( tableResult == -1 ) {
    270                                 cost = Cost( 1, 0, 0 );
    271                         } else {
    272                                 cost = Cost( 0, 0, tableResult + 1 );
    273                         }
    274                 } else if ( dynamic_cast< PointerType* >( dest ) ) {
    275                         cost = Cost( 0, 0, 1 );
    276                 }
    277         }
    278 
    279         void ConversionCost::visit(OneType *oneType) {
    280                 if ( dynamic_cast< OneType* >( dest ) ) {
    281                         cost = Cost::zero;
    282                 } else if ( BasicType *destAsBasic = dynamic_cast< BasicType* >( dest ) ) {
    283                         // copied from visit(BasicType*) for signed int, but +1 for safe conversions
    284                         int tableResult = costMatrix[ BasicType::SignedInt ][ destAsBasic->get_kind() ];
    285                         if ( tableResult == -1 ) {
    286                                 cost = Cost( 1, 0, 0 );
    287                         } else {
    288                                 cost = Cost( 0, 0, tableResult + 1 );
    289                         }
    290                 }
    291         }
    292258} // namespace ResolvExpr
    293259
Note: See TracChangeset for help on using the changeset viewer.