zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 8a9aa9e112bd75b057eff4b6449a5af86ed568a4 (tree)
parent 6df78c3bc17e5922792fcef0025043c358daa52f
Author: Krzysztof Wolicki <der.teufel.mail@gmail.com>
Date:   Thu,  7 Sep 2023 12:42:15 +0200

autodoc: Handle `ref` ZIR instruction

Diffstat:
Mlib/docs/main.js | 6++++++
Msrc/Autodoc.zig | 18++++++++++++++++++
2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/lib/docs/main.js b/lib/docs/main.js @@ -1361,6 +1361,12 @@ Happy writing! return; } + case "ref": { + yield { src: "&", tag: Tag.ampersand }; + yield* ex(zigAnalysis.exprs[expr.ref], opts); + return; + } + case "call": { let call = zigAnalysis.calls[expr.call]; diff --git a/src/Autodoc.zig b/src/Autodoc.zig @@ -797,6 +797,7 @@ const DocData = struct { binOp: BinOp, binOpIndex: usize, load: usize, // index in `exprs` + ref: usize, // index in `exprs` const BinOp = struct { lhs: usize, // index in `exprs` rhs: usize, // index in `exprs` @@ -1521,6 +1522,23 @@ fn walkInstruction( .expr = .{ .load = load_idx }, }; }, + .ref => { + const un_tok = data[inst_index].un_tok; + const operand = try self.walkRef( + file, + parent_scope, + parent_src, + un_tok.operand, + need_type, + call_ctx, + ); + const ref_idx = self.exprs.items.len; + try self.exprs.append(self.arena, operand.expr); + + return DocData.WalkResult{ + .expr = .{ .ref = ref_idx }, + }; + }, // @check array_cat and array_mul .add,