authorgravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-10-28 12:38:31-04:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2023-11-07 00:49:39+00:00
log1acb6a53d04102ed028b73451df2250bd6d45cd9
tree3ba059a0ec157c99784385fe26898c1c7d2232ba
parent35c86984a6c5e275c5c980ebb9d4b372291c9917
signaturelock-open Commit is signed but in an unrecognized format.

wasm: support rendering unions using their backing type if they have no defined tag type


1 files changed, 8 insertions(+), 4 deletions(-)

src/arch/wasm/CodeGen.zig+8-4
...@@ -3372,10 +3372,14 @@ fn lowerConstant(func: *CodeGen, val: Value, ty: Type) InnerError!WValue {...@@ -3372,10 +3372,14 @@ fn lowerConstant(func: *CodeGen, val: Value, ty: Type) InnerError!WValue {
3372 },3372 },
3373 .un => |un| {3373 .un => |un| {
3374 // in this case we have a packed union which will not be passed by reference.3374 // in this case we have a packed union which will not be passed by reference.
3375 const union_obj = mod.typeToUnion(ty).?;3375 const constant_ty = if (un.tag == .none)
3376 const field_index = mod.unionTagFieldIndex(union_obj, un.tag.toValue()).?;3376 try ty.unionBackingType(mod)
3377 const field_ty = union_obj.field_types.get(ip)[field_index].toType();3377 else field_ty: {
3378 return func.lowerConstant(un.val.toValue(), field_ty);3378 const union_obj = mod.typeToUnion(ty).?;
3379 const field_index = mod.unionTagFieldIndex(union_obj, un.tag.toValue()).?;
3380 break :field_ty union_obj.field_types.get(ip)[field_index].toType();
3381 };
3382 return func.lowerConstant(un.val.toValue(), constant_ty);
3379 },3383 },
3380 .memoized_call => unreachable,3384 .memoized_call => unreachable,
3381 }3385 }