From 8ec6f730eff1f6008b7eba1c749824a4a5734e5f Mon Sep 17 00:00:00 2001 From: mlugg Date: Sat, 17 Feb 2024 03:34:47 +0000 Subject: compiler: represent captures directly in InternPool These were previously associated with the type's namespace, but we need to store them directly in the InternPool for #18816. --- src/Module.zig | 33 --------------------------------- 1 file changed, 33 deletions(-) (limited to 'src/Module.zig') diff --git a/src/Module.zig b/src/Module.zig index 7f24a2db6d..eb3168e08b 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -761,37 +761,6 @@ pub const Namespace = struct { /// the Decl Value has to be resolved as a Type which has a Namespace. /// Value is whether the usingnamespace decl is marked `pub`. usingnamespace_set: std.AutoHashMapUnmanaged(Decl.Index, bool) = .{}, - /// Allocated into `gpa`. - /// The ordered set of values captured in this type's closure. - /// `closure_get` instructions look up values in this list. - captures: []CaptureValue, - - /// A single value captured in a container's closure. This is not an - /// `InternPool.Index` so we can differentiate between runtime-known values - /// (where only the type is comptime-known) and comptime-known values. - pub const CaptureValue = enum(u32) { - _, - pub const Unwrapped = union(enum) { - /// Index refers to the value. - @"comptime": InternPool.Index, - /// Index refers to the type. - runtime: InternPool.Index, - }; - pub fn wrap(val: Unwrapped) CaptureValue { - return switch (val) { - .@"comptime" => |i| @enumFromInt(@intFromEnum(i)), - .runtime => |i| @enumFromInt((1 << 31) | @intFromEnum(i)), - }; - } - pub fn unwrap(val: CaptureValue) Unwrapped { - const tag: u1 = @intCast(@intFromEnum(val) >> 31); - const raw = @intFromEnum(val); - return switch (tag) { - 0 => .{ .@"comptime" = @enumFromInt(raw) }, - 1 => .{ .runtime = @enumFromInt(@as(u31, @truncate(raw))) }, - }; - } - }; const Index = InternPool.NamespaceIndex; const OptionalIndex = InternPool.OptionalNamespaceIndex; @@ -2130,7 +2099,6 @@ pub fn deinit(zcu: *Zcu) void { while (it.next()) |namespace| { namespace.decls.deinit(gpa); namespace.usingnamespace_set.deinit(gpa); - gpa.free(namespace.captures); } } @@ -3354,7 +3322,6 @@ pub fn semaFile(mod: *Module, file: *File) SemaError!void { .parent = .none, .decl_index = undefined, .file_scope = file, - .captures = &.{}, }); const new_namespace = mod.namespacePtr(new_namespace_index); errdefer mod.destroyNamespace(new_namespace_index); -- cgit v1.2.3