mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 13:30:45 +00:00
codegen: implement global enum_numbered
This commit is contained in:
parent
e36e9323f4
commit
81664f17d5
@ -1189,12 +1189,16 @@ pub fn genTypedValue(
|
||||
.enum_simple => {
|
||||
return GenResult.mcv(.{ .immediate = field_index.data });
|
||||
},
|
||||
.enum_full, .enum_nonexhaustive => {
|
||||
const enum_full = typed_value.ty.cast(Type.Payload.EnumFull).?.data;
|
||||
if (enum_full.values.count() != 0) {
|
||||
const tag_val = enum_full.values.keys()[field_index.data];
|
||||
.enum_numbered, .enum_full, .enum_nonexhaustive => {
|
||||
const enum_values = if (typed_value.ty.castTag(.enum_numbered)) |pl|
|
||||
pl.data.values
|
||||
else
|
||||
typed_value.ty.cast(Type.Payload.EnumFull).?.data.values;
|
||||
if (enum_values.count() != 0) {
|
||||
const tag_val = enum_values.keys()[field_index.data];
|
||||
var buf: Type.Payload.Bits = undefined;
|
||||
return genTypedValue(bin_file, src_loc, .{
|
||||
.ty = enum_full.tag_ty,
|
||||
.ty = typed_value.ty.intTagType(&buf),
|
||||
.val = tag_val,
|
||||
}, owner_decl_index);
|
||||
} else {
|
||||
|
||||
@ -362,7 +362,6 @@ const MultipleChoice = union(enum(u32)) {
|
||||
D = 1000,
|
||||
};
|
||||
test "simple union(enum(u32))" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
@ -641,7 +640,6 @@ test "tagged union with all void fields but a meaningful tag" {
|
||||
}
|
||||
|
||||
test "union(enum(u32)) with specified and unspecified tag values" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user