aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimon Kruiper <timonkruiper@gmail.com>2021-03-23 11:11:20 +0100
committerIsaac Freund <ifreund@ifreund.xyz>2021-03-23 11:40:55 +0100
commitf3e8073e054c3bcf6fc8dd07cb164658da229b0a (patch)
tree71b91dbf536502973563bc6171330f4bc016ae08 /src
parentd24be85be88737db8399b492931647056c547614 (diff)
downloadzig-f3e8073e054c3bcf6fc8dd07cb164658da229b0a.tar.gz
zig-f3e8073e054c3bcf6fc8dd07cb164658da229b0a.zip
astgen: implement assign operations
Diffstat (limited to 'src')
-rw-r--r--src/astgen.zig15
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 {