| ... | ... | @@ -1317,10 +1317,28 @@ fn astGenExpr(self: *Module, scope: *Scope, ast_node: *ast.Node) InnerError!*zir |
| 1317 | 1317 | .Unreachable => return self.astGenUnreachable(scope, @fieldParentPtr(ast.Node.Unreachable, "base", ast_node)), |
| 1318 | 1318 | .ControlFlowExpression => return self.astGenControlFlowExpression(scope, @fieldParentPtr(ast.Node.ControlFlowExpression, "base", ast_node)), |
| 1319 | 1319 | .If => return self.astGenIf(scope, @fieldParentPtr(ast.Node.If, "base", ast_node)), |
| 1320 | .InfixOp => return self.astGenInfixOp(scope, @fieldParentPtr(ast.Node.InfixOp, "base", ast_node)), |
| 1320 | 1321 | else => return self.failNode(scope, ast_node, "TODO implement astGenExpr for {}", .{@tagName(ast_node.id)}), |
| 1321 | 1322 | } |
| 1322 | 1323 | } |
| 1323 | 1324 | |
| 1325 | fn astGenInfixOp(self: *Module, scope: *Scope, infix_node: *ast.Node.InfixOp) InnerError!*zir.Inst { |
| 1326 | switch (infix_node.op) { |
| 1327 | .Add => { |
| 1328 | const lhs = try self.astGenExpr(scope, infix_node.lhs); |
| 1329 | const rhs = try self.astGenExpr(scope, infix_node.rhs); |
| 1330 | |
| 1331 | const tree = scope.tree(); |
| 1332 | const src = tree.token_locs[infix_node.op_token].start; |
| 1333 | |
| 1334 | return self.addZIRInst(scope, src, zir.Inst.Add, .{ .lhs = lhs, .rhs = rhs }, .{}); |
| 1335 | }, |
| 1336 | else => |op| { |
| 1337 | return self.failNode(scope, &infix_node.base, "TODO implement infix operator {}", .{op}); |
| 1338 | }, |
| 1339 | } |
| 1340 | } |
| 1341 | |
| 1324 | 1342 | fn astGenIf(self: *Module, scope: *Scope, if_node: *ast.Node.If) InnerError!*zir.Inst { |
| 1325 | 1343 | if (if_node.payload) |payload| { |
| 1326 | 1344 | return self.failNode(scope, payload, "TODO implement astGenIf for optionals", .{}); |
| ... | ... | @@ -2933,7 +2951,9 @@ fn analyzeInstAdd(self: *Module, scope: *Scope, inst: *zir.Inst.Add) InnerError! |
| 2933 | 2951 | const lhs = try self.resolveInst(scope, inst.positionals.lhs); |
| 2934 | 2952 | const rhs = try self.resolveInst(scope, inst.positionals.rhs); |
| 2935 | 2953 | |
| 2936 | | if (lhs.ty.zigTypeTag() == .Int and rhs.ty.zigTypeTag() == .Int) { |
| 2954 | if ((lhs.ty.zigTypeTag() == .Int or lhs.ty.zigTypeTag() == .ComptimeInt) and |
| 2955 | (rhs.ty.zigTypeTag() == .Int or rhs.ty.zigTypeTag() == .ComptimeInt)) |
| 2956 | { |
| 2937 | 2957 | if (!lhs.ty.eql(rhs.ty)) { |
| 2938 | 2958 | return self.fail(scope, inst.base.src, "TODO implement peer type resolution", .{}); |
| 2939 | 2959 | } |
| ... | ... | @@ -2977,8 +2997,7 @@ fn analyzeInstAdd(self: *Module, scope: *Scope, inst: *zir.Inst.Add) InnerError! |
| 2977 | 2997 | .rhs = rhs, |
| 2978 | 2998 | }); |
| 2979 | 2999 | } |
| 2980 | | |
| 2981 | | return self.fail(scope, inst.base.src, "TODO implement more analyze add", .{}); |
| 3000 | return self.fail(scope, inst.base.src, "TODO analyze add for {} + {}", .{ lhs.ty.zigTypeTag(), rhs.ty.zigTypeTag() }); |
| 2982 | 3001 | } |
| 2983 | 3002 | |
| 2984 | 3003 | fn analyzeInstDeref(self: *Module, scope: *Scope, deref: *zir.Inst.Deref) InnerError!*Inst { |