From 0134e5d2a1a5042b1485b7bb121870d2eaeb00b6 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Tue, 3 Oct 2023 14:55:18 +0200 Subject: codegen: separate getAnonDeclVAddr into lowerAnonDecl and the former Implement the stub for Elf. I believe that separating the concerns, namely, having an interface function that is responsible for signalling the linker to lower the anon decl only, and a separate function to obtain the decl's vaddr is preferable since it allows us to handle codegen errors in a simpler way. --- src/codegen.zig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/codegen.zig') diff --git a/src/codegen.zig b/src/codegen.zig index f2eff7806a..dd1b6e0cbf 100644 --- a/src/codegen.zig +++ b/src/codegen.zig @@ -739,7 +739,6 @@ fn lowerAnonDeclRef( debug_output: DebugInfoOutput, reloc_info: RelocInfo, ) CodeGenError!Result { - _ = src_loc; _ = debug_output; const target = bin_file.options.target; const mod = bin_file.options.module.?; @@ -752,6 +751,12 @@ fn lowerAnonDeclRef( return Result.ok; } + const res = try bin_file.lowerAnonDecl(decl_val, src_loc); + switch (res) { + .ok => {}, + .fail => |em| return .{ .fail = em }, + } + const vaddr = try bin_file.getAnonDeclVAddr(decl_val, .{ .parent_atom_index = reloc_info.parent_atom_index, .offset = code.items.len, -- cgit v1.2.3