authorgravatar for ian.simonson@protonmail.comIan Simonson <ian.simonson@protonmail.com> 2020-04-30 19:10:10+10:00
committergravatar for ian.simonson@protonmail.comIan Simonson <ian.simonson@protonmail.com> 2020-04-30 19:10:10+10:00
loga2c3ebb75615ea47052eeb5a99b9b6881bc71d11
tree5d74614660ed996a3059297fbb6cd019f3d0e0d6
parente6fa0beb335ad8ecff005fef924c2a39ed748c56

Use transCreateNodeInfixOp instead of maybeSuppressResult


1 files changed, 3 insertions(+), 18 deletions(-)

src-self-hosted/translate_c.zig+3-18
......@@ -1294,36 +1294,21 @@ fn transBinaryOperator(
12941294
12951295 const rhs_node = try transExpr(rp, scope, ZigClangBinaryOperator_getRHS(stmt), .used, .r_value);
12961296
1297 const is_lhs_bool = isBoolRes(lhs_node);
1298 const is_rhs_bool = isBoolRes(rhs_node);
1299
1300 if (!is_lhs_bool and !is_rhs_bool) {
1301 return transCreateNodeInfixOp(rp, scope, lhs_node, op_id, op_token, rhs_node, result_used, true);
1302 }
1303
1304 const lhs = if (is_lhs_bool) init: {
1297 const lhs = if (isBoolRes(lhs_node)) init: {
13051298 const cast_node = try transCreateNodeBuiltinFnCall(rp.c, "@boolToInt");
13061299 try cast_node.params.push(lhs_node);
13071300 cast_node.rparen_token = try appendToken(rp.c, .RParen, ")");
13081301 break :init &cast_node.base;
13091302 } else lhs_node;
13101303
1311 const rhs = if (is_rhs_bool) init: {
1304 const rhs = if (isBoolRes(rhs_node)) init: {
13121305 const cast_node = try transCreateNodeBuiltinFnCall(rp.c, "@boolToInt");
13131306 try cast_node.params.push(rhs_node);
13141307 cast_node.rparen_token = try appendToken(rp.c, .RParen, ")");
13151308 break :init &cast_node.base;
13161309 } else rhs_node;
13171310
1318 const node = try rp.c.a().create(ast.Node.InfixOp);
1319
1320 node.* = .{
1321 .op_token = op_token,
1322 .lhs = lhs,
1323 .op = op_id,
1324 .rhs = rhs,
1325 };
1326 return maybeSuppressResult(rp, scope, result_used, &node.base);
1311 return transCreateNodeInfixOp(rp, scope, lhs, op_id, op_token, rhs, result_used, true);
13271312}
13281313
13291314fn transCompoundStmtInline(