diff options
| author | Ian Simonson <ian.simonson@protonmail.com> | 2020-04-30 19:10:10 +1000 |
|---|---|---|
| committer | Ian Simonson <ian.simonson@protonmail.com> | 2020-04-30 19:10:10 +1000 |
| commit | a2c3ebb75615ea47052eeb5a99b9b6881bc71d11 (patch) | |
| tree | 5d74614660ed996a3059297fbb6cd019f3d0e0d6 /src-self-hosted | |
| parent | e6fa0beb335ad8ecff005fef924c2a39ed748c56 (diff) | |
| download | zig-a2c3ebb75615ea47052eeb5a99b9b6881bc71d11.tar.gz zig-a2c3ebb75615ea47052eeb5a99b9b6881bc71d11.zip | |
Use transCreateNodeInfixOp instead of maybeSuppressResult
Diffstat (limited to 'src-self-hosted')
| -rw-r--r-- | src-self-hosted/translate_c.zig | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/src-self-hosted/translate_c.zig b/src-self-hosted/translate_c.zig index e4a41f75e7..bda152f134 100644 --- a/src-self-hosted/translate_c.zig +++ b/src-self-hosted/translate_c.zig @@ -1294,36 +1294,21 @@ fn transBinaryOperator( const rhs_node = try transExpr(rp, scope, ZigClangBinaryOperator_getRHS(stmt), .used, .r_value); - const is_lhs_bool = isBoolRes(lhs_node); - const is_rhs_bool = isBoolRes(rhs_node); - - if (!is_lhs_bool and !is_rhs_bool) { - return transCreateNodeInfixOp(rp, scope, lhs_node, op_id, op_token, rhs_node, result_used, true); - } - - const lhs = if (is_lhs_bool) init: { + const lhs = if (isBoolRes(lhs_node)) init: { const cast_node = try transCreateNodeBuiltinFnCall(rp.c, "@boolToInt"); try cast_node.params.push(lhs_node); cast_node.rparen_token = try appendToken(rp.c, .RParen, ")"); break :init &cast_node.base; } else lhs_node; - const rhs = if (is_rhs_bool) init: { + const rhs = if (isBoolRes(rhs_node)) init: { const cast_node = try transCreateNodeBuiltinFnCall(rp.c, "@boolToInt"); try cast_node.params.push(rhs_node); cast_node.rparen_token = try appendToken(rp.c, .RParen, ")"); break :init &cast_node.base; } else rhs_node; - const node = try rp.c.a().create(ast.Node.InfixOp); - - node.* = .{ - .op_token = op_token, - .lhs = lhs, - .op = op_id, - .rhs = rhs, - }; - return maybeSuppressResult(rp, scope, result_used, &node.base); + return transCreateNodeInfixOp(rp, scope, lhs, op_id, op_token, rhs, result_used, true); } fn transCompoundStmtInline( |
