Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/ConversionCost.cc

    r0522ebe rbbf2cb1  
    288288            cost = Cost::unsafe;
    289289                }
     290        } else if ( dynamic_cast< const ast::EnumPosType *>(dst) ) {
     291                static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicType::SignedInt ) };
     292                cost = costCalc( basicType, integer, srcIsLvalue, symtab, env );
    290293        }
    291294}
     
    363366}
    364367
    365 void ConversionCost::postvisit( const ast::EnumInstType * ) {
    366         static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicType::SignedInt ) };
    367         cost = costCalc( integer, dst, srcIsLvalue, symtab, env );
    368         // }
    369         if ( cost < Cost::unsafe ) {
    370                 cost.incSafe();
    371         }
    372 }
    373 
    374 void ConversionCost::postvisit( const ast::EnumPosType * ) {
     368void ConversionCost::postvisit( const ast::EnumInstType * inst ) {
    375369        static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicType::SignedInt ) };
    376370        cost = costCalc( integer, dst, srcIsLvalue, symtab, env );
     
    378372                cost.incSafe();
    379373        }
     374}
     375
     376void ConversionCost::postvisit( const ast::EnumPosType * src ) {
     377        if ( auto dstBase = dynamic_cast<const ast::EnumPosType *>( dst ) ) {
     378                // cost = costCalc( src->instance, dstBase->instance, srcIsLvalue, symtab, env );
     379                // if ( cost < Cost::unsafe ) cost.incSafe();
     380                cost = Cost::zero;
     381        }
     382        // if ( auto dstBase = dynamic_cast<const ast::EnumInstType *>( dst ) ) {
     383        //      cost = costCalc( src->instance, dstBase, srcIsLvalue, symtab, env );
     384        //      if ( cost < Cost::unsafe ) cost.incSafe();
     385        // }
     386        else {
     387                static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicType::SignedInt ) };
     388                cost = costCalc( integer, dst, srcIsLvalue, symtab, env );
     389                if ( cost < Cost::unsafe ) {
     390                        cost.incSafe();
     391                }
     392        }
     393
    380394}
    381395
Note: See TracChangeset for help on using the changeset viewer.