From b8d2323b88e68bb5af061dd7e488f51aa0ae8176 Mon Sep 17 00:00:00 2001 From: mlugg Date: Sat, 15 Jun 2024 00:52:26 +0100 Subject: Sema: eliminate Block.src_decl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🦀 src_decl is gone 🦀 This commit eliminates the `src_decl` field from `Sema.Block`. This change goes further to eliminating unnecessary responsibilities of `Decl` in preparation for its major upcoming refactor. The two main remaining reponsibilities had to do with namespace types: `src_decl` was used to determine their line number and their name. The former use case is solved by storing the line number alongside type declarations (and reifications) in ZIR; this is actually more correct, since previously the line number assigned to the type was really the line number of the source declaration it was syntactically contained within, which does not necessarily line up. Consequently, this change makes debug info for namespace types more correct, although I am not sure how debuggers actually utilize this line number, if at all. Naming types was solved by a new field on `Block`, called `type_name_ctx`. In a sense, it represents the "namespace" we are currently within, including comptime function calls etc. We might want to revisit this in future, since the type naming rules seem to be a bit hand-wavey right now. As far as I can tell, there isn't any more preliminary work needed for me to start work on the behemoth task of splitting `Zcu.Decl` into the new `Nav` (Named Addressable Value) and `Cau` (Comptime Analysis Unit) types. This will be a sweeping change, impacting essentially every part of the pipeline after `AstGen`. --- src/main.zig | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/main.zig') diff --git a/src/main.zig b/src/main.zig index 21f7281d74..083954b809 100644 --- a/src/main.zig +++ b/src/main.zig @@ -5965,6 +5965,7 @@ fn cmdAstCheck( .zir = undefined, .mod = undefined, .root_decl = .none, + .path_digest = undefined, }; if (zig_source_file) |file_name| { var f = fs.cwd().openFile(file_name, .{}) catch |err| { @@ -6283,6 +6284,7 @@ fn cmdDumpZir( .zir = try Module.loadZirCache(gpa, f), .mod = undefined, .root_decl = .none, + .path_digest = undefined, }; defer file.zir.deinit(gpa); @@ -6353,6 +6355,7 @@ fn cmdChangelist( .zir = undefined, .mod = undefined, .root_decl = .none, + .path_digest = undefined, }; file.mod = try Package.Module.createLimited(arena, .{ -- cgit v1.2.3