authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-05-03 12:30:06-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-10 20:40:03-07:00
logb125063dcfb95b470bc7830b188614361d3ba4cb
tree3734c41e12b529d63efc035eae55e98d49e9b4ea
parent50f33734c6cec10a0132644c08ee443c2dd224e2

InternPool: implement typeHasOnePossibleValue for simple_type


2 files changed, 92 insertions(+), 2 deletions(-)

src/Sema.zig+46-1
......@@ -32776,7 +32776,52 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
3277632776 .vector_type => @panic("TODO"),
3277732777 .optional_type => @panic("TODO"),
3277832778 .error_union_type => @panic("TODO"),
32779 .simple_type => @panic("TODO"),
32779 .simple_type => |t| switch (t) {
32780 .f16,
32781 .f32,
32782 .f64,
32783 .f80,
32784 .f128,
32785 .usize,
32786 .isize,
32787 .c_char,
32788 .c_short,
32789 .c_ushort,
32790 .c_int,
32791 .c_uint,
32792 .c_long,
32793 .c_ulong,
32794 .c_longlong,
32795 .c_ulonglong,
32796 .c_longdouble,
32797 .anyopaque,
32798 .bool,
32799 .type,
32800 .anyerror,
32801 .comptime_int,
32802 .comptime_float,
32803 .@"anyframe",
32804 .enum_literal,
32805 .atomic_order,
32806 .atomic_rmw_op,
32807 .calling_convention,
32808 .address_space,
32809 .float_mode,
32810 .reduce_op,
32811 .call_modifier,
32812 .prefetch_options,
32813 .export_options,
32814 .extern_options,
32815 .type_info,
32816 => return null,
32817
32818 .void => return Value.void,
32819 .noreturn => return Value.initTag(.unreachable_value),
32820 .null => return Value.null,
32821 .undefined => return Value.undef,
32822
32823 .generic_poison => return error.GenericPoison,
32824 },
3278032825 .struct_type => @panic("TODO"),
3278132826 .simple_value => unreachable,
3278232827 .extern_func => unreachable,
src/type.zig+46-1
......@@ -5030,7 +5030,52 @@ pub const Type = struct {
50305030 .vector_type => @panic("TODO"),
50315031 .optional_type => @panic("TODO"),
50325032 .error_union_type => @panic("TODO"),
5033 .simple_type => @panic("TODO"),
5033 .simple_type => |t| switch (t) {
5034 .f16,
5035 .f32,
5036 .f64,
5037 .f80,
5038 .f128,
5039 .usize,
5040 .isize,
5041 .c_char,
5042 .c_short,
5043 .c_ushort,
5044 .c_int,
5045 .c_uint,
5046 .c_long,
5047 .c_ulong,
5048 .c_longlong,
5049 .c_ulonglong,
5050 .c_longdouble,
5051 .anyopaque,
5052 .bool,
5053 .type,
5054 .anyerror,
5055 .comptime_int,
5056 .comptime_float,
5057 .@"anyframe",
5058 .enum_literal,
5059 .atomic_order,
5060 .atomic_rmw_op,
5061 .calling_convention,
5062 .address_space,
5063 .float_mode,
5064 .reduce_op,
5065 .call_modifier,
5066 .prefetch_options,
5067 .export_options,
5068 .extern_options,
5069 .type_info,
5070 => return null,
5071
5072 .void => return Value.void,
5073 .noreturn => return Value.initTag(.unreachable_value),
5074 .null => return Value.null,
5075 .undefined => return Value.undef,
5076
5077 .generic_poison => unreachable,
5078 },
50345079 .struct_type => @panic("TODO"),
50355080 .simple_value => unreachable,
50365081 .extern_func => unreachable,