diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-06-30 23:59:39 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-07-01 10:22:26 +0300 |
| commit | 2029601cb2ad4a6e9c8b260eec68de881d46735b (patch) | |
| tree | 1c8573a9b47a9432a8e3f8d7574355243309b064 /src/AstGen.zig | |
| parent | a6bf8c2593ae6e60d4c4804d4e9fd87fe29885ed (diff) | |
| download | zig-2029601cb2ad4a6e9c8b260eec68de881d46735b.tar.gz zig-2029601cb2ad4a6e9c8b260eec68de881d46735b.zip | |
AstGen: use elem_{ptr,val}_node for array access syntax
Diffstat (limited to 'src/AstGen.zig')
| -rw-r--r-- | src/AstGen.zig | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/AstGen.zig b/src/AstGen.zig index 8707728313..a0ff7a0e6e 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -5154,16 +5154,14 @@ fn arrayAccess( const tree = astgen.tree; const node_datas = tree.nodes.items(.data); switch (rl) { - .ref => return gz.addBin( - .elem_ptr, - try expr(gz, scope, .ref, node_datas[node].lhs), - try expr(gz, scope, .{ .ty = .usize_type }, node_datas[node].rhs), - ), - else => return rvalue(gz, rl, try gz.addBin( - .elem_val, - try expr(gz, scope, .none, node_datas[node].lhs), - try expr(gz, scope, .{ .coerced_ty = .usize_type }, node_datas[node].rhs), - ), node), + .ref => return gz.addPlNode(.elem_ptr_node, node, Zir.Inst.Bin{ + .lhs = try expr(gz, scope, .ref, node_datas[node].lhs), + .rhs = try expr(gz, scope, .{ .ty = .usize_type }, node_datas[node].rhs), + }), + else => return rvalue(gz, rl, try gz.addPlNode(.elem_val_node, node, Zir.Inst.Bin{ + .lhs = try expr(gz, scope, .none, node_datas[node].lhs), + .rhs = try expr(gz, scope, .{ .ty = .usize_type }, node_datas[node].rhs), + }), node), } } @@ -5685,7 +5683,7 @@ fn whileExpr( try then_scope.addDbgVar(.dbg_var_val, some, dbg_var_inst); } if (while_full.ast.cont_expr != 0) { - _ = try expr(&loop_scope, then_sub_scope, .{ .ty = .void_type }, while_full.ast.cont_expr); + _ = try unusedResultExpr(&loop_scope, then_sub_scope, while_full.ast.cont_expr); } try then_scope.addDbgBlockEnd(); const repeat_tag: Zir.Inst.Tag = if (is_inline) .repeat_inline else .repeat; @@ -5890,7 +5888,10 @@ fn forExpr( if (!mem.eql(u8, value_name, "_")) { const name_str_index = try astgen.identAsString(ident); const tag: Zir.Inst.Tag = if (is_ptr) .elem_ptr else .elem_val; - const payload_inst = try then_scope.addBin(tag, array_ptr, index); + const payload_inst = try then_scope.addPlNode(tag, for_full.ast.cond_expr, Zir.Inst.Bin{ + .lhs = array_ptr, + .rhs = index, + }); try astgen.detectLocalShadowing(&then_scope.base, name_str_index, ident, value_name); payload_val_scope = .{ .parent = &then_scope.base, |
