| ... | ... | @@ -475,7 +475,6 @@ pub fn expr(mod: *Module, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) In |
| 475 | 475 | .unwrap_optional => { |
| 476 | 476 | const src_token = tree.firstToken(node); |
| 477 | 477 | |
| 478 | | const src = token_starts[main_tokens[node]]; |
| 479 | 478 | switch (rl) { |
| 480 | 479 | .ref => return gz.addUnTok( |
| 481 | 480 | .optional_payload_safe_ptr, |
| ... | ... | @@ -518,7 +517,6 @@ pub fn expr(mod: *Module, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) In |
| 518 | 517 | if (true) @panic("TODO update for zir-memory-layout"); |
| 519 | 518 | const ident_token = node_datas[node].rhs; |
| 520 | 519 | const name = try mod.identifierTokenString(scope, ident_token); |
| 521 | | const src = token_starts[ident_token]; |
| 522 | 520 | const result = try addZirInstTag(mod, scope, src, .error_value, .{ .name = name }); |
| 523 | 521 | return rvalue(mod, scope, rl, result); |
| 524 | 522 | }, |
| ... | ... | @@ -526,7 +524,6 @@ pub fn expr(mod: *Module, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) In |
| 526 | 524 | if (true) @panic("TODO update for zir-memory-layout"); |
| 527 | 525 | const error_set = try typeExpr(mod, scope, node_datas[node].lhs); |
| 528 | 526 | const payload = try typeExpr(mod, scope, node_datas[node].rhs); |
| 529 | | const src = token_starts[main_tokens[node]]; |
| 530 | 527 | const result = try addZIRBinOp(mod, scope, src, .error_union_type, error_set, payload); |
| 531 | 528 | return rvalue(mod, scope, rl, result); |
| 532 | 529 | }, |
| ... | ... | @@ -534,14 +531,12 @@ pub fn expr(mod: *Module, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) In |
| 534 | 531 | if (true) @panic("TODO update for zir-memory-layout"); |
| 535 | 532 | const lhs = try typeExpr(mod, scope, node_datas[node].lhs); |
| 536 | 533 | const rhs = try typeExpr(mod, scope, node_datas[node].rhs); |
| 537 | | const src = token_starts[main_tokens[node]]; |
| 538 | 534 | const result = try addZIRBinOp(mod, scope, src, .merge_error_sets, lhs, rhs); |
| 539 | 535 | return rvalue(mod, scope, rl, result); |
| 540 | 536 | }, |
| 541 | 537 | .anyframe_literal => { |
| 542 | 538 | if (true) @panic("TODO update for zir-memory-layout"); |
| 543 | 539 | const main_token = main_tokens[node]; |
| 544 | | const src = token_starts[main_token]; |
| 545 | 540 | const result = try addZIRInstConst(mod, scope, src, .{ |
| 546 | 541 | .ty = Type.initTag(.type), |
| 547 | 542 | .val = Value.initTag(.anyframe_type), |
| ... | ... | @@ -550,7 +545,6 @@ pub fn expr(mod: *Module, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) In |
| 550 | 545 | }, |
| 551 | 546 | .anyframe_type => { |
| 552 | 547 | if (true) @panic("TODO update for zir-memory-layout"); |
| 553 | | const src = token_starts[node_datas[node].lhs]; |
| 554 | 548 | const return_type = try typeExpr(mod, scope, node_datas[node].rhs); |
| 555 | 549 | const result = try addZIRUnOp(mod, scope, src, .anyframe_type, return_type); |
| 556 | 550 | return rvalue(mod, scope, rl, result); |
| ... | ... | @@ -724,7 +718,6 @@ pub fn comptimeExpr( |
| 724 | 718 | // instruction is the block's result value. |
| 725 | 719 | _ = try expr(mod, &block_scope.base, rl, node); |
| 726 | 720 | |
| 727 | | const src = token_starts[tree.firstToken(node)]; |
| 728 | 721 | const block = try addZIRInstBlock(mod, parent_scope, src, .block_comptime_flat, .{ |
| 729 | 722 | .instructions = try block_scope.arena.dupe(zir.Inst.Ref, block_scope.instructions.items), |
| 730 | 723 | }); |
| ... | ... | @@ -744,7 +737,6 @@ fn breakExpr( |
| 744 | 737 | const main_tokens = tree.nodes.items(.main_token); |
| 745 | 738 | const token_starts = tree.tokens.items(.start); |
| 746 | 739 | |
| 747 | | const src = token_starts[main_tokens[node]]; |
| 748 | 740 | const break_label = node_datas[node].lhs; |
| 749 | 741 | const rhs = node_datas[node].rhs; |
| 750 | 742 | |
| ... | ... | @@ -823,7 +815,6 @@ fn continueExpr( |
| 823 | 815 | const main_tokens = tree.nodes.items(.main_token); |
| 824 | 816 | const token_starts = tree.tokens.items(.start); |
| 825 | 817 | |
| 826 | | const src = token_starts[main_tokens[node]]; |
| 827 | 818 | const break_label = node_datas[node].lhs; |
| 828 | 819 | |
| 829 | 820 | // Look for the label in the scope. |
| ... | ... | @@ -958,7 +949,6 @@ fn labeledBlockExpr( |
| 958 | 949 | const lbrace = main_tokens[block_node]; |
| 959 | 950 | const label_token = lbrace - 2; |
| 960 | 951 | assert(token_tags[label_token] == .identifier); |
| 961 | | const src = token_starts[lbrace]; |
| 962 | 952 | |
| 963 | 953 | try checkLabelRedefinition(mod, parent_scope, label_token); |
| 964 | 954 | |
| ... | ... | @@ -1321,7 +1311,6 @@ fn assignOp( |
| 1321 | 1311 | const lhs = try addZIRUnOp(mod, scope, lhs_ptr.src, .deref, lhs_ptr); |
| 1322 | 1312 | const lhs_type = try addZIRUnOp(mod, scope, lhs_ptr.src, .typeof, lhs); |
| 1323 | 1313 | const rhs = try expr(mod, scope, .{ .ty = lhs_type }, node_datas[infix_node].rhs); |
| 1324 | | const src = token_starts[main_tokens[infix_node]]; |
| 1325 | 1314 | const result = try addZIRBinOp(mod, scope, src, op_inst_tag, lhs, rhs); |
| 1326 | 1315 | _ = try addZIRBinOp(mod, scope, src, .store, lhs_ptr, result); |
| 1327 | 1316 | } |
| ... | ... | @@ -1360,7 +1349,6 @@ fn negation( |
| 1360 | 1349 | const main_tokens = tree.nodes.items(.main_token); |
| 1361 | 1350 | const token_starts = tree.tokens.items(.start); |
| 1362 | 1351 | |
| 1363 | | const src = token_starts[main_tokens[node]]; |
| 1364 | 1352 | const lhs = try addZIRInstConst(mod, scope, src, .{ |
| 1365 | 1353 | .ty = Type.initTag(.comptime_int), |
| 1366 | 1354 | .val = Value.initTag(.zero), |
| ... | ... | @@ -1379,8 +1367,6 @@ fn ptrType( |
| 1379 | 1367 | const tree = scope.tree(); |
| 1380 | 1368 | const token_starts = tree.tokens.items(.start); |
| 1381 | 1369 | |
| 1382 | | const src = token_starts[ptr_info.ast.main_token]; |
| 1383 | | |
| 1384 | 1370 | const simple = ptr_info.allowzero_token == null and |
| 1385 | 1371 | ptr_info.ast.align_node == 0 and |
| 1386 | 1372 | ptr_info.volatile_token == null and |
| ... | ... | @@ -1426,7 +1412,6 @@ fn arrayType(mod: *Module, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) ! |
| 1426 | 1412 | const node_datas = tree.nodes.items(.data); |
| 1427 | 1413 | const token_starts = tree.tokens.items(.start); |
| 1428 | 1414 | |
| 1429 | | const src = token_starts[main_tokens[node]]; |
| 1430 | 1415 | const usize_type = try addZIRInstConst(mod, scope, src, .{ |
| 1431 | 1416 | .ty = Type.initTag(.type), |
| 1432 | 1417 | .val = Value.initTag(.usize_type), |
| ... | ... | @@ -1456,7 +1441,6 @@ fn arrayTypeSentinel(mod: *Module, scope: *Scope, rl: ResultLoc, node: ast.Node. |
| 1456 | 1441 | |
| 1457 | 1442 | const len_node = node_datas[node].lhs; |
| 1458 | 1443 | const extra = tree.extraData(node_datas[node].rhs, ast.Node.ArrayTypeSentinel); |
| 1459 | | const src = token_starts[main_tokens[node]]; |
| 1460 | 1444 | const usize_type = try addZIRInstConst(mod, scope, src, .{ |
| 1461 | 1445 | .ty = Type.initTag(.type), |
| 1462 | 1446 | .val = Value.initTag(.usize_type), |
| ... | ... | @@ -1529,7 +1513,6 @@ fn errorSetDecl( |
| 1529 | 1513 | } |
| 1530 | 1514 | } |
| 1531 | 1515 | } |
| 1532 | | const src = token_starts[error_token]; |
| 1533 | 1516 | const result = try addZIRInst(mod, scope, src, zir.Inst.ErrorSet, .{ .fields = fields }, .{}); |
| 1534 | 1517 | return rvalue(mod, scope, rl, result); |
| 1535 | 1518 | } |
| ... | ... | @@ -1551,8 +1534,6 @@ fn orelseCatchExpr( |
| 1551 | 1534 | const tree = scope.tree(); |
| 1552 | 1535 | const token_starts = tree.tokens.items(.start); |
| 1553 | 1536 | |
| 1554 | | const src = token_starts[op_token]; |
| 1555 | | |
| 1556 | 1537 | var block_scope: Scope.GenZir = .{ |
| 1557 | 1538 | .parent = scope, |
| 1558 | 1539 | .decl = scope.ownerDecl().?, |
| ... | ... | @@ -1738,7 +1719,6 @@ pub fn fieldAccess(mod: *Module, scope: *Scope, rl: ResultLoc, node: ast.Node.In |
| 1738 | 1719 | const node_datas = tree.nodes.items(.data); |
| 1739 | 1720 | |
| 1740 | 1721 | const dot_token = main_tokens[node]; |
| 1741 | | const src = token_starts[dot_token]; |
| 1742 | 1722 | const field_ident = dot_token + 1; |
| 1743 | 1723 | const field_name = try mod.identifierTokenString(scope, field_ident); |
| 1744 | 1724 | if (rl == .ref) { |
| ... | ... | @@ -1766,7 +1746,6 @@ fn arrayAccess( |
| 1766 | 1746 | const token_starts = tree.tokens.items(.start); |
| 1767 | 1747 | const node_datas = tree.nodes.items(.data); |
| 1768 | 1748 | |
| 1769 | | const src = token_starts[main_tokens[node]]; |
| 1770 | 1749 | const usize_type = try addZIRInstConst(mod, scope, src, .{ |
| 1771 | 1750 | .ty = Type.initTag(.type), |
| 1772 | 1751 | .val = Value.initTag(.usize_type), |
| ... | ... | @@ -1794,8 +1773,6 @@ fn sliceExpr( |
| 1794 | 1773 | const tree = scope.tree(); |
| 1795 | 1774 | const token_starts = tree.tokens.items(.start); |
| 1796 | 1775 | |
| 1797 | | const src = token_starts[slice.ast.lbracket]; |
| 1798 | | |
| 1799 | 1776 | const usize_type = try addZIRInstConst(mod, scope, src, .{ |
| 1800 | 1777 | .ty = Type.initTag(.type), |
| 1801 | 1778 | .val = Value.initTag(.usize_type), |
| ... | ... | @@ -1848,7 +1825,6 @@ fn simpleBinOp( |
| 1848 | 1825 | |
| 1849 | 1826 | const lhs = try expr(mod, scope, .none, node_datas[infix_node].lhs); |
| 1850 | 1827 | const rhs = try expr(mod, scope, .none, node_datas[infix_node].rhs); |
| 1851 | | const src = token_starts[main_tokens[infix_node]]; |
| 1852 | 1828 | const result = try addZIRBinOp(mod, scope, src, op_inst_tag, lhs, rhs); |
| 1853 | 1829 | return rvalue(mod, scope, rl, result); |
| 1854 | 1830 | } |
| ... | ... | @@ -1866,7 +1842,6 @@ fn boolBinOp( |
| 1866 | 1842 | const main_tokens = tree.nodes.items(.main_token); |
| 1867 | 1843 | const token_starts = tree.tokens.items(.start); |
| 1868 | 1844 | |
| 1869 | | const src = token_starts[main_tokens[infix_node]]; |
| 1870 | 1845 | const bool_type = try addZIRInstConst(mod, scope, src, .{ |
| 1871 | 1846 | .ty = Type.initTag(.type), |
| 1872 | 1847 | .val = Value.initTag(.bool_type), |
| ... | ... | @@ -2880,7 +2855,6 @@ fn parseStringLiteral(mod: *Module, scope: *Scope, token: ast.TokenIndex) ![]u8 |
| 2880 | 2855 | const bytes = std.zig.parseStringLiteral(arena, unparsed, &bad_index) catch |err| switch (err) { |
| 2881 | 2856 | error.InvalidCharacter => { |
| 2882 | 2857 | const bad_byte = unparsed[bad_index]; |
| 2883 | | const src = token_starts[token]; |
| 2884 | 2858 | return mod.fail(scope, src + bad_index, "invalid string literal character: '{c}'", .{ |
| 2885 | 2859 | bad_byte, |
| 2886 | 2860 | }); |
| ... | ... | @@ -2903,7 +2877,6 @@ fn stringLiteral( |
| 2903 | 2877 | |
| 2904 | 2878 | const str_lit_token = main_tokens[str_lit]; |
| 2905 | 2879 | const bytes = try parseStringLiteral(mod, scope, str_lit_token); |
| 2906 | | const src = token_starts[str_lit_token]; |
| 2907 | 2880 | const str_inst = try addZIRInst(mod, scope, src, zir.Inst.Str, .{ .bytes = bytes }, .{}); |
| 2908 | 2881 | return rvalue(mod, scope, rl, str_inst); |
| 2909 | 2882 | } |
| ... | ... | @@ -2953,7 +2926,6 @@ fn multilineStringLiteral( |
| 2953 | 2926 | mem.copy(u8, bytes[byte_i..], line_bytes); |
| 2954 | 2927 | byte_i += line_bytes.len; |
| 2955 | 2928 | } |
| 2956 | | const src = token_starts[start]; |
| 2957 | 2929 | const str_inst = try addZIRInst(mod, scope, src, zir.Inst.Str, .{ .bytes = bytes }, .{}); |
| 2958 | 2930 | return rvalue(mod, scope, rl, str_inst); |
| 2959 | 2931 | } |
| ... | ... | @@ -2965,7 +2937,6 @@ fn charLiteral(mod: *Module, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) |
| 2965 | 2937 | const main_token = main_tokens[node]; |
| 2966 | 2938 | const token_starts = tree.tokens.items(.start); |
| 2967 | 2939 | |
| 2968 | | const src = token_starts[main_token]; |
| 2969 | 2940 | const slice = tree.tokenSlice(main_token); |
| 2970 | 2941 | |
| 2971 | 2942 | var bad_index: usize = undefined; |
| ... | ... | @@ -3025,7 +2996,6 @@ fn floatLiteral( |
| 3025 | 2996 | const float_number = std.fmt.parseFloat(f128, bytes) catch |e| switch (e) { |
| 3026 | 2997 | error.InvalidCharacter => unreachable, // validated by tokenizer |
| 3027 | 2998 | }; |
| 3028 | | const src = token_starts[main_token]; |
| 3029 | 2999 | const result = try addZIRInstConst(mod, scope, src, .{ |
| 3030 | 3000 | .ty = Type.initTag(.comptime_float), |
| 3031 | 3001 | .val = try Value.Tag.float_128.create(arena, float_number), |
| ... | ... | @@ -3048,7 +3018,6 @@ fn asmExpr(mod: *Module, scope: *Scope, rl: ResultLoc, full: ast.full.Asm) Inner |
| 3048 | 3018 | const inputs = try arena.alloc([]const u8, full.inputs.len); |
| 3049 | 3019 | const args = try arena.alloc(zir.Inst.Ref, full.inputs.len); |
| 3050 | 3020 | |
| 3051 | | const src = token_starts[full.ast.asm_token]; |
| 3052 | 3021 | const str_type = try addZIRInstConst(mod, scope, src, .{ |
| 3053 | 3022 | .ty = Type.initTag(.type), |
| 3054 | 3023 | .val = Value.initTag(.const_slice_u8_type), |
| ... | ... | @@ -3258,7 +3227,6 @@ fn builtinCall( |
| 3258 | 3227 | }); |
| 3259 | 3228 | } |
| 3260 | 3229 | } |
| 3261 | | const src = token_starts[builtin_token]; |
| 3262 | 3230 | |
| 3263 | 3231 | switch (info.tag) { |
| 3264 | 3232 | .ptr_to_int => { |