@@ -81,7 +81,7 @@ namespace_name_deps: std.AutoArrayHashMapUnmanaged(NamespaceNameKey, DepEntry.In
81
81
/// Given a `Depender`, points to an entry in `dep_entries` whose `depender`
82
82
/// matches. The `next_dependee` field can be used to iterate all such entries
83
83
/// and remove them from the corresponding lists.
84
- first_dependency : std .AutoArrayHashMapUnmanaged (Depender , DepEntry .Index ) = .{},
84
+ first_dependency : std .AutoArrayHashMapUnmanaged (AnalSubject , DepEntry .Index ) = .{},
85
85
86
86
/// Stores dependency information. The hashmaps declared above are used to look
87
87
/// up entries in this list as required. This is not stored in `extra` so that
@@ -132,39 +132,39 @@ pub fn trackZir(ip: *InternPool, gpa: Allocator, file: *Module.File, inst: Zir.I
132
132
return @enumFromInt (gop .index );
133
133
}
134
134
135
- /// Reperesents the "source" of a dependency edge, i.e. either a Decl or a
136
- /// runtime function (represented as an InternPool index).
137
- /// MSB is 0 for a Decl, 1 for a function.
138
- pub const Depender = enum (u32 ) {
139
- _ ,
135
+ /// Analysis Subject. Represents a single entity which undergoes semantic analysis.
136
+ /// This is either a `Decl` (in future `Cau`) or a runtime function.
137
+ /// The LSB is used as a tag bit.
138
+ /// This is the "source" of an incremental dependency edge.
139
+ pub const AnalSubject = packed struct (u32 ) {
140
+ kind : enum (u1 ) { decl , func },
141
+ index : u31 ,
140
142
pub const Unwrapped = union (enum ) {
141
143
decl : DeclIndex ,
142
144
func : InternPool.Index ,
143
145
};
144
- pub fn unwrap (dep : Depender ) Unwrapped {
145
- const tag : u1 = @truncate (@intFromEnum (dep ) >> 31 );
146
- const val : u31 = @truncate (@intFromEnum (dep ));
147
- return switch (tag ) {
148
- 0 = > .{ .decl = @enumFromInt (val ) },
149
- 1 = > .{ .func = @enumFromInt (val ) },
146
+ pub fn unwrap (as : AnalSubject ) Unwrapped {
147
+ return switch (as .kind ) {
148
+ .decl = > .{ .decl = @enumFromInt (as .index ) },
149
+ .func = > .{ .func = @enumFromInt (as .index ) },
150
150
};
151
151
}
152
- pub fn wrap (raw : Unwrapped ) Depender {
153
- return @enumFromInt ( switch (raw ) {
154
- .decl = > | decl | @ intFromEnum (decl ),
155
- .func = > | func | ( 1 << 31 ) | @ intFromEnum (func ),
156
- }) ;
152
+ pub fn wrap (raw : Unwrapped ) AnalSubject {
153
+ return switch (raw ) {
154
+ .decl = > | decl | .{ . kind = .decl , . index = @intCast ( @ intFromEnum (decl )) } ,
155
+ .func = > | func | .{ . kind = .func , . index = @intCast ( @ intFromEnum (func )) } ,
156
+ };
157
157
}
158
- pub fn toOptional (dep : Depender ) Optional {
159
- return @enumFromInt (@intFromEnum ( dep ));
158
+ pub fn toOptional (as : AnalSubject ) Optional {
159
+ return @enumFromInt (@as ( u32 , @bitCast ( as ) ));
160
160
}
161
161
pub const Optional = enum (u32 ) {
162
162
none = std .math .maxInt (u32 ),
163
163
_ ,
164
- pub fn unwrap (opt : Optional ) ? Depender {
164
+ pub fn unwrap (opt : Optional ) ? AnalSubject {
165
165
return switch (opt ) {
166
166
.none = > null ,
167
- _ = > @enumFromInt (@intFromEnum (opt )),
167
+ _ = > @bitCast (@intFromEnum (opt )),
168
168
};
169
169
}
170
170
};
@@ -178,7 +178,7 @@ pub const Dependee = union(enum) {
178
178
namespace_name : NamespaceNameKey ,
179
179
};
180
180
181
- pub fn removeDependenciesForDepender (ip : * InternPool , gpa : Allocator , depender : Depender ) void {
181
+ pub fn removeDependenciesForDepender (ip : * InternPool , gpa : Allocator , depender : AnalSubject ) void {
182
182
var opt_idx = (ip .first_dependency .fetchSwapRemove (depender ) orelse return ).value .toOptional ();
183
183
184
184
while (opt_idx .unwrap ()) | idx | {
@@ -207,7 +207,7 @@ pub fn removeDependenciesForDepender(ip: *InternPool, gpa: Allocator, depender:
207
207
pub const DependencyIterator = struct {
208
208
ip : * const InternPool ,
209
209
next_entry : DepEntry.Index.Optional ,
210
- pub fn next (it : * DependencyIterator ) ? Depender {
210
+ pub fn next (it : * DependencyIterator ) ? AnalSubject {
211
211
const idx = it .next_entry .unwrap () orelse return null ;
212
212
const entry = it .ip .dep_entries .items [@intFromEnum (idx )];
213
213
it .next_entry = entry .next ;
@@ -236,7 +236,7 @@ pub fn dependencyIterator(ip: *const InternPool, dependee: Dependee) DependencyI
236
236
};
237
237
}
238
238
239
- pub fn addDependency (ip : * InternPool , gpa : Allocator , depender : Depender , dependee : Dependee ) Allocator.Error ! void {
239
+ pub fn addDependency (ip : * InternPool , gpa : Allocator , depender : AnalSubject , dependee : Dependee ) Allocator.Error ! void {
240
240
const first_depender_dep : DepEntry.Index.Optional = if (ip .first_dependency .get (depender )) | idx | dep : {
241
241
// The entry already exists, so there is capacity to overwrite it later.
242
242
break :dep idx .toOptional ();
@@ -300,7 +300,7 @@ pub const DepEntry = extern struct {
300
300
/// the first and only entry in one of `intern_pool.*_deps`, and does not
301
301
/// appear in any list by `first_dependency`, but is not in
302
302
/// `free_dep_entries` since `*_deps` stores a reference to it.
303
- depender : Depender .Optional ,
303
+ depender : AnalSubject .Optional ,
304
304
/// Index into `dep_entries` forming a doubly linked list of all dependencies on this dependee.
305
305
/// Used to iterate all dependers for a given dependee during an update.
306
306
/// null if this is the end of the list.
@@ -6958,7 +6958,6 @@ fn finishFuncInstance(
6958
6958
const decl_index = try ip .createDecl (gpa , .{
6959
6959
.name = undefined ,
6960
6960
.src_namespace = fn_owner_decl .src_namespace ,
6961
- .src_line = fn_owner_decl .src_line ,
6962
6961
.has_tv = true ,
6963
6962
.owns_tv = true ,
6964
6963
.val = @import ("Value.zig" ).fromInterned (func_index ),
0 commit comments