Ignore:
Timestamp:
Apr 11, 2024, 3:43:48 PM (3 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
b78c54f
Parents:
c4024b46
Message:

notZeroExpr (in the parser) has become createCondExpr (in the resolver). A small part of this, with expressions, had been done previously.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CandidateFinder.cpp

    rc4024b46 rab780e6  
    4646#include "AST/Type.hpp"
    4747#include "Common/utility.h"       // for move, copy
    48 #include "Parser/parserutility.h" // for notZeroExpr
    4948#include "SymTab/Mangler.h"
    5049#include "Tuples/Tuples.h"        // for handleTupleAssignment
     
    15871586        void Finder::postvisit( const ast::LogicalExpr * logicalExpr ) {
    15881587                CandidateFinder finder1( context, tenv );
    1589                 ast::ptr<ast::Expr> arg1 = notZeroExpr( logicalExpr->arg1 );
     1588                ast::ptr<ast::Expr> arg1 = createCondExpr( logicalExpr->arg1 );
    15901589                finder1.find( arg1, ResolveMode::withAdjustment() );
    15911590                if ( finder1.candidates.empty() ) return;
    15921591
    15931592                CandidateFinder finder2( context, tenv );
    1594                 ast::ptr<ast::Expr> arg2 = notZeroExpr( logicalExpr->arg2 );
     1593                ast::ptr<ast::Expr> arg2 = createCondExpr( logicalExpr->arg2 );
    15951594                finder2.find( arg2, ResolveMode::withAdjustment() );
    15961595                if ( finder2.candidates.empty() ) return;
     
    16181617        void Finder::postvisit( const ast::ConditionalExpr * conditionalExpr ) {
    16191618                // candidates for condition
    1620                 ast::ptr<ast::Expr> arg1 = notZeroExpr( conditionalExpr->arg1 );
     1619                ast::ptr<ast::Expr> arg1 = createCondExpr( conditionalExpr->arg1 );
    16211620                CandidateFinder finder1( context, tenv );
    16221621                finder1.find( arg1, ResolveMode::withAdjustment() );
     
    22012200}
    22022201
     2202const ast::Expr * createCondExpr( const ast::Expr * expr ) {
     2203        assert( expr );
     2204        return new ast::CastExpr( expr->location,
     2205                ast::UntypedExpr::createCall( expr->location,
     2206                        "?!=?",
     2207                        {
     2208                                expr,
     2209                                new ast::ConstantExpr( expr->location,
     2210                                        new ast::ZeroType(), "0", std::make_optional( 0ull )
     2211                                ),
     2212                        }
     2213                ),
     2214                new ast::BasicType( ast::BasicType::SignedInt )
     2215        );
     2216}
     2217
    22032218} // namespace ResolvExpr
    22042219
Note: See TracChangeset for help on using the changeset viewer.