refactor(ir): move declaration maps into ProgramIndex (A1.1b)
Architecture phase A1.1b — mechanical storage relocation. Move the 9
declaration-fact maps out of the Lowering state bag into ProgramIndex:
high-fanout: fn_ast_map, foreign_class_map, global_names, type_alias_map
medium-fanout: struct_template_map, protocol_decl_map, protocol_ast_map,
module_const_map, ufcs_alias_map
168 self.<map> sites in lower.zig repointed to self.program_index.<map>;
external readers repointed too (core.zig foreign_class_map iteration;
lower.test.zig fn_ast_map / foreign_class_map). No duplicate storage, no
fallback path; zig build enforces no missed reference.
The four maps whose value types were Lowering-private pull those types into
program_index.zig as pub (GlobalInfo, StructTemplate + TemplateParam,
ProtocolDeclInfo + ProtocolMethodInfo, ModuleConstInfo); lower.zig aliases
them at file scope so call sites are unchanged.
Behavior is preserved exactly:
- per-map allocator unchanged — import_flags/fn_ast_map/global_names use the
lowering allocator (ProgramIndex.init), the other 7 keep their page_allocator
inline defaults;
- ProgramIndex.deinit frees only the 10 owned maps, never the borrowed
module_scopes / import_graph;
- TypeTable.aliases still borrows &self.program_index.type_alias_map, loaned at
lowerRoot with the same late-binding lifetime.
Extends program_index.test.zig with declaration-map round-trips (fn AST, type
alias, global, module const, foreign class, protocol decl/AST, struct template,
ufcs alias).
Registration logic (registerStructDecl / registerProtocolDecl /
registerForeignClassDecl, ...) stays in Lowering, writing through the index.
Gate green: zig build, zig build test, bash tests/run_examples.sh
(350 passed, 0 failed). lower.zig 19433 -> 19393 lines.
This commit is contained in:
@@ -479,7 +479,7 @@ test "lower: objcTypeEncodingFromSignature emits @ for Obj-C class pointers" {
|
||||
.is_foreign = true,
|
||||
.is_main = false,
|
||||
};
|
||||
try lowering.foreign_class_map.put("NSString", &ns_fcd);
|
||||
try lowering.program_index.foreign_class_map.put("NSString", &ns_fcd);
|
||||
|
||||
// Return *NSString, no args: "@@:"
|
||||
const e1 = try lowering.objcTypeEncodingFromSignature(ns_ptr, &.{}, null);
|
||||
@@ -510,7 +510,7 @@ test "lower: objcTypeEncodingFromSignature unwraps optional to wire type" {
|
||||
.is_foreign = true,
|
||||
.is_main = false,
|
||||
};
|
||||
try lowering.foreign_class_map.put("NSString", &ns_fcd);
|
||||
try lowering.program_index.foreign_class_map.put("NSString", &ns_fcd);
|
||||
|
||||
// `?s64 -> ?*NSString` collapses to `q -> @` at the Obj-C boundary.
|
||||
const opt_s64 = module.types.optionalOf(.s64);
|
||||
@@ -750,8 +750,8 @@ test "E1.4b converge inferred error sets: empty -> warning, raising -> converged
|
||||
r_body.* = .{ .span = .{ .start = 0, .end = 0 }, .data = .{ .block = .{ .stmts = r_stmts } } };
|
||||
const raiser_fd = ast.FnDecl{ .name = "raiser", .params = &.{}, .return_type = r_rt, .body = r_body };
|
||||
|
||||
lowering.fn_ast_map.put("stub", &stub_fd) catch unreachable;
|
||||
lowering.fn_ast_map.put("raiser", &raiser_fd) catch unreachable;
|
||||
lowering.program_index.fn_ast_map.put("stub", &stub_fd) catch unreachable;
|
||||
lowering.program_index.fn_ast_map.put("raiser", &raiser_fd) catch unreachable;
|
||||
|
||||
lowering.convergeInferredErrorSets();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user