diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-03-26 23:46:37 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-03-26 23:46:37 -0700 |
| commit | 1f5617ac078041532dd5933ae1cf0ccb13c3cd8a (patch) | |
| tree | ab72fff671634323a6993788dab8ba8812ef22f9 /src/Module.zig | |
| parent | da731e18c94fdd985812ec27cfdacff5199e55d2 (diff) | |
| download | zig-1f5617ac078041532dd5933ae1cf0ccb13c3cd8a.tar.gz zig-1f5617ac078041532dd5933ae1cf0ccb13c3cd8a.zip | |
stage2: implement bitwise expr and error literals
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/Module.zig b/src/Module.zig index cb23cf3c8c..c8c1f06538 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -1599,7 +1599,7 @@ pub const SrcLoc = struct { const token_starts = tree.tokens.items(.start); return token_starts[tok_index]; }, - .node_offset => |node_off| { + .node_offset, .node_offset_bin_op => |node_off| { const decl = src_loc.container.decl; const node = decl.relativeToNodeIndex(node_off); const tree = decl.container.file_scope.base.tree(); @@ -1660,9 +1660,28 @@ pub const SrcLoc = struct { const token_starts = tree.tokens.items(.start); return token_starts[tok_index]; }, - .node_offset_bin_op => @panic("TODO"), - .node_offset_bin_lhs => @panic("TODO"), - .node_offset_bin_rhs => @panic("TODO"), + .node_offset_bin_lhs => |node_off| { + const decl = src_loc.container.decl; + const node = decl.relativeToNodeIndex(node_off); + const tree = decl.container.file_scope.base.tree(); + const node_datas = tree.nodes.items(.data); + const src_node = node_datas[node].lhs; + const main_tokens = tree.nodes.items(.main_token); + const tok_index = main_tokens[src_node]; + const token_starts = tree.tokens.items(.start); + return token_starts[tok_index]; + }, + .node_offset_bin_rhs => |node_off| { + const decl = src_loc.container.decl; + const node = decl.relativeToNodeIndex(node_off); + const tree = decl.container.file_scope.base.tree(); + const node_datas = tree.nodes.items(.data); + const src_node = node_datas[node].rhs; + const main_tokens = tree.nodes.items(.main_token); + const tok_index = main_tokens[src_node]; + const token_starts = tree.tokens.items(.start); + return token_starts[tok_index]; + }, } } }; |
