| ... | ... | @@ -1309,6 +1309,33 @@ fn astGenInfixOp(self: *Module, scope: *Scope, infix_node: *ast.Node.InfixOp) In |
| 1309 | 1309 | |
| 1310 | 1310 | return self.addZIRInst(scope, src, zir.Inst.Add, .{ .lhs = lhs, .rhs = rhs }, .{}); |
| 1311 | 1311 | }, |
| 1312 | .BangEqual, |
| 1313 | .EqualEqual, |
| 1314 | .GreaterThan, |
| 1315 | .GreaterOrEqual, |
| 1316 | .LessThan, |
| 1317 | .LessOrEqual, |
| 1318 | => { |
| 1319 | const lhs = try self.astGenExpr(scope, infix_node.lhs); |
| 1320 | const rhs = try self.astGenExpr(scope, infix_node.rhs); |
| 1321 | |
| 1322 | const tree = scope.tree(); |
| 1323 | const src = tree.token_locs[infix_node.op_token].start; |
| 1324 | |
| 1325 | return self.addZIRInst(scope, src, zir.Inst.Cmp, .{ |
| 1326 | .lhs = lhs, |
| 1327 | .op = @as(std.math.CompareOperator, switch (infix_node.op) { |
| 1328 | .BangEqual => .neq, |
| 1329 | .EqualEqual => .eq, |
| 1330 | .GreaterThan => .gt, |
| 1331 | .GreaterOrEqual => .gte, |
| 1332 | .LessThan => .lt, |
| 1333 | .LessOrEqual => .lte, |
| 1334 | else => unreachable, |
| 1335 | }), |
| 1336 | .rhs = rhs, |
| 1337 | }, .{}); |
| 1338 | }, |
| 1312 | 1339 | else => |op| { |
| 1313 | 1340 | return self.failNode(scope, &infix_node.base, "TODO implement infix operator {}", .{op}); |
| 1314 | 1341 | }, |