authorgravatar for vallahor91@gmail.comVallahor <vallahor91@gmail.com> 2022-05-28 16:14:40-03:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-07-19 19:10:11-07:00
log0e5a2bbd63d8acb8c570a384db875bc0f25a4999
tree98acb926a427fa541ad00c9fd1f721fe33541441
parentec8d29ff257a2285665e0559aa53a8cfcb251756

fix: NoReturn and WIP in calling_conventions


2 files changed, 47 insertions(+), 25 deletions(-)

lib/docs/main.js+4
......@@ -1180,6 +1180,10 @@ var zigAnalysis;
11801180 if (typeof typeObj === 'number') typeObj = zigAnalysis.types[typeObj];
11811181 switch (typeObj.kind) {
11821182 default: throw "TODO";
1183 case typeKinds.Unanalyzed:
1184 {
1185 return "Unanalyzed";
1186 }
11831187 case typeKinds.ComptimeExpr:
11841188 {
11851189 return "anyopaque";
src/Autodoc.zig+43-25
......@@ -162,6 +162,9 @@ pub fn generateZirData(self: *Autodoc) !void {
162162 .anyerror_type => .{
163163 .ErrorSet = .{ .name = tmpbuf.toOwnedSlice() },
164164 },
165 // .calling_convention_inline, .calling_convention_c, .calling_convention_type => .{
166 // .EnumLiteral = .{ .name = tmpbuf.toOwnedSlice() },
167 // },
165168 },
166169 );
167170 }
......@@ -515,7 +518,15 @@ const DocData = struct {
515518 .Int => |v| try printTypeBody(v, options, w),
516519 .Float => |v| try printTypeBody(v, options, w),
517520 .Type => |v| try printTypeBody(v, options, w),
521 .NoReturn => |v| try printTypeBody(v, options, w),
518522 .EnumLiteral => |v| try printTypeBody(v, options, w),
523 .Unanalyzed => |_| {
524 if (options.whitespace) |ws| try ws.outputIndent(w);
525 try w.print(
526 \\"Unanalyzed": "Unanalyzed"
527 \\
528 , .{});
529 },
519530 .Pointer => |v| {
520531 if (options.whitespace) |ws| try ws.outputIndent(w);
521532 try w.print(
......@@ -2767,12 +2778,16 @@ fn analyzeFunction(
27672778 const inst_data = data[inst_index].pl_node;
27682779 const extra = file.zir.extraData(Zir.Inst.ExtendedFunc, inst_data.payload_index);
27692780 var cc_index: ?usize = null;
2770 if (extra.data.bits.has_cc) {
2771 // @panic with .calling_convention_inline
2772 // const cc_ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra.end]);
2773 // _ = try self.walkRef(file, scope, cc_ref, false);
2774 // cc_index = self.types.items.len - 1;
2775 }
2781 cc_index = self.types.items.len - 1;
2782 // if (extra.data.bits.has_cc) {
2783 // const cc = file.zir.extra[extra.end];
2784 // const cc_ref = @intToEnum(Zir.Inst.Ref, cc);
2785 // _ = try self.walkRef(file, scope, cc_ref, false);
2786 // cc_index = self.types.items.len - 1;
2787 // std.debug.print("DONE\n", .{});
2788 // std.debug.print("cc_ref = {any}\n", .{cc_ref});
2789 // std.debug.print("index = {}\n", .{cc_index});
2790 // }
27762791
27772792 break :blk .{
27782793 .Fn = .{
......@@ -2781,7 +2796,7 @@ fn analyzeFunction(
27812796 .params = param_type_refs.items,
27822797 .ret = ret_type_ref.expr,
27832798 .is_extern = extra.data.bits.is_extern,
2784 // .has_cc = extra.data.bits.has_cc,
2799 .has_cc = extra.data.bits.has_cc,
27852800 .is_inferred_error = extra.data.bits.is_inferred_error,
27862801 .cc = cc_index,
27872802 },
......@@ -3015,24 +3030,27 @@ fn walkRef(
30153030 };
30163031 },
30173032 // TODO: dunno what to do with those
3018 // .calling_convention_type => {
3019 // return DocData.WalkResult{
3020 // .typeRef = .{ .type = @enumToInt(Ref.calling_convention_type) },
3021 // .expr = .{ .int = .{ .value = 1 } },
3022 // };
3023 // },
3024 // .calling_convention_c => {
3025 // return DocData.WalkResult{
3026 // .typeRef = .{ .type = @enumToInt(Ref.calling_convention_c) },
3027 // .expr = .{ .int = .{ .value = 1 } },
3028 // };
3029 // },
3030 // .calling_convention_inline => {
3031 // return DocData.WalkResult{
3032 // .typeRef = .{ .type = @enumToInt(Ref.calling_convention_inline) },
3033 // .expr = .{ .int = .{ .value = 1 } },
3034 // };
3035 // },
3033 .calling_convention_type => {
3034 return DocData.WalkResult{
3035 // .typeRef = .{ .type = @enumToInt(Ref.calling_convention_type) },
3036 .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) },
3037 .expr = .{ .int = .{ .value = 1 } },
3038 };
3039 },
3040 .calling_convention_c => {
3041 return DocData.WalkResult{
3042 // .typeRef = .{ .type = @enumToInt(Ref.calling_convention_c) },
3043 .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) },
3044 .expr = .{ .int = .{ .value = 1 } },
3045 };
3046 },
3047 .calling_convention_inline => {
3048 return DocData.WalkResult{
3049 // .typeRef = .{ .type = @enumToInt(Ref.calling_convention_inline) },
3050 .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) },
3051 .expr = .{ .int = .{ .value = 1 } },
3052 };
3053 },
30363054 // .generic_poison => {
30373055 // return DocData.WalkResult{ .int = .{
30383056 // .type = @enumToInt(Ref.comptime_int_type),