aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2024-06-22 00:29:38 +0100
committermlugg <mlugg@mlugg.co.uk>2024-06-26 05:28:03 +0100
commit5b523d04690d8a01cb5d97e4f5a35443cb0cbde8 (patch)
treea7c8c3d8266f103e64b1876a0dca90a5a82b663f /lib/std
parent3e9ab6aa7b2d90c25cb906d425a148abf9da3dcb (diff)
downloadzig-5b523d04690d8a01cb5d97e4f5a35443cb0cbde8.tar.gz
zig-5b523d04690d8a01cb5d97e4f5a35443cb0cbde8.zip
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`.
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/zig/AstGen.zig14
-rw-r--r--lib/std/zig/Zir.zig4
2 files changed, 8 insertions, 10 deletions
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) {