Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/StatementNode.cc

    rab780e6 r44adf1b  
    122122        ast::Expr * cond = nullptr;
    123123        if ( ctl->condition ) {
    124                 cond = maybeMoveBuild( ctl->condition );
     124                // compare the provided condition against 0
     125                cond = notZeroExpr( maybeMoveBuild( ctl->condition ) );
    125126        } else {
    126127                for ( ast::ptr<ast::Stmt> & stmt : inits ) {
     
    128129                        auto declStmt = stmt.strict_as<ast::DeclStmt>();
    129130                        auto dwt = declStmt->decl.strict_as<ast::DeclWithType>();
    130                         ast::Expr * nze = new ast::VariableExpr( dwt->location, dwt );
     131                        ast::Expr * nze = notZeroExpr( new ast::VariableExpr( dwt->location, dwt ) );
    131132                        cond = cond ? new ast::LogicalExpr( dwt->location, cond, nze, ast::AndExpr ) : nze;
    132133                }
     
    199200        // do-while cannot have declarations in the contitional, so init is always empty
    200201        return new ast::WhileDoStmt( location,
    201                 maybeMoveBuild( ctl ),
     202                notZeroExpr( maybeMoveBuild( ctl ) ),
    202203                buildMoveSingle( stmt ),
    203204                buildMoveOptional( else_ ),
     
    212213
    213214        ast::Expr * astcond = nullptr;                                          // maybe empty
    214         astcond = maybeMoveBuild( forctl->condition );
     215        astcond = notZeroExpr( maybeMoveBuild( forctl->condition ) );
    215216
    216217        ast::Expr * astincr = nullptr;                                          // maybe empty
     
    329330        clause->target = maybeBuild( targetExpr );
    330331        clause->stmt = maybeMoveBuild( stmt );
    331         clause->when_cond = maybeMoveBuild( when );
     332        clause->when_cond = notZeroExpr( maybeMoveBuild( when ) );
    332333
    333334        ExpressionNode * next = targetExpr->next;
     
    344345ast::WaitForStmt * build_waitfor_else( const CodeLocation & location, ast::WaitForStmt * existing, ExpressionNode * when, StatementNode * stmt ) {
    345346        existing->else_stmt = maybeMoveBuild( stmt );
    346         existing->else_cond = maybeMoveBuild( when );
     347        existing->else_cond = notZeroExpr( maybeMoveBuild( when ) );
    347348
    348349        (void)location;
     
    353354        existing->timeout_time = maybeMoveBuild( timeout );
    354355        existing->timeout_stmt = maybeMoveBuild( stmt );
    355         existing->timeout_cond = maybeMoveBuild( when );
     356        existing->timeout_cond = notZeroExpr( maybeMoveBuild( when ) );
    356357
    357358        (void)location;
     
    361362ast::WaitUntilStmt::ClauseNode * build_waituntil_clause( const CodeLocation & loc, ExpressionNode * when, ExpressionNode * targetExpr, StatementNode * stmt ) {
    362363        ast::WhenClause * clause = new ast::WhenClause( loc );
    363         clause->when_cond = maybeMoveBuild( when );
     364        clause->when_cond = notZeroExpr( maybeMoveBuild( when ) );
    364365        clause->stmt = maybeMoveBuild( stmt );
    365366        clause->target = maybeMoveBuild( targetExpr );
     
    368369ast::WaitUntilStmt::ClauseNode * build_waituntil_else( const CodeLocation & loc, ExpressionNode * when, StatementNode * stmt ) {
    369370        ast::WhenClause * clause = new ast::WhenClause( loc );
    370         clause->when_cond = maybeMoveBuild( when );
     371        clause->when_cond = notZeroExpr( maybeMoveBuild( when ) );
    371372        clause->stmt = maybeMoveBuild( stmt );
    372373        return new ast::WaitUntilStmt::ClauseNode( ast::WaitUntilStmt::ClauseNode::Op::ELSE, clause );
     
    507508
    508509        ast::Expr * astcond = nullptr;                                          // maybe empty
    509         astcond = maybeMoveBuild( forctl->condition );
     510        astcond = notZeroExpr( maybeMoveBuild( forctl->condition ) );
    510511
    511512        ast::Expr * astincr = nullptr;                                          // maybe empty
Note: See TracChangeset for help on using the changeset viewer.