aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-05-03 12:30:06 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-06-10 20:40:03 -0700
commitb125063dcfb95b470bc7830b188614361d3ba4cb (patch)
tree3734c41e12b529d63efc035eae55e98d49e9b4ea /src
parent50f33734c6cec10a0132644c08ee443c2dd224e2 (diff)
downloadzig-b125063dcfb95b470bc7830b188614361d3ba4cb.tar.gz
zig-b125063dcfb95b470bc7830b188614361d3ba4cb.zip
InternPool: implement typeHasOnePossibleValue for simple_type
Diffstat (limited to 'src')
-rw-r--r--src/Sema.zig47
-rw-r--r--src/type.zig47
2 files changed, 92 insertions, 2 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index 45da0927cd..79fe7b2eb0 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -32776,7 +32776,52 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
.vector_type => @panic("TODO"),
.optional_type => @panic("TODO"),
.error_union_type => @panic("TODO"),
- .simple_type => @panic("TODO"),
+ .simple_type => |t| switch (t) {
+ .f16,
+ .f32,
+ .f64,
+ .f80,
+ .f128,
+ .usize,
+ .isize,
+ .c_char,
+ .c_short,
+ .c_ushort,
+ .c_int,
+ .c_uint,
+ .c_long,
+ .c_ulong,
+ .c_longlong,
+ .c_ulonglong,
+ .c_longdouble,
+ .anyopaque,
+ .bool,
+ .type,
+ .anyerror,
+ .comptime_int,
+ .comptime_float,
+ .@"anyframe",
+ .enum_literal,
+ .atomic_order,
+ .atomic_rmw_op,
+ .calling_convention,
+ .address_space,
+ .float_mode,
+ .reduce_op,
+ .call_modifier,
+ .prefetch_options,
+ .export_options,
+ .extern_options,
+ .type_info,
+ => return null,
+
+ .void => return Value.void,
+ .noreturn => return Value.initTag(.unreachable_value),
+ .null => return Value.null,
+ .undefined => return Value.undef,
+
+ .generic_poison => return error.GenericPoison,
+ },
.struct_type => @panic("TODO"),
.simple_value => unreachable,
.extern_func => unreachable,
diff --git a/src/type.zig b/src/type.zig
index 9f14619c2c..a4f1f5174b 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -5030,7 +5030,52 @@ pub const Type = struct {
.vector_type => @panic("TODO"),
.optional_type => @panic("TODO"),
.error_union_type => @panic("TODO"),
- .simple_type => @panic("TODO"),
+ .simple_type => |t| switch (t) {
+ .f16,
+ .f32,
+ .f64,
+ .f80,
+ .f128,
+ .usize,
+ .isize,
+ .c_char,
+ .c_short,
+ .c_ushort,
+ .c_int,
+ .c_uint,
+ .c_long,
+ .c_ulong,
+ .c_longlong,
+ .c_ulonglong,
+ .c_longdouble,
+ .anyopaque,
+ .bool,
+ .type,
+ .anyerror,
+ .comptime_int,
+ .comptime_float,
+ .@"anyframe",
+ .enum_literal,
+ .atomic_order,
+ .atomic_rmw_op,
+ .calling_convention,
+ .address_space,
+ .float_mode,
+ .reduce_op,
+ .call_modifier,
+ .prefetch_options,
+ .export_options,
+ .extern_options,
+ .type_info,
+ => return null,
+
+ .void => return Value.void,
+ .noreturn => return Value.initTag(.unreachable_value),
+ .null => return Value.null,
+ .undefined => return Value.undef,
+
+ .generic_poison => unreachable,
+ },
.struct_type => @panic("TODO"),
.simple_value => unreachable,
.extern_func => unreachable,