Changeset 9ddcee1 for src/ResolvExpr


Ignore:
Timestamp:
Feb 1, 2024, 5:13:04 PM (5 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?

Location:
src/ResolvExpr
Files:
3 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
  • src/ResolvExpr/ConversionCost.cc

    r496ffc17 r9ddcee1  
    361361}
    362362
    363 void ConversionCost::postvisit( const ast::EnumInstType * enumInstType ) {
    364         //      const ast::EnumDecl * baseEnum = enumInstType->base;
    365         // if ( const ast::Type * baseType = baseEnum->base ) {
    366         //      costCalc( baseType, dst, srcIsLvalue, symtab, env );
    367         // } else {
     363void ConversionCost::postvisit( const ast::EnumInstType * ) {
    368364        static ast::ptr<ast::BasicType> integer = { new ast::BasicType( ast::BasicType::SignedInt ) };
    369365        cost = costCalc( integer, dst, srcIsLvalue, symtab, env );
  • src/ResolvExpr/Resolver.cc

    r496ffc17 r9ddcee1  
    411411                const ast::ConstructorInit * previsit( const ast::ConstructorInit * );
    412412
    413                 const ast::EnumPosExpr *         previsit( const ast::EnumPosExpr * );
    414 
    415413                void resolveWithExprs(std::vector<ast::ptr<ast::Expr>> & exprs, std::list<ast::ptr<ast::Stmt>> & stmtsToAdd);
    416414
     
    12321230        }
    12331231
    1234         const ast::EnumPosExpr * Resolver::previsit( const ast::EnumPosExpr * enumPos ) {
    1235                 visitor->maybe_accept( enumPos, &ast::EnumPosExpr::expr );
    1236                 return enumPos;
    1237         }
    1238 
    12391232        // suppress error on autogen functions and mark invalid autogen as deleted.
    12401233        bool Resolver::on_error(ast::ptr<ast::Decl> & decl) {
Note: See TracChangeset for help on using the changeset viewer.