| ... | ... | @@ -839,12 +839,9 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE |
| 839 | 839 | .slice_open => { |
| 840 | 840 | const lhs = try expr(gz, scope, .{ .rl = .ref }, node_datas[node].lhs); |
| 841 | 841 | |
| 842 | | maybeAdvanceSourceCursorToMainToken(gz, node); |
| 843 | | const line = gz.astgen.source_line - gz.decl_line; |
| 844 | | const column = gz.astgen.source_column; |
| 845 | | |
| 842 | const cursor = maybeAdvanceSourceCursorToMainToken(gz, node); |
| 846 | 843 | const start = try expr(gz, scope, .{ .rl = .{ .coerced_ty = .usize_type } }, node_datas[node].rhs); |
| 847 | | try emitDbgStmt(gz, line, column); |
| 844 | try emitDbgStmt(gz, cursor); |
| 848 | 845 | const result = try gz.addPlNode(.slice_start, node, Zir.Inst.SliceStart{ |
| 849 | 846 | .lhs = lhs, |
| 850 | 847 | .start = start, |
| ... | ... | @@ -854,14 +851,11 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE |
| 854 | 851 | .slice => { |
| 855 | 852 | const lhs = try expr(gz, scope, .{ .rl = .ref }, node_datas[node].lhs); |
| 856 | 853 | |
| 857 | | maybeAdvanceSourceCursorToMainToken(gz, node); |
| 858 | | const line = gz.astgen.source_line - gz.decl_line; |
| 859 | | const column = gz.astgen.source_column; |
| 860 | | |
| 854 | const cursor = maybeAdvanceSourceCursorToMainToken(gz, node); |
| 861 | 855 | const extra = tree.extraData(node_datas[node].rhs, Ast.Node.Slice); |
| 862 | 856 | const start = try expr(gz, scope, .{ .rl = .{ .coerced_ty = .usize_type } }, extra.start); |
| 863 | 857 | const end = try expr(gz, scope, .{ .rl = .{ .coerced_ty = .usize_type } }, extra.end); |
| 864 | | try emitDbgStmt(gz, line, column); |
| 858 | try emitDbgStmt(gz, cursor); |
| 865 | 859 | const result = try gz.addPlNode(.slice_end, node, Zir.Inst.SliceEnd{ |
| 866 | 860 | .lhs = lhs, |
| 867 | 861 | .start = start, |
| ... | ... | @@ -872,15 +866,12 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE |
| 872 | 866 | .slice_sentinel => { |
| 873 | 867 | const lhs = try expr(gz, scope, .{ .rl = .ref }, node_datas[node].lhs); |
| 874 | 868 | |
| 875 | | maybeAdvanceSourceCursorToMainToken(gz, node); |
| 876 | | const line = gz.astgen.source_line - gz.decl_line; |
| 877 | | const column = gz.astgen.source_column; |
| 878 | | |
| 869 | const cursor = maybeAdvanceSourceCursorToMainToken(gz, node); |
| 879 | 870 | const extra = tree.extraData(node_datas[node].rhs, Ast.Node.SliceSentinel); |
| 880 | 871 | const start = try expr(gz, scope, .{ .rl = .{ .coerced_ty = .usize_type } }, extra.start); |
| 881 | 872 | const end = if (extra.end != 0) try expr(gz, scope, .{ .rl = .{ .coerced_ty = .usize_type } }, extra.end) else .none; |
| 882 | 873 | const sentinel = try expr(gz, scope, .{ .rl = .none }, extra.sentinel); |
| 883 | | try emitDbgStmt(gz, line, column); |
| 874 | try emitDbgStmt(gz, cursor); |
| 884 | 875 | const result = try gz.addPlNode(.slice_sentinel, node, Zir.Inst.SliceSentinel{ |
| 885 | 876 | .lhs = lhs, |
| 886 | 877 | .start = start, |
| ... | ... | @@ -914,20 +905,16 @@ fn expr(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) InnerE |
| 914 | 905 | .ref => { |
| 915 | 906 | const lhs = try expr(gz, scope, .{ .rl = .ref }, node_datas[node].lhs); |
| 916 | 907 | |
| 917 | | maybeAdvanceSourceCursorToMainToken(gz, node); |
| 918 | | const line = gz.astgen.source_line - gz.decl_line; |
| 919 | | const column = gz.astgen.source_column; |
| 920 | | try emitDbgStmt(gz, line, column); |
| 908 | const cursor = maybeAdvanceSourceCursorToMainToken(gz, node); |
| 909 | try emitDbgStmt(gz, cursor); |
| 921 | 910 | |
| 922 | 911 | return gz.addUnNode(.optional_payload_safe_ptr, lhs, node); |
| 923 | 912 | }, |
| 924 | 913 | else => { |
| 925 | 914 | const lhs = try expr(gz, scope, .{ .rl = .none }, node_datas[node].lhs); |
| 926 | 915 | |
| 927 | | maybeAdvanceSourceCursorToMainToken(gz, node); |
| 928 | | const line = gz.astgen.source_line - gz.decl_line; |
| 929 | | const column = gz.astgen.source_column; |
| 930 | | try emitDbgStmt(gz, line, column); |
| 916 | const cursor = maybeAdvanceSourceCursorToMainToken(gz, node); |
| 917 | try emitDbgStmt(gz, cursor); |
| 931 | 918 | |
| 932 | 919 | return rvalue(gz, ri, try gz.addUnNode(.optional_payload_safe, lhs, node), node); |
| 933 | 920 | }, |
| ... | ... | @@ -3330,23 +3317,17 @@ fn assignOp( |
| 3330 | 3317 | |
| 3331 | 3318 | const lhs_ptr = try lvalExpr(gz, scope, node_datas[infix_node].lhs); |
| 3332 | 3319 | |
| 3333 | | var line: u32 = undefined; |
| 3334 | | var column: u32 = undefined; |
| 3335 | | switch (op_inst_tag) { |
| 3336 | | .add, .sub, .mul, .div, .mod_rem => { |
| 3337 | | maybeAdvanceSourceCursorToMainToken(gz, infix_node); |
| 3338 | | line = gz.astgen.source_line - gz.decl_line; |
| 3339 | | column = gz.astgen.source_column; |
| 3340 | | }, |
| 3341 | | else => {}, |
| 3342 | | } |
| 3320 | const cursor = switch (op_inst_tag) { |
| 3321 | .add, .sub, .mul, .div, .mod_rem => maybeAdvanceSourceCursorToMainToken(gz, infix_node), |
| 3322 | else => undefined, |
| 3323 | }; |
| 3343 | 3324 | const lhs = try gz.addUnNode(.load, lhs_ptr, infix_node); |
| 3344 | 3325 | const lhs_type = try gz.addUnNode(.typeof, lhs, infix_node); |
| 3345 | 3326 | const rhs = try expr(gz, scope, .{ .rl = .{ .coerced_ty = lhs_type } }, node_datas[infix_node].rhs); |
| 3346 | 3327 | |
| 3347 | 3328 | switch (op_inst_tag) { |
| 3348 | 3329 | .add, .sub, .mul, .div, .mod_rem => { |
| 3349 | | try emitDbgStmt(gz, line, column); |
| 3330 | try emitDbgStmt(gz, cursor); |
| 3350 | 3331 | }, |
| 3351 | 3332 | else => {}, |
| 3352 | 3333 | } |
| ... | ... | @@ -5360,8 +5341,7 @@ fn tryExpr( |
| 5360 | 5341 | if (!parent_gz.is_comptime) { |
| 5361 | 5342 | try emitDbgNode(parent_gz, node); |
| 5362 | 5343 | } |
| 5363 | | const try_line = astgen.source_line - parent_gz.decl_line; |
| 5364 | | const try_column = astgen.source_column; |
| 5344 | const try_lc = LineColumn{ astgen.source_line - parent_gz.decl_line, astgen.source_column }; |
| 5365 | 5345 | |
| 5366 | 5346 | const operand_ri: ResultInfo = switch (ri.rl) { |
| 5367 | 5347 | .ref => .{ .rl = .ref, .ctx = .error_handling_expr }, |
| ... | ... | @@ -5382,7 +5362,7 @@ fn tryExpr( |
| 5382 | 5362 | }; |
| 5383 | 5363 | const err_code = try else_scope.addUnNode(err_tag, operand, node); |
| 5384 | 5364 | try genDefers(&else_scope, &fn_block.base, scope, .{ .both = err_code }); |
| 5385 | | try emitDbgStmt(&else_scope, try_line, try_column); |
| 5365 | try emitDbgStmt(&else_scope, try_lc); |
| 5386 | 5366 | _ = try else_scope.addUnNode(.ret_node, err_code, node); |
| 5387 | 5367 | |
| 5388 | 5368 | try else_scope.setTryBody(try_inst, operand); |
| ... | ... | @@ -5607,10 +5587,8 @@ fn addFieldAccess( |
| 5607 | 5587 | const str_index = try astgen.identAsString(field_ident); |
| 5608 | 5588 | const lhs = try expr(gz, scope, lhs_ri, object_node); |
| 5609 | 5589 | |
| 5610 | | maybeAdvanceSourceCursorToMainToken(gz, node); |
| 5611 | | const line = gz.astgen.source_line - gz.decl_line; |
| 5612 | | const column = gz.astgen.source_column; |
| 5613 | | try emitDbgStmt(gz, line, column); |
| 5590 | const cursor = maybeAdvanceSourceCursorToMainToken(gz, node); |
| 5591 | try emitDbgStmt(gz, cursor); |
| 5614 | 5592 | |
| 5615 | 5593 | return gz.addPlNode(tag, node, Zir.Inst.Field{ |
| 5616 | 5594 | .lhs = lhs, |
| ... | ... | @@ -5630,24 +5608,20 @@ fn arrayAccess( |
| 5630 | 5608 | .ref => { |
| 5631 | 5609 | const lhs = try expr(gz, scope, .{ .rl = .ref }, node_datas[node].lhs); |
| 5632 | 5610 | |
| 5633 | | maybeAdvanceSourceCursorToMainToken(gz, node); |
| 5634 | | const line = gz.astgen.source_line - gz.decl_line; |
| 5635 | | const column = gz.astgen.source_column; |
| 5611 | const cursor = maybeAdvanceSourceCursorToMainToken(gz, node); |
| 5636 | 5612 | |
| 5637 | 5613 | const rhs = try expr(gz, scope, .{ .rl = .{ .ty = .usize_type } }, node_datas[node].rhs); |
| 5638 | | try emitDbgStmt(gz, line, column); |
| 5614 | try emitDbgStmt(gz, cursor); |
| 5639 | 5615 | |
| 5640 | 5616 | return gz.addPlNode(.elem_ptr_node, node, Zir.Inst.Bin{ .lhs = lhs, .rhs = rhs }); |
| 5641 | 5617 | }, |
| 5642 | 5618 | else => { |
| 5643 | 5619 | const lhs = try expr(gz, scope, .{ .rl = .none }, node_datas[node].lhs); |
| 5644 | 5620 | |
| 5645 | | maybeAdvanceSourceCursorToMainToken(gz, node); |
| 5646 | | const line = gz.astgen.source_line - gz.decl_line; |
| 5647 | | const column = gz.astgen.source_column; |
| 5621 | const cursor = maybeAdvanceSourceCursorToMainToken(gz, node); |
| 5648 | 5622 | |
| 5649 | 5623 | const rhs = try expr(gz, scope, .{ .rl = .{ .ty = .usize_type } }, node_datas[node].rhs); |
| 5650 | | try emitDbgStmt(gz, line, column); |
| 5624 | try emitDbgStmt(gz, cursor); |
| 5651 | 5625 | |
| 5652 | 5626 | return rvalue(gz, ri, try gz.addPlNode(.elem_val_node, node, Zir.Inst.Bin{ .lhs = lhs, .rhs = rhs }), node); |
| 5653 | 5627 | }, |
| ... | ... | @@ -5674,21 +5648,15 @@ fn simpleBinOp( |
| 5674 | 5648 | } |
| 5675 | 5649 | |
| 5676 | 5650 | const lhs = try reachableExpr(gz, scope, .{ .rl = .none }, node_datas[node].lhs, node); |
| 5677 | | var line: u32 = undefined; |
| 5678 | | var column: u32 = undefined; |
| 5679 | | switch (op_inst_tag) { |
| 5680 | | .add, .sub, .mul, .div, .mod_rem => { |
| 5681 | | maybeAdvanceSourceCursorToMainToken(gz, node); |
| 5682 | | line = gz.astgen.source_line - gz.decl_line; |
| 5683 | | column = gz.astgen.source_column; |
| 5684 | | }, |
| 5685 | | else => {}, |
| 5686 | | } |
| 5651 | const cursor = switch (op_inst_tag) { |
| 5652 | .add, .sub, .mul, .div, .mod_rem => maybeAdvanceSourceCursorToMainToken(gz, node), |
| 5653 | else => undefined, |
| 5654 | }; |
| 5687 | 5655 | const rhs = try reachableExpr(gz, scope, .{ .rl = .none }, node_datas[node].rhs, node); |
| 5688 | 5656 | |
| 5689 | 5657 | switch (op_inst_tag) { |
| 5690 | 5658 | .add, .sub, .mul, .div, .mod_rem => { |
| 5691 | | try emitDbgStmt(gz, line, column); |
| 5659 | try emitDbgStmt(gz, cursor); |
| 5692 | 5660 | }, |
| 5693 | 5661 | else => {}, |
| 5694 | 5662 | } |
| ... | ... | @@ -6787,14 +6755,15 @@ fn switchExpr( |
| 6787 | 6755 | } |
| 6788 | 6756 | |
| 6789 | 6757 | const operand_ri: ResultInfo = .{ .rl = if (any_payload_is_ref) .ref else .none }; |
| 6758 | |
| 6790 | 6759 | astgen.advanceSourceCursorToNode(operand_node); |
| 6791 | | const operand_line = astgen.source_line - parent_gz.decl_line; |
| 6792 | | const operand_column = astgen.source_column; |
| 6760 | const operand_lc = LineColumn{ astgen.source_line - parent_gz.decl_line, astgen.source_column }; |
| 6761 | |
| 6793 | 6762 | const raw_operand = try expr(parent_gz, scope, operand_ri, operand_node); |
| 6794 | 6763 | const cond_tag: Zir.Inst.Tag = if (any_payload_is_ref) .switch_cond_ref else .switch_cond; |
| 6795 | 6764 | const cond = try parent_gz.addUnNode(cond_tag, raw_operand, operand_node); |
| 6796 | 6765 | // Sema expects a dbg_stmt immediately after switch_cond(_ref) |
| 6797 | | try emitDbgStmt(parent_gz, operand_line, operand_column); |
| 6766 | try emitDbgStmt(parent_gz, operand_lc); |
| 6798 | 6767 | // We need the type of the operand to use as the result location for all the prong items. |
| 6799 | 6768 | const cond_ty_inst = try parent_gz.addUnNode(.typeof, cond, operand_node); |
| 6800 | 6769 | const item_ri: ResultInfo = .{ .rl = .{ .ty = cond_ty_inst } }; |
| ... | ... | @@ -7154,8 +7123,7 @@ fn ret(gz: *GenZir, scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Inst.Ref |
| 7154 | 7123 | if (!gz.is_comptime) { |
| 7155 | 7124 | try emitDbgNode(gz, node); |
| 7156 | 7125 | } |
| 7157 | | const ret_line = astgen.source_line - gz.decl_line; |
| 7158 | | const ret_column = astgen.source_column; |
| 7126 | const ret_lc = LineColumn{ astgen.source_line - gz.decl_line, astgen.source_column }; |
| 7159 | 7127 | |
| 7160 | 7128 | const defer_outer = &astgen.fn_block.?.base; |
| 7161 | 7129 | |
| ... | ... | @@ -7179,13 +7147,13 @@ fn ret(gz: *GenZir, scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Inst.Ref |
| 7179 | 7147 | const defer_counts = countDefers(defer_outer, scope); |
| 7180 | 7148 | if (!defer_counts.need_err_code) { |
| 7181 | 7149 | try genDefers(gz, defer_outer, scope, .both_sans_err); |
| 7182 | | try emitDbgStmt(gz, ret_line, ret_column); |
| 7150 | try emitDbgStmt(gz, ret_lc); |
| 7183 | 7151 | _ = try gz.addStrTok(.ret_err_value, err_name_str_index, ident_token); |
| 7184 | 7152 | return Zir.Inst.Ref.unreachable_value; |
| 7185 | 7153 | } |
| 7186 | 7154 | const err_code = try gz.addStrTok(.ret_err_value_code, err_name_str_index, ident_token); |
| 7187 | 7155 | try genDefers(gz, defer_outer, scope, .{ .both = err_code }); |
| 7188 | | try emitDbgStmt(gz, ret_line, ret_column); |
| 7156 | try emitDbgStmt(gz, ret_lc); |
| 7189 | 7157 | _ = try gz.addUnNode(.ret_node, err_code, node); |
| 7190 | 7158 | return Zir.Inst.Ref.unreachable_value; |
| 7191 | 7159 | } |
| ... | ... | @@ -7210,7 +7178,7 @@ fn ret(gz: *GenZir, scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Inst.Ref |
| 7210 | 7178 | // As our last action before the return, "pop" the error trace if needed |
| 7211 | 7179 | _ = try gz.addRestoreErrRetIndex(.ret, .always); |
| 7212 | 7180 | |
| 7213 | | try emitDbgStmt(gz, ret_line, ret_column); |
| 7181 | try emitDbgStmt(gz, ret_lc); |
| 7214 | 7182 | try gz.addRet(ri, operand, node); |
| 7215 | 7183 | return Zir.Inst.Ref.unreachable_value; |
| 7216 | 7184 | }, |
| ... | ... | @@ -7218,7 +7186,7 @@ fn ret(gz: *GenZir, scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Inst.Ref |
| 7218 | 7186 | // Value is always an error. Emit both error defers and regular defers. |
| 7219 | 7187 | const err_code = if (ri.rl == .ptr) try gz.addUnNode(.load, ri.rl.ptr.inst, node) else operand; |
| 7220 | 7188 | try genDefers(gz, defer_outer, scope, .{ .both = err_code }); |
| 7221 | | try emitDbgStmt(gz, ret_line, ret_column); |
| 7189 | try emitDbgStmt(gz, ret_lc); |
| 7222 | 7190 | try gz.addRet(ri, operand, node); |
| 7223 | 7191 | return Zir.Inst.Ref.unreachable_value; |
| 7224 | 7192 | }, |
| ... | ... | @@ -7227,7 +7195,7 @@ fn ret(gz: *GenZir, scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Inst.Ref |
| 7227 | 7195 | if (!defer_counts.have_err) { |
| 7228 | 7196 | // Only regular defers; no branch needed. |
| 7229 | 7197 | try genDefers(gz, defer_outer, scope, .normal_only); |
| 7230 | | try emitDbgStmt(gz, ret_line, ret_column); |
| 7198 | try emitDbgStmt(gz, ret_lc); |
| 7231 | 7199 | |
| 7232 | 7200 | // As our last action before the return, "pop" the error trace if needed |
| 7233 | 7201 | const result = if (ri.rl == .ptr) try gz.addUnNode(.load, ri.rl.ptr.inst, node) else operand; |
| ... | ... | @@ -7250,7 +7218,7 @@ fn ret(gz: *GenZir, scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Inst.Ref |
| 7250 | 7218 | // As our last action before the return, "pop" the error trace if needed |
| 7251 | 7219 | _ = try then_scope.addRestoreErrRetIndex(.ret, .always); |
| 7252 | 7220 | |
| 7253 | | try emitDbgStmt(&then_scope, ret_line, ret_column); |
| 7221 | try emitDbgStmt(&then_scope, ret_lc); |
| 7254 | 7222 | try then_scope.addRet(ri, operand, node); |
| 7255 | 7223 | |
| 7256 | 7224 | var else_scope = gz.makeSubBlock(scope); |
| ... | ... | @@ -7260,7 +7228,7 @@ fn ret(gz: *GenZir, scope: *Scope, node: Ast.Node.Index) InnerError!Zir.Inst.Ref |
| 7260 | 7228 | .both = try else_scope.addUnNode(.err_union_code, result, node), |
| 7261 | 7229 | }; |
| 7262 | 7230 | try genDefers(&else_scope, defer_outer, scope, which_ones); |
| 7263 | | try emitDbgStmt(&else_scope, ret_line, ret_column); |
| 7231 | try emitDbgStmt(&else_scope, ret_lc); |
| 7264 | 7232 | try else_scope.addRet(ri, operand, node); |
| 7265 | 7233 | |
| 7266 | 7234 | try setCondBrPayload(condbr, is_non_err, &then_scope, 0, &else_scope, 0); |
| ... | ... | @@ -8649,11 +8617,14 @@ fn typeCast( |
| 8649 | 8617 | rhs_node: Ast.Node.Index, |
| 8650 | 8618 | tag: Zir.Inst.Tag, |
| 8651 | 8619 | ) InnerError!Zir.Inst.Ref { |
| 8652 | | try emitDbgNode(gz, node); |
| 8620 | const cursor = maybeAdvanceSourceCursorToMainToken(gz, node); |
| 8621 | const result_type = try typeExpr(gz, scope, lhs_node); |
| 8622 | const operand = try expr(gz, scope, .{ .rl = .none }, rhs_node); |
| 8653 | 8623 | |
| 8624 | try emitDbgStmt(gz, cursor); |
| 8654 | 8625 | const result = try gz.addPlNode(tag, node, Zir.Inst.Bin{ |
| 8655 | | .lhs = try typeExpr(gz, scope, lhs_node), |
| 8656 | | .rhs = try expr(gz, scope, .{ .rl = .none }, rhs_node), |
| 8626 | .lhs = result_type, |
| 8627 | .rhs = operand, |
| 8657 | 8628 | }); |
| 8658 | 8629 | return rvalue(gz, ri, result, node); |
| 8659 | 8630 | } |
| ... | ... | @@ -8680,14 +8651,15 @@ fn simpleUnOp( |
| 8680 | 8651 | operand_node: Ast.Node.Index, |
| 8681 | 8652 | tag: Zir.Inst.Tag, |
| 8682 | 8653 | ) InnerError!Zir.Inst.Ref { |
| 8683 | | switch (tag) { |
| 8684 | | .tag_name, .error_name, .ptr_to_int => try emitDbgNode(gz, node), |
| 8685 | | else => {}, |
| 8686 | | } |
| 8654 | const cursor = maybeAdvanceSourceCursorToMainToken(gz, node); |
| 8687 | 8655 | const operand = if (tag == .compile_error) |
| 8688 | 8656 | try comptimeExpr(gz, scope, operand_ri, operand_node) |
| 8689 | 8657 | else |
| 8690 | 8658 | try expr(gz, scope, operand_ri, operand_node); |
| 8659 | switch (tag) { |
| 8660 | .tag_name, .error_name, .ptr_to_int => try emitDbgStmt(gz, cursor), |
| 8661 | else => {}, |
| 8662 | } |
| 8691 | 8663 | const result = try gz.addUnNode(tag, operand, node); |
| 8692 | 8664 | return rvalue(gz, ri, result, node); |
| 8693 | 8665 | } |
| ... | ... | @@ -8759,12 +8731,12 @@ fn divBuiltin( |
| 8759 | 8731 | rhs_node: Ast.Node.Index, |
| 8760 | 8732 | tag: Zir.Inst.Tag, |
| 8761 | 8733 | ) InnerError!Zir.Inst.Ref { |
| 8762 | | try emitDbgNode(gz, node); |
| 8734 | const cursor = maybeAdvanceSourceCursorToMainToken(gz, node); |
| 8735 | const lhs = try expr(gz, scope, .{ .rl = .none }, lhs_node); |
| 8736 | const rhs = try expr(gz, scope, .{ .rl = .none }, rhs_node); |
| 8763 | 8737 | |
| 8764 | | const result = try gz.addPlNode(tag, node, Zir.Inst.Bin{ |
| 8765 | | .lhs = try expr(gz, scope, .{ .rl = .none }, lhs_node), |
| 8766 | | .rhs = try expr(gz, scope, .{ .rl = .none }, rhs_node), |
| 8767 | | }); |
| 8738 | try emitDbgStmt(gz, cursor); |
| 8739 | const result = try gz.addPlNode(tag, node, Zir.Inst.Bin{ .lhs = lhs, .rhs = rhs }); |
| 8768 | 8740 | return rvalue(gz, ri, result, node); |
| 8769 | 8741 | } |
| 8770 | 8742 | |
| ... | ... | @@ -8813,23 +8785,21 @@ fn shiftOp( |
| 8813 | 8785 | rhs_node: Ast.Node.Index, |
| 8814 | 8786 | tag: Zir.Inst.Tag, |
| 8815 | 8787 | ) InnerError!Zir.Inst.Ref { |
| 8816 | | var line = gz.astgen.source_line - gz.decl_line; |
| 8817 | | var column = gz.astgen.source_column; |
| 8818 | 8788 | const lhs = try expr(gz, scope, .{ .rl = .none }, lhs_node); |
| 8819 | 8789 | |
| 8820 | | switch (gz.astgen.tree.nodes.items(.tag)[node]) { |
| 8821 | | .shl, .shr => { |
| 8822 | | maybeAdvanceSourceCursorToMainToken(gz, node); |
| 8823 | | line = gz.astgen.source_line - gz.decl_line; |
| 8824 | | column = gz.astgen.source_column; |
| 8825 | | }, |
| 8826 | | else => {}, |
| 8827 | | } |
| 8790 | const cursor = switch (gz.astgen.tree.nodes.items(.tag)[node]) { |
| 8791 | .shl, .shr => maybeAdvanceSourceCursorToMainToken(gz, node), |
| 8792 | else => undefined, |
| 8793 | }; |
| 8828 | 8794 | |
| 8829 | 8795 | const log2_int_type = try gz.addUnNode(.typeof_log2_int_type, lhs, lhs_node); |
| 8830 | 8796 | const rhs = try expr(gz, scope, .{ .rl = .{ .ty = log2_int_type }, .ctx = .shift_op }, rhs_node); |
| 8831 | 8797 | |
| 8832 | | try emitDbgStmt(gz, line, column); |
| 8798 | switch (gz.astgen.tree.nodes.items(.tag)[node]) { |
| 8799 | .shl, .shr => try emitDbgStmt(gz, cursor), |
| 8800 | else => undefined, |
| 8801 | } |
| 8802 | |
| 8833 | 8803 | const result = try gz.addPlNode(tag, node, Zir.Inst.Bin{ |
| 8834 | 8804 | .lhs = lhs, |
| 8835 | 8805 | .rhs = rhs, |
| ... | ... | @@ -12593,16 +12563,20 @@ fn detectLocalShadowing( |
| 12593 | 12563 | }; |
| 12594 | 12564 | } |
| 12595 | 12565 | |
| 12566 | const LineColumn = struct { u32, u32 }; |
| 12567 | |
| 12596 | 12568 | /// Advances the source cursor to the main token of `node` if not in comptime scope. |
| 12597 | 12569 | /// Usually paired with `emitDbgStmt`. |
| 12598 | | fn maybeAdvanceSourceCursorToMainToken(gz: *GenZir, node: Ast.Node.Index) void { |
| 12599 | | if (gz.is_comptime) return; |
| 12570 | fn maybeAdvanceSourceCursorToMainToken(gz: *GenZir, node: Ast.Node.Index) LineColumn { |
| 12571 | if (gz.is_comptime) return .{ gz.astgen.source_line - gz.decl_line, gz.astgen.source_column }; |
| 12600 | 12572 | |
| 12601 | 12573 | const tree = gz.astgen.tree; |
| 12602 | 12574 | const token_starts = tree.tokens.items(.start); |
| 12603 | 12575 | const main_tokens = tree.nodes.items(.main_token); |
| 12604 | 12576 | const node_start = token_starts[main_tokens[node]]; |
| 12605 | 12577 | gz.astgen.advanceSourceCursor(node_start); |
| 12578 | |
| 12579 | return .{ gz.astgen.source_line - gz.decl_line, gz.astgen.source_column }; |
| 12606 | 12580 | } |
| 12607 | 12581 | |
| 12608 | 12582 | /// Advances the source cursor to the beginning of `node`. |
| ... | ... | @@ -12806,13 +12780,13 @@ fn countBodyLenAfterFixups(astgen: *AstGen, body: []const Zir.Inst.Index) u32 { |
| 12806 | 12780 | return @intCast(u32, count); |
| 12807 | 12781 | } |
| 12808 | 12782 | |
| 12809 | | fn emitDbgStmt(gz: *GenZir, line: u32, column: u32) !void { |
| 12783 | fn emitDbgStmt(gz: *GenZir, lc: LineColumn) !void { |
| 12810 | 12784 | if (gz.is_comptime) return; |
| 12811 | 12785 | |
| 12812 | 12786 | _ = try gz.add(.{ .tag = .dbg_stmt, .data = .{ |
| 12813 | 12787 | .dbg_stmt = .{ |
| 12814 | | .line = line, |
| 12815 | | .column = column, |
| 12788 | .line = lc[0], |
| 12789 | .column = lc[1], |
| 12816 | 12790 | }, |
| 12817 | 12791 | } }); |
| 12818 | 12792 | } |