This commit is contained in:
agra
2026-02-26 14:46:21 +02:00
parent dd14f1206b
commit 2552882ce6
14 changed files with 6433 additions and 159 deletions

View File

@@ -272,6 +272,30 @@ pub const TypeTable = struct {
return id;
}
/// Update the TypeInfo for an existing TypeId. Used when a forward-declared
/// type (e.g., struct with empty fields) gets its full definition later.
pub fn update(self: *TypeTable, id: TypeId, info: TypeInfo) void {
const idx = id.index();
if (idx < self.infos.items.len) {
self.infos.items[idx] = info;
}
}
/// Find a named type (struct/union/enum) by its StringId name.
/// Returns the TypeId if found, null otherwise.
pub fn findByName(self: *const TypeTable, name: StringId) ?TypeId {
for (self.infos.items, 0..) |info, i| {
const n: ?StringId = switch (info) {
.@"struct" => |s| s.name,
.@"union" => |u| u.name,
.@"enum" => |e| e.name,
else => null,
};
if (n != null and n.? == name) return TypeId.fromIndex(@intCast(i));
}
return null;
}
// ── Convenience constructors ────────────────────────────────────────
pub fn ptrTo(self: *TypeTable, pointee: TypeId) TypeId {