diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-05-03 20:04:47 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-06-10 20:40:04 -0700 |
| commit | 85c69c51945d7fb5d4cd2dea03fdb7915ecc55fa (patch) | |
| tree | 2705f666129a04e8100861d056f6df9bb89fd582 /src/InternPool.zig | |
| parent | fb16ad3add77eff23f9c5dbaf802fdecfb4c8cc0 (diff) | |
| download | zig-85c69c51945d7fb5d4cd2dea03fdb7915ecc55fa.tar.gz zig-85c69c51945d7fb5d4cd2dea03fdb7915ecc55fa.zip | |
Type.isSlice: make it InternPool aware
Diffstat (limited to 'src/InternPool.zig')
| -rw-r--r-- | src/InternPool.zig | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/src/InternPool.zig b/src/InternPool.zig index 6345d36f26..3ecc18c426 100644 --- a/src/InternPool.zig +++ b/src/InternPool.zig @@ -629,7 +629,7 @@ pub const Tag = enum(u8) { /// A vector type. /// data is payload to Vector. type_vector, - /// A pointer type along with all its bells and whistles. + /// A fully explicitly specified pointer type. /// data is payload to Pointer. type_pointer, /// An optional type. @@ -682,13 +682,13 @@ pub const Tag = enum(u8) { /// An enum tag identified by a negative integer value. /// data is a limbs index to Int. enum_tag_negative, - /// A float value that can be represented by f32. + /// An f32 value. /// data is float value bitcasted to u32. float_f32, - /// A float value that can be represented by f64. + /// An f64 value. /// data is payload index to Float64. float_f64, - /// A float value that can be represented by f128. + /// An f128 value. /// data is payload index to Float128. float_f128, /// An extern function. @@ -871,7 +871,47 @@ pub fn indexToKey(ip: InternPool, index: Index) Key { .simple_type => .{ .simple_type = @intToEnum(SimpleType, data) }, .simple_value => .{ .simple_value = @intToEnum(SimpleValue, data) }, - else => @panic("TODO"), + .type_vector => { + const vector_info = ip.extraData(Vector, data); + return .{ .vector_type = .{ + .len = vector_info.len, + .child = vector_info.child, + } }; + }, + + .type_pointer => { + const ptr_info = ip.extraData(Pointer, data); + return .{ .ptr_type = .{ + .elem_type = ptr_info.child, + .sentinel = ptr_info.sentinel, + .alignment = ptr_info.flags.alignment, + .size = ptr_info.flags.size, + .is_const = ptr_info.flags.is_const, + .is_volatile = ptr_info.flags.is_volatile, + .is_allowzero = ptr_info.flags.is_allowzero, + .address_space = ptr_info.flags.address_space, + } }; + }, + + .type_optional => .{ .optional_type = .{ .payload_type = @intToEnum(Index, data) } }, + + .type_error_union => @panic("TODO"), + .type_enum_simple => @panic("TODO"), + .simple_internal => @panic("TODO"), + .int_small_u32 => @panic("TODO"), + .int_small_i32 => @panic("TODO"), + .int_small_usize => @panic("TODO"), + .int_small_comptime_unsigned => @panic("TODO"), + .int_small_comptime_signed => @panic("TODO"), + .int_positive => @panic("TODO"), + .int_negative => @panic("TODO"), + .enum_tag_positive => @panic("TODO"), + .enum_tag_negative => @panic("TODO"), + .float_f32 => @panic("TODO"), + .float_f64 => @panic("TODO"), + .float_f128 => @panic("TODO"), + .extern_func => @panic("TODO"), + .func => @panic("TODO"), }; } |
