authorgravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2023-03-05 17:00:09+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-06 18:18:52-05:00
log70cbe5ac7c96c107985e0246dacefe04ea283761
treed214f28ec1c410428e29f700cc501d3821af86dc
parentccf00ccdf71fae7ecd25d9b1bf11dc7eb52d5d1d

AstGen: remove unnecessary `pub`s

I think it helps when you know that something is entirely self-contained, which AstGen is. The only function public is `generate`.

1 files changed, 22 insertions(+), 22 deletions(-)

src/AstGen.zig+22-22
...@@ -205,7 +205,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {...@@ -205,7 +205,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {
205 };205 };
206}206}
207207
208pub fn deinit(astgen: *AstGen, gpa: Allocator) void {208fn deinit(astgen: *AstGen, gpa: Allocator) void {
209 astgen.instructions.deinit(gpa);209 astgen.instructions.deinit(gpa);
210 astgen.extra.deinit(gpa);210 astgen.extra.deinit(gpa);
211 astgen.string_table.deinit(gpa);211 astgen.string_table.deinit(gpa);
...@@ -216,7 +216,7 @@ pub fn deinit(astgen: *AstGen, gpa: Allocator) void {...@@ -216,7 +216,7 @@ pub fn deinit(astgen: *AstGen, gpa: Allocator) void {
216 astgen.ref_table.deinit(gpa);216 astgen.ref_table.deinit(gpa);
217}217}
218218
219pub const ResultInfo = struct {219const ResultInfo = struct {
220 /// The semantics requested for the result location220 /// The semantics requested for the result location
221 rl: Loc,221 rl: Loc,
222222
...@@ -245,7 +245,7 @@ pub const ResultInfo = struct {...@@ -245,7 +245,7 @@ pub const ResultInfo = struct {
245 }245 }
246 }246 }
247247
248 pub const Loc = union(enum) {248 const Loc = union(enum) {
249 /// The expression is the right-hand side of assignment to `_`. Only the side-effects of the249 /// The expression is the right-hand side of assignment to `_`. Only the side-effects of the
250 /// expression should be generated. The result instruction from the expression must250 /// expression should be generated. The result instruction from the expression must
251 /// be ignored.251 /// be ignored.
...@@ -277,11 +277,11 @@ pub const ResultInfo = struct {...@@ -277,11 +277,11 @@ pub const ResultInfo = struct {
277 src_node: ?Ast.Node.Index = null,277 src_node: ?Ast.Node.Index = null,
278 };278 };
279279
280 pub const Strategy = struct {280 const Strategy = struct {
281 elide_store_to_block_ptr_instructions: bool,281 elide_store_to_block_ptr_instructions: bool,
282 tag: Tag,282 tag: Tag,
283283
284 pub const Tag = enum {284 const Tag = enum {
285 /// Both branches will use break_void; result location is used to communicate the285 /// Both branches will use break_void; result location is used to communicate the
286 /// result instruction.286 /// result instruction.
287 break_void,287 break_void,
...@@ -331,7 +331,7 @@ pub const ResultInfo = struct {...@@ -331,7 +331,7 @@ pub const ResultInfo = struct {
331 }331 }
332 };332 };
333333
334 pub const Context = enum {334 const Context = enum {
335 /// The expression is the operand to a return expression.335 /// The expression is the operand to a return expression.
336 @"return",336 @"return",
337 /// The expression is the input to an error-handling operator (if-else, try, or catch).337 /// The expression is the input to an error-handling operator (if-else, try, or catch).
...@@ -349,11 +349,11 @@ pub const ResultInfo = struct {...@@ -349,11 +349,11 @@ pub const ResultInfo = struct {
349 };349 };
350};350};
351351
352pub const align_ri: ResultInfo = .{ .rl = .{ .ty = .u29_type } };352const align_ri: ResultInfo = .{ .rl = .{ .ty = .u29_type } };
353pub const coerced_align_ri: ResultInfo = .{ .rl = .{ .coerced_ty = .u29_type } };353const coerced_align_ri: ResultInfo = .{ .rl = .{ .coerced_ty = .u29_type } };
354pub const bool_ri: ResultInfo = .{ .rl = .{ .ty = .bool_type } };354const bool_ri: ResultInfo = .{ .rl = .{ .ty = .bool_type } };
355pub const type_ri: ResultInfo = .{ .rl = .{ .ty = .type_type } };355const type_ri: ResultInfo = .{ .rl = .{ .ty = .type_type } };
356pub const coerced_type_ri: ResultInfo = .{ .rl = .{ .coerced_ty = .type_type } };356const coerced_type_ri: ResultInfo = .{ .rl = .{ .coerced_ty = .type_type } };
357357
358fn typeExpr(gz: *GenZir, scope: *Scope, type_node: Ast.Node.Index) InnerError!Zir.Inst.Ref {358fn typeExpr(gz: *GenZir, scope: *Scope, type_node: Ast.Node.Index) InnerError!Zir.Inst.Ref {
359 const prev_force_comptime = gz.force_comptime;359 const prev_force_comptime = gz.force_comptime;
...@@ -3507,7 +3507,7 @@ const WipMembers = struct {...@@ -3507,7 +3507,7 @@ const WipMembers = struct {
3507 /// (4 for src_hash + line + name + value + doc_comment + align + link_section + address_space )3507 /// (4 for src_hash + line + name + value + doc_comment + align + link_section + address_space )
3508 const max_decl_size = 11;3508 const max_decl_size = 11;
35093509
3510 pub fn init(gpa: Allocator, payload: *ArrayListUnmanaged(u32), decl_count: u32, field_count: u32, comptime bits_per_field: u32, comptime max_field_size: u32) Allocator.Error!Self {3510 fn init(gpa: Allocator, payload: *ArrayListUnmanaged(u32), decl_count: u32, field_count: u32, comptime bits_per_field: u32, comptime max_field_size: u32) Allocator.Error!Self {
3511 const payload_top = @intCast(u32, payload.items.len);3511 const payload_top = @intCast(u32, payload.items.len);
3512 const decls_start = payload_top + (decl_count + decls_per_u32 - 1) / decls_per_u32;3512 const decls_start = payload_top + (decl_count + decls_per_u32 - 1) / decls_per_u32;
3513 const field_bits_start = decls_start + decl_count * max_decl_size;3513 const field_bits_start = decls_start + decl_count * max_decl_size;
...@@ -3528,7 +3528,7 @@ const WipMembers = struct {...@@ -3528,7 +3528,7 @@ const WipMembers = struct {
3528 };3528 };
3529 }3529 }
35303530
3531 pub fn nextDecl(self: *Self, is_pub: bool, is_export: bool, has_align: bool, has_section_or_addrspace: bool) void {3531 fn nextDecl(self: *Self, is_pub: bool, is_export: bool, has_align: bool, has_section_or_addrspace: bool) void {
3532 const index = self.payload_top + self.decl_index / decls_per_u32;3532 const index = self.payload_top + self.decl_index / decls_per_u32;
3533 assert(index < self.decls_start);3533 assert(index < self.decls_start);
3534 const bit_bag: u32 = if (self.decl_index % decls_per_u32 == 0) 0 else self.payload.items[index];3534 const bit_bag: u32 = if (self.decl_index % decls_per_u32 == 0) 0 else self.payload.items[index];
...@@ -3540,7 +3540,7 @@ const WipMembers = struct {...@@ -3540,7 +3540,7 @@ const WipMembers = struct {
3540 self.decl_index += 1;3540 self.decl_index += 1;
3541 }3541 }
35423542
3543 pub fn nextField(self: *Self, comptime bits_per_field: u32, bits: [bits_per_field]bool) void {3543 fn nextField(self: *Self, comptime bits_per_field: u32, bits: [bits_per_field]bool) void {
3544 const fields_per_u32 = 32 / bits_per_field;3544 const fields_per_u32 = 32 / bits_per_field;
3545 const index = self.field_bits_start + self.field_index / fields_per_u32;3545 const index = self.field_bits_start + self.field_index / fields_per_u32;
3546 assert(index < self.fields_start);3546 assert(index < self.fields_start);
...@@ -3554,25 +3554,25 @@ const WipMembers = struct {...@@ -3554,25 +3554,25 @@ const WipMembers = struct {
3554 self.field_index += 1;3554 self.field_index += 1;
3555 }3555 }
35563556
3557 pub fn appendToDecl(self: *Self, data: u32) void {3557 fn appendToDecl(self: *Self, data: u32) void {
3558 assert(self.decls_end < self.field_bits_start);3558 assert(self.decls_end < self.field_bits_start);
3559 self.payload.items[self.decls_end] = data;3559 self.payload.items[self.decls_end] = data;
3560 self.decls_end += 1;3560 self.decls_end += 1;
3561 }3561 }
35623562
3563 pub fn appendToDeclSlice(self: *Self, data: []const u32) void {3563 fn appendToDeclSlice(self: *Self, data: []const u32) void {
3564 assert(self.decls_end + data.len <= self.field_bits_start);3564 assert(self.decls_end + data.len <= self.field_bits_start);
3565 mem.copy(u32, self.payload.items[self.decls_end..], data);3565 mem.copy(u32, self.payload.items[self.decls_end..], data);
3566 self.decls_end += @intCast(u32, data.len);3566 self.decls_end += @intCast(u32, data.len);
3567 }3567 }
35683568
3569 pub fn appendToField(self: *Self, data: u32) void {3569 fn appendToField(self: *Self, data: u32) void {
3570 assert(self.fields_end < self.payload.items.len);3570 assert(self.fields_end < self.payload.items.len);
3571 self.payload.items[self.fields_end] = data;3571 self.payload.items[self.fields_end] = data;
3572 self.fields_end += 1;3572 self.fields_end += 1;
3573 }3573 }
35743574
3575 pub fn finishBits(self: *Self, comptime bits_per_field: u32) void {3575 fn finishBits(self: *Self, comptime bits_per_field: u32) void {
3576 const empty_decl_slots = decls_per_u32 - (self.decl_index % decls_per_u32);3576 const empty_decl_slots = decls_per_u32 - (self.decl_index % decls_per_u32);
3577 if (self.decl_index > 0 and empty_decl_slots < decls_per_u32) {3577 if (self.decl_index > 0 and empty_decl_slots < decls_per_u32) {
3578 const index = self.payload_top + self.decl_index / decls_per_u32;3578 const index = self.payload_top + self.decl_index / decls_per_u32;
...@@ -3588,15 +3588,15 @@ const WipMembers = struct {...@@ -3588,15 +3588,15 @@ const WipMembers = struct {
3588 }3588 }
3589 }3589 }
35903590
3591 pub fn declsSlice(self: *Self) []u32 {3591 fn declsSlice(self: *Self) []u32 {
3592 return self.payload.items[self.payload_top..self.decls_end];3592 return self.payload.items[self.payload_top..self.decls_end];
3593 }3593 }
35943594
3595 pub fn fieldsSlice(self: *Self) []u32 {3595 fn fieldsSlice(self: *Self) []u32 {
3596 return self.payload.items[self.field_bits_start..self.fields_end];3596 return self.payload.items[self.field_bits_start..self.fields_end];
3597 }3597 }
35983598
3599 pub fn deinit(self: *Self) void {3599 fn deinit(self: *Self) void {
3600 self.payload.items.len = self.payload_top;3600 self.payload.items.len = self.payload_top;
3601 }3601 }
3602};3602};
...@@ -10803,7 +10803,7 @@ const Scope = struct {...@@ -10803,7 +10803,7 @@ const Scope = struct {
10803 /// ref of the capture for decls in this namespace10803 /// ref of the capture for decls in this namespace
10804 captures: std.AutoArrayHashMapUnmanaged(Zir.Inst.Index, Zir.Inst.Index) = .{},10804 captures: std.AutoArrayHashMapUnmanaged(Zir.Inst.Index, Zir.Inst.Index) = .{},
1080510805
10806 pub fn deinit(self: *Namespace, gpa: Allocator) void {10806 fn deinit(self: *Namespace, gpa: Allocator) void {
10807 self.decls.deinit(gpa);10807 self.decls.deinit(gpa);
10808 self.captures.deinit(gpa);10808 self.captures.deinit(gpa);
10809 self.* = undefined;10809 self.* = undefined;