| ... | ... | @@ -393,8 +393,42 @@ fn transBinaryOperator( |
| 393 | 393 | .node_scope = scope, |
| 394 | 394 | }); |
| 395 | 395 | }, |
| 396 | | .Mul, |
| 397 | | .Div, |
| 396 | .Mul => { |
| 397 | const node = if (cIsUnsignedInteger(qt)) |
| 398 | try transCreateNodeInfixOp(rp, scope, stmt, .MultWrap, .AsteriskPercent, "*%", true) |
| 399 | else |
| 400 | try transCreateNodeInfixOp(rp, scope, stmt, .Mult, .Asterisk, "*", true); |
| 401 | return maybeSuppressResult(rp, scope, result_used, TransResult{ |
| 402 | .node = node, |
| 403 | .child_scope = scope, |
| 404 | .node_scope = scope, |
| 405 | }); |
| 406 | }, |
| 407 | .Div => { |
| 408 | if (!cIsUnsignedInteger(qt)) { |
| 409 | // signed integer division uses @divTrunc |
| 410 | const div_trunc_node = try transCreateNodeBuiltinFnCall(rp.c, "@divTrunc"); |
| 411 | const lhs = try transExpr(rp, scope, ZigClangBinaryOperator_getLHS(stmt), .used, .l_value); |
| 412 | try div_trunc_node.params.push(lhs.node); |
| 413 | _ = try appendToken(rp.c, .Comma, ","); |
| 414 | const rhs = try transExpr(rp, scope, ZigClangBinaryOperator_getRHS(stmt), .used, .r_value); |
| 415 | try div_trunc_node.params.push(rhs.node); |
| 416 | div_trunc_node.rparen_token = try appendToken(rp.c, .RParen, ")"); |
| 417 | return maybeSuppressResult(rp, scope, result_used, TransResult{ |
| 418 | .node = &div_trunc_node.base, |
| 419 | .child_scope = scope, |
| 420 | .node_scope = scope, |
| 421 | }); |
| 422 | } else { |
| 423 | // unsigned/float division uses the operator |
| 424 | const node = try transCreateNodeInfixOp(rp, scope, stmt, .Div, .Slash, "/", true); |
| 425 | return maybeSuppressResult(rp, scope, result_used, TransResult{ |
| 426 | .node = node, |
| 427 | .child_scope = scope, |
| 428 | .node_scope = scope, |
| 429 | }); |
| 430 | } |
| 431 | }, |
| 398 | 432 | .Rem, |
| 399 | 433 | .Shl, |
| 400 | 434 | .Shr, |