authorgravatar for jacoblevgw@gmail.comJacob G-W <jacoblevgw@gmail.com> 2022-01-28 17:54:02-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-07-19 19:10:10-07:00
log66a46888bbf8636c4ba9e59544fc3679d39a32f6
treec6bcc6a5f7e0d6f3c6d45b3a6f9ccd0444ac99ea
parent025337a78d1f213183050079f79065b0a6c454de

autodoc: generate WalkResults for ref types


1 files changed, 22 insertions(+), 2 deletions(-)

src/Autodoc.zig+22-2
......@@ -47,6 +47,19 @@ pub fn generateZirData(self: Autodoc) !void {
4747 .kind = 0,
4848 .name = "type",
4949 });
50 // append all the types in Zir.Inst.Ref
51 {
52 // we don't count .none
53 var i: u32 = 1;
54 while (i <= @enumToInt(Zir.Inst.Ref.anyerror_void_error_union_type)) : (i += 1) {
55 var tmpbuf = std.ArrayList(u8).init(gpa);
56 try Zir.Inst.Ref.typed_value_map[i].val.format("", .{}, tmpbuf.writer());
57 try types.append(.{
58 .kind = 0,
59 .name = tmpbuf.toOwnedSlice(),
60 });
61 }
62 }
5063
5164 var root_scope: Scope = .{ .parent = null };
5265 try ast_nodes.append(.{ .name = "(root)" });
......@@ -233,8 +246,15 @@ fn walkInstruction(
233246
234247 std.debug.print("body len: {}\n", .{body_len});
235248
236 const result_index = inst_index + body_len - 1;
237 return walkInstruction(zir, gpa, parent_scope, types, decls, ast_nodes, result_index);
249 const break_index = inst_index + body_len;
250 const break_operand = data[break_index].@"break".operand;
251 return if (Zir.refToIndex(break_operand)) |bi|
252 walkInstruction(zir, gpa, parent_scope, types, decls, ast_nodes, bi)
253 else if (@enumToInt(break_operand) <= @enumToInt(Zir.Inst.Ref.anyerror_void_error_union_type))
254 // we append all the types in ref first, so we can just do this if we encounter a ref that is a type
255 return DocData.WalkResult{ .type = @enumToInt(break_operand) }
256 else
257 std.debug.todo("generate WalkResults for refs that are not types");
238258 },
239259 .extended => {
240260 const extended = data[inst_index].extended;