aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-07-06 11:36:39 +0300
committerVeikka Tuominen <git@vexu.eu>2022-07-07 10:50:06 +0300
commit2ca752ea1ad4afb9d510687ae097c709668316b9 (patch)
treeeaff16d368cff38f09a05d8dec03ec3dea040435 /src/Module.zig
parent89cef9f5f731f8f33dc935aac3c21bd57c92900d (diff)
downloadzig-2ca752ea1ad4afb9d510687ae097c709668316b9.tar.gz
zig-2ca752ea1ad4afb9d510687ae097c709668316b9.zip
Module: add `.node_offset_un_op`
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Module.zig b/src/Module.zig
index 1f70a44df5..d4e981f834 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -2501,6 +2501,16 @@ pub const SrcLoc = struct {
const token_starts = tree.tokens.items(.start);
return token_starts[tok_index];
},
+ .node_offset_un_op => |node_off| {
+ const tree = try src_loc.file_scope.getTree(gpa);
+ const node_datas = tree.nodes.items(.data);
+ const node = src_loc.declRelativeToNodeIndex(node_off);
+
+ const main_tokens = tree.nodes.items(.main_token);
+ const tok_index = main_tokens[node_datas[node].lhs];
+ const token_starts = tree.tokens.items(.start);
+ return token_starts[tok_index];
+ },
}
}
@@ -2728,6 +2738,9 @@ pub const LazySrcLoc = union(enum) {
/// to the elem expression.
/// The Decl is determined contextually.
node_offset_array_type_elem: i32,
+ /// The source location points to the operand of an unary expression.
+ /// The Decl is determined contextually.
+ node_offset_un_op: i32,
pub const nodeOffset = if (TracedOffset.want_tracing) nodeOffsetDebug else nodeOffsetRelease;
@@ -2788,6 +2801,7 @@ pub const LazySrcLoc = union(enum) {
.node_offset_array_type_len,
.node_offset_array_type_sentinel,
.node_offset_array_type_elem,
+ .node_offset_un_op,
=> .{
.file_scope = decl.getFileScope(),
.parent_decl_node = decl.src_node,