| ... | @@ -561,6 +561,7 @@ const DocData = struct { | ... | @@ -561,6 +561,7 @@ const DocData = struct { |
| 561 | privDecls: []usize = &.{}, // index into decls | 561 | privDecls: []usize = &.{}, // index into decls |
| 562 | pubDecls: []usize = &.{}, // index into decls | 562 | pubDecls: []usize = &.{}, // index into decls |
| 563 | fields: ?[]Expr = null, // (use src->fields to find names) | 563 | fields: ?[]Expr = null, // (use src->fields to find names) |
| | 564 | is_tuple: bool, |
| 564 | line_number: usize, | 565 | line_number: usize, |
| 565 | outer_decl: usize, | 566 | outer_decl: usize, |
| 566 | }, | 567 | }, |
| ... | @@ -2942,6 +2943,7 @@ fn walkInstruction( | ... | @@ -2942,6 +2943,7 @@ fn walkInstruction( |
| 2942 | &field_type_refs, | 2943 | &field_type_refs, |
| 2943 | &field_name_indexes, | 2944 | &field_name_indexes, |
| 2944 | extra_index, | 2945 | extra_index, |
| | 2946 | small.is_tuple, |
| 2945 | ); | 2947 | ); |
| 2946 | | 2948 | |
| 2947 | self.ast_nodes.items[self_ast_node_index].fields = field_name_indexes.items; | 2949 | self.ast_nodes.items[self_ast_node_index].fields = field_name_indexes.items; |
| ... | @@ -2953,6 +2955,7 @@ fn walkInstruction( | ... | @@ -2953,6 +2955,7 @@ fn walkInstruction( |
| 2953 | .privDecls = priv_decl_indexes.items, | 2955 | .privDecls = priv_decl_indexes.items, |
| 2954 | .pubDecls = decl_indexes.items, | 2956 | .pubDecls = decl_indexes.items, |
| 2955 | .fields = field_type_refs.items, | 2957 | .fields = field_type_refs.items, |
| | 2958 | .is_tuple = small.is_tuple, |
| 2956 | .line_number = self.ast_nodes.items[self_ast_node_index].line, | 2959 | .line_number = self.ast_nodes.items[self_ast_node_index].line, |
| 2957 | .outer_decl = type_slot_index - 1, | 2960 | .outer_decl = type_slot_index - 1, |
| 2958 | }, | 2961 | }, |
| ... | @@ -4116,6 +4119,7 @@ fn collectStructFieldInfo( | ... | @@ -4116,6 +4119,7 @@ fn collectStructFieldInfo( |
| 4116 | field_type_refs: *std.ArrayListUnmanaged(DocData.Expr), | 4119 | field_type_refs: *std.ArrayListUnmanaged(DocData.Expr), |
| 4117 | field_name_indexes: *std.ArrayListUnmanaged(usize), | 4120 | field_name_indexes: *std.ArrayListUnmanaged(usize), |
| 4118 | ei: usize, | 4121 | ei: usize, |
| | 4122 | is_tuple: bool, |
| 4119 | ) !void { | 4123 | ) !void { |
| 4120 | if (fields_len == 0) return; | 4124 | if (fields_len == 0) return; |
| 4121 | var extra_index = ei; | 4125 | var extra_index = ei; |
| ... | @@ -4125,7 +4129,7 @@ fn collectStructFieldInfo( | ... | @@ -4125,7 +4129,7 @@ fn collectStructFieldInfo( |
| 4125 | const bit_bags_count = std.math.divCeil(usize, fields_len, fields_per_u32) catch unreachable; | 4129 | const bit_bags_count = std.math.divCeil(usize, fields_len, fields_per_u32) catch unreachable; |
| 4126 | | 4130 | |
| 4127 | const Field = struct { | 4131 | const Field = struct { |
| 4128 | field_name: u32, | 4132 | field_name: ?u32, |
| 4129 | doc_comment_index: u32, | 4133 | doc_comment_index: u32, |
| 4130 | type_body_len: u32 = 0, | 4134 | type_body_len: u32 = 0, |
| 4131 | align_body_len: u32 = 0, | 4135 | align_body_len: u32 = 0, |
| ... | @@ -4153,8 +4157,12 @@ fn collectStructFieldInfo( | ... | @@ -4153,8 +4157,12 @@ fn collectStructFieldInfo( |
| 4153 | const has_type_body = @truncate(u1, cur_bit_bag) != 0; | 4157 | const has_type_body = @truncate(u1, cur_bit_bag) != 0; |
| 4154 | cur_bit_bag >>= 1; | 4158 | cur_bit_bag >>= 1; |
| 4155 | | 4159 | |
| 4156 | const field_name = file.zir.extra[extra_index]; | 4160 | const field_name: ?u32 = if (!is_tuple) blk: { |
| 4157 | extra_index += 1; | 4161 | const fname = file.zir.extra[extra_index]; |
| | 4162 | extra_index += 1; |
| | 4163 | break :blk fname; |
| | 4164 | } else null; |
| | 4165 | |
| 4158 | const doc_comment_index = file.zir.extra[extra_index]; | 4166 | const doc_comment_index = file.zir.extra[extra_index]; |
| 4159 | extra_index += 1; | 4167 | extra_index += 1; |
| 4160 | | 4168 | |
| ... | @@ -4217,8 +4225,13 @@ fn collectStructFieldInfo( | ... | @@ -4217,8 +4225,13 @@ fn collectStructFieldInfo( |
| 4217 | file.zir.nullTerminatedString(field.doc_comment_index) | 4225 | file.zir.nullTerminatedString(field.doc_comment_index) |
| 4218 | else | 4226 | else |
| 4219 | null; | 4227 | null; |
| | 4228 | const field_name: []const u8 = if (field.field_name) |f_name| |
| | 4229 | file.zir.nullTerminatedString(f_name) |
| | 4230 | else |
| | 4231 | ""; |
| | 4232 | |
| 4220 | try self.ast_nodes.append(self.arena, .{ | 4233 | try self.ast_nodes.append(self.arena, .{ |
| 4221 | .name = file.zir.nullTerminatedString(field.field_name), | 4234 | .name = field_name, |
| 4222 | .docs = doc_comment, | 4235 | .docs = doc_comment, |
| 4223 | }); | 4236 | }); |
| 4224 | } | 4237 | } |