Changeset 61e362f


Ignore:
Timestamp:
Jan 23, 2024, 2:16:13 PM (20 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
71b5aad5
Parents:
a4ed165
Message:

Changed notZeroExpr so that expressions with conditional contexts are handled in the resolver instead of the parser. Bugs kept the same from being done with statements. (Also a bit of clean-up from the last commit and a small fix in code-gen.)

Location:
src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cpp

    ra4ed165 r61e362f  
    11351135                if ( clause->when_cond ) {
    11361136                        output << "when(";
    1137                         stmt->timeout_cond->accept( *visitor );
     1137                        clause->when_cond->accept( *visitor );
    11381138                        output << ") ";
    11391139                }
  • src/InitTweak/FixInit.cpp

    ra4ed165 r61e362f  
    11761176                throw errors;
    11771177        }
    1178         // return funcDecl;
    11791178        return function;
    11801179}
  • src/Parser/ExpressionNode.cc

    ra4ed165 r61e362f  
    673673                ast::LogicalFlag flag ) {
    674674        return new ast::LogicalExpr( location,
    675                 notZeroExpr( maybeMoveBuild( expr_node1 ) ),
    676                 notZeroExpr( maybeMoveBuild( expr_node2 ) ),
     675                maybeMoveBuild( expr_node1 ),
     676                maybeMoveBuild( expr_node2 ),
    677677                flag
    678678        );
     
    713713                ExpressionNode * expr_node3 ) {
    714714        return new ast::ConditionalExpr( location,
    715                 notZeroExpr( maybeMoveBuild( expr_node1 ) ),
     715                maybeMoveBuild( expr_node1 ),
    716716                maybeMoveBuild( expr_node2 ),
    717717                maybeMoveBuild( expr_node3 )
  • src/Parser/parserutility.cc

    ra4ed165 r61e362f  
    2727//    if ( (int)(x != 0) ) ...
    2828
    29 ast::Expr * notZeroExpr( ast::Expr * orig ) {
     29ast::Expr * notZeroExpr( const ast::Expr * orig ) {
    3030        return ( !orig ) ? nullptr : new ast::CastExpr( orig->location,
    3131                ast::UntypedExpr::createCall( orig->location,
  • src/Parser/parserutility.h

    ra4ed165 r61e362f  
    2121}
    2222
    23 ast::Expr * notZeroExpr( ast::Expr *orig );
     23ast::Expr * notZeroExpr( const ast::Expr *orig );
    2424
    2525template< typename T >
  • src/ResolvExpr/CandidateFinder.cpp

    ra4ed165 r61e362f  
    4646#include "AST/Type.hpp"
    4747#include "Common/utility.h"       // for move, copy
     48#include "Parser/parserutility.h" // for notZeroExpr
    4849#include "SymTab/Mangler.h"
    4950#include "Tuples/Tuples.h"        // for handleTupleAssignment
     
    15021503        void Finder::postvisit( const ast::LogicalExpr * logicalExpr ) {
    15031504                CandidateFinder finder1( context, tenv );
    1504                 finder1.find( logicalExpr->arg1, ResolveMode::withAdjustment() );
     1505                ast::ptr<ast::Expr> arg1 = notZeroExpr( logicalExpr->arg1 );
     1506                finder1.find( arg1, ResolveMode::withAdjustment() );
    15051507                if ( finder1.candidates.empty() ) return;
    15061508
    15071509                CandidateFinder finder2( context, tenv );
    1508                 finder2.find( logicalExpr->arg2, ResolveMode::withAdjustment() );
     1510                ast::ptr<ast::Expr> arg2 = notZeroExpr( logicalExpr->arg2 );
     1511                finder2.find( arg2, ResolveMode::withAdjustment() );
    15091512                if ( finder2.candidates.empty() ) return;
    15101513
     
    15321535                // candidates for condition
    15331536                CandidateFinder finder1( context, tenv );
    1534                 finder1.find( conditionalExpr->arg1, ResolveMode::withAdjustment() );
     1537                ast::ptr<ast::Expr> arg1 = notZeroExpr( conditionalExpr->arg1 );
     1538                finder1.find( arg1, ResolveMode::withAdjustment() );
    15351539                if ( finder1.candidates.empty() ) return;
    15361540
  • src/main.cc

    ra4ed165 r61e362f  
    8282#include "Validate/ReturnCheck.hpp"         // for checkReturnStatements
    8383#include "Validate/VerifyCtorDtorAssign.hpp" // for verifyCtorDtorAssign
    84 #include "Validate/ReplacePseudoFunc.hpp"
     84#include "Validate/ReplacePseudoFunc.hpp"   // for replacePseudoFunc
    8585#include "Virtual/ExpandCasts.h"            // for expandCasts
    8686#include "Virtual/VirtualDtor.hpp"          // for implementVirtDtors
Note: See TracChangeset for help on using the changeset viewer.