| ... | @@ -2643,7 +2643,14 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool | ... | @@ -2643,7 +2643,14 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2643 | try uleb128(diw, nav_val.toType().abiAlignment(zcu).toByteUnits().?); | 2643 | try uleb128(diw, nav_val.toType().abiAlignment(zcu).toByteUnits().?); |
| 2644 | for (0..loaded_struct.field_types.len) |field_index| { | 2644 | for (0..loaded_struct.field_types.len) |field_index| { |
| 2645 | const is_comptime = loaded_struct.fieldIsComptime(ip, field_index); | 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 | if (loaded_struct.fieldName(ip, field_index).unwrap()) |field_name| try wip_nav.strp(field_name.toSlice(ip)) else { | 2654 | if (loaded_struct.fieldName(ip, field_index).unwrap()) |field_name| try wip_nav.strp(field_name.toSlice(ip)) else { |
| 2648 | const field_name = try std.fmt.allocPrint(dwarf.gpa, "{d}", .{field_index}); | 2655 | const field_name = try std.fmt.allocPrint(dwarf.gpa, "{d}", .{field_index}); |
| 2649 | defer dwarf.gpa.free(field_name); | 2656 | defer dwarf.gpa.free(field_name); |
| ... | @@ -2651,14 +2658,12 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool | ... | @@ -2651,14 +2658,12 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool |
| 2651 | } | 2658 | } |
| 2652 | const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]); | 2659 | const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]); |
| 2653 | try wip_nav.refType(field_type); | 2660 | try wip_nav.refType(field_type); |
| 2654 | if (is_comptime) try wip_nav.blockValue( | 2661 | if (!is_comptime) { |
| 2655 | nav_src_loc, | | |
| 2656 | Value.fromInterned(loaded_struct.fieldInit(ip, field_index)), | | |
| 2657 | ) else { | | |
| 2658 | try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]); | 2662 | try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]); |
| 2659 | try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse | 2663 | try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse |
| 2660 | field_type.abiAlignment(zcu).toByteUnits().?); | 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 | try uleb128(diw, @intFromEnum(AbbrevCode.null)); | 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,7 +3503,14 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3498 | try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?); | 3503 | try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?); |
| 3499 | for (0..loaded_struct.field_types.len) |field_index| { | 3504 | for (0..loaded_struct.field_types.len) |field_index| { |
| 3500 | const is_comptime = loaded_struct.fieldIsComptime(ip, field_index); | 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 | if (loaded_struct.fieldName(ip, field_index).unwrap()) |field_name| try wip_nav.strp(field_name.toSlice(ip)) else { | 3514 | if (loaded_struct.fieldName(ip, field_index).unwrap()) |field_name| try wip_nav.strp(field_name.toSlice(ip)) else { |
| 3503 | const field_name = try std.fmt.allocPrint(dwarf.gpa, "{d}", .{field_index}); | 3515 | const field_name = try std.fmt.allocPrint(dwarf.gpa, "{d}", .{field_index}); |
| 3504 | defer dwarf.gpa.free(field_name); | 3516 | defer dwarf.gpa.free(field_name); |
| ... | @@ -3506,14 +3518,12 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP | ... | @@ -3506,14 +3518,12 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3506 | } | 3518 | } |
| 3507 | const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]); | 3519 | const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]); |
| 3508 | try wip_nav.refType(field_type); | 3520 | try wip_nav.refType(field_type); |
| 3509 | if (is_comptime) try wip_nav.blockValue( | 3521 | if (!is_comptime) { |
| 3510 | ty_src_loc, | | |
| 3511 | Value.fromInterned(loaded_struct.fieldInit(ip, field_index)), | | |
| 3512 | ) else { | | |
| 3513 | try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]); | 3522 | try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]); |
| 3514 | try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse | 3523 | try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse |
| 3515 | field_type.abiAlignment(zcu).toByteUnits().?); | 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 | try uleb128(diw, @intFromEnum(AbbrevCode.null)); | 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,7 +3579,14 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3569 | try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?); | 3579 | try uleb128(diw, ty.abiAlignment(zcu).toByteUnits().?); |
| 3570 | for (0..loaded_struct.field_types.len) |field_index| { | 3580 | for (0..loaded_struct.field_types.len) |field_index| { |
| 3571 | const is_comptime = loaded_struct.fieldIsComptime(ip, field_index); | 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 | if (loaded_struct.fieldName(ip, field_index).unwrap()) |field_name| try wip_nav.strp(field_name.toSlice(ip)) else { | 3590 | if (loaded_struct.fieldName(ip, field_index).unwrap()) |field_name| try wip_nav.strp(field_name.toSlice(ip)) else { |
| 3574 | const field_name = try std.fmt.allocPrint(dwarf.gpa, "{d}", .{field_index}); | 3591 | const field_name = try std.fmt.allocPrint(dwarf.gpa, "{d}", .{field_index}); |
| 3575 | defer dwarf.gpa.free(field_name); | 3592 | defer dwarf.gpa.free(field_name); |
| ... | @@ -3577,14 +3594,12 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP | ... | @@ -3577,14 +3594,12 @@ pub fn updateContainerType(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternP |
| 3577 | } | 3594 | } |
| 3578 | const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]); | 3595 | const field_type = Type.fromInterned(loaded_struct.field_types.get(ip)[field_index]); |
| 3579 | try wip_nav.refType(field_type); | 3596 | try wip_nav.refType(field_type); |
| 3580 | if (is_comptime) try wip_nav.blockValue( | 3597 | if (!is_comptime) { |
| 3581 | ty_src_loc, | | |
| 3582 | Value.fromInterned(loaded_struct.fieldInit(ip, field_index)), | | |
| 3583 | ) else { | | |
| 3584 | try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]); | 3598 | try uleb128(diw, loaded_struct.offsets.get(ip)[field_index]); |
| 3585 | try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse | 3599 | try uleb128(diw, loaded_struct.fieldAlign(ip, field_index).toByteUnits() orelse |
| 3586 | field_type.abiAlignment(zcu).toByteUnits().?); | 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 | try uleb128(diw, @intFromEnum(AbbrevCode.null)); | 3604 | try uleb128(diw, @intFromEnum(AbbrevCode.null)); |
| 3590 | } | 3605 | } |
| ... | @@ -4165,6 +4180,7 @@ const AbbrevCode = enum { | ... | @@ -4165,6 +4180,7 @@ const AbbrevCode = enum { |
| 4165 | big_enum_field, | 4180 | big_enum_field, |
| 4166 | generated_field, | 4181 | generated_field, |
| 4167 | struct_field, | 4182 | struct_field, |
| | 4183 | struct_field_default, |
| 4168 | struct_field_comptime, | 4184 | struct_field_comptime, |
| 4169 | packed_struct_field, | 4185 | packed_struct_field, |
| 4170 | untagged_union_field, | 4186 | untagged_union_field, |
| ... | @@ -4412,13 +4428,23 @@ const AbbrevCode = enum { | ... | @@ -4412,13 +4428,23 @@ const AbbrevCode = enum { |
| 4412 | .{ .alignment, .udata }, | 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 | .struct_field_comptime = .{ | 4441 | .struct_field_comptime = .{ |
| 4416 | .tag = .member, | 4442 | .tag = .member, |
| 4417 | .attrs = &.{ | 4443 | .attrs = &.{ |
| 4418 | .{ .const_expr, .flag_present }, | 4444 | .{ .const_expr, .flag_present }, |
| 4419 | .{ .name, .strp }, | 4445 | .{ .name, .strp }, |
| 4420 | .{ .type, .ref_addr }, | 4446 | .{ .type, .ref_addr }, |
| 4421 | .{ .default_value, .block }, | 4447 | .{ .const_value, .block }, |
| 4422 | }, | 4448 | }, |
| 4423 | }, | 4449 | }, |
| 4424 | .packed_struct_field = .{ | 4450 | .packed_struct_field = .{ |