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(
79407940 },
79417941
79427942 .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);
79447946 const result = try gz.addExtendedPayload(.builtin_src, Zir.Inst.Src{
79457947 .node = gz.nodeIndexToRelative(node),
79467948 .line = astgen.source_line,
src/Autodoc.zig+12-3
......@@ -2129,7 +2129,15 @@ fn walkInstruction(
21292129 file,
21302130 parent_scope,
21312131 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 },
21332141 need_type,
21342142 );
21352143 },
......@@ -3155,7 +3163,7 @@ fn walkDecls(
31553163 2 => {
31563164 // decl test
31573165 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
31603168 const pl_node = data[Zir.refToIndex(func_index).?].pl_node;
31613169 const fn_src = try self.srcLocInfo(file, pl_node.src_node, decl_src);
......@@ -4301,12 +4309,13 @@ fn walkRef(
43014309 }
43024310}
43034311
4304fn getBlockInlineBreak(zir: Zir, inst_index: usize) Zir.Inst.Ref {
4312fn getBlockInlineBreak(zir: Zir, inst_index: usize) ?Zir.Inst.Ref {
43054313 const tags = zir.instructions.items(.tag);
43064314 const data = zir.instructions.items(.data);
43074315 const pl_node = data[inst_index].pl_node;
43084316 const extra = zir.extraData(Zir.Inst.Block, pl_node.payload_index);
43094317 const break_index = zir.extra[extra.end..][extra.data.body_len - 1];
4318 if (tags[break_index] == .condbr_inline) return null;
43104319 std.debug.assert(tags[break_index] == .break_inline);
43114320 return data[break_index].@"break".operand;
43124321}