commit 66a46888bbf8636c4ba9e59544fc3679d39a32f6 (tree)
parent 025337a78d1f213183050079f79065b0a6c454de
Author: Jacob G-W <jacoblevgw@gmail.com>
Date: Fri, 28 Jan 2022 17:54:02 -0500
autodoc: generate WalkResults for ref types
Diffstat:
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/src/Autodoc.zig b/src/Autodoc.zig
@@ -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;