autodoc: Handle ref ZIR instruction

This commit is contained in:
Krzysztof Wolicki 2023-09-07 12:42:15 +02:00 committed by Loris Cro
parent 6df78c3bc1
commit 8a9aa9e112
2 changed files with 24 additions and 0 deletions

View File

@ -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];

View File

@ -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,