authorgravatar for timonkruiper@gmail.comTimon Kruiper <timonkruiper@gmail.com> 2021-03-23 11:11:20+01:00
committergravatar for mail@isaacfreund.comIsaac Freund <mail@isaacfreund.com> 2021-03-23 11:40:55+01:00
logf3e8073e054c3bcf6fc8dd07cb164658da229b0a
tree71b91dbf536502973563bc6171330f4bc016ae08
parentd24be85be88737db8399b492931647056c547614

astgen: implement assign operations


1 files changed, 9 insertions(+), 6 deletions(-)

src/astgen.zig+9-6
...@@ -1438,17 +1438,20 @@ fn assignOp(...@@ -1438,17 +1438,20 @@ fn assignOp(
1438 infix_node: ast.Node.Index,1438 infix_node: ast.Node.Index,
1439 op_inst_tag: zir.Inst.Tag,1439 op_inst_tag: zir.Inst.Tag,
1440) InnerError!void {1440) InnerError!void {
1441 if (true) @panic("TODO update for zir-memory-layout");
1442 const tree = scope.tree();1441 const tree = scope.tree();
1443 const node_datas = tree.nodes.items(.data);1442 const node_datas = tree.nodes.items(.data);
1444 const main_tokens = tree.nodes.items(.main_token);1443 const gz = scope.getGenZir();
14451444
1446 const lhs_ptr = try lvalExpr(mod, scope, node_datas[infix_node].lhs);1445 const lhs_ptr = try lvalExpr(mod, scope, node_datas[infix_node].lhs);
1447 const lhs = try addZIRUnOp(mod, scope, lhs_ptr.src, .deref, lhs_ptr);1446 const lhs = try gz.addUnNode(.deref_node, lhs_ptr, infix_node);
1448 const lhs_type = try addZIRUnOp(mod, scope, lhs_ptr.src, .typeof, lhs);1447 const lhs_type = try gz.addUnTok(.typeof, lhs, infix_node);
1449 const rhs = try expr(mod, scope, .{ .ty = lhs_type }, node_datas[infix_node].rhs);1448 const rhs = try expr(mod, scope, .{ .ty = lhs_type }, node_datas[infix_node].rhs);
1450 const result = try addZIRBinOp(mod, scope, src, op_inst_tag, lhs, rhs);1449
1451 _ = try addZIRBinOp(mod, scope, src, .store, lhs_ptr, result);1450 const result = try gz.addPlNode(op_inst_tag, infix_node, zir.Inst.Bin{
1451 .lhs = lhs,
1452 .rhs = rhs,
1453 });
1454 _ = try gz.addBin(.store, lhs_ptr, result);
1452}1455}
14531456
1454fn boolNot(mod: *Module, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerError!zir.Inst.Ref {1457fn boolNot(mod: *Module, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerError!zir.Inst.Ref {