refactor(ir): extract ProgramIndex, move low-fanout decl facts (A1.1a)
Architecture phase A1.1a. Introduce src/ir/program_index.zig as the single storage owner for declaration-name / import / visibility facts, and move the three low-fanout maps out of the Lowering state bag: - import_flags (owned by ProgramIndex) - module_scopes (borrowed pointer into a core.zig-owned map) - import_graph (borrowed pointer into a core.zig-owned map) Lowering embeds one ProgramIndex by value and reaches every moved fact through self.program_index.<field>; later phases hand collaborator modules a *ProgramIndex instead of *Lowering. 8 call sites in lower.zig + 2 setters in core.zig repointed. No duplicate storage, no fallback path; zig build enforces no missed reference. Mutation-heavy registration (registerStructDecl etc.) stays in Lowering and now writes import_flags through the index. High-fanout maps are deferred to A1.1b. Adds src/ir/program_index.test.zig (init-empty, import_flags round-trip, borrowed-view ownership) wired into the ir.zig barrel. Behavior-preserving: zig build, zig build test, and bash tests/run_examples.sh (350 passed, 0 failed) all green.
This commit is contained in:
@@ -288,8 +288,8 @@ pub const Compilation = struct {
|
||||
lowering.resolved_root = root;
|
||||
lowering.target_config = self.target_config;
|
||||
lowering.diagnostics = &self.diagnostics;
|
||||
lowering.module_scopes = &self.module_scopes;
|
||||
lowering.import_graph = &self.import_graph;
|
||||
lowering.program_index.module_scopes = &self.module_scopes;
|
||||
lowering.program_index.import_graph = &self.import_graph;
|
||||
lowering.lowerRoot(root);
|
||||
if (self.diagnostics.hasErrors()) return error.CompileError;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user