| ... | @@ -112,7 +112,7 @@ pub fn generateZirData(self: *Autodoc) !void { | ... | @@ -112,7 +112,7 @@ pub fn generateZirData(self: *Autodoc) !void { |
| 112 | .ComptimeExpr = .{ .name = "ComptimeExpr" }, | 112 | .ComptimeExpr = .{ .name = "ComptimeExpr" }, |
| 113 | }); | 113 | }); |
| 114 | | 114 | |
| 115 | // this skipts Ref.none but it's ok becuse we replaced it with ComptimeExpr | 115 | // this skips Ref.none but it's ok becuse we replaced it with ComptimeExpr |
| 116 | var i: u32 = 1; | 116 | var i: u32 = 1; |
| 117 | while (i <= @enumToInt(Ref.anyerror_void_error_union_type)) : (i += 1) { | 117 | while (i <= @enumToInt(Ref.anyerror_void_error_union_type)) : (i += 1) { |
| 118 | var tmpbuf = std.ArrayList(u8).init(self.arena); | 118 | var tmpbuf = std.ArrayList(u8).init(self.arena); |
| ... | @@ -196,8 +196,10 @@ pub fn generateZirData(self: *Autodoc) !void { | ... | @@ -196,8 +196,10 @@ pub fn generateZirData(self: *Autodoc) !void { |
| 196 | .anyerror_type => .{ | 196 | .anyerror_type => .{ |
| 197 | .ErrorSet = .{ .name = try tmpbuf.toOwnedSlice() }, | 197 | .ErrorSet = .{ .name = try tmpbuf.toOwnedSlice() }, |
| 198 | }, | 198 | }, |
| 199 | .calling_convention_inline, .calling_convention_c, .calling_convention_type => .{ | 199 | // should be an Enum but if we don't analyze std we don't get the ast node |
| 200 | .EnumLiteral = .{ .name = try tmpbuf.toOwnedSlice() }, | 200 | // since it's std.builtin.CallingConvention |
| | 201 | .calling_convention_type => .{ |
| | 202 | .Type = .{ .name = try tmpbuf.toOwnedSlice() }, |
| 201 | }, | 203 | }, |
| 202 | }, | 204 | }, |
| 203 | ); | 205 | ); |
| ... | @@ -4009,17 +4011,27 @@ fn analyzeFancyFunction( | ... | @@ -4009,17 +4011,27 @@ fn analyzeFancyFunction( |
| 4009 | } | 4011 | } |
| 4010 | | 4012 | |
| 4011 | var cc_index: ?usize = null; | 4013 | var cc_index: ?usize = null; |
| 4012 | if (extra.data.bits.has_cc_ref) { | 4014 | if (extra.data.bits.has_cc_ref and !extra.data.bits.has_cc_body) { |
| 4013 | const cc_ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); | 4015 | const cc_ref = @intToEnum(Zir.Inst.Ref, file.zir.extra[extra_index]); |
| | 4016 | const cc_expr = try self.walkRef(file, scope, parent_src, cc_ref, false); |
| | 4017 | |
| 4014 | cc_index = self.exprs.items.len; | 4018 | cc_index = self.exprs.items.len; |
| 4015 | _ = try self.walkRef(file, scope, parent_src, cc_ref, false); | 4019 | try self.exprs.append(self.arena, cc_expr.expr); |
| | 4020 | |
| 4016 | extra_index += 1; | 4021 | extra_index += 1; |
| 4017 | } else if (extra.data.bits.has_cc_body) { | 4022 | } else if (extra.data.bits.has_cc_body) { |
| 4018 | const cc_body_len = file.zir.extra[extra_index]; | 4023 | const cc_body_len = file.zir.extra[extra_index]; |
| 4019 | extra_index += 1; | 4024 | extra_index += 1; |
| 4020 | const cc_body = file.zir.extra[extra_index .. extra_index + cc_body_len]; | 4025 | const cc_body = file.zir.extra[extra_index..][0..cc_body_len]; |
| 4021 | _ = cc_body; | 4026 | |
| 4022 | // TODO: analyze the block (or bail with a comptimeExpr) | 4027 | // We assume the body ends with a break_inline |
| | 4028 | const break_index = cc_body[cc_body.len - 1]; |
| | 4029 | const break_operand = data[break_index].@"break".operand; |
| | 4030 | const cc_expr = try self.walkRef(file, scope, parent_src, break_operand, false); |
| | 4031 | |
| | 4032 | cc_index = self.exprs.items.len; |
| | 4033 | try self.exprs.append(self.arena, cc_expr.expr); |
| | 4034 | |
| 4023 | extra_index += cc_body_len; | 4035 | extra_index += cc_body_len; |
| 4024 | } else { | 4036 | } else { |
| 4025 | // auto calling convention | 4037 | // auto calling convention |
| ... | @@ -4564,26 +4576,22 @@ fn walkRef( | ... | @@ -4564,26 +4576,22 @@ fn walkRef( |
| 4564 | .expr = .{ .int = .{ .value = 1 } }, | 4576 | .expr = .{ .int = .{ .value = 1 } }, |
| 4565 | }; | 4577 | }; |
| 4566 | }, | 4578 | }, |
| 4567 | // TODO: dunno what to do with those | | |
| 4568 | .calling_convention_type => { | 4579 | .calling_convention_type => { |
| 4569 | return DocData.WalkResult{ | 4580 | return DocData.WalkResult{ |
| 4570 | .typeRef = .{ .type = @enumToInt(Ref.calling_convention_type) }, | 4581 | .typeRef = .{ .type = @enumToInt(Ref.type_type) }, |
| 4571 | // .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) }, | 4582 | .expr = .{ .type = @enumToInt(Ref.calling_convention_type) }, |
| 4572 | .expr = .{ .int = .{ .value = 1 } }, | | |
| 4573 | }; | 4583 | }; |
| 4574 | }, | 4584 | }, |
| 4575 | .calling_convention_c => { | 4585 | .calling_convention_c => { |
| 4576 | return DocData.WalkResult{ | 4586 | return DocData.WalkResult{ |
| 4577 | .typeRef = .{ .type = @enumToInt(Ref.calling_convention_c) }, | 4587 | .typeRef = .{ .type = @enumToInt(Ref.calling_convention_type) }, |
| 4578 | // .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) }, | 4588 | .expr = .{ .enumLiteral = "C" }, |
| 4579 | .expr = .{ .int = .{ .value = 1 } }, | | |
| 4580 | }; | 4589 | }; |
| 4581 | }, | 4590 | }, |
| 4582 | .calling_convention_inline => { | 4591 | .calling_convention_inline => { |
| 4583 | return DocData.WalkResult{ | 4592 | return DocData.WalkResult{ |
| 4584 | .typeRef = .{ .type = @enumToInt(Ref.calling_convention_inline) }, | 4593 | .typeRef = .{ .type = @enumToInt(Ref.calling_convention_type) }, |
| 4585 | // .typeRef = .{ .type = @enumToInt(Ref.comptime_int_type) }, | 4594 | .expr = .{ .enumLiteral = "Inline" }, |
| 4586 | .expr = .{ .int = .{ .value = 1 } }, | | |
| 4587 | }; | 4595 | }; |
| 4588 | }, | 4596 | }, |
| 4589 | // .generic_poison => { | 4597 | // .generic_poison => { |