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!...@@ -1361,6 +1361,12 @@ Happy writing!
1361 return;1361 return;
1362 }1362 }
13631363
1364 case "ref": {
1365 yield { src: "&", tag: Tag.ampersand };
1366 yield* ex(zigAnalysis.exprs[expr.ref], opts);
1367 return;
1368 }
1369
1364 case "call": {1370 case "call": {
13651371
1366 let call = zigAnalysis.calls[expr.call];1372 let call = zigAnalysis.calls[expr.call];
src/Autodoc.zig+18
...@@ -797,6 +797,7 @@ const DocData = struct {...@@ -797,6 +797,7 @@ const DocData = struct {
797 binOp: BinOp,797 binOp: BinOp,
798 binOpIndex: usize,798 binOpIndex: usize,
799 load: usize, // index in `exprs`799 load: usize, // index in `exprs`
800 ref: usize, // index in `exprs`
800 const BinOp = struct {801 const BinOp = struct {
801 lhs: usize, // index in `exprs`802 lhs: usize, // index in `exprs`
802 rhs: usize, // index in `exprs`803 rhs: usize, // index in `exprs`
...@@ -1521,6 +1522,23 @@ fn walkInstruction(...@@ -1521,6 +1522,23 @@ fn walkInstruction(
1521 .expr = .{ .load = load_idx },1522 .expr = .{ .load = load_idx },
1522 };1523 };
1523 },1524 },
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
1525 // @check array_cat and array_mul1543 // @check array_cat and array_mul
1526 .add,1544 .add,