Changeset bbf2cb1 for src/ResolvExpr


Ignore:
Timestamp:
Mar 6, 2024, 6:06:30 AM (4 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
f6e8c67
Parents:
00eaeb8
Message:

Add the Working support to succ() and pred() pseudo function to Enum

Location:
src/ResolvExpr
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CommonType.cc

    r00eaeb8 rbbf2cb1  
    672672
    673673        void postvisit( const ast::EnumInstType * enumInst ) {
    674                 if (!dynamic_cast<const ast::EnumInstType *>(type2))
     674                // if ( dynamic_cast<const ast::EnumPosType *>(enumInst) ) {
     675                //      result = enumInst;
     676                // } else
     677                if (!dynamic_cast<const ast::EnumInstType *>(type2)) {
    675678                        result = commonType( type2, enumInst, tenv, need, have, open, widen);
    676679                }
     680        }
     681
     682        void postvisit( const ast::EnumPosType * enumPos ) {
     683                if ( auto type2AsPos = dynamic_cast<const ast::EnumPosType *>(type2) ) {
     684                        // result = commonType( type2AsPos->instance, enumPos->instance, tenv, need, have, open, widen );
     685                        result = enumPos;
     686                } else if (  auto typeAsBasic = dynamic_cast<const ast::BasicType *>(type2) ) {
     687                        result = type2;
     688                }
     689        }
    677690
    678691        void postvisit( const ast::TraitInstType * ) {}
  • src/ResolvExpr/ConversionCost.cc

    r00eaeb8 rbbf2cb1  
    366366}
    367367
    368 void ConversionCost::postvisit( const ast::EnumInstType * ) {
     368void ConversionCost::postvisit( const ast::EnumInstType * inst ) {
    369369        static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicType::SignedInt ) };
    370370        cost = costCalc( integer, dst, srcIsLvalue, symtab, env );
     
    374374}
    375375
    376 void ConversionCost::postvisit( const ast::EnumPosType * ) {
    377         if ( dynamic_cast<const ast::EnumPosType *>( dst ) ) {
    378                 // Tempoarary
    379                 cost = Cost::zero;
    380         } else {
     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 {
    381387                static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicType::SignedInt ) };
    382388                cost = costCalc( integer, dst, srcIsLvalue, symtab, env );
  • src/ResolvExpr/Unify.cc

    r00eaeb8 rbbf2cb1  
    518518
    519519                void postvisit( const ast::EnumPosType * ) {
    520                         // Does nothing for now. Handled in ReplacePseudoFunc
    521                         // Might move here in the future
     520                        // Lazy approach for now
     521                        auto otherPos = dynamic_cast< const ast::EnumPosType *>(type2);
     522                        if (otherPos) this->result = otherPos;
    522523                }
    523524
Note: See TracChangeset for help on using the changeset viewer.