@@ -28,7 +28,7 @@ global_enum_set: IdentifierSet,
2828pub const IdentifierSet = std .ArrayHashMapUnmanaged (Ast .TokenIndex , void , IdentifierTokenContext , true );
2929
3030pub const IdentifierTokenContext = struct {
31- tree : Ast ,
31+ tree : * const Ast ,
3232
3333 pub fn eql (self : @This (), a : Ast .TokenIndex , b : Ast.TokenIndex , b_index : usize ) bool {
3434 _ = b_index ;
@@ -137,11 +137,11 @@ pub const Declaration = union(enum) {
137137 param_index : u16 ,
138138 func : Ast.Node.Index ,
139139
140- pub fn get (self : Param , tree : Ast ) ? Ast.full.FnProto.Param {
140+ pub fn get (self : Param , tree : * const Ast ) ? Ast.full.FnProto.Param {
141141 var buffer : [1 ]Ast.Node.Index = undefined ;
142142 const func = tree .fullFnProto (& buffer , self .func ).? ;
143143 var param_index : u16 = 0 ;
144- var it = func .iterate (& tree );
144+ var it = func .iterate (tree );
145145 while (ast .nextFnParam (& it )) | param | : (param_index += 1 ) {
146146 if (self .param_index == param_index ) return param ;
147147 }
@@ -154,12 +154,12 @@ pub const Declaration = union(enum) {
154154 node : Ast.Node.Index ,
155155 index : u32 ,
156156
157- pub fn getVarDeclNode (self : AssignDestructure , tree : Ast ) Ast.Node.Index {
157+ pub fn getVarDeclNode (self : AssignDestructure , tree : * const Ast ) Ast.Node.Index {
158158 const extra_index = tree .nodeData (self .node ).extra_and_node [0 ];
159159 return @enumFromInt (tree .extra_data [@intFromEnum (extra_index ) + 1 .. ][self .index ]);
160160 }
161161
162- pub fn getFullVarDecl (self : AssignDestructure , tree : Ast ) Ast.full.VarDecl {
162+ pub fn getFullVarDecl (self : AssignDestructure , tree : * const Ast ) Ast.full.VarDecl {
163163 return tree .fullVarDecl (self .getVarDeclNode (tree )).? ;
164164 }
165165 };
@@ -170,7 +170,7 @@ pub const Declaration = union(enum) {
170170 /// is guaranteed to have a payload_token
171171 case_index : u32 ,
172172
173- pub fn getCase (self : Switch , tree : Ast ) Ast.full.SwitchCase {
173+ pub fn getCase (self : Switch , tree : * const Ast ) Ast.full.SwitchCase {
174174 const extra_index = tree .nodeData (self .node ).node_and_extra [1 ];
175175 const cases = tree .extraDataSlice (tree .extraData (extra_index , Ast .Node .SubRange ), Ast .Node .Index );
176176 return tree .fullSwitchCase (cases [self .case_index ]).? ;
@@ -200,7 +200,7 @@ pub const Declaration = union(enum) {
200200 }
201201
202202 /// Returns a `.identifier` or `.builtin` token.
203- pub fn nameToken (decl : Declaration , tree : Ast ) Ast.TokenIndex {
203+ pub fn nameToken (decl : Declaration , tree : * const Ast ) Ast.TokenIndex {
204204 return switch (decl ) {
205205 .ast_node = > | node | {
206206 var buffer : [1 ]Ast.Node.Index = undefined ;
@@ -339,7 +339,7 @@ pub const Scope = struct {
339339
340340const ScopeContext = struct {
341341 allocator : std.mem.Allocator ,
342- tree : Ast ,
342+ tree : * const Ast ,
343343 doc_scope : * DocumentScope ,
344344
345345 current_scope : Scope.OptionalIndex = .none ,
@@ -515,7 +515,7 @@ const ScopeContext = struct {
515515 }
516516};
517517
518- pub fn init (allocator : std.mem.Allocator , tree : Ast ) error {OutOfMemory }! DocumentScope {
518+ pub fn init (allocator : std.mem.Allocator , tree : * const Ast ) error {OutOfMemory }! DocumentScope {
519519 const tracy_zone = tracy .trace (@src ());
520520 defer tracy_zone .end ();
521521
@@ -574,7 +574,7 @@ fn locToSmallLoc(loc: offsets.Loc) Scope.SmallLoc {
574574/// Caller must finalize the scope
575575fn walkNodeEnsureScope (
576576 context : * ScopeContext ,
577- tree : Ast ,
577+ tree : * const Ast ,
578578 node_idx : Ast.Node.Index ,
579579 start_token : Ast.TokenIndex ,
580580) error {OutOfMemory }! ScopeContext.PushedScope {
@@ -602,7 +602,7 @@ fn walkNodeEnsureScope(
602602
603603fn walkNode (
604604 context : * ScopeContext ,
605- tree : Ast ,
605+ tree : * const Ast ,
606606 node_idx : Ast.Node.Index ,
607607) error {OutOfMemory }! void {
608608 const tag = tree .nodeTag (node_idx );
@@ -799,7 +799,7 @@ fn walkNode(
799799
800800noinline fn walkContainerDecl (
801801 context : * ScopeContext ,
802- tree : Ast ,
802+ tree : * const Ast ,
803803 node_idx : Ast.Node.Index ,
804804) error {OutOfMemory }! void {
805805 const tracy_zone = tracy .trace (@src ());
@@ -840,7 +840,7 @@ noinline fn walkContainerDecl(
840840 var container_field = tree .fullContainerField (decl ).? ;
841841 if (is_struct and container_field .ast .tuple_like ) continue ;
842842
843- container_field .convertToNonTupleLike (& tree );
843+ container_field .convertToNonTupleLike (tree );
844844 if (container_field .ast .tuple_like ) continue ;
845845 const main_token = container_field .ast .main_token ;
846846 if (tree .tokenTag (main_token ) != .identifier ) continue ;
@@ -891,7 +891,7 @@ noinline fn walkContainerDecl(
891891
892892noinline fn walkErrorSetNode (
893893 context : * ScopeContext ,
894- tree : Ast ,
894+ tree : * const Ast ,
895895 node_idx : Ast.Node.Index ,
896896) error {OutOfMemory }! void {
897897 const scope = try context .startScope (
@@ -922,7 +922,7 @@ noinline fn walkErrorSetNode(
922922
923923noinline fn walkFuncNode (
924924 context : * ScopeContext ,
925- tree : Ast ,
925+ tree : * const Ast ,
926926 node_idx : Ast.Node.Index ,
927927) error {OutOfMemory }! void {
928928 var buf : [1 ]Ast.Node.Index = undefined ;
@@ -935,7 +935,7 @@ noinline fn walkFuncNode(
935935 );
936936
937937 var param_index : u16 = 0 ;
938- var it = func .iterate (& tree );
938+ var it = func .iterate (tree );
939939 while (ast .nextFnParam (& it )) | param | : (param_index += 1 ) {
940940 if (param .name_token ) | name_token | {
941941 try scope .pushDeclaration (
@@ -963,7 +963,7 @@ noinline fn walkFuncNode(
963963
964964noinline fn walkBlockNode (
965965 context : * ScopeContext ,
966- tree : Ast ,
966+ tree : * const Ast ,
967967 node_idx : Ast.Node.Index ,
968968) error {OutOfMemory }! void {
969969 const pushed_scope = try walkBlockNodeKeepOpen (context , tree , node_idx , tree .firstToken (node_idx ));
@@ -972,7 +972,7 @@ noinline fn walkBlockNode(
972972
973973fn walkBlockNodeKeepOpen (
974974 context : * ScopeContext ,
975- tree : Ast ,
975+ tree : * const Ast ,
976976 node_idx : Ast.Node.Index ,
977977 start_token : Ast.TokenIndex ,
978978) error {OutOfMemory }! ScopeContext.PushedScope {
@@ -1029,7 +1029,7 @@ fn walkBlockNodeKeepOpen(
10291029
10301030noinline fn walkIfNode (
10311031 context : * ScopeContext ,
1032- tree : Ast ,
1032+ tree : * const Ast ,
10331033 node_idx : Ast.Node.Index ,
10341034) error {OutOfMemory }! void {
10351035 const if_node = ast .fullIf (tree , node_idx ).? ;
@@ -1068,7 +1068,7 @@ noinline fn walkIfNode(
10681068
10691069noinline fn walkCatchNode (
10701070 context : * ScopeContext ,
1071- tree : Ast ,
1071+ tree : * const Ast ,
10721072 node_idx : Ast.Node.Index ,
10731073) error {OutOfMemory }! void {
10741074 const lhs , const rhs = tree .nodeData (node_idx ).node_and_node ;
@@ -1094,7 +1094,7 @@ noinline fn walkCatchNode(
10941094/// label_token: inline_token while (cond_expr) |payload_token| : (cont_expr) then_expr else |error_token| else_expr
10951095noinline fn walkWhileNode (
10961096 context : * ScopeContext ,
1097- tree : Ast ,
1097+ tree : * const Ast ,
10981098 node_idx : Ast.Node.Index ,
10991099) error {OutOfMemory }! void {
11001100 const while_node = ast .fullWhile (tree , node_idx ).? ;
@@ -1172,7 +1172,7 @@ noinline fn walkWhileNode(
11721172/// label_token: inline_token for (inputs) |capture_tokens| then_expr else else_expr
11731173noinline fn walkForNode (
11741174 context : * ScopeContext ,
1175- tree : Ast ,
1175+ tree : * const Ast ,
11761176 node_idx : Ast.Node.Index ,
11771177) error {OutOfMemory }! void {
11781178 const for_node = ast .fullFor (tree , node_idx ).? ;
@@ -1225,7 +1225,7 @@ noinline fn walkForNode(
12251225
12261226noinline fn walkSwitchNode (
12271227 context : * ScopeContext ,
1228- tree : Ast ,
1228+ tree : * const Ast ,
12291229 node_idx : Ast.Node.Index ,
12301230) error {OutOfMemory }! void {
12311231 const full = tree .fullSwitch (node_idx ).? ;
@@ -1282,7 +1282,7 @@ noinline fn walkSwitchNode(
12821282
12831283noinline fn walkErrdeferNode (
12841284 context : * ScopeContext ,
1285- tree : Ast ,
1285+ tree : * const Ast ,
12861286 node_idx : Ast.Node.Index ,
12871287) error {OutOfMemory }! void {
12881288 const opt_payload_token , const rhs = tree .nodeData (node_idx ).opt_token_and_node ;
@@ -1300,31 +1300,31 @@ noinline fn walkErrdeferNode(
13001300 }
13011301}
13021302
1303- noinline fn walkUnaryOpNode (context : * ScopeContext , tree : Ast , node_idx : Ast.Node.Index ) error {OutOfMemory }! void {
1303+ noinline fn walkUnaryOpNode (context : * ScopeContext , tree : * const Ast , node_idx : Ast.Node.Index ) error {OutOfMemory }! void {
13041304 try walkNode (context , tree , tree .nodeData (node_idx ).node );
13051305}
13061306
1307- noinline fn walkBinOpNode (context : * ScopeContext , tree : Ast , node_idx : Ast.Node.Index ) error {OutOfMemory }! void {
1307+ noinline fn walkBinOpNode (context : * ScopeContext , tree : * const Ast , node_idx : Ast.Node.Index ) error {OutOfMemory }! void {
13081308 const lhs , const rhs = tree .nodeData (node_idx ).node_and_node ;
13091309 try walkNode (context , tree , lhs );
13101310 try walkNode (context , tree , rhs );
13111311}
13121312
1313- noinline fn walkOptNodeAndOptNode (context : * ScopeContext , tree : Ast , node_idx : Ast.Node.Index ) error {OutOfMemory }! void {
1313+ noinline fn walkOptNodeAndOptNode (context : * ScopeContext , tree : * const Ast , node_idx : Ast.Node.Index ) error {OutOfMemory }! void {
13141314 const opt_lhs , const opt_rhs = tree .nodeData (node_idx ).opt_node_and_opt_node ;
13151315 if (opt_lhs .unwrap ()) | lhs | try walkNode (context , tree , lhs );
13161316 if (opt_rhs .unwrap ()) | rhs | try walkNode (context , tree , rhs );
13171317}
13181318
1319- noinline fn walkNodeAndOptNode (context : * ScopeContext , tree : Ast , node_idx : Ast.Node.Index ) error {OutOfMemory }! void {
1319+ noinline fn walkNodeAndOptNode (context : * ScopeContext , tree : * const Ast , node_idx : Ast.Node.Index ) error {OutOfMemory }! void {
13201320 const lhs , const opt_rhs = tree .nodeData (node_idx ).node_and_opt_node ;
13211321 try walkNode (context , tree , lhs );
13221322 if (opt_rhs .unwrap ()) | rhs | try walkNode (context , tree , rhs );
13231323}
13241324
13251325noinline fn walkOtherNode (
13261326 context : * ScopeContext ,
1327- tree : Ast ,
1327+ tree : * const Ast ,
13281328 node_idx : Ast.Node.Index ,
13291329) error {OutOfMemory }! void {
13301330 try ast .iterateChildren (tree , node_idx , context , error {OutOfMemory }, walkNode );
0 commit comments