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;...@@ -1180,6 +1180,10 @@ var zigAnalysis;
1180 if (typeof typeObj === 'number') typeObj = zigAnalysis.types[typeObj];1180 if (typeof typeObj === 'number') typeObj = zigAnalysis.types[typeObj];
1181 switch (typeObj.kind) {1181 switch (typeObj.kind) {
1182 default: throw "TODO";1182 default: throw "TODO";
1183 case typeKinds.Unanalyzed:
1184 {
1185 return "Unanalyzed";
1186 }
1183 case typeKinds.ComptimeExpr:1187 case typeKinds.ComptimeExpr:
1184 {1188 {
1185 return "anyopaque";1189 return "anyopaque";
src/Autodoc.zig+43-25
...@@ -162,6 +162,9 @@ pub fn generateZirData(self: *Autodoc) !void {...@@ -162,6 +162,9 @@ pub fn generateZirData(self: *Autodoc) !void {
162 .anyerror_type => .{162 .anyerror_type => .{
163 .ErrorSet = .{ .name = tmpbuf.toOwnedSlice() },163 .ErrorSet = .{ .name = tmpbuf.toOwnedSlice() },
164 },164 },
165 // .calling_convention_inline, .calling_convention_c, .calling_convention_type => .{
166 // .EnumLiteral = .{ .name = tmpbuf.toOwnedSlice() },
167 // },
165 },168 },
166 );169 );
167 }170 }
...@@ -515,7 +518,15 @@ const DocData = struct {...@@ -515,7 +518,15 @@ const DocData = struct {
515 .Int => |v| try printTypeBody(v, options, w),518 .Int => |v| try printTypeBody(v, options, w),
516 .Float => |v| try printTypeBody(v, options, w),519 .Float => |v| try printTypeBody(v, options, w),
517 .Type => |v| try printTypeBody(v, options, w),520 .Type => |v| try printTypeBody(v, options, w),
521 .NoReturn => |v| try printTypeBody(v, options, w),
518 .EnumLiteral => |v| try printTypeBody(v, options, w),522 .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 },
519 .Pointer => |v| {530 .Pointer => |v| {
520 if (options.whitespace) |ws| try ws.outputIndent(w);531 if (options.whitespace) |ws| try ws.outputIndent(w);
521 try w.print(532 try w.print(
...@@ -2767,12 +2778,16 @@ fn analyzeFunction(...@@ -2767,12 +2778,16 @@ fn analyzeFunction(
2767 const inst_data = data[inst_index].pl_node;2778 const inst_data = data[inst_index].pl_node;
2768 const extra = file.zir.extraData(Zir.Inst.ExtendedFunc, inst_data.payload_index);2779 const extra = file.zir.extraData(Zir.Inst.ExtendedFunc, inst_data.payload_index);
2769 var cc_index: ?usize = null;2780 var cc_index: ?usize = null;
2770 if (extra.data.bits.has_cc) {2781 cc_index = self.types.items.len - 1;
2771 // @panic with .calling_convention_inline2782 // if (extra.data.bits.has_cc) {
2772 // const cc_ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra.end]);2783 // const cc = file.zir.extra[extra.end];
2773 // _ = try self.walkRef(file, scope, cc_ref, false);2784 // const cc_ref = @intToEnum(Zir.Inst.Ref, cc);
2774 // cc_index = self.types.items.len - 1;2785 // _ = try self.walkRef(file, scope, cc_ref, false);
2775 }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
2777 break :blk .{2792 break :blk .{
2778 .Fn = .{2793 .Fn = .{
...@@ -2781,7 +2796,7 @@ fn analyzeFunction(...@@ -2781,7 +2796,7 @@ fn analyzeFunction(
2781 .params = param_type_refs.items,2796 .params = param_type_refs.items,
2782 .ret = ret_type_ref.expr,2797 .ret = ret_type_ref.expr,
2783 .is_extern = extra.data.bits.is_extern,2798 .is_extern = extra.data.bits.is_extern,
2784 // .has_cc = extra.data.bits.has_cc,2799 .has_cc = extra.data.bits.has_cc,
2785 .is_inferred_error = extra.data.bits.is_inferred_error,2800 .is_inferred_error = extra.data.bits.is_inferred_error,
2786 .cc = cc_index,2801 .cc = cc_index,
2787 },2802 },
...@@ -3015,24 +3030,27 @@ fn walkRef(...@@ -3015,24 +3030,27 @@ fn walkRef(
3015 };3030 };
3016 },3031 },
3017 // TODO: dunno what to do with those3032 // TODO: dunno what to do with those
3018 // .calling_convention_type => {3033 .calling_convention_type => {
3019 // return DocData.WalkResult{3034 return DocData.WalkResult{
3020 // .typeRef = .{ .type = @enumToInt(Ref.calling_convention_type) },3035 // .typeRef = .{ .type = @enumToInt(Ref.calling_convention_type) },
3021 // .expr = .{ .int = .{ .value = 1 } },3036 .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) },
3022 // };3037 .expr = .{ .int = .{ .value = 1 } },
3023 // },3038 };
3024 // .calling_convention_c => {3039 },
3025 // return DocData.WalkResult{3040 .calling_convention_c => {
3026 // .typeRef = .{ .type = @enumToInt(Ref.calling_convention_c) },3041 return DocData.WalkResult{
3027 // .expr = .{ .int = .{ .value = 1 } },3042 // .typeRef = .{ .type = @enumToInt(Ref.calling_convention_c) },
3028 // };3043 .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) },
3029 // },3044 .expr = .{ .int = .{ .value = 1 } },
3030 // .calling_convention_inline => {3045 };
3031 // return DocData.WalkResult{3046 },
3032 // .typeRef = .{ .type = @enumToInt(Ref.calling_convention_inline) },3047 .calling_convention_inline => {
3033 // .expr = .{ .int = .{ .value = 1 } },3048 return DocData.WalkResult{
3034 // };3049 // .typeRef = .{ .type = @enumToInt(Ref.calling_convention_inline) },
3035 // },3050 .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) },
3051 .expr = .{ .int = .{ .value = 1 } },
3052 };
3053 },
3036 // .generic_poison => {3054 // .generic_poison => {
3037 // return DocData.WalkResult{ .int = .{3055 // return DocData.WalkResult{ .int = .{
3038 // .type = @enumToInt(Ref.comptime_int_type),3056 // .type = @enumToInt(Ref.comptime_int_type),