authorgravatar for der.teufel.mail@gmail.comKrzysztof Wolicki <der.teufel.mail@gmail.com> 2023-09-07 12:42:15+02:00
committergravatar for kappaloris@gmail.comLoris Cro <kappaloris@gmail.com> 2023-09-16 17:30:49+02:00
log8a9aa9e112bd75b057eff4b6449a5af86ed568a4
treeb087f96b160da82805efeb4848684bdc08b32b5e
parent6df78c3bc17e5922792fcef0025043c358daa52f

autodoc: Handle `ref` ZIR instruction


2 files changed, 24 insertions(+), 0 deletions(-)

lib/docs/main.js+6
......@@ -1361,6 +1361,12 @@ Happy writing!
13611361 return;
13621362 }
13631363
1364 case "ref": {
1365 yield { src: "&", tag: Tag.ampersand };
1366 yield* ex(zigAnalysis.exprs[expr.ref], opts);
1367 return;
1368 }
1369
13641370 case "call": {
13651371
13661372 let call = zigAnalysis.calls[expr.call];
src/Autodoc.zig+18
......@@ -797,6 +797,7 @@ const DocData = struct {
797797 binOp: BinOp,
798798 binOpIndex: usize,
799799 load: usize, // index in `exprs`
800 ref: usize, // index in `exprs`
800801 const BinOp = struct {
801802 lhs: usize, // index in `exprs`
802803 rhs: usize, // index in `exprs`
......@@ -1521,6 +1522,23 @@ fn walkInstruction(
15211522 .expr = .{ .load = load_idx },
15221523 };
15231524 },
1525 .ref => {
1526 const un_tok = data[inst_index].un_tok;
1527 const operand = try self.walkRef(
1528 file,
1529 parent_scope,
1530 parent_src,
1531 un_tok.operand,
1532 need_type,
1533 call_ctx,
1534 );
1535 const ref_idx = self.exprs.items.len;
1536 try self.exprs.append(self.arena, operand.expr);
1537
1538 return DocData.WalkResult{
1539 .expr = .{ .ref = ref_idx },
1540 };
1541 },
15241542
15251543 // @check array_cat and array_mul
15261544 .add,