| ... | @@ -11937,7 +11937,23 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I | ... | @@ -11937,7 +11937,23 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I |
| 11937 | const ty = try Type.vector(sema.arena, len, try child_ty.copy(sema.arena)); | 11937 | const ty = try Type.vector(sema.arena, len, try child_ty.copy(sema.arena)); |
| 11938 | return sema.addType(ty); | 11938 | return sema.addType(ty); |
| 11939 | }, | 11939 | }, |
| 11940 | .Float => return sema.fail(block, src, "TODO: Sema.zirReify for Float", .{}), | 11940 | .Float => { |
| | 11941 | const struct_val = union_val.val.castTag(.@"struct").?.data; |
| | 11942 | // TODO use reflection instead of magic numbers here |
| | 11943 | // bits: comptime_int, |
| | 11944 | const bits_val = struct_val[0]; |
| | 11945 | |
| | 11946 | const bits = @intCast(u16, bits_val.toUnsignedInt()); |
| | 11947 | const ty = switch (bits) { |
| | 11948 | 16 => Type.@"f16", |
| | 11949 | 32 => Type.@"f32", |
| | 11950 | 64 => Type.@"f64", |
| | 11951 | 80 => Type.@"f80", |
| | 11952 | 128 => Type.@"f128", |
| | 11953 | else => return sema.fail(block, src, "{}-bit float unsupported", .{bits}), |
| | 11954 | }; |
| | 11955 | return sema.addType(ty); |
| | 11956 | }, |
| 11941 | .Pointer => { | 11957 | .Pointer => { |
| 11942 | const struct_val = union_val.val.castTag(.@"struct").?.data; | 11958 | const struct_val = union_val.val.castTag(.@"struct").?.data; |
| 11943 | // TODO use reflection instead of magic numbers here | 11959 | // TODO use reflection instead of magic numbers here |
| ... | @@ -11977,10 +11993,58 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I | ... | @@ -11977,10 +11993,58 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I |
| 11977 | }); | 11993 | }); |
| 11978 | return sema.addType(ty); | 11994 | return sema.addType(ty); |
| 11979 | }, | 11995 | }, |
| 11980 | .Array => return sema.fail(block, src, "TODO: Sema.zirReify for Array", .{}), | 11996 | .Array => { |
| | 11997 | const struct_val = union_val.val.castTag(.@"struct").?.data; |
| | 11998 | // TODO use reflection instead of magic numbers here |
| | 11999 | // len: comptime_int, |
| | 12000 | const len_val = struct_val[0]; |
| | 12001 | // child: type, |
| | 12002 | const child_val = struct_val[1]; |
| | 12003 | // sentinel: ?*const anyopaque, |
| | 12004 | const sentinel_val = struct_val[2]; |
| | 12005 | |
| | 12006 | const len = len_val.toUnsignedInt(); |
| | 12007 | var buffer: Value.ToTypeBuffer = undefined; |
| | 12008 | const child_ty = try child_val.toType(&buffer).copy(sema.arena); |
| | 12009 | const sentinel = if (sentinel_val.castTag(.opt_payload)) |p| blk: { |
| | 12010 | const ptr_ty = try Type.ptr(sema.arena, .{ .@"addrspace" = .generic, .pointee_type = child_ty }); |
| | 12011 | break :blk (try sema.pointerDeref(block, src, p.data, ptr_ty)).?; |
| | 12012 | } else null; |
| | 12013 | |
| | 12014 | const ty = try Type.array(sema.arena, len, sentinel, child_ty); |
| | 12015 | return sema.addType(ty); |
| | 12016 | }, |
| 11981 | .Struct => return sema.fail(block, src, "TODO: Sema.zirReify for Struct", .{}), | 12017 | .Struct => return sema.fail(block, src, "TODO: Sema.zirReify for Struct", .{}), |
| 11982 | .Optional => return sema.fail(block, src, "TODO: Sema.zirReify for Optional", .{}), | 12018 | .Optional => { |
| 11983 | .ErrorUnion => return sema.fail(block, src, "TODO: Sema.zirReify for ErrorUnion", .{}), | 12019 | const struct_val = union_val.val.castTag(.@"struct").?.data; |
| | 12020 | // TODO use reflection instead of magic numbers here |
| | 12021 | // child: type, |
| | 12022 | const child_val = struct_val[0]; |
| | 12023 | |
| | 12024 | var buffer: Value.ToTypeBuffer = undefined; |
| | 12025 | const child_ty = try child_val.toType(&buffer).copy(sema.arena); |
| | 12026 | |
| | 12027 | const ty = try Type.optional(sema.arena, child_ty); |
| | 12028 | return sema.addType(ty); |
| | 12029 | }, |
| | 12030 | .ErrorUnion => { |
| | 12031 | const struct_val = union_val.val.castTag(.@"struct").?.data; |
| | 12032 | // TODO use reflection instead of magic numbers here |
| | 12033 | // error_set: type, |
| | 12034 | const error_set_val = struct_val[0]; |
| | 12035 | // payload: type, |
| | 12036 | const payload_val = struct_val[1]; |
| | 12037 | |
| | 12038 | var buffer: Value.ToTypeBuffer = undefined; |
| | 12039 | const error_set_ty = try error_set_val.toType(&buffer).copy(sema.arena); |
| | 12040 | const payload_ty = try payload_val.toType(&buffer).copy(sema.arena); |
| | 12041 | |
| | 12042 | const ty = try Type.Tag.error_union.create(sema.arena, .{ |
| | 12043 | .error_set = error_set_ty, |
| | 12044 | .payload = payload_ty, |
| | 12045 | }); |
| | 12046 | return sema.addType(ty); |
| | 12047 | }, |
| 11984 | .ErrorSet => return sema.fail(block, src, "TODO: Sema.zirReify for ErrorSet", .{}), | 12048 | .ErrorSet => return sema.fail(block, src, "TODO: Sema.zirReify for ErrorSet", .{}), |
| 11985 | .Enum => return sema.fail(block, src, "TODO: Sema.zirReify for Enum", .{}), | 12049 | .Enum => return sema.fail(block, src, "TODO: Sema.zirReify for Enum", .{}), |
| 11986 | .Union => return sema.fail(block, src, "TODO: Sema.zirReify for Union", .{}), | 12050 | .Union => return sema.fail(block, src, "TODO: Sema.zirReify for Union", .{}), |