| ... | ... | @@ -2643,7 +2643,14 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2643 | 2643 | try uleb128(diw, nav_val.toType().abiAlignment(zcu).toByteUnits().?); |
| 2644 | 2644 | for (0..loaded_struct.field_types.len) |field_index| { |
| 2645 | 2645 | const is_comptime = loaded_struct.fieldIsComptime(ip, field_index); |
| 2646 | | try wip_nav.abbrevCode(if (is_comptime) .struct_field_comptime else .struct_field); |
| 2646 | const field_init = loaded_struct.fieldInit(ip, field_index); |
| 2647 | assert(!(is_comptime and field_init == .none)); |
| 2648 | try wip_nav.abbrevCode(if (is_comptime) |
| 2649 | .struct_field_comptime |
| 2650 | else if (field_init != .none) |
| 2651 | .struct_field_default |
| 2652 | else |
| 2653 | .struct_field); |
| 2647 | 2654 | if (loaded_struct.fieldName(ip, field_index).unwrap()) |field_name| try wip_nav.strp(field_name.toSlice(ip)) else { |
| 2648 | 2655 | const field_name = try std.fmt.allocPrint(dwarf.gpa, "{d}", .{field_index}); |
| 2649 | 2656 | defer dwarf.gpa.free(field_name); |
| ... | ... | @@ -2651,14 +2658,12 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2651 | 2658 | } |
| 2652 | 2659 | const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]); |
| 2653 | 2660 | try wip_nav.refType(field_type); |
| 2654 | | if (is_comptime) try wip_nav.blockValue( |
| 2655 | | nav_src_loc, |
| 2656 | | Value.fromInterned(loaded_struct.fieldInit(ip, field_index)), |
| 2657 | | ) else { |
| 2661 | if (!is_comptime) { |
| 2658 | 2662 | try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]); |
| 2659 | 2663 | try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse |
| 2660 | 2664 | field_type.abiAlignment(zcu).toByteUnits().?); |
| 2661 | 2665 | } |
| 2666 | if (field_init != .none) try wip_nav.blockValue(nav_src_loc, Value.fromInterned(field_init)); |
| 2662 | 2667 | } |
| 2663 | 2668 | try uleb128(diw, @intFromEnum(AbbrevCode.null)); |
| 2664 | 2669 | } |
| ... | ... | @@ -3498,7 +3503,14 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3498 | 3503 | try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?); |
| 3499 | 3504 | for (0..loaded_struct.field_types.len) |field_index| { |
| 3500 | 3505 | const is_comptime = loaded_struct.fieldIsComptime(ip, field_index); |
| 3501 | | try wip_nav.abbrevCode(if (is_comptime) .struct_field_comptime else .struct_field); |
| 3506 | const field_init = loaded_struct.fieldInit(ip, field_index); |
| 3507 | assert(!(is_comptime and field_init == .none)); |
| 3508 | try wip_nav.abbrevCode(if (is_comptime) |
| 3509 | .struct_field_comptime |
| 3510 | else if (field_init != .none) |
| 3511 | .struct_field_default |
| 3512 | else |
| 3513 | .struct_field); |
| 3502 | 3514 | if (loaded_struct.fieldName(ip, field_index).unwrap()) |field_name| try wip_nav.strp(field_name.toSlice(ip)) else { |
| 3503 | 3515 | const field_name = try std.fmt.allocPrint(dwarf.gpa, "{d}", .{field_index}); |
| 3504 | 3516 | defer dwarf.gpa.free(field_name); |
| ... | ... | @@ -3506,14 +3518,12 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3506 | 3518 | } |
| 3507 | 3519 | const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]); |
| 3508 | 3520 | try wip_nav.refType(field_type); |
| 3509 | | if (is_comptime) try wip_nav.blockValue( |
| 3510 | | ty_src_loc, |
| 3511 | | Value.fromInterned(loaded_struct.fieldInit(ip, field_index)), |
| 3512 | | ) else { |
| 3521 | if (!is_comptime) { |
| 3513 | 3522 | try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]); |
| 3514 | 3523 | try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse |
| 3515 | 3524 | field_type.abiAlignment(zcu).toByteUnits().?); |
| 3516 | 3525 | } |
| 3526 | if (field_init != .none) try wip_nav.blockValue(ty_src_loc, Value.fromInterned(field_init)); |
| 3517 | 3527 | } |
| 3518 | 3528 | try uleb128(diw, @intFromEnum(AbbrevCode.null)); |
| 3519 | 3529 | } |
| ... | ... | @@ -3569,7 +3579,14 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3569 | 3579 | try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?); |
| 3570 | 3580 | for (0..loaded_struct.field_types.len) |field_index| { |
| 3571 | 3581 | const is_comptime = loaded_struct.fieldIsComptime(ip, field_index); |
| 3572 | | try wip_nav.abbrevCode(if (is_comptime) .struct_field_comptime else .struct_field); |
| 3582 | const field_init = loaded_struct.fieldInit(ip, field_index); |
| 3583 | assert(!(is_comptime and field_init == .none)); |
| 3584 | try wip_nav.abbrevCode(if (is_comptime) |
| 3585 | .struct_field_comptime |
| 3586 | else if (field_init != .none) |
| 3587 | .struct_field_default |
| 3588 | else |
| 3589 | .struct_field); |
| 3573 | 3590 | if (loaded_struct.fieldName(ip, field_index).unwrap()) |field_name| try wip_nav.strp(field_name.toSlice(ip)) else { |
| 3574 | 3591 | const field_name = try std.fmt.allocPrint(dwarf.gpa, "{d}", .{field_index}); |
| 3575 | 3592 | defer dwarf.gpa.free(field_name); |
| ... | ... | @@ -3577,14 +3594,12 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3577 | 3594 | } |
| 3578 | 3595 | const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]); |
| 3579 | 3596 | try wip_nav.refType(field_type); |
| 3580 | | if (is_comptime) try wip_nav.blockValue( |
| 3581 | | ty_src_loc, |
| 3582 | | Value.fromInterned(loaded_struct.fieldInit(ip, field_index)), |
| 3583 | | ) else { |
| 3597 | if (!is_comptime) { |
| 3584 | 3598 | try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]); |
| 3585 | 3599 | try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse |
| 3586 | 3600 | field_type.abiAlignment(zcu).toByteUnits().?); |
| 3587 | 3601 | } |
| 3602 | if (field_init != .none) try wip_nav.blockValue(ty_src_loc, Value.fromInterned(field_init)); |
| 3588 | 3603 | } |
| 3589 | 3604 | try uleb128(diw, @intFromEnum(AbbrevCode.null)); |
| 3590 | 3605 | } |
| ... | ... | @@ -4165,6 +4180,7 @@ const AbbrevCode = enum { |
| 4165 | 4180 | big_enum_field, |
| 4166 | 4181 | generated_field, |
| 4167 | 4182 | struct_field, |
| 4183 | struct_field_default, |
| 4168 | 4184 | struct_field_comptime, |
| 4169 | 4185 | packed_struct_field, |
| 4170 | 4186 | untagged_union_field, |
| ... | ... | @@ -4412,13 +4428,23 @@ const AbbrevCode = enum { |
| 4412 | 4428 | .{ .alignment, .udata }, |
| 4413 | 4429 | }, |
| 4414 | 4430 | }, |
| 4431 | .struct_field_default = .{ |
| 4432 | .tag = .member, |
| 4433 | .attrs = &.{ |
| 4434 | .{ .name, .strp }, |
| 4435 | .{ .type, .ref_addr }, |
| 4436 | .{ .data_member_location, .udata }, |
| 4437 | .{ .alignment, .udata }, |
| 4438 | .{ .default_value, .block }, |
| 4439 | }, |
| 4440 | }, |
| 4415 | 4441 | .struct_field_comptime = .{ |
| 4416 | 4442 | .tag = .member, |
| 4417 | 4443 | .attrs = &.{ |
| 4418 | 4444 | .{ .const_expr, .flag_present }, |
| 4419 | 4445 | .{ .name, .strp }, |
| 4420 | 4446 | .{ .type, .ref_addr }, |
| 4421 | | .{ .default_value, .block }, |
| 4447 | .{ .const_value, .block }, |
| 4422 | 4448 | }, |
| 4423 | 4449 | }, |
| 4424 | 4450 | .packed_struct_field = .{ |