authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-11-09 23:06:26+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-11-11 18:01:14+02:00
loge01ec96288bd32c7ec3bba01ee200cc115cdfb1d
tree7a24e7026127811683cdffaf1dada813d8b89e93
parent52b8efc726097df70dca7287b0a8e16b0a8a642d

Autodoc: not all `block_inline`s contain a `break_inline`


2 files changed, 15 insertions(+), 4 deletions(-)

src/AstGen.zig+3-1
...@@ -7940,7 +7940,9 @@ fn builtinCall(...@@ -7940,7 +7940,9 @@ fn builtinCall(
7940 },7940 },
79417941
7942 .src => {7942 .src => {
7943 maybeAdvanceSourceCursorToMainToken(gz, node);7943 const token_starts = tree.tokens.items(.start);
7944 const node_start = token_starts[tree.firstToken(node)];
7945 astgen.advanceSourceCursor(node_start);
7944 const result = try gz.addExtendedPayload(.builtin_src, Zir.Inst.Src{7946 const result = try gz.addExtendedPayload(.builtin_src, Zir.Inst.Src{
7945 .node = gz.nodeIndexToRelative(node),7947 .node = gz.nodeIndexToRelative(node),
7946 .line = astgen.source_line,7948 .line = astgen.source_line,
src/Autodoc.zig+12-3
...@@ -2129,7 +2129,15 @@ fn walkInstruction(...@@ -2129,7 +2129,15 @@ fn walkInstruction(
2129 file,2129 file,
2130 parent_scope,2130 parent_scope,
2131 parent_src,2131 parent_src,
2132 getBlockInlineBreak(file.zir, inst_index),2132 getBlockInlineBreak(file.zir, inst_index) orelse {
2133 const res = DocData.WalkResult{ .expr = .{
2134 .comptimeExpr = self.comptime_exprs.items.len,
2135 } };
2136 try self.comptime_exprs.append(self.arena, .{
2137 .code = "if (...) { ... }",
2138 });
2139 return res;
2140 },
2133 need_type,2141 need_type,
2134 );2142 );
2135 },2143 },
...@@ -3155,7 +3163,7 @@ fn walkDecls(...@@ -3155,7 +3163,7 @@ fn walkDecls(
3155 2 => {3163 2 => {
3156 // decl test3164 // decl test
3157 const decl_being_tested = scope.resolveDeclName(doc_comment_index);3165 const decl_being_tested = scope.resolveDeclName(doc_comment_index);
3158 const func_index = getBlockInlineBreak(file.zir, value_index);3166 const func_index = getBlockInlineBreak(file.zir, value_index).?;
31593167
3160 const pl_node = data[Zir.refToIndex(func_index).?].pl_node;3168 const pl_node = data[Zir.refToIndex(func_index).?].pl_node;
3161 const fn_src = try self.srcLocInfo(file, pl_node.src_node, decl_src);3169 const fn_src = try self.srcLocInfo(file, pl_node.src_node, decl_src);
...@@ -4301,12 +4309,13 @@ fn walkRef(...@@ -4301,12 +4309,13 @@ fn walkRef(
4301 }4309 }
4302}4310}
43034311
4304fn getBlockInlineBreak(zir: Zir, inst_index: usize) Zir.Inst.Ref {4312fn getBlockInlineBreak(zir: Zir, inst_index: usize) ?Zir.Inst.Ref {
4305 const tags = zir.instructions.items(.tag);4313 const tags = zir.instructions.items(.tag);
4306 const data = zir.instructions.items(.data);4314 const data = zir.instructions.items(.data);
4307 const pl_node = data[inst_index].pl_node;4315 const pl_node = data[inst_index].pl_node;
4308 const extra = zir.extraData(Zir.Inst.Block, pl_node.payload_index);4316 const extra = zir.extraData(Zir.Inst.Block, pl_node.payload_index);
4309 const break_index = zir.extra[extra.end..][extra.data.body_len - 1];4317 const break_index = zir.extra[extra.end..][extra.data.body_len - 1];
4318 if (tags[break_index] == .condbr_inline) return null;
4310 std.debug.assert(tags[break_index] == .break_inline);4319 std.debug.assert(tags[break_index] == .break_inline);
4311 return data[break_index].@"break".operand;4320 return data[break_index].@"break".operand;
4312}4321}