autodoc: generate WalkResults for ref types

This commit is contained in:
Jacob G-W 2022-01-28 17:54:02 -05:00 committed by Andrew Kelley
parent 025337a78d
commit 66a46888bb

View File

@ -47,6 +47,19 @@ pub fn generateZirData(self: Autodoc) !void {
.kind = 0,
.name = "type",
});
// append all the types in Zir.Inst.Ref
{
// we don't count .none
var i: u32 = 1;
while (i <= @enumToInt(Zir.Inst.Ref.anyerror_void_error_union_type)) : (i += 1) {
var tmpbuf = std.ArrayList(u8).init(gpa);
try Zir.Inst.Ref.typed_value_map[i].val.format("", .{}, tmpbuf.writer());
try types.append(.{
.kind = 0,
.name = tmpbuf.toOwnedSlice(),
});
}
}
var root_scope: Scope = .{ .parent = null };
try ast_nodes.append(.{ .name = "(root)" });
@ -233,8 +246,15 @@ fn walkInstruction(
std.debug.print("body len: {}\n", .{body_len});
const result_index = inst_index + body_len - 1;
return walkInstruction(zir, gpa, parent_scope, types, decls, ast_nodes, result_index);
const break_index = inst_index + body_len;
const break_operand = data[break_index].@"break".operand;
return if (Zir.refToIndex(break_operand)) |bi|
walkInstruction(zir, gpa, parent_scope, types, decls, ast_nodes, bi)
else if (@enumToInt(break_operand) <= @enumToInt(Zir.Inst.Ref.anyerror_void_error_union_type))
// we append all the types in ref first, so we can just do this if we encounter a ref that is a type
return DocData.WalkResult{ .type = @enumToInt(break_operand) }
else
std.debug.todo("generate WalkResults for refs that are not types");
},
.extended => {
const extended = data[inst_index].extended;