| ... | @@ -6457,13 +6457,28 @@ fn getTagNameFunction(func: *CodeGen, enum_ty: Type) InnerError!u32 { | ... | @@ -6457,13 +6457,28 @@ fn getTagNameFunction(func: *CodeGen, enum_ty: Type) InnerError!u32 { |
| 6457 | // for each tag name, create an unnamed const, | 6457 | // for each tag name, create an unnamed const, |
| 6458 | // and then get a pointer to its value. | 6458 | // and then get a pointer to its value. |
| 6459 | var name_ty_payload: Type.Payload.Len = .{ | 6459 | var name_ty_payload: Type.Payload.Len = .{ |
| 6460 | .base = .{ .tag = .array_u8 }, | 6460 | .base = .{ .tag = .array_u8_sentinel_0 }, |
| 6461 | .data = @intCast(u64, tag_name.len), | 6461 | .data = @intCast(u64, tag_name.len), |
| 6462 | }; | 6462 | }; |
| 6463 | const name_ty = Type.initPayload(&name_ty_payload.base); | 6463 | const name_ty = Type.initPayload(&name_ty_payload.base); |
| 6464 | var name_val_payload: Value.Payload.Bytes = .{ | 6464 | const string_bytes = &module.string_literal_bytes; |
| 6465 | .base = .{ .tag = .bytes }, | 6465 | try string_bytes.ensureUnusedCapacity(module.gpa, tag_name.len); |
| 6466 | .data = tag_name, | 6466 | const gop = try module.string_literal_table.getOrPutContextAdapted(module.gpa, tag_name, Module.StringLiteralAdapter{ |
| | 6467 | .bytes = string_bytes, |
| | 6468 | }, Module.StringLiteralContext{ |
| | 6469 | .bytes = string_bytes, |
| | 6470 | }); |
| | 6471 | if (!gop.found_existing) { |
| | 6472 | gop.key_ptr.* = .{ |
| | 6473 | .index = @intCast(u32, string_bytes.items.len), |
| | 6474 | .len = @intCast(u32, tag_name.len), |
| | 6475 | }; |
| | 6476 | string_bytes.appendSliceAssumeCapacity(tag_name); |
| | 6477 | gop.value_ptr.* = .none; |
| | 6478 | } |
| | 6479 | var name_val_payload: Value.Payload.StrLit = .{ |
| | 6480 | .base = .{ .tag = .str_lit }, |
| | 6481 | .data = gop.key_ptr.*, |
| 6467 | }; | 6482 | }; |
| 6468 | const name_val = Value.initPayload(&name_val_payload.base); | 6483 | const name_val = Value.initPayload(&name_val_payload.base); |
| 6469 | const tag_sym_index = try func.bin_file.lowerUnnamedConst( | 6484 | const tag_sym_index = try func.bin_file.lowerUnnamedConst( |