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 {
205205 };
206206}
207207
208pub fn deinit(astgen: *AstGen, gpa: Allocator) void {
208fn deinit(astgen: *AstGen, gpa: Allocator) void {
209209 astgen.instructions.deinit(gpa);
210210 astgen.extra.deinit(gpa);
211211 astgen.string_table.deinit(gpa);
......@@ -216,7 +216,7 @@ pub fn deinit(astgen: *AstGen, gpa: Allocator) void {
216216 astgen.ref_table.deinit(gpa);
217217}
218218
219pub const ResultInfo = struct {
219const ResultInfo = struct {
220220 /// The semantics requested for the result location
221221 rl: Loc,
222222
......@@ -245,7 +245,7 @@ pub const ResultInfo = struct {
245245 }
246246 }
247247
248 pub const Loc = union(enum) {
248 const Loc = union(enum) {
249249 /// The expression is the right-hand side of assignment to `_`. Only the side-effects of the
250250 /// expression should be generated. The result instruction from the expression must
251251 /// be ignored.
......@@ -277,11 +277,11 @@ pub const ResultInfo = struct {
277277 src_node: ?Ast.Node.Index = null,
278278 };
279279
280 pub const Strategy = struct {
280 const Strategy = struct {
281281 elide_store_to_block_ptr_instructions: bool,
282282 tag: Tag,
283283
284 pub const Tag = enum {
284 const Tag = enum {
285285 /// Both branches will use break_void; result location is used to communicate the
286286 /// result instruction.
287287 break_void,
......@@ -331,7 +331,7 @@ pub const ResultInfo = struct {
331331 }
332332 };
333333
334 pub const Context = enum {
334 const Context = enum {
335335 /// The expression is the operand to a return expression.
336336 @"return",
337337 /// The expression is the input to an error-handling operator (if-else, try, or catch).
......@@ -349,11 +349,11 @@ pub const ResultInfo = struct {
349349 };
350350};
351351
352pub const align_ri: ResultInfo = .{ .rl = .{ .ty = .u29_type } };
353pub const coerced_align_ri: ResultInfo = .{ .rl = .{ .coerced_ty = .u29_type } };
354pub const bool_ri: ResultInfo = .{ .rl = .{ .ty = .bool_type } };
355pub const type_ri: ResultInfo = .{ .rl = .{ .ty = .type_type } };
356pub const coerced_type_ri: ResultInfo = .{ .rl = .{ .coerced_ty = .type_type } };
352const align_ri: ResultInfo = .{ .rl = .{ .ty = .u29_type } };
353const coerced_align_ri: ResultInfo = .{ .rl = .{ .coerced_ty = .u29_type } };
354const bool_ri: ResultInfo = .{ .rl = .{ .ty = .bool_type } };
355const type_ri: ResultInfo = .{ .rl = .{ .ty = .type_type } };
356const coerced_type_ri: ResultInfo = .{ .rl = .{ .coerced_ty = .type_type } };
357357
358358fn typeExpr(gz: *GenZir, scope: *Scope, type_node: Ast.Node.Index) InnerError!Zir.Inst.Ref {
359359 const prev_force_comptime = gz.force_comptime;
......@@ -3507,7 +3507,7 @@ const WipMembers = struct {
35073507 /// (4 for src_hash + line + name + value + doc_comment + align + link_section + address_space )
35083508 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 {
35113511 const payload_top = @intCast(u32, payload.items.len);
35123512 const decls_start = payload_top + (decl_count + decls_per_u32 - 1) / decls_per_u32;
35133513 const field_bits_start = decls_start + decl_count * max_decl_size;
......@@ -3528,7 +3528,7 @@ const WipMembers = struct {
35283528 };
35293529 }
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 {
35323532 const index = self.payload_top + self.decl_index / decls_per_u32;
35333533 assert(index < self.decls_start);
35343534 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 {
35403540 self.decl_index += 1;
35413541 }
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 {
35443544 const fields_per_u32 = 32 / bits_per_field;
35453545 const index = self.field_bits_start + self.field_index / fields_per_u32;
35463546 assert(index < self.fields_start);
......@@ -3554,25 +3554,25 @@ const WipMembers = struct {
35543554 self.field_index += 1;
35553555 }
35563556
3557 pub fn appendToDecl(self: *Self, data: u32) void {
3557 fn appendToDecl(self: *Self, data: u32) void {
35583558 assert(self.decls_end < self.field_bits_start);
35593559 self.payload.items[self.decls_end] = data;
35603560 self.decls_end += 1;
35613561 }
35623562
3563 pub fn appendToDeclSlice(self: *Self, data: []const u32) void {
3563 fn appendToDeclSlice(self: *Self, data: []const u32) void {
35643564 assert(self.decls_end + data.len <= self.field_bits_start);
35653565 mem.copy(u32, self.payload.items[self.decls_end..], data);
35663566 self.decls_end += @intCast(u32, data.len);
35673567 }
35683568
3569 pub fn appendToField(self: *Self, data: u32) void {
3569 fn appendToField(self: *Self, data: u32) void {
35703570 assert(self.fields_end < self.payload.items.len);
35713571 self.payload.items[self.fields_end] = data;
35723572 self.fields_end += 1;
35733573 }
35743574
3575 pub fn finishBits(self: *Self, comptime bits_per_field: u32) void {
3575 fn finishBits(self: *Self, comptime bits_per_field: u32) void {
35763576 const empty_decl_slots = decls_per_u32 - (self.decl_index % decls_per_u32);
35773577 if (self.decl_index > 0 and empty_decl_slots < decls_per_u32) {
35783578 const index = self.payload_top + self.decl_index / decls_per_u32;
......@@ -3588,15 +3588,15 @@ const WipMembers = struct {
35883588 }
35893589 }
35903590
3591 pub fn declsSlice(self: *Self) []u32 {
3591 fn declsSlice(self: *Self) []u32 {
35923592 return self.payload.items[self.payload_top..self.decls_end];
35933593 }
35943594
3595 pub fn fieldsSlice(self: *Self) []u32 {
3595 fn fieldsSlice(self: *Self) []u32 {
35963596 return self.payload.items[self.field_bits_start..self.fields_end];
35973597 }
35983598
3599 pub fn deinit(self: *Self) void {
3599 fn deinit(self: *Self) void {
36003600 self.payload.items.len = self.payload_top;
36013601 }
36023602};
......@@ -10803,7 +10803,7 @@ const Scope = struct {
1080310803 /// ref of the capture for decls in this namespace
1080410804 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 {
1080710807 self.decls.deinit(gpa);
1080810808 self.captures.deinit(gpa);
1080910809 self.* = undefined;