authorgravatar for john.schmidt.h@gmail.comJohn Schmidt <john.schmidt.h@gmail.com> 2022-02-12 16:57:52+01:00
committergravatar for john.schmidt.h@gmail.comJohn Schmidt <john.schmidt.h@gmail.com> 2022-03-25 23:15:37+01:00
loga7b3082ba0d07c66d2ec19304ffe993d77f714b7
tree9631a700dd082721a43bc52055fdb4201ef10641
parent1c33ea2c35e9260babedb116ad527256e0a4ef5e

Implement `type.bitSize` for unions


1 files changed, 13 insertions(+), 1 deletions(-)

src/type.zig+13-1
...@@ -3251,8 +3251,20 @@ pub const Type = extern union {...@@ -3251,8 +3251,20 @@ pub const Type = extern union {
3251 const int_tag_ty = ty.intTagType(&buffer);3251 const int_tag_ty = ty.intTagType(&buffer);
3252 return int_tag_ty.bitSize(target);3252 return int_tag_ty.bitSize(target);
3253 },3253 },
3254
3254 .@"union", .union_tagged => {3255 .@"union", .union_tagged => {
3255 @panic("TODO bitSize unions");3256 const union_obj = ty.cast(Payload.Union).?.data;
3257
3258 const fields = union_obj.fields;
3259 if (fields.count() == 0) return 0;
3260
3261 assert(union_obj.haveFieldTypes());
3262
3263 var size: u64 = 0;
3264 for (fields.values()) |field| {
3265 size = @maximum(size, field.ty.bitSize(target));
3266 }
3267 return size;
3256 },3268 },
32573269
3258 .vector => {3270 .vector => {