Commit 66a46888bb
Changed files (1)
src
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;