Ignore:
Timestamp:
Feb 1, 2024, 5:13:04 PM (6 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
020fa10
Parents:
496ffc17
Message:

Remove EnumPosExpr?, an early design that no longer used. The implementation of the feature has been replaced by ReplacePseudoFunc?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CandidateFinder.cpp

    r496ffc17 r9ddcee1  
    659659                void postvisit( const ast::OffsetofExpr * offsetofExpr );
    660660                void postvisit( const ast::OffsetPackExpr * offsetPackExpr );
    661                 void postvisit( const ast::EnumPosExpr * enumPosExpr );
    662661                void postvisit( const ast::LogicalExpr * logicalExpr );
    663662                void postvisit( const ast::ConditionalExpr * conditionalExpr );
     
    15071506        void Finder::postvisit( const ast::OffsetPackExpr * offsetPackExpr ) {
    15081507                addCandidate( offsetPackExpr, tenv );
    1509         }
    1510 
    1511         void Finder::postvisit( const ast::EnumPosExpr * enumPosExpr ) {
    1512                 CandidateFinder finder( context, tenv );
    1513                 finder.find( enumPosExpr->expr );
    1514                 CandidateList winners = findMinCost( finder.candidates );
    1515                 if ( winners.size() != 1 ) SemanticError( enumPosExpr->expr.get(), "Ambiguous expression in position. ");
    1516                 CandidateRef & choice = winners.front();
    1517                 auto refExpr = referenceToRvalueConversion( choice->expr, choice->cost );
    1518                 auto refResult = (refExpr->result).as<ast::EnumInstType>();
    1519                 if ( !refResult ) {
    1520                         SemanticError( refExpr, "Position for Non enum type is not supported" );
    1521                 }
    1522                 // determineEnumPosConstant( enumPosExpr, refResult );
    1523 
    1524                 const ast::NameExpr * const nameExpr = enumPosExpr->expr.strict_as<ast::NameExpr>();
    1525                 const ast::EnumDecl * base = refResult->base;
    1526                 if ( !base ) {
    1527                         SemanticError( enumPosExpr, "Cannot be reference to a defined enumeration type" );
    1528                 }
    1529                 auto it = std::find_if( std::begin( base->members ), std::end( base->members ),
    1530                         [nameExpr]( ast::ptr<ast::Decl> decl ) { return decl->name == nameExpr->name; } );
    1531                 unsigned position = it - base->members.begin();
    1532                 addCandidate( ast::ConstantExpr::from_int( enumPosExpr->location, position ), tenv );
    15331508        }
    15341509
Note: See TracChangeset for help on using the changeset viewer.