| ... | @@ -3067,51 +3067,6 @@ fn lowerConstant(func: *CodeGen, arg_val: Value, ty: Type) InnerError!WValue { | ... | @@ -3067,51 +3067,6 @@ fn lowerConstant(func: *CodeGen, arg_val: Value, ty: Type) InnerError!WValue { |
| 3067 | } | 3067 | } |
| 3068 | if (val.isUndefDeep(mod)) return func.emitUndefined(ty); | 3068 | if (val.isUndefDeep(mod)) return func.emitUndefined(ty); |
| 3069 | | 3069 | |
| 3070 | if (val.ip_index == .none) switch (ty.zigTypeTag(mod)) { | | |
| 3071 | .Array => |zig_type| return func.fail("Wasm TODO: LowerConstant for zigTypeTag {}", .{zig_type}), | | |
| 3072 | .Struct => { | | |
| 3073 | const struct_obj = mod.typeToStruct(ty).?; | | |
| 3074 | assert(struct_obj.layout == .Packed); | | |
| 3075 | var buf: [8]u8 = .{0} ** 8; // zero the buffer so we do not read 0xaa as integer | | |
| 3076 | val.writeToPackedMemory(ty, func.bin_file.base.options.module.?, &buf, 0) catch unreachable; | | |
| 3077 | const int_val = try mod.intValue( | | |
| 3078 | struct_obj.backing_int_ty, | | |
| 3079 | std.mem.readIntLittle(u64, &buf), | | |
| 3080 | ); | | |
| 3081 | return func.lowerConstant(int_val, struct_obj.backing_int_ty); | | |
| 3082 | }, | | |
| 3083 | .Vector => { | | |
| 3084 | assert(determineSimdStoreStrategy(ty, mod) == .direct); | | |
| 3085 | var buf: [16]u8 = undefined; | | |
| 3086 | val.writeToMemory(ty, mod, &buf) catch unreachable; | | |
| 3087 | return func.storeSimdImmd(buf); | | |
| 3088 | }, | | |
| 3089 | .Frame, | | |
| 3090 | .AnyFrame, | | |
| 3091 | => return func.fail("Wasm TODO: LowerConstant for type {}", .{ty.fmt(mod)}), | | |
| 3092 | .Float, | | |
| 3093 | .Union, | | |
| 3094 | .Optional, | | |
| 3095 | .ErrorUnion, | | |
| 3096 | .ErrorSet, | | |
| 3097 | .Int, | | |
| 3098 | .Enum, | | |
| 3099 | .Bool, | | |
| 3100 | .Pointer, | | |
| 3101 | => unreachable, // handled below | | |
| 3102 | .Type, | | |
| 3103 | .Void, | | |
| 3104 | .NoReturn, | | |
| 3105 | .ComptimeFloat, | | |
| 3106 | .ComptimeInt, | | |
| 3107 | .Undefined, | | |
| 3108 | .Null, | | |
| 3109 | .Opaque, | | |
| 3110 | .EnumLiteral, | | |
| 3111 | .Fn, | | |
| 3112 | => unreachable, // comptime-only types | | |
| 3113 | }; | | |
| 3114 | | | |
| 3115 | switch (ip.indexToKey(val.ip_index)) { | 3070 | switch (ip.indexToKey(val.ip_index)) { |
| 3116 | .int_type, | 3071 | .int_type, |
| 3117 | .ptr_type, | 3072 | .ptr_type, |