authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-08-03 17:59:11-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-08-03 17:59:11-04:00
logc5f1925bc801c34133437d0d78de6b1d520f9f12
tree2dbe57d7ed8899750fad57359269157c5dc6a302
parent5dfcd09e496160054d4f333500d084e35f2fbdd2

when decls don't change, don't regenerate them


4 files changed, 149 insertions(+), 119 deletions(-)

src-self-hosted/compilation.zig+19-7
......@@ -876,13 +876,25 @@ pub const Compilation = struct {
876876
877877 if (existing_decls.remove(name)) |entry| {
878878 // compare new code to existing
879 const existing_decl = entry.value;
880 // Just compare the old bytes to the new bytes of the top level decl.
881 // Even if the AST is technically the same, we want error messages to display
882 // from the most recent source.
883 @panic("TODO handle decl comparison");
884 // Add the new thing before dereferencing the old thing. This way we don't end
885 // up pointlessly re-creating things we end up using in the new thing.
879 if (entry.value.cast(Decl.Fn)) |existing_fn_decl| {
880 // Just compare the old bytes to the new bytes of the top level decl.
881 // Even if the AST is technically the same, we want error messages to display
882 // from the most recent source.
883 const old_decl_src = existing_fn_decl.base.tree_scope.tree.getNodeSource(
884 &existing_fn_decl.fn_proto.base,
885 );
886 const new_decl_src = tree_scope.tree.getNodeSource(&fn_proto.base);
887 if (mem.eql(u8, old_decl_src, new_decl_src)) {
888 // it's the same, we can skip this decl
889 continue;
890 } else {
891 @panic("TODO decl changed implementation");
892 // Add the new thing before dereferencing the old thing. This way we don't end
893 // up pointlessly re-creating things we end up using in the new thing.
894 }
895 } else {
896 @panic("TODO decl changed kind");
897 }
886898 } else {
887899 // add new decl
888900 const fn_decl = try self.gpa().create(Decl.Fn{
src-self-hosted/decl.zig+5-1
......@@ -22,6 +22,11 @@ pub const Decl = struct {
2222
2323 pub const Table = std.HashMap([]const u8, *Decl, mem.hash_slice_u8, mem.eql_slice_u8);
2424
25 pub fn cast(base: *Decl, comptime T: type) ?*T {
26 if (base.id != @field(Id, @typeName(T))) return null;
27 return @fieldParentPtr(T, "base", base);
28 }
29
2530 pub fn isExported(base: *const Decl, tree: *ast.Tree) bool {
2631 switch (base.id) {
2732 Id.Fn => {
......@@ -98,4 +103,3 @@ pub const Decl = struct {
98103 base: Decl,
99104 };
100105};
101
std/segmented_list.zig+13-5
......@@ -2,7 +2,7 @@ const std = @import("index.zig");
22const assert = std.debug.assert;
33const Allocator = std.mem.Allocator;
44
5// Imagine that `fn at(self: &Self, index: usize) &T` is a customer asking for a box
5// Imagine that `fn at(self: *Self, index: usize) &T` is a customer asking for a box
66// from a warehouse, based on a flat array, boxes ordered from 0 to N - 1.
77// But the warehouse actually stores boxes in shelves of increasing powers of 2 sizes.
88// So when the customer requests a box index, we have to translate it to shelf index
......@@ -93,6 +93,14 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
9393
9494 pub const prealloc_count = prealloc_item_count;
9595
96 fn AtType(comptime SelfType: type) type {
97 if (@typeInfo(SelfType).Pointer.is_const) {
98 return *const T;
99 } else {
100 return *T;
101 }
102 }
103
96104 /// Deinitialize with `deinit`
97105 pub fn init(allocator: *Allocator) Self {
98106 return Self{
......@@ -109,7 +117,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
109117 self.* = undefined;
110118 }
111119
112 pub fn at(self: *Self, i: usize) *T {
120 pub fn at(self: var, i: usize) AtType(@typeOf(self)) {
113121 assert(i < self.len);
114122 return self.uncheckedAt(i);
115123 }
......@@ -133,7 +141,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
133141 if (self.len == 0) return null;
134142
135143 const index = self.len - 1;
136 const result = self.uncheckedAt(index).*;
144 const result = uncheckedAt(self, index).*;
137145 self.len = index;
138146 return result;
139147 }
......@@ -141,7 +149,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
141149 pub fn addOne(self: *Self) !*T {
142150 const new_length = self.len + 1;
143151 try self.growCapacity(new_length);
144 const result = self.uncheckedAt(self.len);
152 const result = uncheckedAt(self, self.len);
145153 self.len = new_length;
146154 return result;
147155 }
......@@ -193,7 +201,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
193201 self.dynamic_segments = self.allocator.shrink([*]T, self.dynamic_segments, new_cap_shelf_count);
194202 }
195203
196 pub fn uncheckedAt(self: *Self, index: usize) *T {
204 pub fn uncheckedAt(self: var, index: usize) AtType(@typeOf(self)) {
197205 if (index < prealloc_item_count) {
198206 return &self.prealloc_segment[index];
199207 }
std/zig/ast.zig+112-106
......@@ -32,6 +32,12 @@ pub const Tree = struct {
3232 return self.source[token.start..token.end];
3333 }
3434
35 pub fn getNodeSource(self: *const Tree, node: *const Node) []const u8 {
36 const first_token = self.tokens.at(node.firstToken());
37 const last_token = self.tokens.at(node.lastToken());
38 return self.source[first_token.start..last_token.end];
39 }
40
3541 pub const Location = struct {
3642 line: usize,
3743 column: usize,
......@@ -338,7 +344,7 @@ pub const Node = struct {
338344 unreachable;
339345 }
340346
341 pub fn firstToken(base: *Node) TokenIndex {
347 pub fn firstToken(base: *const Node) TokenIndex {
342348 comptime var i = 0;
343349 inline while (i < @memberCount(Id)) : (i += 1) {
344350 if (base.id == @field(Id, @memberName(Id, i))) {
......@@ -349,7 +355,7 @@ pub const Node = struct {
349355 unreachable;
350356 }
351357
352 pub fn lastToken(base: *Node) TokenIndex {
358 pub fn lastToken(base: *const Node) TokenIndex {
353359 comptime var i = 0;
354360 inline while (i < @memberCount(Id)) : (i += 1) {
355361 if (base.id == @field(Id, @memberName(Id, i))) {
......@@ -473,11 +479,11 @@ pub const Node = struct {
473479 return null;
474480 }
475481
476 pub fn firstToken(self: *Root) TokenIndex {
482 pub fn firstToken(self: *const Root) TokenIndex {
477483 return if (self.decls.len == 0) self.eof_token else (self.decls.at(0).*).firstToken();
478484 }
479485
480 pub fn lastToken(self: *Root) TokenIndex {
486 pub fn lastToken(self: *const Root) TokenIndex {
481487 return if (self.decls.len == 0) self.eof_token else (self.decls.at(self.decls.len - 1).*).lastToken();
482488 }
483489 };
......@@ -518,7 +524,7 @@ pub const Node = struct {
518524 return null;
519525 }
520526
521 pub fn firstToken(self: *VarDecl) TokenIndex {
527 pub fn firstToken(self: *const VarDecl) TokenIndex {
522528 if (self.visib_token) |visib_token| return visib_token;
523529 if (self.comptime_token) |comptime_token| return comptime_token;
524530 if (self.extern_export_token) |extern_export_token| return extern_export_token;
......@@ -526,7 +532,7 @@ pub const Node = struct {
526532 return self.mut_token;
527533 }
528534
529 pub fn lastToken(self: *VarDecl) TokenIndex {
535 pub fn lastToken(self: *const VarDecl) TokenIndex {
530536 return self.semicolon_token;
531537 }
532538 };
......@@ -548,12 +554,12 @@ pub const Node = struct {
548554 return null;
549555 }
550556
551 pub fn firstToken(self: *Use) TokenIndex {
557 pub fn firstToken(self: *const Use) TokenIndex {
552558 if (self.visib_token) |visib_token| return visib_token;
553559 return self.use_token;
554560 }
555561
556 pub fn lastToken(self: *Use) TokenIndex {
562 pub fn lastToken(self: *const Use) TokenIndex {
557563 return self.semicolon_token;
558564 }
559565 };
......@@ -575,11 +581,11 @@ pub const Node = struct {
575581 return null;
576582 }
577583
578 pub fn firstToken(self: *ErrorSetDecl) TokenIndex {
584 pub fn firstToken(self: *const ErrorSetDecl) TokenIndex {
579585 return self.error_token;
580586 }
581587
582 pub fn lastToken(self: *ErrorSetDecl) TokenIndex {
588 pub fn lastToken(self: *const ErrorSetDecl) TokenIndex {
583589 return self.rbrace_token;
584590 }
585591 };
......@@ -618,14 +624,14 @@ pub const Node = struct {
618624 return null;
619625 }
620626
621 pub fn firstToken(self: *ContainerDecl) TokenIndex {
627 pub fn firstToken(self: *const ContainerDecl) TokenIndex {
622628 if (self.layout_token) |layout_token| {
623629 return layout_token;
624630 }
625631 return self.kind_token;
626632 }
627633
628 pub fn lastToken(self: *ContainerDecl) TokenIndex {
634 pub fn lastToken(self: *const ContainerDecl) TokenIndex {
629635 return self.rbrace_token;
630636 }
631637 };
......@@ -646,12 +652,12 @@ pub const Node = struct {
646652 return null;
647653 }
648654
649 pub fn firstToken(self: *StructField) TokenIndex {
655 pub fn firstToken(self: *const StructField) TokenIndex {
650656 if (self.visib_token) |visib_token| return visib_token;
651657 return self.name_token;
652658 }
653659
654 pub fn lastToken(self: *StructField) TokenIndex {
660 pub fn lastToken(self: *const StructField) TokenIndex {
655661 return self.type_expr.lastToken();
656662 }
657663 };
......@@ -679,11 +685,11 @@ pub const Node = struct {
679685 return null;
680686 }
681687
682 pub fn firstToken(self: *UnionTag) TokenIndex {
688 pub fn firstToken(self: *const UnionTag) TokenIndex {
683689 return self.name_token;
684690 }
685691
686 pub fn lastToken(self: *UnionTag) TokenIndex {
692 pub fn lastToken(self: *const UnionTag) TokenIndex {
687693 if (self.value_expr) |value_expr| {
688694 return value_expr.lastToken();
689695 }
......@@ -712,11 +718,11 @@ pub const Node = struct {
712718 return null;
713719 }
714720
715 pub fn firstToken(self: *EnumTag) TokenIndex {
721 pub fn firstToken(self: *const EnumTag) TokenIndex {
716722 return self.name_token;
717723 }
718724
719 pub fn lastToken(self: *EnumTag) TokenIndex {
725 pub fn lastToken(self: *const EnumTag) TokenIndex {
720726 if (self.value) |value| {
721727 return value.lastToken();
722728 }
......@@ -741,11 +747,11 @@ pub const Node = struct {
741747 return null;
742748 }
743749
744 pub fn firstToken(self: *ErrorTag) TokenIndex {
750 pub fn firstToken(self: *const ErrorTag) TokenIndex {
745751 return self.name_token;
746752 }
747753
748 pub fn lastToken(self: *ErrorTag) TokenIndex {
754 pub fn lastToken(self: *const ErrorTag) TokenIndex {
749755 return self.name_token;
750756 }
751757 };
......@@ -758,11 +764,11 @@ pub const Node = struct {
758764 return null;
759765 }
760766
761 pub fn firstToken(self: *Identifier) TokenIndex {
767 pub fn firstToken(self: *const Identifier) TokenIndex {
762768 return self.token;
763769 }
764770
765 pub fn lastToken(self: *Identifier) TokenIndex {
771 pub fn lastToken(self: *const Identifier) TokenIndex {
766772 return self.token;
767773 }
768774 };
......@@ -784,11 +790,11 @@ pub const Node = struct {
784790 return null;
785791 }
786792
787 pub fn firstToken(self: *AsyncAttribute) TokenIndex {
793 pub fn firstToken(self: *const AsyncAttribute) TokenIndex {
788794 return self.async_token;
789795 }
790796
791 pub fn lastToken(self: *AsyncAttribute) TokenIndex {
797 pub fn lastToken(self: *const AsyncAttribute) TokenIndex {
792798 if (self.rangle_bracket) |rangle_bracket| {
793799 return rangle_bracket;
794800 }
......@@ -856,7 +862,7 @@ pub const Node = struct {
856862 return null;
857863 }
858864
859 pub fn firstToken(self: *FnProto) TokenIndex {
865 pub fn firstToken(self: *const FnProto) TokenIndex {
860866 if (self.visib_token) |visib_token| return visib_token;
861867 if (self.async_attr) |async_attr| return async_attr.firstToken();
862868 if (self.extern_export_inline_token) |extern_export_inline_token| return extern_export_inline_token;
......@@ -865,7 +871,7 @@ pub const Node = struct {
865871 return self.fn_token;
866872 }
867873
868 pub fn lastToken(self: *FnProto) TokenIndex {
874 pub fn lastToken(self: *const FnProto) TokenIndex {
869875 if (self.body_node) |body_node| return body_node.lastToken();
870876 switch (self.return_type) {
871877 // TODO allow this and next prong to share bodies since the types are the same
......@@ -896,11 +902,11 @@ pub const Node = struct {
896902 return null;
897903 }
898904
899 pub fn firstToken(self: *PromiseType) TokenIndex {
905 pub fn firstToken(self: *const PromiseType) TokenIndex {
900906 return self.promise_token;
901907 }
902908
903 pub fn lastToken(self: *PromiseType) TokenIndex {
909 pub fn lastToken(self: *const PromiseType) TokenIndex {
904910 if (self.result) |result| return result.return_type.lastToken();
905911 return self.promise_token;
906912 }
......@@ -923,14 +929,14 @@ pub const Node = struct {
923929 return null;
924930 }
925931
926 pub fn firstToken(self: *ParamDecl) TokenIndex {
932 pub fn firstToken(self: *const ParamDecl) TokenIndex {
927933 if (self.comptime_token) |comptime_token| return comptime_token;
928934 if (self.noalias_token) |noalias_token| return noalias_token;
929935 if (self.name_token) |name_token| return name_token;
930936 return self.type_node.firstToken();
931937 }
932938
933 pub fn lastToken(self: *ParamDecl) TokenIndex {
939 pub fn lastToken(self: *const ParamDecl) TokenIndex {
934940 if (self.var_args_token) |var_args_token| return var_args_token;
935941 return self.type_node.lastToken();
936942 }
......@@ -954,7 +960,7 @@ pub const Node = struct {
954960 return null;
955961 }
956962
957 pub fn firstToken(self: *Block) TokenIndex {
963 pub fn firstToken(self: *const Block) TokenIndex {
958964 if (self.label) |label| {
959965 return label;
960966 }
......@@ -962,7 +968,7 @@ pub const Node = struct {
962968 return self.lbrace;
963969 }
964970
965 pub fn lastToken(self: *Block) TokenIndex {
971 pub fn lastToken(self: *const Block) TokenIndex {
966972 return self.rbrace;
967973 }
968974 };
......@@ -981,11 +987,11 @@ pub const Node = struct {
981987 return null;
982988 }
983989
984 pub fn firstToken(self: *Defer) TokenIndex {
990 pub fn firstToken(self: *const Defer) TokenIndex {
985991 return self.defer_token;
986992 }
987993
988 pub fn lastToken(self: *Defer) TokenIndex {
994 pub fn lastToken(self: *const Defer) TokenIndex {
989995 return self.expr.lastToken();
990996 }
991997 };
......@@ -1005,11 +1011,11 @@ pub const Node = struct {
10051011 return null;
10061012 }
10071013
1008 pub fn firstToken(self: *Comptime) TokenIndex {
1014 pub fn firstToken(self: *const Comptime) TokenIndex {
10091015 return self.comptime_token;
10101016 }
10111017
1012 pub fn lastToken(self: *Comptime) TokenIndex {
1018 pub fn lastToken(self: *const Comptime) TokenIndex {
10131019 return self.expr.lastToken();
10141020 }
10151021 };
......@@ -1029,11 +1035,11 @@ pub const Node = struct {
10291035 return null;
10301036 }
10311037
1032 pub fn firstToken(self: *Payload) TokenIndex {
1038 pub fn firstToken(self: *const Payload) TokenIndex {
10331039 return self.lpipe;
10341040 }
10351041
1036 pub fn lastToken(self: *Payload) TokenIndex {
1042 pub fn lastToken(self: *const Payload) TokenIndex {
10371043 return self.rpipe;
10381044 }
10391045 };
......@@ -1054,11 +1060,11 @@ pub const Node = struct {
10541060 return null;
10551061 }
10561062
1057 pub fn firstToken(self: *PointerPayload) TokenIndex {
1063 pub fn firstToken(self: *const PointerPayload) TokenIndex {
10581064 return self.lpipe;
10591065 }
10601066
1061 pub fn lastToken(self: *PointerPayload) TokenIndex {
1067 pub fn lastToken(self: *const PointerPayload) TokenIndex {
10621068 return self.rpipe;
10631069 }
10641070 };
......@@ -1085,11 +1091,11 @@ pub const Node = struct {
10851091 return null;
10861092 }
10871093
1088 pub fn firstToken(self: *PointerIndexPayload) TokenIndex {
1094 pub fn firstToken(self: *const PointerIndexPayload) TokenIndex {
10891095 return self.lpipe;
10901096 }
10911097
1092 pub fn lastToken(self: *PointerIndexPayload) TokenIndex {
1098 pub fn lastToken(self: *const PointerIndexPayload) TokenIndex {
10931099 return self.rpipe;
10941100 }
10951101 };
......@@ -1114,11 +1120,11 @@ pub const Node = struct {
11141120 return null;
11151121 }
11161122
1117 pub fn firstToken(self: *Else) TokenIndex {
1123 pub fn firstToken(self: *const Else) TokenIndex {
11181124 return self.else_token;
11191125 }
11201126
1121 pub fn lastToken(self: *Else) TokenIndex {
1127 pub fn lastToken(self: *const Else) TokenIndex {
11221128 return self.body.lastToken();
11231129 }
11241130 };
......@@ -1146,11 +1152,11 @@ pub const Node = struct {
11461152 return null;
11471153 }
11481154
1149 pub fn firstToken(self: *Switch) TokenIndex {
1155 pub fn firstToken(self: *const Switch) TokenIndex {
11501156 return self.switch_token;
11511157 }
11521158
1153 pub fn lastToken(self: *Switch) TokenIndex {
1159 pub fn lastToken(self: *const Switch) TokenIndex {
11541160 return self.rbrace;
11551161 }
11561162 };
......@@ -1181,11 +1187,11 @@ pub const Node = struct {
11811187 return null;
11821188 }
11831189
1184 pub fn firstToken(self: *SwitchCase) TokenIndex {
1190 pub fn firstToken(self: *const SwitchCase) TokenIndex {
11851191 return (self.items.at(0).*).firstToken();
11861192 }
11871193
1188 pub fn lastToken(self: *SwitchCase) TokenIndex {
1194 pub fn lastToken(self: *const SwitchCase) TokenIndex {
11891195 return self.expr.lastToken();
11901196 }
11911197 };
......@@ -1198,11 +1204,11 @@ pub const Node = struct {
11981204 return null;
11991205 }
12001206
1201 pub fn firstToken(self: *SwitchElse) TokenIndex {
1207 pub fn firstToken(self: *const SwitchElse) TokenIndex {
12021208 return self.token;
12031209 }
12041210
1205 pub fn lastToken(self: *SwitchElse) TokenIndex {
1211 pub fn lastToken(self: *const SwitchElse) TokenIndex {
12061212 return self.token;
12071213 }
12081214 };
......@@ -1245,7 +1251,7 @@ pub const Node = struct {
12451251 return null;
12461252 }
12471253
1248 pub fn firstToken(self: *While) TokenIndex {
1254 pub fn firstToken(self: *const While) TokenIndex {
12491255 if (self.label) |label| {
12501256 return label;
12511257 }
......@@ -1257,7 +1263,7 @@ pub const Node = struct {
12571263 return self.while_token;
12581264 }
12591265
1260 pub fn lastToken(self: *While) TokenIndex {
1266 pub fn lastToken(self: *const While) TokenIndex {
12611267 if (self.@"else") |@"else"| {
12621268 return @"else".body.lastToken();
12631269 }
......@@ -1298,7 +1304,7 @@ pub const Node = struct {
12981304 return null;
12991305 }
13001306
1301 pub fn firstToken(self: *For) TokenIndex {
1307 pub fn firstToken(self: *const For) TokenIndex {
13021308 if (self.label) |label| {
13031309 return label;
13041310 }
......@@ -1310,7 +1316,7 @@ pub const Node = struct {
13101316 return self.for_token;
13111317 }
13121318
1313 pub fn lastToken(self: *For) TokenIndex {
1319 pub fn lastToken(self: *const For) TokenIndex {
13141320 if (self.@"else") |@"else"| {
13151321 return @"else".body.lastToken();
13161322 }
......@@ -1349,11 +1355,11 @@ pub const Node = struct {
13491355 return null;
13501356 }
13511357
1352 pub fn firstToken(self: *If) TokenIndex {
1358 pub fn firstToken(self: *const If) TokenIndex {
13531359 return self.if_token;
13541360 }
13551361
1356 pub fn lastToken(self: *If) TokenIndex {
1362 pub fn lastToken(self: *const If) TokenIndex {
13571363 if (self.@"else") |@"else"| {
13581364 return @"else".body.lastToken();
13591365 }
......@@ -1480,11 +1486,11 @@ pub const Node = struct {
14801486 return null;
14811487 }
14821488
1483 pub fn firstToken(self: *InfixOp) TokenIndex {
1489 pub fn firstToken(self: *const InfixOp) TokenIndex {
14841490 return self.lhs.firstToken();
14851491 }
14861492
1487 pub fn lastToken(self: *InfixOp) TokenIndex {
1493 pub fn lastToken(self: *const InfixOp) TokenIndex {
14881494 return self.rhs.lastToken();
14891495 }
14901496 };
......@@ -1570,11 +1576,11 @@ pub const Node = struct {
15701576 return null;
15711577 }
15721578
1573 pub fn firstToken(self: *PrefixOp) TokenIndex {
1579 pub fn firstToken(self: *const PrefixOp) TokenIndex {
15741580 return self.op_token;
15751581 }
15761582
1577 pub fn lastToken(self: *PrefixOp) TokenIndex {
1583 pub fn lastToken(self: *const PrefixOp) TokenIndex {
15781584 return self.rhs.lastToken();
15791585 }
15801586 };
......@@ -1594,11 +1600,11 @@ pub const Node = struct {
15941600 return null;
15951601 }
15961602
1597 pub fn firstToken(self: *FieldInitializer) TokenIndex {
1603 pub fn firstToken(self: *const FieldInitializer) TokenIndex {
15981604 return self.period_token;
15991605 }
16001606
1601 pub fn lastToken(self: *FieldInitializer) TokenIndex {
1607 pub fn lastToken(self: *const FieldInitializer) TokenIndex {
16021608 return self.expr.lastToken();
16031609 }
16041610 };
......@@ -1673,7 +1679,7 @@ pub const Node = struct {
16731679 return null;
16741680 }
16751681
1676 pub fn firstToken(self: *SuffixOp) TokenIndex {
1682 pub fn firstToken(self: *const SuffixOp) TokenIndex {
16771683 switch (self.op) {
16781684 @TagType(Op).Call => |*call_info| if (call_info.async_attr) |async_attr| return async_attr.firstToken(),
16791685 else => {},
......@@ -1681,7 +1687,7 @@ pub const Node = struct {
16811687 return self.lhs.firstToken();
16821688 }
16831689
1684 pub fn lastToken(self: *SuffixOp) TokenIndex {
1690 pub fn lastToken(self: *const SuffixOp) TokenIndex {
16851691 return self.rtoken;
16861692 }
16871693 };
......@@ -1701,11 +1707,11 @@ pub const Node = struct {
17011707 return null;
17021708 }
17031709
1704 pub fn firstToken(self: *GroupedExpression) TokenIndex {
1710 pub fn firstToken(self: *const GroupedExpression) TokenIndex {
17051711 return self.lparen;
17061712 }
17071713
1708 pub fn lastToken(self: *GroupedExpression) TokenIndex {
1714 pub fn lastToken(self: *const GroupedExpression) TokenIndex {
17091715 return self.rparen;
17101716 }
17111717 };
......@@ -1749,11 +1755,11 @@ pub const Node = struct {
17491755 return null;
17501756 }
17511757
1752 pub fn firstToken(self: *ControlFlowExpression) TokenIndex {
1758 pub fn firstToken(self: *const ControlFlowExpression) TokenIndex {
17531759 return self.ltoken;
17541760 }
17551761
1756 pub fn lastToken(self: *ControlFlowExpression) TokenIndex {
1762 pub fn lastToken(self: *const ControlFlowExpression) TokenIndex {
17571763 if (self.rhs) |rhs| {
17581764 return rhs.lastToken();
17591765 }
......@@ -1792,11 +1798,11 @@ pub const Node = struct {
17921798 return null;
17931799 }
17941800
1795 pub fn firstToken(self: *Suspend) TokenIndex {
1801 pub fn firstToken(self: *const Suspend) TokenIndex {
17961802 return self.suspend_token;
17971803 }
17981804
1799 pub fn lastToken(self: *Suspend) TokenIndex {
1805 pub fn lastToken(self: *const Suspend) TokenIndex {
18001806 if (self.body) |body| {
18011807 return body.lastToken();
18021808 }
......@@ -1813,11 +1819,11 @@ pub const Node = struct {
18131819 return null;
18141820 }
18151821
1816 pub fn firstToken(self: *IntegerLiteral) TokenIndex {
1822 pub fn firstToken(self: *const IntegerLiteral) TokenIndex {
18171823 return self.token;
18181824 }
18191825
1820 pub fn lastToken(self: *IntegerLiteral) TokenIndex {
1826 pub fn lastToken(self: *const IntegerLiteral) TokenIndex {
18211827 return self.token;
18221828 }
18231829 };
......@@ -1830,11 +1836,11 @@ pub const Node = struct {
18301836 return null;
18311837 }
18321838
1833 pub fn firstToken(self: *FloatLiteral) TokenIndex {
1839 pub fn firstToken(self: *const FloatLiteral) TokenIndex {
18341840 return self.token;
18351841 }
18361842
1837 pub fn lastToken(self: *FloatLiteral) TokenIndex {
1843 pub fn lastToken(self: *const FloatLiteral) TokenIndex {
18381844 return self.token;
18391845 }
18401846 };
......@@ -1856,11 +1862,11 @@ pub const Node = struct {
18561862 return null;
18571863 }
18581864
1859 pub fn firstToken(self: *BuiltinCall) TokenIndex {
1865 pub fn firstToken(self: *const BuiltinCall) TokenIndex {
18601866 return self.builtin_token;
18611867 }
18621868
1863 pub fn lastToken(self: *BuiltinCall) TokenIndex {
1869 pub fn lastToken(self: *const BuiltinCall) TokenIndex {
18641870 return self.rparen_token;
18651871 }
18661872 };
......@@ -1873,11 +1879,11 @@ pub const Node = struct {
18731879 return null;
18741880 }
18751881
1876 pub fn firstToken(self: *StringLiteral) TokenIndex {
1882 pub fn firstToken(self: *const StringLiteral) TokenIndex {
18771883 return self.token;
18781884 }
18791885
1880 pub fn lastToken(self: *StringLiteral) TokenIndex {
1886 pub fn lastToken(self: *const StringLiteral) TokenIndex {
18811887 return self.token;
18821888 }
18831889 };
......@@ -1892,11 +1898,11 @@ pub const Node = struct {
18921898 return null;
18931899 }
18941900
1895 pub fn firstToken(self: *MultilineStringLiteral) TokenIndex {
1901 pub fn firstToken(self: *const MultilineStringLiteral) TokenIndex {
18961902 return self.lines.at(0).*;
18971903 }
18981904
1899 pub fn lastToken(self: *MultilineStringLiteral) TokenIndex {
1905 pub fn lastToken(self: *const MultilineStringLiteral) TokenIndex {
19001906 return self.lines.at(self.lines.len - 1).*;
19011907 }
19021908 };
......@@ -1909,11 +1915,11 @@ pub const Node = struct {
19091915 return null;
19101916 }
19111917
1912 pub fn firstToken(self: *CharLiteral) TokenIndex {
1918 pub fn firstToken(self: *const CharLiteral) TokenIndex {
19131919 return self.token;
19141920 }
19151921
1916 pub fn lastToken(self: *CharLiteral) TokenIndex {
1922 pub fn lastToken(self: *const CharLiteral) TokenIndex {
19171923 return self.token;
19181924 }
19191925 };
......@@ -1926,11 +1932,11 @@ pub const Node = struct {
19261932 return null;
19271933 }
19281934
1929 pub fn firstToken(self: *BoolLiteral) TokenIndex {
1935 pub fn firstToken(self: *const BoolLiteral) TokenIndex {
19301936 return self.token;
19311937 }
19321938
1933 pub fn lastToken(self: *BoolLiteral) TokenIndex {
1939 pub fn lastToken(self: *const BoolLiteral) TokenIndex {
19341940 return self.token;
19351941 }
19361942 };
......@@ -1943,11 +1949,11 @@ pub const Node = struct {
19431949 return null;
19441950 }
19451951
1946 pub fn firstToken(self: *NullLiteral) TokenIndex {
1952 pub fn firstToken(self: *const NullLiteral) TokenIndex {
19471953 return self.token;
19481954 }
19491955
1950 pub fn lastToken(self: *NullLiteral) TokenIndex {
1956 pub fn lastToken(self: *const NullLiteral) TokenIndex {
19511957 return self.token;
19521958 }
19531959 };
......@@ -1960,11 +1966,11 @@ pub const Node = struct {
19601966 return null;
19611967 }
19621968
1963 pub fn firstToken(self: *UndefinedLiteral) TokenIndex {
1969 pub fn firstToken(self: *const UndefinedLiteral) TokenIndex {
19641970 return self.token;
19651971 }
19661972
1967 pub fn lastToken(self: *UndefinedLiteral) TokenIndex {
1973 pub fn lastToken(self: *const UndefinedLiteral) TokenIndex {
19681974 return self.token;
19691975 }
19701976 };
......@@ -1977,11 +1983,11 @@ pub const Node = struct {
19771983 return null;
19781984 }
19791985
1980 pub fn firstToken(self: *ThisLiteral) TokenIndex {
1986 pub fn firstToken(self: *const ThisLiteral) TokenIndex {
19811987 return self.token;
19821988 }
19831989
1984 pub fn lastToken(self: *ThisLiteral) TokenIndex {
1990 pub fn lastToken(self: *const ThisLiteral) TokenIndex {
19851991 return self.token;
19861992 }
19871993 };
......@@ -2022,11 +2028,11 @@ pub const Node = struct {
20222028 return null;
20232029 }
20242030
2025 pub fn firstToken(self: *AsmOutput) TokenIndex {
2031 pub fn firstToken(self: *const AsmOutput) TokenIndex {
20262032 return self.lbracket;
20272033 }
20282034
2029 pub fn lastToken(self: *AsmOutput) TokenIndex {
2035 pub fn lastToken(self: *const AsmOutput) TokenIndex {
20302036 return self.rparen;
20312037 }
20322038 };
......@@ -2054,11 +2060,11 @@ pub const Node = struct {
20542060 return null;
20552061 }
20562062
2057 pub fn firstToken(self: *AsmInput) TokenIndex {
2063 pub fn firstToken(self: *const AsmInput) TokenIndex {
20582064 return self.lbracket;
20592065 }
20602066
2061 pub fn lastToken(self: *AsmInput) TokenIndex {
2067 pub fn lastToken(self: *const AsmInput) TokenIndex {
20622068 return self.rparen;
20632069 }
20642070 };
......@@ -2089,11 +2095,11 @@ pub const Node = struct {
20892095 return null;
20902096 }
20912097
2092 pub fn firstToken(self: *Asm) TokenIndex {
2098 pub fn firstToken(self: *const Asm) TokenIndex {
20932099 return self.asm_token;
20942100 }
20952101
2096 pub fn lastToken(self: *Asm) TokenIndex {
2102 pub fn lastToken(self: *const Asm) TokenIndex {
20972103 return self.rparen;
20982104 }
20992105 };
......@@ -2106,11 +2112,11 @@ pub const Node = struct {
21062112 return null;
21072113 }
21082114
2109 pub fn firstToken(self: *Unreachable) TokenIndex {
2115 pub fn firstToken(self: *const Unreachable) TokenIndex {
21102116 return self.token;
21112117 }
21122118
2113 pub fn lastToken(self: *Unreachable) TokenIndex {
2119 pub fn lastToken(self: *const Unreachable) TokenIndex {
21142120 return self.token;
21152121 }
21162122 };
......@@ -2123,11 +2129,11 @@ pub const Node = struct {
21232129 return null;
21242130 }
21252131
2126 pub fn firstToken(self: *ErrorType) TokenIndex {
2132 pub fn firstToken(self: *const ErrorType) TokenIndex {
21272133 return self.token;
21282134 }
21292135
2130 pub fn lastToken(self: *ErrorType) TokenIndex {
2136 pub fn lastToken(self: *const ErrorType) TokenIndex {
21312137 return self.token;
21322138 }
21332139 };
......@@ -2140,11 +2146,11 @@ pub const Node = struct {
21402146 return null;
21412147 }
21422148
2143 pub fn firstToken(self: *VarType) TokenIndex {
2149 pub fn firstToken(self: *const VarType) TokenIndex {
21442150 return self.token;
21452151 }
21462152
2147 pub fn lastToken(self: *VarType) TokenIndex {
2153 pub fn lastToken(self: *const VarType) TokenIndex {
21482154 return self.token;
21492155 }
21502156 };
......@@ -2159,11 +2165,11 @@ pub const Node = struct {
21592165 return null;
21602166 }
21612167
2162 pub fn firstToken(self: *DocComment) TokenIndex {
2168 pub fn firstToken(self: *const DocComment) TokenIndex {
21632169 return self.lines.at(0).*;
21642170 }
21652171
2166 pub fn lastToken(self: *DocComment) TokenIndex {
2172 pub fn lastToken(self: *const DocComment) TokenIndex {
21672173 return self.lines.at(self.lines.len - 1).*;
21682174 }
21692175 };
......@@ -2184,11 +2190,11 @@ pub const Node = struct {
21842190 return null;
21852191 }
21862192
2187 pub fn firstToken(self: *TestDecl) TokenIndex {
2193 pub fn firstToken(self: *const TestDecl) TokenIndex {
21882194 return self.test_token;
21892195 }
21902196
2191 pub fn lastToken(self: *TestDecl) TokenIndex {
2197 pub fn lastToken(self: *const TestDecl) TokenIndex {
21922198 return self.body_node.lastToken();
21932199 }
21942200 };