Ignore:
Timestamp:
Feb 3, 2025, 11:46:55 AM (2 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
54f70c6
Parents:
bbbff10
Message:

I set out to do a enum rework. It ended up being much the same and I unwound the core rework. But I hope the new names are a bit clearer and other minor fixes are helpful, so I am keeping those.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/ResolvExpr/ConversionCost.cpp

    rbbbff10 r90e683b  
    246246                }
    247247                if (const ast::EnumInstType * srcAsInst = dynamic_cast< const ast::EnumInstType * >( src )) {
    248                         if (srcAsInst->base && !srcAsInst->base->isCfa) {
     248                        if ( srcAsInst->base && srcAsInst->base->is_c_enum() ) {
    249249                                static const ast::BasicType* integer = new ast::BasicType( ast::BasicKind::UnsignedInt );
    250250                                return ast::Pass<ConversionCost>::read( integer, dst, srcIsLvalue, symtab, env, conversionCost );
     
    324324                conversionCostFromBasicToBasic( basicType, dstAsBasic );
    325325        } else if ( auto dstAsEnumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) {
    326                 if ( dstAsEnumInst->base && !dstAsEnumInst->base->isCfa ) {
     326                if ( dstAsEnumInst->base && dstAsEnumInst->base->is_c_enum() ) {
    327327                        cost = Cost::safe;
    328328                }
     
    405405        if ( auto dstInst = dynamic_cast<const ast::EnumInstType *>( dst ) ) {
    406406                cost = enumCastCost(inst, dstInst, symtab, env);
    407         } else if ( !inst->base->isCfa ) {
     407        } else if ( inst->base->is_c_enum() ) {
    408408                static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicKind::SignedInt ) };
    409409                cost = costCalc( integer, dst, srcIsLvalue, symtab, env );
     
    455455}
    456456
    457 void ConversionCost::postvisit( const ast::VarArgsType * varArgsType ) {
    458         (void)varArgsType;
     457void ConversionCost::postvisit( const ast::VarArgsType * ) {
    459458        if ( dynamic_cast< const ast::VarArgsType * >( dst ) ) {
    460459                cost = Cost::zero;
     
    462461}
    463462
    464 void ConversionCost::postvisit( const ast::ZeroType * zeroType ) {
    465         (void)zeroType;
     463void ConversionCost::postvisit( const ast::ZeroType * ) {
    466464        if ( dynamic_cast< const ast::ZeroType * >( dst ) ) {
    467465                cost = Cost::zero;
     
    487485                // assuming 0p is supposed to be used for pointers?
    488486        } else if ( auto dstAsEnumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) {
    489                 if ( dstAsEnumInst->base && !dstAsEnumInst->base->isCfa ) {
     487                if ( dstAsEnumInst->base && dstAsEnumInst->base->is_c_enum() ) {
    490488                        cost = Cost::safe;
    491489                }
     
    493491}
    494492
    495 void ConversionCost::postvisit( const ast::OneType * oneType ) {
    496         (void)oneType;
     493void ConversionCost::postvisit( const ast::OneType * ) {
    497494        if ( dynamic_cast< const ast::OneType * >( dst ) ) {
    498495                cost = Cost::zero;
     
    508505                }
    509506        } else if ( auto dstAsEnumInst = dynamic_cast< const ast::EnumInstType * >( dst ) ) {
    510                 if ( dstAsEnumInst->base && !dstAsEnumInst->base->isCfa ) {
     507                if ( dstAsEnumInst->base && dstAsEnumInst->base->is_c_enum() ) {
    511508                        cost = Cost::safe;
    512509                }
Note: See TracChangeset for help on using the changeset viewer.