05
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user