compiler: rename AnalSubject to AnalUnit
I meant to call it this originally, I just got mixed up -- sorry!
This commit is contained in:
@@ -81,7 +81,7 @@ namespace_name_deps: std.AutoArrayHashMapUnmanaged(NamespaceNameKey, DepEntry.In
|
||||
/// Given a `Depender`, points to an entry in `dep_entries` whose `depender`
|
||||
/// matches. The `next_dependee` field can be used to iterate all such entries
|
||||
/// and remove them from the corresponding lists.
|
||||
first_dependency: std.AutoArrayHashMapUnmanaged(AnalSubject, DepEntry.Index) = .{},
|
||||
first_dependency: std.AutoArrayHashMapUnmanaged(AnalUnit, DepEntry.Index) = .{},
|
||||
|
||||
/// Stores dependency information. The hashmaps declared above are used to look
|
||||
/// up entries in this list as required. This is not stored in `extra` so that
|
||||
@@ -132,36 +132,36 @@ pub fn trackZir(ip: *InternPool, gpa: Allocator, file: *Module.File, inst: Zir.I
|
||||
return @enumFromInt(gop.index);
|
||||
}
|
||||
|
||||
/// Analysis Subject. Represents a single entity which undergoes semantic analysis.
|
||||
/// Analysis Unit. Represents a single entity which undergoes semantic analysis.
|
||||
/// This is either a `Decl` (in future `Cau`) or a runtime function.
|
||||
/// The LSB is used as a tag bit.
|
||||
/// This is the "source" of an incremental dependency edge.
|
||||
pub const AnalSubject = packed struct(u32) {
|
||||
pub const AnalUnit = packed struct(u32) {
|
||||
kind: enum(u1) { decl, func },
|
||||
index: u31,
|
||||
pub const Unwrapped = union(enum) {
|
||||
decl: DeclIndex,
|
||||
func: InternPool.Index,
|
||||
};
|
||||
pub fn unwrap(as: AnalSubject) Unwrapped {
|
||||
pub fn unwrap(as: AnalUnit) Unwrapped {
|
||||
return switch (as.kind) {
|
||||
.decl => .{ .decl = @enumFromInt(as.index) },
|
||||
.func => .{ .func = @enumFromInt(as.index) },
|
||||
};
|
||||
}
|
||||
pub fn wrap(raw: Unwrapped) AnalSubject {
|
||||
pub fn wrap(raw: Unwrapped) AnalUnit {
|
||||
return switch (raw) {
|
||||
.decl => |decl| .{ .kind = .decl, .index = @intCast(@intFromEnum(decl)) },
|
||||
.func => |func| .{ .kind = .func, .index = @intCast(@intFromEnum(func)) },
|
||||
};
|
||||
}
|
||||
pub fn toOptional(as: AnalSubject) Optional {
|
||||
pub fn toOptional(as: AnalUnit) Optional {
|
||||
return @enumFromInt(@as(u32, @bitCast(as)));
|
||||
}
|
||||
pub const Optional = enum(u32) {
|
||||
none = std.math.maxInt(u32),
|
||||
_,
|
||||
pub fn unwrap(opt: Optional) ?AnalSubject {
|
||||
pub fn unwrap(opt: Optional) ?AnalUnit {
|
||||
return switch (opt) {
|
||||
.none => null,
|
||||
_ => @bitCast(@intFromEnum(opt)),
|
||||
@@ -178,7 +178,7 @@ pub const Dependee = union(enum) {
|
||||
namespace_name: NamespaceNameKey,
|
||||
};
|
||||
|
||||
pub fn removeDependenciesForDepender(ip: *InternPool, gpa: Allocator, depender: AnalSubject) void {
|
||||
pub fn removeDependenciesForDepender(ip: *InternPool, gpa: Allocator, depender: AnalUnit) void {
|
||||
var opt_idx = (ip.first_dependency.fetchSwapRemove(depender) orelse return).value.toOptional();
|
||||
|
||||
while (opt_idx.unwrap()) |idx| {
|
||||
@@ -207,7 +207,7 @@ pub fn removeDependenciesForDepender(ip: *InternPool, gpa: Allocator, depender:
|
||||
pub const DependencyIterator = struct {
|
||||
ip: *const InternPool,
|
||||
next_entry: DepEntry.Index.Optional,
|
||||
pub fn next(it: *DependencyIterator) ?AnalSubject {
|
||||
pub fn next(it: *DependencyIterator) ?AnalUnit {
|
||||
const idx = it.next_entry.unwrap() orelse return null;
|
||||
const entry = it.ip.dep_entries.items[@intFromEnum(idx)];
|
||||
it.next_entry = entry.next;
|
||||
@@ -236,7 +236,7 @@ pub fn dependencyIterator(ip: *const InternPool, dependee: Dependee) DependencyI
|
||||
};
|
||||
}
|
||||
|
||||
pub fn addDependency(ip: *InternPool, gpa: Allocator, depender: AnalSubject, dependee: Dependee) Allocator.Error!void {
|
||||
pub fn addDependency(ip: *InternPool, gpa: Allocator, depender: AnalUnit, dependee: Dependee) Allocator.Error!void {
|
||||
const first_depender_dep: DepEntry.Index.Optional = if (ip.first_dependency.get(depender)) |idx| dep: {
|
||||
// The entry already exists, so there is capacity to overwrite it later.
|
||||
break :dep idx.toOptional();
|
||||
@@ -300,7 +300,7 @@ pub const DepEntry = extern struct {
|
||||
/// the first and only entry in one of `intern_pool.*_deps`, and does not
|
||||
/// appear in any list by `first_dependency`, but is not in
|
||||
/// `free_dep_entries` since `*_deps` stores a reference to it.
|
||||
depender: AnalSubject.Optional,
|
||||
depender: AnalUnit.Optional,
|
||||
/// Index into `dep_entries` forming a doubly linked list of all dependencies on this dependee.
|
||||
/// Used to iterate all dependers for a given dependee during an update.
|
||||
/// null if this is the end of the list.
|
||||
|
||||
Reference in New Issue
Block a user