authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-01-07 17:27:58-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-01-08 01:01:09-05:00
log3f586781b6c8d698468cc58ab64797097323c253
tree7807b9e17f8b7b78e2c144ec921cffaea2263876
parentc4ab8d9e12afbe07fc5b3cc4535a9fa2cfcad94d

std: fix zig.Ast being called Tree internally


1 files changed, 74 insertions(+), 74 deletions(-)

lib/std/zig/Ast.zig+74-74
......@@ -16,7 +16,7 @@ const assert = std.debug.assert;
1616const testing = std.testing;
1717const mem = std.mem;
1818const Token = std.zig.Token;
19const Tree = @This();
19const Ast = @This();
2020
2121pub const TokenIndex = u32;
2222pub const ByteOffset = u32;
......@@ -34,7 +34,7 @@ pub const Location = struct {
3434 line_end: usize,
3535};
3636
37pub fn deinit(tree: *Tree, gpa: mem.Allocator) void {
37pub fn deinit(tree: *Ast, gpa: mem.Allocator) void {
3838 tree.tokens.deinit(gpa);
3939 tree.nodes.deinit(gpa);
4040 gpa.free(tree.extra_data);
......@@ -52,7 +52,7 @@ pub const RenderError = error{
5252/// for allocating extra stack memory if needed, because this function utilizes recursion.
5353/// Note: that's not actually true yet, see https://github.com/ziglang/zig/issues/1006.
5454/// Caller owns the returned slice of bytes, allocated with `gpa`.
55pub fn render(tree: Tree, gpa: mem.Allocator) RenderError![]u8 {
55pub fn render(tree: Ast, gpa: mem.Allocator) RenderError![]u8 {
5656 var buffer = std.ArrayList(u8).init(gpa);
5757 defer buffer.deinit();
5858
......@@ -60,11 +60,11 @@ pub fn render(tree: Tree, gpa: mem.Allocator) RenderError![]u8 {
6060 return buffer.toOwnedSlice();
6161}
6262
63pub fn renderToArrayList(tree: Tree, buffer: *std.ArrayList(u8)) RenderError!void {
63pub fn renderToArrayList(tree: Ast, buffer: *std.ArrayList(u8)) RenderError!void {
6464 return @import("./render.zig").renderTree(buffer, tree);
6565}
6666
67pub fn tokenLocation(self: Tree, start_offset: ByteOffset, token_index: TokenIndex) Location {
67pub fn tokenLocation(self: Ast, start_offset: ByteOffset, token_index: TokenIndex) Location {
6868 var loc = Location{
6969 .line = 0,
7070 .column = 0,
......@@ -91,7 +91,7 @@ pub fn tokenLocation(self: Tree, start_offset: ByteOffset, token_index: TokenInd
9191 return loc;
9292}
9393
94pub fn tokenSlice(tree: Tree, token_index: TokenIndex) []const u8 {
94pub fn tokenSlice(tree: Ast, token_index: TokenIndex) []const u8 {
9595 const token_starts = tree.tokens.items(.start);
9696 const token_tags = tree.tokens.items(.tag);
9797 const token_tag = token_tags[token_index];
......@@ -112,7 +112,7 @@ pub fn tokenSlice(tree: Tree, token_index: TokenIndex) []const u8 {
112112 return tree.source[token.loc.start..token.loc.end];
113113}
114114
115pub fn extraData(tree: Tree, index: usize, comptime T: type) T {
115pub fn extraData(tree: Ast, index: usize, comptime T: type) T {
116116 const fields = std.meta.fields(T);
117117 var result: T = undefined;
118118 inline for (fields) |field, i| {
......@@ -122,13 +122,13 @@ pub fn extraData(tree: Tree, index: usize, comptime T: type) T {
122122 return result;
123123}
124124
125pub fn rootDecls(tree: Tree) []const Node.Index {
125pub fn rootDecls(tree: Ast) []const Node.Index {
126126 // Root is always index 0.
127127 const nodes_data = tree.nodes.items(.data);
128128 return tree.extra_data[nodes_data[0].lhs..nodes_data[0].rhs];
129129}
130130
131pub fn renderError(tree: Tree, parse_error: Error, stream: anytype) !void {
131pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void {
132132 const token_tags = tree.tokens.items(.tag);
133133 switch (parse_error.tag) {
134134 .asterisk_after_ptr_deref => {
......@@ -321,7 +321,7 @@ pub fn renderError(tree: Tree, parse_error: Error, stream: anytype) !void {
321321 }
322322}
323323
324pub fn firstToken(tree: Tree, node: Node.Index) TokenIndex {
324pub fn firstToken(tree: Ast, node: Node.Index) TokenIndex {
325325 const tags = tree.nodes.items(.tag);
326326 const datas = tree.nodes.items(.data);
327327 const main_tokens = tree.nodes.items(.main_token);
......@@ -625,7 +625,7 @@ pub fn firstToken(tree: Tree, node: Node.Index) TokenIndex {
625625 };
626626}
627627
628pub fn lastToken(tree: Tree, node: Node.Index) TokenIndex {
628pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex {
629629 const tags = tree.nodes.items(.tag);
630630 const datas = tree.nodes.items(.data);
631631 const main_tokens = tree.nodes.items(.main_token);
......@@ -1157,13 +1157,13 @@ pub fn lastToken(tree: Tree, node: Node.Index) TokenIndex {
11571157 };
11581158}
11591159
1160pub fn tokensOnSameLine(tree: Tree, token1: TokenIndex, token2: TokenIndex) bool {
1160pub fn tokensOnSameLine(tree: Ast, token1: TokenIndex, token2: TokenIndex) bool {
11611161 const token_starts = tree.tokens.items(.start);
11621162 const source = tree.source[token_starts[token1]..token_starts[token2]];
11631163 return mem.indexOfScalar(u8, source, '\n') == null;
11641164}
11651165
1166pub fn getNodeSource(tree: Tree, node: Node.Index) []const u8 {
1166pub fn getNodeSource(tree: Ast, node: Node.Index) []const u8 {
11671167 const token_starts = tree.tokens.items(.start);
11681168 const first_token = tree.firstToken(node);
11691169 const last_token = tree.lastToken(node);
......@@ -1172,7 +1172,7 @@ pub fn getNodeSource(tree: Tree, node: Node.Index) []const u8 {
11721172 return tree.source[start..end];
11731173}
11741174
1175pub fn globalVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
1175pub fn globalVarDecl(tree: Ast, node: Node.Index) full.VarDecl {
11761176 assert(tree.nodes.items(.tag)[node] == .global_var_decl);
11771177 const data = tree.nodes.items(.data)[node];
11781178 const extra = tree.extraData(data.lhs, Node.GlobalVarDecl);
......@@ -1186,7 +1186,7 @@ pub fn globalVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
11861186 });
11871187}
11881188
1189pub fn localVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
1189pub fn localVarDecl(tree: Ast, node: Node.Index) full.VarDecl {
11901190 assert(tree.nodes.items(.tag)[node] == .local_var_decl);
11911191 const data = tree.nodes.items(.data)[node];
11921192 const extra = tree.extraData(data.lhs, Node.LocalVarDecl);
......@@ -1200,7 +1200,7 @@ pub fn localVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
12001200 });
12011201}
12021202
1203pub fn simpleVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
1203pub fn simpleVarDecl(tree: Ast, node: Node.Index) full.VarDecl {
12041204 assert(tree.nodes.items(.tag)[node] == .simple_var_decl);
12051205 const data = tree.nodes.items(.data)[node];
12061206 return tree.fullVarDecl(.{
......@@ -1213,7 +1213,7 @@ pub fn simpleVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
12131213 });
12141214}
12151215
1216pub fn alignedVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
1216pub fn alignedVarDecl(tree: Ast, node: Node.Index) full.VarDecl {
12171217 assert(tree.nodes.items(.tag)[node] == .aligned_var_decl);
12181218 const data = tree.nodes.items(.data)[node];
12191219 return tree.fullVarDecl(.{
......@@ -1226,7 +1226,7 @@ pub fn alignedVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
12261226 });
12271227}
12281228
1229pub fn ifSimple(tree: Tree, node: Node.Index) full.If {
1229pub fn ifSimple(tree: Ast, node: Node.Index) full.If {
12301230 assert(tree.nodes.items(.tag)[node] == .if_simple);
12311231 const data = tree.nodes.items(.data)[node];
12321232 return tree.fullIf(.{
......@@ -1237,7 +1237,7 @@ pub fn ifSimple(tree: Tree, node: Node.Index) full.If {
12371237 });
12381238}
12391239
1240pub fn ifFull(tree: Tree, node: Node.Index) full.If {
1240pub fn ifFull(tree: Ast, node: Node.Index) full.If {
12411241 assert(tree.nodes.items(.tag)[node] == .@"if");
12421242 const data = tree.nodes.items(.data)[node];
12431243 const extra = tree.extraData(data.rhs, Node.If);
......@@ -1249,7 +1249,7 @@ pub fn ifFull(tree: Tree, node: Node.Index) full.If {
12491249 });
12501250}
12511251
1252pub fn containerField(tree: Tree, node: Node.Index) full.ContainerField {
1252pub fn containerField(tree: Ast, node: Node.Index) full.ContainerField {
12531253 assert(tree.nodes.items(.tag)[node] == .container_field);
12541254 const data = tree.nodes.items(.data)[node];
12551255 const extra = tree.extraData(data.rhs, Node.ContainerField);
......@@ -1261,7 +1261,7 @@ pub fn containerField(tree: Tree, node: Node.Index) full.ContainerField {
12611261 });
12621262}
12631263
1264pub fn containerFieldInit(tree: Tree, node: Node.Index) full.ContainerField {
1264pub fn containerFieldInit(tree: Ast, node: Node.Index) full.ContainerField {
12651265 assert(tree.nodes.items(.tag)[node] == .container_field_init);
12661266 const data = tree.nodes.items(.data)[node];
12671267 return tree.fullContainerField(.{
......@@ -1272,7 +1272,7 @@ pub fn containerFieldInit(tree: Tree, node: Node.Index) full.ContainerField {
12721272 });
12731273}
12741274
1275pub fn containerFieldAlign(tree: Tree, node: Node.Index) full.ContainerField {
1275pub fn containerFieldAlign(tree: Ast, node: Node.Index) full.ContainerField {
12761276 assert(tree.nodes.items(.tag)[node] == .container_field_align);
12771277 const data = tree.nodes.items(.data)[node];
12781278 return tree.fullContainerField(.{
......@@ -1283,7 +1283,7 @@ pub fn containerFieldAlign(tree: Tree, node: Node.Index) full.ContainerField {
12831283 });
12841284}
12851285
1286pub fn fnProtoSimple(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.FnProto {
1286pub fn fnProtoSimple(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.FnProto {
12871287 assert(tree.nodes.items(.tag)[node] == .fn_proto_simple);
12881288 const data = tree.nodes.items(.data)[node];
12891289 buffer[0] = data.lhs;
......@@ -1300,7 +1300,7 @@ pub fn fnProtoSimple(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.
13001300 });
13011301}
13021302
1303pub fn fnProtoMulti(tree: Tree, node: Node.Index) full.FnProto {
1303pub fn fnProtoMulti(tree: Ast, node: Node.Index) full.FnProto {
13041304 assert(tree.nodes.items(.tag)[node] == .fn_proto_multi);
13051305 const data = tree.nodes.items(.data)[node];
13061306 const params_range = tree.extraData(data.lhs, Node.SubRange);
......@@ -1317,7 +1317,7 @@ pub fn fnProtoMulti(tree: Tree, node: Node.Index) full.FnProto {
13171317 });
13181318}
13191319
1320pub fn fnProtoOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.FnProto {
1320pub fn fnProtoOne(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.FnProto {
13211321 assert(tree.nodes.items(.tag)[node] == .fn_proto_one);
13221322 const data = tree.nodes.items(.data)[node];
13231323 const extra = tree.extraData(data.lhs, Node.FnProtoOne);
......@@ -1335,7 +1335,7 @@ pub fn fnProtoOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.FnP
13351335 });
13361336}
13371337
1338pub fn fnProto(tree: Tree, node: Node.Index) full.FnProto {
1338pub fn fnProto(tree: Ast, node: Node.Index) full.FnProto {
13391339 assert(tree.nodes.items(.tag)[node] == .fn_proto);
13401340 const data = tree.nodes.items(.data)[node];
13411341 const extra = tree.extraData(data.lhs, Node.FnProto);
......@@ -1352,7 +1352,7 @@ pub fn fnProto(tree: Tree, node: Node.Index) full.FnProto {
13521352 });
13531353}
13541354
1355pub fn structInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.StructInit {
1355pub fn structInitOne(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.StructInit {
13561356 assert(tree.nodes.items(.tag)[node] == .struct_init_one or
13571357 tree.nodes.items(.tag)[node] == .struct_init_one_comma);
13581358 const data = tree.nodes.items(.data)[node];
......@@ -1365,7 +1365,7 @@ pub fn structInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.
13651365 });
13661366}
13671367
1368pub fn structInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.StructInit {
1368pub fn structInitDotTwo(tree: Ast, buffer: *[2]Node.Index, node: Node.Index) full.StructInit {
13691369 assert(tree.nodes.items(.tag)[node] == .struct_init_dot_two or
13701370 tree.nodes.items(.tag)[node] == .struct_init_dot_two_comma);
13711371 const data = tree.nodes.items(.data)[node];
......@@ -1383,7 +1383,7 @@ pub fn structInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) fu
13831383 });
13841384}
13851385
1386pub fn structInitDot(tree: Tree, node: Node.Index) full.StructInit {
1386pub fn structInitDot(tree: Ast, node: Node.Index) full.StructInit {
13871387 assert(tree.nodes.items(.tag)[node] == .struct_init_dot or
13881388 tree.nodes.items(.tag)[node] == .struct_init_dot_comma);
13891389 const data = tree.nodes.items(.data)[node];
......@@ -1394,7 +1394,7 @@ pub fn structInitDot(tree: Tree, node: Node.Index) full.StructInit {
13941394 });
13951395}
13961396
1397pub fn structInit(tree: Tree, node: Node.Index) full.StructInit {
1397pub fn structInit(tree: Ast, node: Node.Index) full.StructInit {
13981398 assert(tree.nodes.items(.tag)[node] == .struct_init or
13991399 tree.nodes.items(.tag)[node] == .struct_init_comma);
14001400 const data = tree.nodes.items(.data)[node];
......@@ -1406,7 +1406,7 @@ pub fn structInit(tree: Tree, node: Node.Index) full.StructInit {
14061406 });
14071407}
14081408
1409pub fn arrayInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.ArrayInit {
1409pub fn arrayInitOne(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.ArrayInit {
14101410 assert(tree.nodes.items(.tag)[node] == .array_init_one or
14111411 tree.nodes.items(.tag)[node] == .array_init_one_comma);
14121412 const data = tree.nodes.items(.data)[node];
......@@ -1421,7 +1421,7 @@ pub fn arrayInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.A
14211421 };
14221422}
14231423
1424pub fn arrayInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ArrayInit {
1424pub fn arrayInitDotTwo(tree: Ast, buffer: *[2]Node.Index, node: Node.Index) full.ArrayInit {
14251425 assert(tree.nodes.items(.tag)[node] == .array_init_dot_two or
14261426 tree.nodes.items(.tag)[node] == .array_init_dot_two_comma);
14271427 const data = tree.nodes.items(.data)[node];
......@@ -1441,7 +1441,7 @@ pub fn arrayInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) ful
14411441 };
14421442}
14431443
1444pub fn arrayInitDot(tree: Tree, node: Node.Index) full.ArrayInit {
1444pub fn arrayInitDot(tree: Ast, node: Node.Index) full.ArrayInit {
14451445 assert(tree.nodes.items(.tag)[node] == .array_init_dot or
14461446 tree.nodes.items(.tag)[node] == .array_init_dot_comma);
14471447 const data = tree.nodes.items(.data)[node];
......@@ -1454,7 +1454,7 @@ pub fn arrayInitDot(tree: Tree, node: Node.Index) full.ArrayInit {
14541454 };
14551455}
14561456
1457pub fn arrayInit(tree: Tree, node: Node.Index) full.ArrayInit {
1457pub fn arrayInit(tree: Ast, node: Node.Index) full.ArrayInit {
14581458 assert(tree.nodes.items(.tag)[node] == .array_init or
14591459 tree.nodes.items(.tag)[node] == .array_init_comma);
14601460 const data = tree.nodes.items(.data)[node];
......@@ -1468,7 +1468,7 @@ pub fn arrayInit(tree: Tree, node: Node.Index) full.ArrayInit {
14681468 };
14691469}
14701470
1471pub fn arrayType(tree: Tree, node: Node.Index) full.ArrayType {
1471pub fn arrayType(tree: Ast, node: Node.Index) full.ArrayType {
14721472 assert(tree.nodes.items(.tag)[node] == .array_type);
14731473 const data = tree.nodes.items(.data)[node];
14741474 return .{
......@@ -1481,7 +1481,7 @@ pub fn arrayType(tree: Tree, node: Node.Index) full.ArrayType {
14811481 };
14821482}
14831483
1484pub fn arrayTypeSentinel(tree: Tree, node: Node.Index) full.ArrayType {
1484pub fn arrayTypeSentinel(tree: Ast, node: Node.Index) full.ArrayType {
14851485 assert(tree.nodes.items(.tag)[node] == .array_type_sentinel);
14861486 const data = tree.nodes.items(.data)[node];
14871487 const extra = tree.extraData(data.rhs, Node.ArrayTypeSentinel);
......@@ -1496,7 +1496,7 @@ pub fn arrayTypeSentinel(tree: Tree, node: Node.Index) full.ArrayType {
14961496 };
14971497}
14981498
1499pub fn ptrTypeAligned(tree: Tree, node: Node.Index) full.PtrType {
1499pub fn ptrTypeAligned(tree: Ast, node: Node.Index) full.PtrType {
15001500 assert(tree.nodes.items(.tag)[node] == .ptr_type_aligned);
15011501 const data = tree.nodes.items(.data)[node];
15021502 return tree.fullPtrType(.{
......@@ -1510,7 +1510,7 @@ pub fn ptrTypeAligned(tree: Tree, node: Node.Index) full.PtrType {
15101510 });
15111511}
15121512
1513pub fn ptrTypeSentinel(tree: Tree, node: Node.Index) full.PtrType {
1513pub fn ptrTypeSentinel(tree: Ast, node: Node.Index) full.PtrType {
15141514 assert(tree.nodes.items(.tag)[node] == .ptr_type_sentinel);
15151515 const data = tree.nodes.items(.data)[node];
15161516 return tree.fullPtrType(.{
......@@ -1524,7 +1524,7 @@ pub fn ptrTypeSentinel(tree: Tree, node: Node.Index) full.PtrType {
15241524 });
15251525}
15261526
1527pub fn ptrType(tree: Tree, node: Node.Index) full.PtrType {
1527pub fn ptrType(tree: Ast, node: Node.Index) full.PtrType {
15281528 assert(tree.nodes.items(.tag)[node] == .ptr_type);
15291529 const data = tree.nodes.items(.data)[node];
15301530 const extra = tree.extraData(data.lhs, Node.PtrType);
......@@ -1539,7 +1539,7 @@ pub fn ptrType(tree: Tree, node: Node.Index) full.PtrType {
15391539 });
15401540}
15411541
1542pub fn ptrTypeBitRange(tree: Tree, node: Node.Index) full.PtrType {
1542pub fn ptrTypeBitRange(tree: Ast, node: Node.Index) full.PtrType {
15431543 assert(tree.nodes.items(.tag)[node] == .ptr_type_bit_range);
15441544 const data = tree.nodes.items(.data)[node];
15451545 const extra = tree.extraData(data.lhs, Node.PtrTypeBitRange);
......@@ -1554,7 +1554,7 @@ pub fn ptrTypeBitRange(tree: Tree, node: Node.Index) full.PtrType {
15541554 });
15551555}
15561556
1557pub fn sliceOpen(tree: Tree, node: Node.Index) full.Slice {
1557pub fn sliceOpen(tree: Ast, node: Node.Index) full.Slice {
15581558 assert(tree.nodes.items(.tag)[node] == .slice_open);
15591559 const data = tree.nodes.items(.data)[node];
15601560 return .{
......@@ -1568,7 +1568,7 @@ pub fn sliceOpen(tree: Tree, node: Node.Index) full.Slice {
15681568 };
15691569}
15701570
1571pub fn slice(tree: Tree, node: Node.Index) full.Slice {
1571pub fn slice(tree: Ast, node: Node.Index) full.Slice {
15721572 assert(tree.nodes.items(.tag)[node] == .slice);
15731573 const data = tree.nodes.items(.data)[node];
15741574 const extra = tree.extraData(data.rhs, Node.Slice);
......@@ -1583,7 +1583,7 @@ pub fn slice(tree: Tree, node: Node.Index) full.Slice {
15831583 };
15841584}
15851585
1586pub fn sliceSentinel(tree: Tree, node: Node.Index) full.Slice {
1586pub fn sliceSentinel(tree: Ast, node: Node.Index) full.Slice {
15871587 assert(tree.nodes.items(.tag)[node] == .slice_sentinel);
15881588 const data = tree.nodes.items(.data)[node];
15891589 const extra = tree.extraData(data.rhs, Node.SliceSentinel);
......@@ -1598,7 +1598,7 @@ pub fn sliceSentinel(tree: Tree, node: Node.Index) full.Slice {
15981598 };
15991599}
16001600
1601pub fn containerDeclTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl {
1601pub fn containerDeclTwo(tree: Ast, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl {
16021602 assert(tree.nodes.items(.tag)[node] == .container_decl_two or
16031603 tree.nodes.items(.tag)[node] == .container_decl_two_trailing);
16041604 const data = tree.nodes.items(.data)[node];
......@@ -1617,7 +1617,7 @@ pub fn containerDeclTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) fu
16171617 });
16181618}
16191619
1620pub fn containerDecl(tree: Tree, node: Node.Index) full.ContainerDecl {
1620pub fn containerDecl(tree: Ast, node: Node.Index) full.ContainerDecl {
16211621 assert(tree.nodes.items(.tag)[node] == .container_decl or
16221622 tree.nodes.items(.tag)[node] == .container_decl_trailing);
16231623 const data = tree.nodes.items(.data)[node];
......@@ -1629,7 +1629,7 @@ pub fn containerDecl(tree: Tree, node: Node.Index) full.ContainerDecl {
16291629 });
16301630}
16311631
1632pub fn containerDeclArg(tree: Tree, node: Node.Index) full.ContainerDecl {
1632pub fn containerDeclArg(tree: Ast, node: Node.Index) full.ContainerDecl {
16331633 assert(tree.nodes.items(.tag)[node] == .container_decl_arg or
16341634 tree.nodes.items(.tag)[node] == .container_decl_arg_trailing);
16351635 const data = tree.nodes.items(.data)[node];
......@@ -1642,7 +1642,7 @@ pub fn containerDeclArg(tree: Tree, node: Node.Index) full.ContainerDecl {
16421642 });
16431643}
16441644
1645pub fn taggedUnionTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl {
1645pub fn taggedUnionTwo(tree: Ast, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl {
16461646 assert(tree.nodes.items(.tag)[node] == .tagged_union_two or
16471647 tree.nodes.items(.tag)[node] == .tagged_union_two_trailing);
16481648 const data = tree.nodes.items(.data)[node];
......@@ -1662,7 +1662,7 @@ pub fn taggedUnionTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full
16621662 });
16631663}
16641664
1665pub fn taggedUnion(tree: Tree, node: Node.Index) full.ContainerDecl {
1665pub fn taggedUnion(tree: Ast, node: Node.Index) full.ContainerDecl {
16661666 assert(tree.nodes.items(.tag)[node] == .tagged_union or
16671667 tree.nodes.items(.tag)[node] == .tagged_union_trailing);
16681668 const data = tree.nodes.items(.data)[node];
......@@ -1675,7 +1675,7 @@ pub fn taggedUnion(tree: Tree, node: Node.Index) full.ContainerDecl {
16751675 });
16761676}
16771677
1678pub fn taggedUnionEnumTag(tree: Tree, node: Node.Index) full.ContainerDecl {
1678pub fn taggedUnionEnumTag(tree: Ast, node: Node.Index) full.ContainerDecl {
16791679 assert(tree.nodes.items(.tag)[node] == .tagged_union_enum_tag or
16801680 tree.nodes.items(.tag)[node] == .tagged_union_enum_tag_trailing);
16811681 const data = tree.nodes.items(.data)[node];
......@@ -1689,7 +1689,7 @@ pub fn taggedUnionEnumTag(tree: Tree, node: Node.Index) full.ContainerDecl {
16891689 });
16901690}
16911691
1692pub fn switchCaseOne(tree: Tree, node: Node.Index) full.SwitchCase {
1692pub fn switchCaseOne(tree: Ast, node: Node.Index) full.SwitchCase {
16931693 const data = &tree.nodes.items(.data)[node];
16941694 const values: *[1]Node.Index = &data.lhs;
16951695 return tree.fullSwitchCase(.{
......@@ -1699,7 +1699,7 @@ pub fn switchCaseOne(tree: Tree, node: Node.Index) full.SwitchCase {
16991699 });
17001700}
17011701
1702pub fn switchCase(tree: Tree, node: Node.Index) full.SwitchCase {
1702pub fn switchCase(tree: Ast, node: Node.Index) full.SwitchCase {
17031703 const data = tree.nodes.items(.data)[node];
17041704 const extra = tree.extraData(data.lhs, Node.SubRange);
17051705 return tree.fullSwitchCase(.{
......@@ -1709,7 +1709,7 @@ pub fn switchCase(tree: Tree, node: Node.Index) full.SwitchCase {
17091709 });
17101710}
17111711
1712pub fn asmSimple(tree: Tree, node: Node.Index) full.Asm {
1712pub fn asmSimple(tree: Ast, node: Node.Index) full.Asm {
17131713 const data = tree.nodes.items(.data)[node];
17141714 return tree.fullAsm(.{
17151715 .asm_token = tree.nodes.items(.main_token)[node],
......@@ -1719,7 +1719,7 @@ pub fn asmSimple(tree: Tree, node: Node.Index) full.Asm {
17191719 });
17201720}
17211721
1722pub fn asmFull(tree: Tree, node: Node.Index) full.Asm {
1722pub fn asmFull(tree: Ast, node: Node.Index) full.Asm {
17231723 const data = tree.nodes.items(.data)[node];
17241724 const extra = tree.extraData(data.rhs, Node.Asm);
17251725 return tree.fullAsm(.{
......@@ -1730,7 +1730,7 @@ pub fn asmFull(tree: Tree, node: Node.Index) full.Asm {
17301730 });
17311731}
17321732
1733pub fn whileSimple(tree: Tree, node: Node.Index) full.While {
1733pub fn whileSimple(tree: Ast, node: Node.Index) full.While {
17341734 const data = tree.nodes.items(.data)[node];
17351735 return tree.fullWhile(.{
17361736 .while_token = tree.nodes.items(.main_token)[node],
......@@ -1741,7 +1741,7 @@ pub fn whileSimple(tree: Tree, node: Node.Index) full.While {
17411741 });
17421742}
17431743
1744pub fn whileCont(tree: Tree, node: Node.Index) full.While {
1744pub fn whileCont(tree: Ast, node: Node.Index) full.While {
17451745 const data = tree.nodes.items(.data)[node];
17461746 const extra = tree.extraData(data.rhs, Node.WhileCont);
17471747 return tree.fullWhile(.{
......@@ -1753,7 +1753,7 @@ pub fn whileCont(tree: Tree, node: Node.Index) full.While {
17531753 });
17541754}
17551755
1756pub fn whileFull(tree: Tree, node: Node.Index) full.While {
1756pub fn whileFull(tree: Ast, node: Node.Index) full.While {
17571757 const data = tree.nodes.items(.data)[node];
17581758 const extra = tree.extraData(data.rhs, Node.While);
17591759 return tree.fullWhile(.{
......@@ -1765,7 +1765,7 @@ pub fn whileFull(tree: Tree, node: Node.Index) full.While {
17651765 });
17661766}
17671767
1768pub fn forSimple(tree: Tree, node: Node.Index) full.While {
1768pub fn forSimple(tree: Ast, node: Node.Index) full.While {
17691769 const data = tree.nodes.items(.data)[node];
17701770 return tree.fullWhile(.{
17711771 .while_token = tree.nodes.items(.main_token)[node],
......@@ -1776,7 +1776,7 @@ pub fn forSimple(tree: Tree, node: Node.Index) full.While {
17761776 });
17771777}
17781778
1779pub fn forFull(tree: Tree, node: Node.Index) full.While {
1779pub fn forFull(tree: Ast, node: Node.Index) full.While {
17801780 const data = tree.nodes.items(.data)[node];
17811781 const extra = tree.extraData(data.rhs, Node.If);
17821782 return tree.fullWhile(.{
......@@ -1788,7 +1788,7 @@ pub fn forFull(tree: Tree, node: Node.Index) full.While {
17881788 });
17891789}
17901790
1791pub fn callOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.Call {
1791pub fn callOne(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.Call {
17921792 const data = tree.nodes.items(.data)[node];
17931793 buffer.* = .{data.rhs};
17941794 const params = if (data.rhs != 0) buffer[0..1] else buffer[0..0];
......@@ -1799,7 +1799,7 @@ pub fn callOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.Call {
17991799 });
18001800}
18011801
1802pub fn callFull(tree: Tree, node: Node.Index) full.Call {
1802pub fn callFull(tree: Ast, node: Node.Index) full.Call {
18031803 const data = tree.nodes.items(.data)[node];
18041804 const extra = tree.extraData(data.rhs, Node.SubRange);
18051805 return tree.fullCall(.{
......@@ -1809,7 +1809,7 @@ pub fn callFull(tree: Tree, node: Node.Index) full.Call {
18091809 });
18101810}
18111811
1812fn fullVarDecl(tree: Tree, info: full.VarDecl.Components) full.VarDecl {
1812fn fullVarDecl(tree: Ast, info: full.VarDecl.Components) full.VarDecl {
18131813 const token_tags = tree.tokens.items(.tag);
18141814 var result: full.VarDecl = .{
18151815 .ast = info,
......@@ -1834,7 +1834,7 @@ fn fullVarDecl(tree: Tree, info: full.VarDecl.Components) full.VarDecl {
18341834 return result;
18351835}
18361836
1837fn fullIf(tree: Tree, info: full.If.Components) full.If {
1837fn fullIf(tree: Ast, info: full.If.Components) full.If {
18381838 const token_tags = tree.tokens.items(.tag);
18391839 var result: full.If = .{
18401840 .ast = info,
......@@ -1859,7 +1859,7 @@ fn fullIf(tree: Tree, info: full.If.Components) full.If {
18591859 return result;
18601860}
18611861
1862fn fullContainerField(tree: Tree, info: full.ContainerField.Components) full.ContainerField {
1862fn fullContainerField(tree: Ast, info: full.ContainerField.Components) full.ContainerField {
18631863 const token_tags = tree.tokens.items(.tag);
18641864 var result: full.ContainerField = .{
18651865 .ast = info,
......@@ -1873,7 +1873,7 @@ fn fullContainerField(tree: Tree, info: full.ContainerField.Components) full.Con
18731873 return result;
18741874}
18751875
1876fn fullFnProto(tree: Tree, info: full.FnProto.Components) full.FnProto {
1876fn fullFnProto(tree: Ast, info: full.FnProto.Components) full.FnProto {
18771877 const token_tags = tree.tokens.items(.tag);
18781878 var result: full.FnProto = .{
18791879 .ast = info,
......@@ -1909,7 +1909,7 @@ fn fullFnProto(tree: Tree, info: full.FnProto.Components) full.FnProto {
19091909 return result;
19101910}
19111911
1912fn fullStructInit(tree: Tree, info: full.StructInit.Components) full.StructInit {
1912fn fullStructInit(tree: Ast, info: full.StructInit.Components) full.StructInit {
19131913 _ = tree;
19141914 var result: full.StructInit = .{
19151915 .ast = info,
......@@ -1917,7 +1917,7 @@ fn fullStructInit(tree: Tree, info: full.StructInit.Components) full.StructInit
19171917 return result;
19181918}
19191919
1920fn fullPtrType(tree: Tree, info: full.PtrType.Components) full.PtrType {
1920fn fullPtrType(tree: Ast, info: full.PtrType.Components) full.PtrType {
19211921 const token_tags = tree.tokens.items(.tag);
19221922 // TODO: looks like stage1 isn't quite smart enough to handle enum
19231923 // literals in some places here
......@@ -1966,7 +1966,7 @@ fn fullPtrType(tree: Tree, info: full.PtrType.Components) full.PtrType {
19661966 return result;
19671967}
19681968
1969fn fullContainerDecl(tree: Tree, info: full.ContainerDecl.Components) full.ContainerDecl {
1969fn fullContainerDecl(tree: Ast, info: full.ContainerDecl.Components) full.ContainerDecl {
19701970 const token_tags = tree.tokens.items(.tag);
19711971 var result: full.ContainerDecl = .{
19721972 .ast = info,
......@@ -1979,7 +1979,7 @@ fn fullContainerDecl(tree: Tree, info: full.ContainerDecl.Components) full.Conta
19791979 return result;
19801980}
19811981
1982fn fullSwitchCase(tree: Tree, info: full.SwitchCase.Components) full.SwitchCase {
1982fn fullSwitchCase(tree: Ast, info: full.SwitchCase.Components) full.SwitchCase {
19831983 const token_tags = tree.tokens.items(.tag);
19841984 var result: full.SwitchCase = .{
19851985 .ast = info,
......@@ -1991,7 +1991,7 @@ fn fullSwitchCase(tree: Tree, info: full.SwitchCase.Components) full.SwitchCase
19911991 return result;
19921992}
19931993
1994fn fullAsm(tree: Tree, info: full.Asm.Components) full.Asm {
1994fn fullAsm(tree: Ast, info: full.Asm.Components) full.Asm {
19951995 const token_tags = tree.tokens.items(.tag);
19961996 const node_tags = tree.nodes.items(.tag);
19971997 var result: full.Asm = .{
......@@ -2054,7 +2054,7 @@ fn fullAsm(tree: Tree, info: full.Asm.Components) full.Asm {
20542054 return result;
20552055}
20562056
2057fn fullWhile(tree: Tree, info: full.While.Components) full.While {
2057fn fullWhile(tree: Ast, info: full.While.Components) full.While {
20582058 const token_tags = tree.tokens.items(.tag);
20592059 var result: full.While = .{
20602060 .ast = info,
......@@ -2089,7 +2089,7 @@ fn fullWhile(tree: Tree, info: full.While.Components) full.While {
20892089 return result;
20902090}
20912091
2092fn fullCall(tree: Tree, info: full.Call.Components) full.Call {
2092fn fullCall(tree: Ast, info: full.Call.Components) full.Call {
20932093 const token_tags = tree.tokens.items(.tag);
20942094 var result: full.Call = .{
20952095 .ast = info,
......@@ -2201,7 +2201,7 @@ pub const full = struct {
22012201 /// in the params slice, since they are simple identifiers and
22022202 /// not sub-expressions.
22032203 pub const Iterator = struct {
2204 tree: *const Tree,
2204 tree: *const Ast,
22052205 fn_proto: *const FnProto,
22062206 param_i: usize,
22072207 tok_i: TokenIndex,
......@@ -2291,7 +2291,7 @@ pub const full = struct {
22912291 }
22922292 };
22932293
2294 pub fn iterate(fn_proto: FnProto, tree: Tree) Iterator {
2294 pub fn iterate(fn_proto: FnProto, tree: Ast) Iterator {
22952295 return .{
22962296 .tree = &tree,
22972297 .fn_proto = &fn_proto,
......@@ -2485,7 +2485,7 @@ pub const Node = struct {
24852485 }
24862486
24872487 /// Note: The FooComma/FooSemicolon variants exist to ease the implementation of
2488 /// Tree.lastToken()
2488 /// Ast.lastToken()
24892489 pub const Tag = enum {
24902490 /// sub_list[lhs...rhs]
24912491 root,