aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2021-09-13 23:12:19 +0200
committerJakub Konka <kubkon@jakubkonka.com>2021-09-13 23:40:38 +0200
commita38b636045c0384faad1565d47dfbf774821021e (patch)
treea78193473fd5b725feaf2762b10cfc189a26a325 /src/type.zig
parent760241ce50eaa9031339f6b591358b53f5797486 (diff)
parentf011f13933b72f4d63a5f635c7646b68beee726e (diff)
downloadzig-a38b636045c0384faad1565d47dfbf774821021e.tar.gz
zig-a38b636045c0384faad1565d47dfbf774821021e.zip
Merge remote-tracking branch 'origin/master' into zld-incr
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 = .{