diff options
| author | Timon Kruiper <timonkruiper@gmail.com> | 2021-03-23 11:11:20 +0100 |
|---|---|---|
| committer | Isaac Freund <ifreund@ifreund.xyz> | 2021-03-23 11:40:55 +0100 |
| commit | f3e8073e054c3bcf6fc8dd07cb164658da229b0a (patch) | |
| tree | 71b91dbf536502973563bc6171330f4bc016ae08 | |
| parent | d24be85be88737db8399b492931647056c547614 (diff) | |
| download | zig-f3e8073e054c3bcf6fc8dd07cb164658da229b0a.tar.gz zig-f3e8073e054c3bcf6fc8dd07cb164658da229b0a.zip | |
astgen: implement assign operations
| -rw-r--r-- | src/astgen.zig | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/astgen.zig b/src/astgen.zig index 0aee5caeee..b2cfc04f95 100644 --- a/src/astgen.zig +++ b/src/astgen.zig @@ -1438,17 +1438,20 @@ fn assignOp( infix_node: ast.Node.Index, op_inst_tag: zir.Inst.Tag, ) InnerError!void { - if (true) @panic("TODO update for zir-memory-layout"); const tree = scope.tree(); const node_datas = tree.nodes.items(.data); - const main_tokens = tree.nodes.items(.main_token); + const gz = scope.getGenZir(); const lhs_ptr = try lvalExpr(mod, scope, node_datas[infix_node].lhs); - const lhs = try addZIRUnOp(mod, scope, lhs_ptr.src, .deref, lhs_ptr); - const lhs_type = try addZIRUnOp(mod, scope, lhs_ptr.src, .typeof, lhs); + const lhs = try gz.addUnNode(.deref_node, lhs_ptr, infix_node); + const lhs_type = try gz.addUnTok(.typeof, lhs, infix_node); const rhs = try expr(mod, scope, .{ .ty = lhs_type }, node_datas[infix_node].rhs); - const result = try addZIRBinOp(mod, scope, src, op_inst_tag, lhs, rhs); - _ = try addZIRBinOp(mod, scope, src, .store, lhs_ptr, result); + + const result = try gz.addPlNode(op_inst_tag, infix_node, zir.Inst.Bin{ + .lhs = lhs, + .rhs = rhs, + }); + _ = try gz.addBin(.store, lhs_ptr, result); } fn boolNot(mod: *Module, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerError!zir.Inst.Ref { |
