From 5b523d04690d8a01cb5d97e4f5a35443cb0cbde8 Mon Sep 17 00:00:00 2001 From: mlugg Date: Sat, 22 Jun 2024 00:29:38 +0100 Subject: Zir: make `src_line` absolute for `declaration` instructions We need special logic for updating line numbers anyway, so it's fine to just use absolute numbers here. This eliminates a field from `Decl`. --- lib/std/zig/AstGen.zig | 14 +++++++------- lib/std/zig/Zir.zig | 4 +--- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'lib/std') diff --git a/lib/std/zig/AstGen.zig b/lib/std/zig/AstGen.zig index eecda76031..febd6b60bb 100644 --- a/lib/std/zig/AstGen.zig +++ b/lib/std/zig/AstGen.zig @@ -4368,7 +4368,7 @@ fn fnDecl( decl_inst, std.zig.hashSrc(tree.getNodeSource(decl_node)), .{ .named = fn_name_token }, - decl_gz.decl_line - gz.decl_line, + decl_gz.decl_line, is_pub, is_export, doc_comment_index, @@ -4529,7 +4529,7 @@ fn globalVarDecl( decl_inst, std.zig.hashSrc(tree.getNodeSource(node)), .{ .named = name_token }, - block_scope.decl_line - gz.decl_line, + block_scope.decl_line, is_pub, is_export, doc_comment_index, @@ -4579,7 +4579,7 @@ fn comptimeDecl( decl_inst, std.zig.hashSrc(tree.getNodeSource(node)), .@"comptime", - decl_block.decl_line - gz.decl_line, + decl_block.decl_line, false, false, .empty, @@ -4629,7 +4629,7 @@ fn usingnamespaceDecl( decl_inst, std.zig.hashSrc(tree.getNodeSource(node)), .@"usingnamespace", - decl_block.decl_line - gz.decl_line, + decl_block.decl_line, is_pub, false, .empty, @@ -4818,7 +4818,7 @@ fn testDecl( decl_inst, std.zig.hashSrc(tree.getNodeSource(node)), test_name, - decl_block.decl_line - gz.decl_line, + decl_block.decl_line, false, false, .empty, @@ -13861,7 +13861,7 @@ fn setDeclaration( decl_inst: Zir.Inst.Index, src_hash: std.zig.SrcHash, name: DeclarationName, - line_offset: u32, + src_line: u32, is_pub: bool, is_export: bool, doc_comment: Zir.NullTerminatedString, @@ -13913,7 +13913,7 @@ fn setDeclaration( .@"comptime" => .@"comptime", .@"usingnamespace" => .@"usingnamespace", }, - .line_offset = line_offset, + .src_line = src_line, .flags = .{ .value_body_len = @intCast(value_len), .is_pub = is_pub, diff --git a/lib/std/zig/Zir.zig b/lib/std/zig/Zir.zig index 5dd69f9923..be462e5edb 100644 --- a/lib/std/zig/Zir.zig +++ b/lib/std/zig/Zir.zig @@ -2598,9 +2598,7 @@ pub const Inst = struct { src_hash_3: u32, /// The name of this `Decl`. Also indicates whether it is a test, comptime block, etc. name: Name, - /// This Decl's line number relative to that of its parent. - /// TODO: column must be encoded similarly to respect non-formatted code! - line_offset: u32, + src_line: u32, flags: Flags, pub const Flags = packed struct(u32) { -- cgit v1.2.3