authorgravatar for kappaloris@gmail.comLoris Cro <kappaloris@gmail.com> 2022-02-11 19:11:03+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-07-19 19:10:11-07:00
logee16eddecfc700e37d1acc5393bc2a2ac4e72250
tree6f3a08c9cbd7e4f23dc83b3f0ce54b2ee44b4d87
parent4a868fa2be1713a5cdc0ae75276c2fdf28a56d94

autodoc: added basic support for `@import`


2 files changed, 120 insertions(+), 115 deletions(-)

lib/docs/main.js+17-21
......@@ -264,15 +264,10 @@
264264 }
265265
266266 var childDeclValue = resolveValue(childDecl.value);
267 if ("type" in childDeclValue &&
268 zigAnalysis.types[childDeclValue.type].kind !== typeKinds.Fn){
269 if (i + 1 === curNav.declNames.length) {
270 curNav.declObjs.push(zigAnalysis.types[childDeclValue.type]);
271 break;
272 } else {
273 return render404();
274 }
267 if ("type" in childDeclValue) {
268 childDecl = zigAnalysis.types[childDeclValue.type];
275269 }
270
276271 currentType = childDecl;
277272 curNav.declObjs.push(currentType);
278273 }
......@@ -1458,7 +1453,7 @@
14581453 }
14591454
14601455 function findSubDecl(parentType, childName) {
1461 if (!parentType.pubDecls) throw new Error("parent object has no public decls");
1456 if (!parentType.pubDecls) return null;
14621457 for (var i = 0; i < parentType.pubDecls.length; i += 1) {
14631458 var declIndex = parentType.pubDecls[i];
14641459 var childDecl = zigAnalysis.decls[declIndex];
......@@ -1523,24 +1518,25 @@
15231518 if (list[mainDeclIndex] != null) continue;
15241519
15251520 var decl = zigAnalysis.decls[mainDeclIndex];
1526 var declValTypeId = resolveDeclValueTypeId(decl);
1527 if (declValTypeId === typeTypeId &&
1528 declCanRepresentTypeKind(zigAnalysis.types[declValTypeId].kind))
1529 {
1530 canonTypeDecls[declValTypeId] = mainDeclIndex;
1531 }
1521 var declVal = resolveValue(decl.value);
15321522 var declNames = item.declNames.concat([decl.name]);
15331523 list[mainDeclIndex] = {
15341524 pkgNames: pkgNames,
15351525 declNames: declNames,
15361526 };
1527 if ("type" in declVal) {
1528 var value = zigAnalysis.types[declVal.type];
1529 if (declCanRepresentTypeKind(value.kind))
1530 {
1531 canonTypeDecls[declVal.type] = mainDeclIndex;
1532 }
15371533
1538 var declType = zigAnalysis.types[declValTypeId];
1539 if (isContainerType(declType)) {
1540 stack.push({
1541 declNames: declNames,
1542 type: declType,
1543 });
1534 if (isContainerType(value)) {
1535 stack.push({
1536 declNames: declNames,
1537 type:value,
1538 });
1539 }
15441540 }
15451541 }
15461542 }
src/Autodoc.zig+103-94
......@@ -2,18 +2,19 @@ const std = @import("std");
22const Autodoc = @This();
33const Compilation = @import("Compilation.zig");
44const Module = @import("Module.zig");
5const File = Module.File;
56const Zir = @import("Zir.zig");
67const Ref = Zir.Inst.Ref;
78
89module: *Module,
9doc_location: ?Compilation.EmitLoc,
10doc_location: Compilation.EmitLoc,
1011arena: std.mem.Allocator,
1112types: std.ArrayListUnmanaged(DocData.Type) = .{},
1213decls: std.ArrayListUnmanaged(DocData.Decl) = .{},
1314ast_nodes: std.ArrayListUnmanaged(DocData.AstNode) = .{},
1415
1516var arena_allocator: std.heap.ArenaAllocator = undefined;
16pub fn init(m: *Module, doc_location: ?Compilation.EmitLoc) Autodoc {
17pub fn init(m: *Module, doc_location: Compilation.EmitLoc) Autodoc {
1718 arena_allocator = std.heap.ArenaAllocator.init(m.gpa);
1819 return .{
1920 .module = m,
......@@ -27,11 +28,9 @@ pub fn deinit(_: *Autodoc) void {
2728}
2829
2930pub fn generateZirData(self: *Autodoc) !void {
30 if (self.doc_location) |loc| {
31 if (loc.directory) |dir| {
32 if (dir.path) |path| {
33 std.debug.print("path: {s}\n", .{path});
34 }
31 if (self.doc_location.directory) |dir| {
32 if (dir.path) |path| {
33 std.debug.print("path: {s}\n", .{path});
3534 }
3635 }
3736 std.debug.print("basename: {s}\n", .{self.doc_location.basename});
......@@ -45,7 +44,7 @@ pub fn generateZirData(self: *Autodoc) !void {
4544 const root_file_path = self.module.main_pkg.root_src_path;
4645 const abs_root_path = try std.fs.path.join(self.arena, &.{ dir, root_file_path });
4746 defer self.arena.free(abs_root_path);
48 const zir = self.module.import_table.get(abs_root_path).?.zir;
47 const file = self.module.import_table.get(abs_root_path).?;
4948
5049 // append all the types in Zir.Inst.Ref
5150 {
......@@ -122,7 +121,7 @@ pub fn generateZirData(self: *Autodoc) !void {
122121
123122 var root_scope: Scope = .{ .parent = null };
124123 try self.ast_nodes.append(self.arena, .{ .name = "(root)" });
125 const main_type_index = try self.walkInstruction(zir, &root_scope, Zir.main_struct_inst);
124 const main_type_index = try self.walkInstruction(file, &root_scope, Zir.main_struct_inst);
126125
127126 var data = DocData{
128127 .files = &[1][]const u8{root_file_path},
......@@ -467,12 +466,12 @@ const DocData = struct {
467466
468467fn walkInstruction(
469468 self: *Autodoc,
470 zir: Zir,
469 file: *File,
471470 parent_scope: *Scope,
472471 inst_index: usize,
473472) error{OutOfMemory}!DocData.WalkResult {
474 const tags = zir.instructions.items(.tag);
475 const data = zir.instructions.items(.data);
473 const tags = file.zir.instructions.items(.tag);
474 const data = file.zir.instructions.items(.data);
476475
477476 // We assume that the topmost ast_node entry corresponds to our decl
478477 const self_ast_node_index = self.ast_nodes.items.len - 1;
......@@ -484,6 +483,16 @@ fn walkInstruction(
484483 .{@tagName(tags[inst_index])},
485484 );
486485 },
486 .import => {
487 const str_tok = data[inst_index].str_tok;
488 const path = str_tok.get(file.zir);
489 // importFile cannot error out since all files
490 // are already loaded at this point
491 const new_file = self.module.importFile(file, path) catch unreachable;
492 // TODO: cycles not handled, add file info to outuput
493 var new_scope = Scope{ .parent = null };
494 return self.walkInstruction(new_file.file, &new_scope, Zir.main_struct_inst);
495 },
487496 .int => {
488497 const int = data[inst_index].int;
489498 return DocData.WalkResult{
......@@ -509,7 +518,7 @@ fn walkInstruction(
509518 .negate => {
510519 const un_node = data[inst_index].un_node;
511520 var operand: DocData.WalkResult = try self.walkRef(
512 zir,
521 file,
513522 parent_scope,
514523 un_node.operand,
515524 );
......@@ -518,11 +527,11 @@ fn walkInstruction(
518527 },
519528 .as_node => {
520529 const pl_node = data[inst_index].pl_node;
521 const extra = zir.extraData(Zir.Inst.As, pl_node.payload_index);
522 const dest_type_walk = try self.walkRef(zir, parent_scope, extra.data.dest_type);
530 const extra = file.zir.extraData(Zir.Inst.As, pl_node.payload_index);
531 const dest_type_walk = try self.walkRef(file, parent_scope, extra.data.dest_type);
523532 const dest_type_ref = walkResultToTypeRef(dest_type_walk);
524533
525 var operand = try self.walkRef(zir, parent_scope, extra.data.operand);
534 var operand = try self.walkRef(file, parent_scope, extra.data.operand);
526535
527536 switch (operand) {
528537 else => std.debug.panic(
......@@ -562,20 +571,20 @@ fn walkInstruction(
562571 },
563572 //.block => {
564573 //const pl_node = data[inst_index].pl_node;
565 //const extra = zir.extraData(Zir.Inst.Block, pl_node.payload_index);
566 //const last_instr_index = zir.extra[extra.end..][extra.data.body_len - 1];
574 //const extra = file.zir.extraData(Zir.Inst.Block, pl_node.payload_index);
575 //const last_instr_index = file.zir.extra[extra.end..][extra.data.body_len - 1];
567576 //const break_operand = data[break_index].@"break".operand;
568 //return self.walkRef(zir, parent_scope, break_operand);
577 //return self.walkRef(file, parent_scope, break_operand);
569578 //},
570579 .block_inline => {
571580 const pl_node = data[inst_index].pl_node;
572 const extra = zir.extraData(Zir.Inst.Block, pl_node.payload_index);
573 const break_index = zir.extra[extra.end..][extra.data.body_len - 1];
581 const extra = file.zir.extraData(Zir.Inst.Block, pl_node.payload_index);
582 const break_index = file.zir.extra[extra.end..][extra.data.body_len - 1];
574583 const break_operand = data[break_index].@"break".operand;
575 return self.walkRef(zir, parent_scope, break_operand);
584 return self.walkRef(file, parent_scope, break_operand);
576585 },
577586 .func => {
578 const fn_info = zir.getFnInfo(@intCast(u32, inst_index));
587 const fn_info = file.zir.getFnInfo(@intCast(u32, inst_index));
579588
580589 // TODO: change this to a resize and change the appends accordingly
581590 try self.ast_nodes.ensureUnusedCapacity(self.arena, fn_info.total_params_len);
......@@ -591,21 +600,21 @@ fn walkInstruction(
591600 for (fn_info.param_body[0..fn_info.total_params_len]) |param_index| {
592601 if (tags[param_index] != .param) unreachable; // TODO: handle more param types
593602 const pl_tok = data[param_index].pl_tok;
594 const extra = zir.extraData(Zir.Inst.Param, pl_tok.payload_index);
603 const extra = file.zir.extraData(Zir.Inst.Param, pl_tok.payload_index);
595604 const doc_comment = if (extra.data.doc_comment != 0)
596 zir.nullTerminatedString(extra.data.doc_comment)
605 file.zir.nullTerminatedString(extra.data.doc_comment)
597606 else
598607 "";
599608
600609 param_ast_indexes.appendAssumeCapacity(self.ast_nodes.items.len);
601610 try self.ast_nodes.append(self.arena, .{
602 .name = zir.nullTerminatedString(extra.data.name),
611 .name = file.zir.nullTerminatedString(extra.data.name),
603612 .docs = doc_comment,
604613 });
605614
606 const break_index = zir.extra[extra.end..][extra.data.body_len - 1];
615 const break_index = file.zir.extra[extra.end..][extra.data.body_len - 1];
607616 const break_operand = data[break_index].@"break".operand;
608 const param_type_ref = try self.walkRef(zir, parent_scope, break_operand);
617 const param_type_ref = try self.walkRef(file, parent_scope, break_operand);
609618
610619 param_type_refs.appendAssumeCapacity(
611620 DocData.TypeRef.fromWalkResult(param_type_ref),
......@@ -616,7 +625,7 @@ fn walkInstruction(
616625 const ret_type_ref = blk: {
617626 const last_instr_index = fn_info.ret_ty_body[fn_info.ret_ty_body.len - 1];
618627 const break_operand = data[last_instr_index].@"break".operand;
619 const wr = try self.walkRef(zir, parent_scope, break_operand);
628 const wr = try self.walkRef(file, parent_scope, break_operand);
620629 break :blk DocData.TypeRef.fromWalkResult(wr);
621630 };
622631
......@@ -647,34 +656,34 @@ fn walkInstruction(
647656 var extra_index: usize = extended.operand;
648657
649658 const src_node: ?i32 = if (small.has_src_node) blk: {
650 const src_node = @bitCast(i32, zir.extra[extra_index]);
659 const src_node = @bitCast(i32, file.zir.extra[extra_index]);
651660 extra_index += 1;
652661 break :blk src_node;
653662 } else null;
654663 _ = src_node;
655664
656665 const tag_type: ?Ref = if (small.has_tag_type) blk: {
657 const tag_type = zir.extra[extra_index];
666 const tag_type = file.zir.extra[extra_index];
658667 extra_index += 1;
659668 break :blk @intToEnum(Ref, tag_type);
660669 } else null;
661670 _ = tag_type;
662671
663672 const body_len = if (small.has_body_len) blk: {
664 const body_len = zir.extra[extra_index];
673 const body_len = file.zir.extra[extra_index];
665674 extra_index += 1;
666675 break :blk body_len;
667676 } else 0;
668677
669678 const fields_len = if (small.has_fields_len) blk: {
670 const fields_len = zir.extra[extra_index];
679 const fields_len = file.zir.extra[extra_index];
671680 extra_index += 1;
672681 break :blk fields_len;
673682 } else 0;
674683 _ = fields_len;
675684
676685 const decls_len = if (small.has_decls_len) blk: {
677 const decls_len = zir.extra[extra_index];
686 const decls_len = file.zir.extra[extra_index];
678687 extra_index += 1;
679688 break :blk decls_len;
680689 } else 0;
......@@ -687,17 +696,17 @@ fn walkInstruction(
687696 // Done to make sure that all decl refs can be resolved correctly,
688697 // even if we haven't fully analyzed the decl yet.
689698 {
690 var it = zir.declIterator(@intCast(u32, inst_index));
699 var it = file.zir.declIterator(@intCast(u32, inst_index));
691700 try self.decls.resize(self.arena, decls_first_index + it.decls_len);
692701 var decls_slot_index = decls_first_index;
693702 while (it.next()) |d| : (decls_slot_index += 1) {
694 const decl_name_index = zir.extra[d.sub_index + 5];
703 const decl_name_index = file.zir.extra[d.sub_index + 5];
695704 try scope.insertDeclRef(self.arena, decl_name_index, decls_slot_index);
696705 }
697706 }
698707
699708 extra_index = try self.walkDecls(
700 zir,
709 file,
701710 &scope,
702711 decls_first_index,
703712 decls_len,
......@@ -706,7 +715,7 @@ fn walkInstruction(
706715 extra_index,
707716 );
708717
709 // const body = zir.extra[extra_index..][0..body_len];
718 // const body = file.zir.extra[extra_index..][0..body_len];
710719 extra_index += body_len;
711720
712721 var field_type_refs = try std.ArrayListUnmanaged(DocData.TypeRef).initCapacity(
......@@ -718,7 +727,7 @@ fn walkInstruction(
718727 fields_len,
719728 );
720729 try self.collectUnionFieldInfo(
721 zir,
730 file,
722731 &scope,
723732 fields_len,
724733 &field_type_refs,
......@@ -747,34 +756,34 @@ fn walkInstruction(
747756 var extra_index: usize = extended.operand;
748757
749758 const src_node: ?i32 = if (small.has_src_node) blk: {
750 const src_node = @bitCast(i32, zir.extra[extra_index]);
759 const src_node = @bitCast(i32, file.zir.extra[extra_index]);
751760 extra_index += 1;
752761 break :blk src_node;
753762 } else null;
754763 _ = src_node;
755764
756765 const tag_type: ?Ref = if (small.has_tag_type) blk: {
757 const tag_type = zir.extra[extra_index];
766 const tag_type = file.zir.extra[extra_index];
758767 extra_index += 1;
759768 break :blk @intToEnum(Ref, tag_type);
760769 } else null;
761770 _ = tag_type;
762771
763772 const body_len = if (small.has_body_len) blk: {
764 const body_len = zir.extra[extra_index];
773 const body_len = file.zir.extra[extra_index];
765774 extra_index += 1;
766775 break :blk body_len;
767776 } else 0;
768777
769778 const fields_len = if (small.has_fields_len) blk: {
770 const fields_len = zir.extra[extra_index];
779 const fields_len = file.zir.extra[extra_index];
771780 extra_index += 1;
772781 break :blk fields_len;
773782 } else 0;
774783 _ = fields_len;
775784
776785 const decls_len = if (small.has_decls_len) blk: {
777 const decls_len = zir.extra[extra_index];
786 const decls_len = file.zir.extra[extra_index];
778787 extra_index += 1;
779788 break :blk decls_len;
780789 } else 0;
......@@ -787,17 +796,17 @@ fn walkInstruction(
787796 // Done to make sure that all decl refs can be resolved correctly,
788797 // even if we haven't fully analyzed the decl yet.
789798 {
790 var it = zir.declIterator(@intCast(u32, inst_index));
799 var it = file.zir.declIterator(@intCast(u32, inst_index));
791800 try self.decls.resize(self.arena, decls_first_index + it.decls_len);
792801 var decls_slot_index = decls_first_index;
793802 while (it.next()) |d| : (decls_slot_index += 1) {
794 const decl_name_index = zir.extra[d.sub_index + 5];
803 const decl_name_index = file.zir.extra[d.sub_index + 5];
795804 try scope.insertDeclRef(self.arena, decl_name_index, decls_slot_index);
796805 }
797806 }
798807
799808 extra_index = try self.walkDecls(
800 zir,
809 file,
801810 &scope,
802811 decls_first_index,
803812 decls_len,
......@@ -806,7 +815,7 @@ fn walkInstruction(
806815 extra_index,
807816 );
808817
809 // const body = zir.extra[extra_index..][0..body_len];
818 // const body = file.zir.extra[extra_index..][0..body_len];
810819 extra_index += body_len;
811820
812821 var field_name_indexes: std.ArrayListUnmanaged(usize) = .{};
......@@ -818,31 +827,31 @@ fn walkInstruction(
818827 var idx: usize = 0;
819828 while (idx < fields_len) : (idx += 1) {
820829 if (idx % 32 == 0) {
821 cur_bit_bag = zir.extra[bit_bag_idx];
830 cur_bit_bag = file.zir.extra[bit_bag_idx];
822831 bit_bag_idx += 1;
823832 }
824833
825834 const has_value = @truncate(u1, cur_bit_bag) != 0;
826835 cur_bit_bag >>= 1;
827836
828 const field_name_index = zir.extra[extra_index];
837 const field_name_index = file.zir.extra[extra_index];
829838 extra_index += 1;
830839
831 const doc_comment_index = zir.extra[extra_index];
840 const doc_comment_index = file.zir.extra[extra_index];
832841 extra_index += 1;
833842
834843 const value_ref: ?Ref = if (has_value) blk: {
835 const value_ref = zir.extra[extra_index];
844 const value_ref = file.zir.extra[extra_index];
836845 extra_index += 1;
837846 break :blk @intToEnum(Ref, value_ref);
838847 } else null;
839848 _ = value_ref;
840849
841 const field_name = zir.nullTerminatedString(field_name_index);
850 const field_name = file.zir.nullTerminatedString(field_name_index);
842851
843852 try field_name_indexes.append(self.arena, self.ast_nodes.items.len);
844853 const doc_comment: ?[]const u8 = if (doc_comment_index != 0)
845 zir.nullTerminatedString(doc_comment_index)
854 file.zir.nullTerminatedString(doc_comment_index)
846855 else
847856 null;
848857 try self.ast_nodes.append(self.arena, .{
......@@ -872,27 +881,27 @@ fn walkInstruction(
872881 var extra_index: usize = extended.operand;
873882
874883 const src_node: ?i32 = if (small.has_src_node) blk: {
875 const src_node = @bitCast(i32, zir.extra[extra_index]);
884 const src_node = @bitCast(i32, file.zir.extra[extra_index]);
876885 extra_index += 1;
877886 break :blk src_node;
878887 } else null;
879888 _ = src_node;
880889
881890 const body_len = if (small.has_body_len) blk: {
882 const body_len = zir.extra[extra_index];
891 const body_len = file.zir.extra[extra_index];
883892 extra_index += 1;
884893 break :blk body_len;
885894 } else 0;
886895
887896 const fields_len = if (small.has_fields_len) blk: {
888 const fields_len = zir.extra[extra_index];
897 const fields_len = file.zir.extra[extra_index];
889898 extra_index += 1;
890899 break :blk fields_len;
891900 } else 0;
892901 _ = fields_len;
893902
894903 const decls_len = if (small.has_decls_len) blk: {
895 const decls_len = zir.extra[extra_index];
904 const decls_len = file.zir.extra[extra_index];
896905 extra_index += 1;
897906 break :blk decls_len;
898907 } else 0;
......@@ -905,17 +914,17 @@ fn walkInstruction(
905914 // Done to make sure that all decl refs can be resolved correctly,
906915 // even if we haven't fully analyzed the decl yet.
907916 {
908 var it = zir.declIterator(@intCast(u32, inst_index));
917 var it = file.zir.declIterator(@intCast(u32, inst_index));
909918 try self.decls.resize(self.arena, decls_first_index + it.decls_len);
910919 var decls_slot_index = decls_first_index;
911920 while (it.next()) |d| : (decls_slot_index += 1) {
912 const decl_name_index = zir.extra[d.sub_index + 5];
921 const decl_name_index = file.zir.extra[d.sub_index + 5];
913922 try scope.insertDeclRef(self.arena, decl_name_index, decls_slot_index);
914923 }
915924 }
916925
917926 extra_index = try self.walkDecls(
918 zir,
927 file,
919928 &scope,
920929 decls_first_index,
921930 decls_len,
......@@ -924,13 +933,13 @@ fn walkInstruction(
924933 extra_index,
925934 );
926935
927 // const body = zir.extra[extra_index..][0..body_len];
936 // const body = file.zir.extra[extra_index..][0..body_len];
928937 extra_index += body_len;
929938
930939 var field_type_refs: std.ArrayListUnmanaged(DocData.TypeRef) = .{};
931940 var field_name_indexes: std.ArrayListUnmanaged(usize) = .{};
932941 try self.collectStructFieldInfo(
933 zir,
942 file,
934943 &scope,
935944 fields_len,
936945 &field_type_refs,
......@@ -966,7 +975,7 @@ fn walkInstruction(
966975/// slots in `self.decls`, which are then filled out by `walkDecls`.
967976fn walkDecls(
968977 self: *Autodoc,
969 zir: Zir,
978 file: *File,
970979 scope: *Scope,
971980 decls_first_index: usize,
972981 decls_len: u32,
......@@ -984,7 +993,7 @@ fn walkDecls(
984993 const decls_slot_index = decls_first_index + decl_i;
985994
986995 if (decl_i % 8 == 0) {
987 cur_bit_bag = zir.extra[bit_bag_index];
996 cur_bit_bag = file.zir.extra[bit_bag_index];
988997 bit_bag_index += 1;
989998 }
990999 const is_pub = @truncate(u1, cur_bit_bag) != 0;
......@@ -998,29 +1007,29 @@ fn walkDecls(
9981007
9991008 // const sub_index = extra_index;
10001009
1001 // const hash_u32s = zir.extra[extra_index..][0..4];
1010 // const hash_u32s = file.zir.extra[extra_index..][0..4];
10021011 extra_index += 4;
1003 // const line = zir.extra[extra_index];
1012 // const line = file.zir.extra[extra_index];
10041013 extra_index += 1;
1005 const decl_name_index = zir.extra[extra_index];
1014 const decl_name_index = file.zir.extra[extra_index];
10061015 extra_index += 1;
1007 const decl_index = zir.extra[extra_index];
1016 const decl_index = file.zir.extra[extra_index];
10081017 extra_index += 1;
1009 const doc_comment_index = zir.extra[extra_index];
1018 const doc_comment_index = file.zir.extra[extra_index];
10101019 extra_index += 1;
10111020
10121021 // const align_inst: Zir.Inst.Ref = if (!has_align) .none else inst: {
1013 // const inst = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]);
1022 // const inst = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]);
10141023 // extra_index += 1;
10151024 // break :inst inst;
10161025 // };
10171026 // const section_inst: Zir.Inst.Ref = if (!has_section_or_addrspace) .none else inst: {
1018 // const inst = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]);
1027 // const inst = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]);
10191028 // extra_index += 1;
10201029 // break :inst inst;
10211030 // };
10221031 // const addrspace_inst: Zir.Inst.Ref = if (!has_section_or_addrspace) .none else inst: {
1023 // const inst = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]);
1032 // const inst = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]);
10241033 // extra_index += 1;
10251034 // break :inst inst;
10261035 // };
......@@ -1034,9 +1043,9 @@ fn walkDecls(
10341043 } else if (decl_name_index == 1) {
10351044 break :blk "test";
10361045 } else {
1037 const raw_decl_name = zir.nullTerminatedString(decl_name_index);
1046 const raw_decl_name = file.zir.nullTerminatedString(decl_name_index);
10381047 if (raw_decl_name.len == 0) {
1039 break :blk zir.nullTerminatedString(decl_name_index + 1);
1048 break :blk file.zir.nullTerminatedString(decl_name_index + 1);
10401049 } else {
10411050 break :blk raw_decl_name;
10421051 }
......@@ -1044,7 +1053,7 @@ fn walkDecls(
10441053 };
10451054
10461055 const doc_comment: ?[]const u8 = if (doc_comment_index != 0)
1047 zir.nullTerminatedString(doc_comment_index)
1056 file.zir.nullTerminatedString(doc_comment_index)
10481057 else
10491058 null;
10501059
......@@ -1061,7 +1070,7 @@ fn walkDecls(
10611070 break :idx idx;
10621071 };
10631072
1064 const walk_result = try self.walkInstruction(zir, scope, decl_index);
1073 const walk_result = try self.walkInstruction(file, scope, decl_index);
10651074
10661075 if (is_pub) {
10671076 try decl_indexes.append(self.arena, decls_slot_index);
......@@ -1098,7 +1107,7 @@ fn walkDecls(
10981107
10991108fn collectUnionFieldInfo(
11001109 self: *Autodoc,
1101 zir: Zir,
1110 file: *File,
11021111 scope: *Scope,
11031112 fields_len: usize,
11041113 field_type_refs: *std.ArrayListUnmanaged(DocData.TypeRef),
......@@ -1118,7 +1127,7 @@ fn collectUnionFieldInfo(
11181127 var field_i: u32 = 0;
11191128 while (field_i < fields_len) : (field_i += 1) {
11201129 if (field_i % fields_per_u32 == 0) {
1121 cur_bit_bag = zir.extra[bit_bag_index];
1130 cur_bit_bag = file.zir.extra[bit_bag_index];
11221131 bit_bag_index += 1;
11231132 }
11241133 const has_type = @truncate(u1, cur_bit_bag) != 0;
......@@ -1131,12 +1140,12 @@ fn collectUnionFieldInfo(
11311140 cur_bit_bag >>= 1;
11321141 _ = unused;
11331142
1134 const field_name = zir.nullTerminatedString(zir.extra[extra_index]);
1143 const field_name = file.zir.nullTerminatedString(file.zir.extra[extra_index]);
11351144 extra_index += 1;
1136 const doc_comment_index = zir.extra[extra_index];
1145 const doc_comment_index = file.zir.extra[extra_index];
11371146 extra_index += 1;
11381147 const field_type = if (has_type)
1139 @intToEnum(Zir.Inst.Ref, zir.extra[extra_index])
1148 @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index])
11401149 else
11411150 .void_type;
11421151 extra_index += 1;
......@@ -1146,7 +1155,7 @@ fn collectUnionFieldInfo(
11461155
11471156 // type
11481157 {
1149 const walk_result = try self.walkRef(zir, scope, field_type);
1158 const walk_result = try self.walkRef(file, scope, field_type);
11501159 try field_type_refs.append(
11511160 self.arena,
11521161 walkResultToTypeRef(walk_result),
......@@ -1157,7 +1166,7 @@ fn collectUnionFieldInfo(
11571166 {
11581167 try field_name_indexes.append(self.arena, self.ast_nodes.items.len);
11591168 const doc_comment: ?[]const u8 = if (doc_comment_index != 0)
1160 zir.nullTerminatedString(doc_comment_index)
1169 file.zir.nullTerminatedString(doc_comment_index)
11611170 else
11621171 null;
11631172 try self.ast_nodes.append(self.arena, .{
......@@ -1170,7 +1179,7 @@ fn collectUnionFieldInfo(
11701179
11711180fn collectStructFieldInfo(
11721181 self: *Autodoc,
1173 zir: Zir,
1182 file: *File,
11741183 scope: *Scope,
11751184 fields_len: usize,
11761185 field_type_refs: *std.ArrayListUnmanaged(DocData.TypeRef),
......@@ -1190,7 +1199,7 @@ fn collectStructFieldInfo(
11901199 var field_i: u32 = 0;
11911200 while (field_i < fields_len) : (field_i += 1) {
11921201 if (field_i % fields_per_u32 == 0) {
1193 cur_bit_bag = zir.extra[bit_bag_index];
1202 cur_bit_bag = file.zir.extra[bit_bag_index];
11941203 bit_bag_index += 1;
11951204 }
11961205 const has_align = @truncate(u1, cur_bit_bag) != 0;
......@@ -1203,11 +1212,11 @@ fn collectStructFieldInfo(
12031212 cur_bit_bag >>= 1;
12041213 _ = unused;
12051214
1206 const field_name = zir.nullTerminatedString(zir.extra[extra_index]);
1215 const field_name = file.zir.nullTerminatedString(file.zir.extra[extra_index]);
12071216 extra_index += 1;
1208 const field_type = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]);
1217 const field_type = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]);
12091218 extra_index += 1;
1210 const doc_comment_index = zir.extra[extra_index];
1219 const doc_comment_index = file.zir.extra[extra_index];
12111220 extra_index += 1;
12121221
12131222 if (has_align) extra_index += 1;
......@@ -1215,7 +1224,7 @@ fn collectStructFieldInfo(
12151224
12161225 // type
12171226 {
1218 const walk_result = try self.walkRef(zir, scope, field_type);
1227 const walk_result = try self.walkRef(file, scope, field_type);
12191228 try field_type_refs.append(
12201229 self.arena,
12211230 walkResultToTypeRef(walk_result),
......@@ -1226,7 +1235,7 @@ fn collectStructFieldInfo(
12261235 {
12271236 try field_name_indexes.append(self.arena, self.ast_nodes.items.len);
12281237 const doc_comment: ?[]const u8 = if (doc_comment_index != 0)
1229 zir.nullTerminatedString(doc_comment_index)
1238 file.zir.nullTerminatedString(doc_comment_index)
12301239 else
12311240 null;
12321241 try self.ast_nodes.append(self.arena, .{
......@@ -1239,7 +1248,7 @@ fn collectStructFieldInfo(
12391248
12401249fn walkRef(
12411250 self: *Autodoc,
1242 zir: Zir,
1251 file: *File,
12431252 parent_scope: *Scope,
12441253 ref: Ref,
12451254) !DocData.WalkResult {
......@@ -1327,7 +1336,7 @@ fn walkRef(
13271336 }
13281337 } else {
13291338 const zir_index = enum_value - Ref.typed_value_map.len;
1330 return self.walkInstruction(zir, parent_scope, zir_index);
1339 return self.walkInstruction(file, parent_scope, zir_index);
13311340 }
13321341}
13331342
......@@ -1343,6 +1352,6 @@ fn walkResultToTypeRef(wr: DocData.WalkResult) DocData.TypeRef {
13431352 };
13441353}
13451354
1346//fn collectParamInfo(self: *Autodoc, zir: Zir, scope: *Scope, inst_idx: Zir.Index) void {
1355//fn collectParamInfo(self: *Autodoc, file: *File, scope: *Scope, inst_idx: Zir.Index) void {
13471356
13481357//}