From dfeffcfbf825c29d89ccec281ab95dd2383317ac Mon Sep 17 00:00:00 2001 From: Veikka Tuominen Date: Mon, 28 Feb 2022 10:09:23 +0200 Subject: stage2: tuple mul/cat --- src/type.zig | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/type.zig') diff --git a/src/type.zig b/src/type.zig index a84a0f4520..fb3ab5d28f 100644 --- a/src/type.zig +++ b/src/type.zig @@ -4531,7 +4531,15 @@ pub const Type = extern union { }; pub fn isTuple(ty: Type) bool { - return ty.tag() == .tuple; + return ty.tag() == .tuple or ty.tag() == .empty_struct_literal; + } + + pub fn tupleFields(ty: Type) Payload.Tuple.Data { + return switch (ty.tag()) { + .tuple => ty.castTag(.tuple).?.data, + .empty_struct_literal => .{ .types = &.{}, .values = &.{} }, + else => unreachable, + }; } /// The sub-types are named after what fields they contain. @@ -4683,11 +4691,13 @@ pub const Type = extern union { pub const Tuple = struct { base: Payload = .{ .tag = .tuple }, - data: struct { + data: Data, + + pub const Data = struct { types: []Type, /// unreachable_value elements are used to indicate runtime-known. values: []Value, - }, + }; }; pub const Union = struct { -- cgit v1.2.3