aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/type.zig')
-rw-r--r--src/type.zig11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/type.zig b/src/type.zig
index 467e9c931b..b6602ba18d 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -197,7 +197,7 @@ pub const Type = extern union {
/// Prefer `castTag` to this.
pub fn cast(self: Type, comptime T: type) ?*T {
if (@hasField(T, "base_tag")) {
- return base.castTag(T.base_tag);
+ return self.castTag(T.base_tag);
}
if (self.tag_if_small_enough < Tag.no_payload_count) {
return null;
@@ -273,6 +273,15 @@ pub const Type = extern union {
};
}
+ pub const ArrayInfo = struct { elem_type: Type, sentinel: ?Value = null, len: u64 };
+ pub fn arrayInfo(self: Type) ArrayInfo {
+ return .{
+ .len = self.arrayLen(),
+ .sentinel = self.sentinel(),
+ .elem_type = self.elemType(),
+ };
+ }
+
pub fn ptrInfo(self: Type) Payload.Pointer {
switch (self.tag()) {
.single_const_pointer_to_comptime_int => return .{ .data = .{