Changes in src/Parser/StatementNode.cc [ab780e6:44adf1b]
- File:
-
- 1 edited
-
src/Parser/StatementNode.cc (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/StatementNode.cc
rab780e6 r44adf1b 122 122 ast::Expr * cond = nullptr; 123 123 if ( ctl->condition ) { 124 cond = maybeMoveBuild( ctl->condition ); 124 // compare the provided condition against 0 125 cond = notZeroExpr( maybeMoveBuild( ctl->condition ) ); 125 126 } else { 126 127 for ( ast::ptr<ast::Stmt> & stmt : inits ) { … … 128 129 auto declStmt = stmt.strict_as<ast::DeclStmt>(); 129 130 auto dwt = declStmt->decl.strict_as<ast::DeclWithType>(); 130 ast::Expr * nze = n ew ast::VariableExpr( dwt->location, dwt);131 ast::Expr * nze = notZeroExpr( new ast::VariableExpr( dwt->location, dwt ) ); 131 132 cond = cond ? new ast::LogicalExpr( dwt->location, cond, nze, ast::AndExpr ) : nze; 132 133 } … … 199 200 // do-while cannot have declarations in the contitional, so init is always empty 200 201 return new ast::WhileDoStmt( location, 201 maybeMoveBuild( ctl),202 notZeroExpr( maybeMoveBuild( ctl ) ), 202 203 buildMoveSingle( stmt ), 203 204 buildMoveOptional( else_ ), … … 212 213 213 214 ast::Expr * astcond = nullptr; // maybe empty 214 astcond = maybeMoveBuild( forctl->condition);215 astcond = notZeroExpr( maybeMoveBuild( forctl->condition ) ); 215 216 216 217 ast::Expr * astincr = nullptr; // maybe empty … … 329 330 clause->target = maybeBuild( targetExpr ); 330 331 clause->stmt = maybeMoveBuild( stmt ); 331 clause->when_cond = maybeMoveBuild( when);332 clause->when_cond = notZeroExpr( maybeMoveBuild( when ) ); 332 333 333 334 ExpressionNode * next = targetExpr->next; … … 344 345 ast::WaitForStmt * build_waitfor_else( const CodeLocation & location, ast::WaitForStmt * existing, ExpressionNode * when, StatementNode * stmt ) { 345 346 existing->else_stmt = maybeMoveBuild( stmt ); 346 existing->else_cond = maybeMoveBuild( when);347 existing->else_cond = notZeroExpr( maybeMoveBuild( when ) ); 347 348 348 349 (void)location; … … 353 354 existing->timeout_time = maybeMoveBuild( timeout ); 354 355 existing->timeout_stmt = maybeMoveBuild( stmt ); 355 existing->timeout_cond = maybeMoveBuild( when);356 existing->timeout_cond = notZeroExpr( maybeMoveBuild( when ) ); 356 357 357 358 (void)location; … … 361 362 ast::WaitUntilStmt::ClauseNode * build_waituntil_clause( const CodeLocation & loc, ExpressionNode * when, ExpressionNode * targetExpr, StatementNode * stmt ) { 362 363 ast::WhenClause * clause = new ast::WhenClause( loc ); 363 clause->when_cond = maybeMoveBuild( when);364 clause->when_cond = notZeroExpr( maybeMoveBuild( when ) ); 364 365 clause->stmt = maybeMoveBuild( stmt ); 365 366 clause->target = maybeMoveBuild( targetExpr ); … … 368 369 ast::WaitUntilStmt::ClauseNode * build_waituntil_else( const CodeLocation & loc, ExpressionNode * when, StatementNode * stmt ) { 369 370 ast::WhenClause * clause = new ast::WhenClause( loc ); 370 clause->when_cond = maybeMoveBuild( when);371 clause->when_cond = notZeroExpr( maybeMoveBuild( when ) ); 371 372 clause->stmt = maybeMoveBuild( stmt ); 372 373 return new ast::WaitUntilStmt::ClauseNode( ast::WaitUntilStmt::ClauseNode::Op::ELSE, clause ); … … 507 508 508 509 ast::Expr * astcond = nullptr; // maybe empty 509 astcond = maybeMoveBuild( forctl->condition);510 astcond = notZeroExpr( maybeMoveBuild( forctl->condition ) ); 510 511 511 512 ast::Expr * astincr = nullptr; // maybe empty
Note:
See TracChangeset
for help on using the changeset viewer.