revert std.zig.ast iterator changes back to master branch API
parent
c78a2e2e8d
commit
f771545a7e
|
@ -399,22 +399,6 @@ pub const Error = union(enum) {
|
||||||
pub const Node = struct {
|
pub const Node = struct {
|
||||||
id: Id,
|
id: Id,
|
||||||
|
|
||||||
/// All the child Node types use this same Iterator state for their iteration.
|
|
||||||
pub const Iterator = struct {
|
|
||||||
parent_node: *const Node,
|
|
||||||
index: usize,
|
|
||||||
|
|
||||||
pub fn next(it: *Iterator) ?*Node {
|
|
||||||
inline for (@typeInfo(Id).Enum.fields) |f| {
|
|
||||||
if (it.parent_node.id == @field(Id, f.name)) {
|
|
||||||
const T = @field(Node, f.name);
|
|
||||||
return @fieldParentPtr(T, "base", it.parent_node).iterateNext(it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unreachable;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const Id = enum {
|
pub const Id = enum {
|
||||||
// Top level
|
// Top level
|
||||||
Root,
|
Root,
|
||||||
|
@ -497,11 +481,11 @@ pub const Node = struct {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iterate(base: *Node) Iterator {
|
pub fn iterate(base: *Node, index: usize) ?*Node {
|
||||||
inline for (@typeInfo(Id).Enum.fields) |f| {
|
inline for (@typeInfo(Id).Enum.fields) |f| {
|
||||||
if (base.id == @field(Id, f.name)) {
|
if (base.id == @field(Id, f.name)) {
|
||||||
const T = @field(Node, f.name);
|
const T = @field(Node, f.name);
|
||||||
return @fieldParentPtr(T, "base", base).iterate();
|
return @fieldParentPtr(T, "base", base).iterate(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unreachable;
|
unreachable;
|
||||||
|
@ -647,13 +631,8 @@ pub const Node = struct {
|
||||||
allocator.free(bytes);
|
allocator.free(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iterate(self: *const Root) Node.Iterator {
|
pub fn iterate(self: *const Root, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const Root, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < self.decls_len) return self.declsConst()[i];
|
if (i < self.decls_len) return self.declsConst()[i];
|
||||||
return null;
|
return null;
|
||||||
|
@ -701,13 +680,8 @@ pub const Node = struct {
|
||||||
init_node: ?*Node,
|
init_node: ?*Node,
|
||||||
semicolon_token: TokenIndex,
|
semicolon_token: TokenIndex,
|
||||||
|
|
||||||
pub fn iterate(self: *const VarDecl) Node.Iterator {
|
pub fn iterate(self: *const VarDecl, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const VarDecl, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (self.type_node) |type_node| {
|
if (self.type_node) |type_node| {
|
||||||
if (i < 1) return type_node;
|
if (i < 1) return type_node;
|
||||||
|
@ -755,13 +729,8 @@ pub const Node = struct {
|
||||||
expr: *Node,
|
expr: *Node,
|
||||||
semicolon_token: TokenIndex,
|
semicolon_token: TokenIndex,
|
||||||
|
|
||||||
pub fn iterate(self: *const Use) Node.Iterator {
|
pub fn iterate(self: *const Use, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const Use, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < 1) return self.expr;
|
if (i < 1) return self.expr;
|
||||||
i -= 1;
|
i -= 1;
|
||||||
|
@ -796,13 +765,8 @@ pub const Node = struct {
|
||||||
allocator.free(bytes);
|
allocator.free(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iterate(self: *const ErrorSetDecl) Node.Iterator {
|
pub fn iterate(self: *const ErrorSetDecl, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const ErrorSetDecl, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < self.decls_len) return self.declsConst()[i];
|
if (i < self.decls_len) return self.declsConst()[i];
|
||||||
i -= self.decls_len;
|
i -= self.decls_len;
|
||||||
|
@ -860,13 +824,8 @@ pub const Node = struct {
|
||||||
allocator.free(bytes);
|
allocator.free(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iterate(self: *const ContainerDecl) Node.Iterator {
|
pub fn iterate(self: *const ContainerDecl, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const ContainerDecl, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
switch (self.init_arg_expr) {
|
switch (self.init_arg_expr) {
|
||||||
.Type => |t| {
|
.Type => |t| {
|
||||||
|
@ -917,13 +876,8 @@ pub const Node = struct {
|
||||||
value_expr: ?*Node,
|
value_expr: ?*Node,
|
||||||
align_expr: ?*Node,
|
align_expr: ?*Node,
|
||||||
|
|
||||||
pub fn iterate(self: *const ContainerField) Node.Iterator {
|
pub fn iterate(self: *const ContainerField, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const ContainerField, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (self.type_expr) |type_expr| {
|
if (self.type_expr) |type_expr| {
|
||||||
if (i < 1) return type_expr;
|
if (i < 1) return type_expr;
|
||||||
|
@ -969,13 +923,8 @@ pub const Node = struct {
|
||||||
doc_comments: ?*DocComment,
|
doc_comments: ?*DocComment,
|
||||||
name_token: TokenIndex,
|
name_token: TokenIndex,
|
||||||
|
|
||||||
pub fn iterate(self: *const ErrorTag) Node.Iterator {
|
pub fn iterate(self: *const ErrorTag, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const ErrorTag, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (self.doc_comments) |comments| {
|
if (self.doc_comments) |comments| {
|
||||||
if (i < 1) return &comments.base;
|
if (i < 1) return &comments.base;
|
||||||
|
@ -998,11 +947,7 @@ pub const Node = struct {
|
||||||
base: Node = Node{ .id = .Identifier },
|
base: Node = Node{ .id = .Identifier },
|
||||||
token: TokenIndex,
|
token: TokenIndex,
|
||||||
|
|
||||||
pub fn iterate(self: *const Identifier) Node.Iterator {
|
pub fn iterate(self: *const Identifier, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const Identifier, it: *Node.Iterator) ?*Node {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1053,13 +998,8 @@ pub const Node = struct {
|
||||||
type_expr: *Node,
|
type_expr: *Node,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn iterate(self: *const ParamDecl) Node.Iterator {
|
pub fn iterate(self: *const ParamDecl, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const ParamDecl, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < 1) {
|
if (i < 1) {
|
||||||
switch (self.param_type) {
|
switch (self.param_type) {
|
||||||
|
@ -1101,30 +1041,26 @@ pub const Node = struct {
|
||||||
allocator.free(bytes);
|
allocator.free(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iterate(self: *const FnProto) Node.Iterator {
|
pub fn iterate(self: *const FnProto, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const FnProto, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (self.lib_name) |lib_name| {
|
if (self.lib_name) |lib_name| {
|
||||||
if (i < 1) return lib_name;
|
if (i < 1) return lib_name;
|
||||||
i -= 1;
|
i -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < self.params_len) {
|
const params_len = switch (self.paramsConst()[self.params_len - 1].param_type) {
|
||||||
|
.var_type, .type_expr => self.params_len,
|
||||||
|
.var_args => self.params_len - 1,
|
||||||
|
};
|
||||||
|
if (i < params_len) {
|
||||||
switch (self.paramsConst()[i].param_type) {
|
switch (self.paramsConst()[i].param_type) {
|
||||||
.var_type => |n| return n,
|
.var_type => |n| return n,
|
||||||
.var_args => {
|
.var_args => unreachable,
|
||||||
i += 1;
|
|
||||||
it.index += 1;
|
|
||||||
},
|
|
||||||
.type_expr => |n| return n,
|
.type_expr => |n| return n,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i -= self.params_len;
|
i -= params_len;
|
||||||
|
|
||||||
if (self.align_expr) |align_expr| {
|
if (self.align_expr) |align_expr| {
|
||||||
if (i < 1) return align_expr;
|
if (i < 1) return align_expr;
|
||||||
|
@ -1192,13 +1128,8 @@ pub const Node = struct {
|
||||||
return_type: *Node,
|
return_type: *Node,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn iterate(self: *const AnyFrameType) Node.Iterator {
|
pub fn iterate(self: *const AnyFrameType, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const AnyFrameType, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (self.result) |result| {
|
if (self.result) |result| {
|
||||||
if (i < 1) return result.return_type;
|
if (i < 1) return result.return_type;
|
||||||
|
@ -1237,13 +1168,8 @@ pub const Node = struct {
|
||||||
allocator.free(bytes);
|
allocator.free(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iterate(self: *const Block) Node.Iterator {
|
pub fn iterate(self: *const Block, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const Block, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < self.statements_len) return self.statementsConst()[i];
|
if (i < self.statements_len) return self.statementsConst()[i];
|
||||||
i -= self.statements_len;
|
i -= self.statements_len;
|
||||||
|
@ -1284,13 +1210,8 @@ pub const Node = struct {
|
||||||
payload: ?*Node,
|
payload: ?*Node,
|
||||||
expr: *Node,
|
expr: *Node,
|
||||||
|
|
||||||
pub fn iterate(self: *const Defer) Node.Iterator {
|
pub fn iterate(self: *const Defer, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const Defer, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < 1) return self.expr;
|
if (i < 1) return self.expr;
|
||||||
i -= 1;
|
i -= 1;
|
||||||
|
@ -1313,13 +1234,8 @@ pub const Node = struct {
|
||||||
comptime_token: TokenIndex,
|
comptime_token: TokenIndex,
|
||||||
expr: *Node,
|
expr: *Node,
|
||||||
|
|
||||||
pub fn iterate(self: *const Comptime) Node.Iterator {
|
pub fn iterate(self: *const Comptime, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const Comptime, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < 1) return self.expr;
|
if (i < 1) return self.expr;
|
||||||
i -= 1;
|
i -= 1;
|
||||||
|
@ -1341,13 +1257,8 @@ pub const Node = struct {
|
||||||
nosuspend_token: TokenIndex,
|
nosuspend_token: TokenIndex,
|
||||||
expr: *Node,
|
expr: *Node,
|
||||||
|
|
||||||
pub fn iterate(self: *const Nosuspend) Node.Iterator {
|
pub fn iterate(self: *const Nosuspend, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const Nosuspend, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < 1) return self.expr;
|
if (i < 1) return self.expr;
|
||||||
i -= 1;
|
i -= 1;
|
||||||
|
@ -1370,13 +1281,8 @@ pub const Node = struct {
|
||||||
error_symbol: *Node,
|
error_symbol: *Node,
|
||||||
rpipe: TokenIndex,
|
rpipe: TokenIndex,
|
||||||
|
|
||||||
pub fn iterate(self: *const Payload) Node.Iterator {
|
pub fn iterate(self: *const Payload, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const Payload, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < 1) return self.error_symbol;
|
if (i < 1) return self.error_symbol;
|
||||||
i -= 1;
|
i -= 1;
|
||||||
|
@ -1400,13 +1306,8 @@ pub const Node = struct {
|
||||||
value_symbol: *Node,
|
value_symbol: *Node,
|
||||||
rpipe: TokenIndex,
|
rpipe: TokenIndex,
|
||||||
|
|
||||||
pub fn iterate(self: *const PointerPayload) Node.Iterator {
|
pub fn iterate(self: *const PointerPayload, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const PointerPayload, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < 1) return self.value_symbol;
|
if (i < 1) return self.value_symbol;
|
||||||
i -= 1;
|
i -= 1;
|
||||||
|
@ -1431,13 +1332,8 @@ pub const Node = struct {
|
||||||
index_symbol: ?*Node,
|
index_symbol: ?*Node,
|
||||||
rpipe: TokenIndex,
|
rpipe: TokenIndex,
|
||||||
|
|
||||||
pub fn iterate(self: *const PointerIndexPayload) Node.Iterator {
|
pub fn iterate(self: *const PointerIndexPayload, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const PointerIndexPayload, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < 1) return self.value_symbol;
|
if (i < 1) return self.value_symbol;
|
||||||
i -= 1;
|
i -= 1;
|
||||||
|
@ -1465,13 +1361,8 @@ pub const Node = struct {
|
||||||
payload: ?*Node,
|
payload: ?*Node,
|
||||||
body: *Node,
|
body: *Node,
|
||||||
|
|
||||||
pub fn iterate(self: *const Else) Node.Iterator {
|
pub fn iterate(self: *const Else, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const Else, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (self.payload) |payload| {
|
if (self.payload) |payload| {
|
||||||
if (i < 1) return payload;
|
if (i < 1) return payload;
|
||||||
|
@ -1513,13 +1404,8 @@ pub const Node = struct {
|
||||||
allocator.free(bytes);
|
allocator.free(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iterate(self: *const Switch) Node.Iterator {
|
pub fn iterate(self: *const Switch, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const Switch, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < 1) return self.expr;
|
if (i < 1) return self.expr;
|
||||||
i -= 1;
|
i -= 1;
|
||||||
|
@ -1572,13 +1458,8 @@ pub const Node = struct {
|
||||||
allocator.free(bytes);
|
allocator.free(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iterate(self: *const SwitchCase) Node.Iterator {
|
pub fn iterate(self: *const SwitchCase, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const SwitchCase, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < self.items_len) return self.itemsConst()[i];
|
if (i < self.items_len) return self.itemsConst()[i];
|
||||||
i -= self.items_len;
|
i -= self.items_len;
|
||||||
|
@ -1621,11 +1502,7 @@ pub const Node = struct {
|
||||||
base: Node = Node{ .id = .SwitchElse },
|
base: Node = Node{ .id = .SwitchElse },
|
||||||
token: TokenIndex,
|
token: TokenIndex,
|
||||||
|
|
||||||
pub fn iterate(self: *const SwitchElse) Node.Iterator {
|
pub fn iterate(self: *const SwitchElse, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const SwitchElse, it: *Node.Iterator) ?*Node {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1649,13 +1526,8 @@ pub const Node = struct {
|
||||||
body: *Node,
|
body: *Node,
|
||||||
@"else": ?*Else,
|
@"else": ?*Else,
|
||||||
|
|
||||||
pub fn iterate(self: *const While) Node.Iterator {
|
pub fn iterate(self: *const While, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const While, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < 1) return self.condition;
|
if (i < 1) return self.condition;
|
||||||
i -= 1;
|
i -= 1;
|
||||||
|
@ -1712,13 +1584,8 @@ pub const Node = struct {
|
||||||
body: *Node,
|
body: *Node,
|
||||||
@"else": ?*Else,
|
@"else": ?*Else,
|
||||||
|
|
||||||
pub fn iterate(self: *const For) Node.Iterator {
|
pub fn iterate(self: *const For, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const For, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < 1) return self.array_expr;
|
if (i < 1) return self.array_expr;
|
||||||
i -= 1;
|
i -= 1;
|
||||||
|
@ -1766,13 +1633,8 @@ pub const Node = struct {
|
||||||
body: *Node,
|
body: *Node,
|
||||||
@"else": ?*Else,
|
@"else": ?*Else,
|
||||||
|
|
||||||
pub fn iterate(self: *const If) Node.Iterator {
|
pub fn iterate(self: *const If, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const If, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < 1) return self.condition;
|
if (i < 1) return self.condition;
|
||||||
i -= 1;
|
i -= 1;
|
||||||
|
@ -1859,13 +1721,8 @@ pub const Node = struct {
|
||||||
UnwrapOptional,
|
UnwrapOptional,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn iterate(self: *const InfixOp) Node.Iterator {
|
pub fn iterate(self: *const InfixOp, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const InfixOp, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < 1) return self.lhs;
|
if (i < 1) return self.lhs;
|
||||||
i -= 1;
|
i -= 1;
|
||||||
|
@ -1982,13 +1839,8 @@ pub const Node = struct {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn iterate(self: *const PrefixOp) Node.Iterator {
|
pub fn iterate(self: *const PrefixOp, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const PrefixOp, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
switch (self.op) {
|
switch (self.op) {
|
||||||
.PtrType, .SliceType => |addr_of_info| {
|
.PtrType, .SliceType => |addr_of_info| {
|
||||||
|
@ -2045,13 +1897,8 @@ pub const Node = struct {
|
||||||
name_token: TokenIndex,
|
name_token: TokenIndex,
|
||||||
expr: *Node,
|
expr: *Node,
|
||||||
|
|
||||||
pub fn iterate(self: *const FieldInitializer) Node.Iterator {
|
pub fn iterate(self: *const FieldInitializer, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const FieldInitializer, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < 1) return self.expr;
|
if (i < 1) return self.expr;
|
||||||
i -= 1;
|
i -= 1;
|
||||||
|
@ -2086,13 +1933,8 @@ pub const Node = struct {
|
||||||
allocator.free(bytes);
|
allocator.free(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iterate(self: *const ArrayInitializer) Node.Iterator {
|
pub fn iterate(self: *const ArrayInitializer, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const ArrayInitializer, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < 1) return self.lhs;
|
if (i < 1) return self.lhs;
|
||||||
i -= 1;
|
i -= 1;
|
||||||
|
@ -2144,13 +1986,8 @@ pub const Node = struct {
|
||||||
allocator.free(bytes);
|
allocator.free(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iterate(self: *const ArrayInitializerDot) Node.Iterator {
|
pub fn iterate(self: *const ArrayInitializerDot, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const ArrayInitializerDot, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < self.list_len) return self.listConst()[i];
|
if (i < self.list_len) return self.listConst()[i];
|
||||||
i -= self.list_len;
|
i -= self.list_len;
|
||||||
|
@ -2199,13 +2036,8 @@ pub const Node = struct {
|
||||||
allocator.free(bytes);
|
allocator.free(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iterate(self: *const StructInitializer) Node.Iterator {
|
pub fn iterate(self: *const StructInitializer, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const StructInitializer, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < 1) return self.lhs;
|
if (i < 1) return self.lhs;
|
||||||
i -= 1;
|
i -= 1;
|
||||||
|
@ -2257,13 +2089,8 @@ pub const Node = struct {
|
||||||
allocator.free(bytes);
|
allocator.free(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iterate(self: *const StructInitializerDot) Node.Iterator {
|
pub fn iterate(self: *const StructInitializerDot, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const StructInitializerDot, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < self.list_len) return self.listConst()[i];
|
if (i < self.list_len) return self.listConst()[i];
|
||||||
i -= self.list_len;
|
i -= self.list_len;
|
||||||
|
@ -2313,13 +2140,8 @@ pub const Node = struct {
|
||||||
allocator.free(bytes);
|
allocator.free(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iterate(self: *const Call) Node.Iterator {
|
pub fn iterate(self: *const Call, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0};
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const Call, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < 1) return self.lhs;
|
if (i < 1) return self.lhs;
|
||||||
i -= 1;
|
i -= 1;
|
||||||
|
@ -2373,13 +2195,8 @@ pub const Node = struct {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn iterate(self: *const SuffixOp) Node.Iterator {
|
pub fn iterate(self: *const SuffixOp, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0};
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const SuffixOp, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i == 0) return self.lhs;
|
if (i == 0) return self.lhs;
|
||||||
i -= 1;
|
i -= 1;
|
||||||
|
@ -2425,13 +2242,8 @@ pub const Node = struct {
|
||||||
expr: *Node,
|
expr: *Node,
|
||||||
rparen: TokenIndex,
|
rparen: TokenIndex,
|
||||||
|
|
||||||
pub fn iterate(self: *const GroupedExpression) Node.Iterator {
|
pub fn iterate(self: *const GroupedExpression, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const GroupedExpression, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < 1) return self.expr;
|
if (i < 1) return self.expr;
|
||||||
i -= 1;
|
i -= 1;
|
||||||
|
@ -2460,13 +2272,8 @@ pub const Node = struct {
|
||||||
Return,
|
Return,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn iterate(self: *const ControlFlowExpression) Node.Iterator {
|
pub fn iterate(self: *const ControlFlowExpression, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const ControlFlowExpression, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
switch (self.kind) {
|
switch (self.kind) {
|
||||||
.Break, .Continue => |maybe_label| {
|
.Break, .Continue => |maybe_label| {
|
||||||
|
@ -2513,13 +2320,8 @@ pub const Node = struct {
|
||||||
suspend_token: TokenIndex,
|
suspend_token: TokenIndex,
|
||||||
body: ?*Node,
|
body: ?*Node,
|
||||||
|
|
||||||
pub fn iterate(self: *const Suspend) Node.Iterator {
|
pub fn iterate(self: *const Suspend, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const Suspend, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (self.body) |body| {
|
if (self.body) |body| {
|
||||||
if (i < 1) return body;
|
if (i < 1) return body;
|
||||||
|
@ -2546,11 +2348,7 @@ pub const Node = struct {
|
||||||
base: Node = Node{ .id = .IntegerLiteral },
|
base: Node = Node{ .id = .IntegerLiteral },
|
||||||
token: TokenIndex,
|
token: TokenIndex,
|
||||||
|
|
||||||
pub fn iterate(self: *const IntegerLiteral) Node.Iterator {
|
pub fn iterate(self: *const IntegerLiteral, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const IntegerLiteral, it: *Node.Iterator) ?*Node {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2568,11 +2366,7 @@ pub const Node = struct {
|
||||||
dot: TokenIndex,
|
dot: TokenIndex,
|
||||||
name: TokenIndex,
|
name: TokenIndex,
|
||||||
|
|
||||||
pub fn iterate(self: *const EnumLiteral) Node.Iterator {
|
pub fn iterate(self: *const EnumLiteral, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const EnumLiteral, it: *Node.Iterator) ?*Node {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2589,11 +2383,7 @@ pub const Node = struct {
|
||||||
base: Node = Node{ .id = .FloatLiteral },
|
base: Node = Node{ .id = .FloatLiteral },
|
||||||
token: TokenIndex,
|
token: TokenIndex,
|
||||||
|
|
||||||
pub fn iterate(self: *const FloatLiteral) Node.Iterator {
|
pub fn iterate(self: *const FloatLiteral, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const FloatLiteral, it: *Node.Iterator) ?*Node {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2624,13 +2414,8 @@ pub const Node = struct {
|
||||||
allocator.free(bytes);
|
allocator.free(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iterate(self: *const BuiltinCall) Node.Iterator {
|
pub fn iterate(self: *const BuiltinCall, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const BuiltinCall, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < self.params_len) return self.paramsConst()[i];
|
if (i < self.params_len) return self.paramsConst()[i];
|
||||||
i -= self.params_len;
|
i -= self.params_len;
|
||||||
|
@ -2665,11 +2450,7 @@ pub const Node = struct {
|
||||||
base: Node = Node{ .id = .StringLiteral },
|
base: Node = Node{ .id = .StringLiteral },
|
||||||
token: TokenIndex,
|
token: TokenIndex,
|
||||||
|
|
||||||
pub fn iterate(self: *const StringLiteral) Node.Iterator {
|
pub fn iterate(self: *const StringLiteral, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const StringLiteral, it: *Node.Iterator) ?*Node {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2698,11 +2479,7 @@ pub const Node = struct {
|
||||||
allocator.free(bytes);
|
allocator.free(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iterate(self: *const MultilineStringLiteral) Node.Iterator {
|
pub fn iterate(self: *const MultilineStringLiteral, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const MultilineStringLiteral, it: *Node.Iterator) ?*Node {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2733,11 +2510,7 @@ pub const Node = struct {
|
||||||
base: Node = Node{ .id = .CharLiteral },
|
base: Node = Node{ .id = .CharLiteral },
|
||||||
token: TokenIndex,
|
token: TokenIndex,
|
||||||
|
|
||||||
pub fn iterate(self: *const CharLiteral) Node.Iterator {
|
pub fn iterate(self: *const CharLiteral, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const CharLiteral, it: *Node.Iterator) ?*Node {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2754,11 +2527,7 @@ pub const Node = struct {
|
||||||
base: Node = Node{ .id = .BoolLiteral },
|
base: Node = Node{ .id = .BoolLiteral },
|
||||||
token: TokenIndex,
|
token: TokenIndex,
|
||||||
|
|
||||||
pub fn iterate(self: *const BoolLiteral) Node.Iterator {
|
pub fn iterate(self: *const BoolLiteral, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const BoolLiteral, it: *Node.Iterator) ?*Node {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2775,11 +2544,7 @@ pub const Node = struct {
|
||||||
base: Node = Node{ .id = .NullLiteral },
|
base: Node = Node{ .id = .NullLiteral },
|
||||||
token: TokenIndex,
|
token: TokenIndex,
|
||||||
|
|
||||||
pub fn iterate(self: *const NullLiteral) Node.Iterator {
|
pub fn iterate(self: *const NullLiteral, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const NullLiteral, it: *Node.Iterator) ?*Node {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2796,11 +2561,7 @@ pub const Node = struct {
|
||||||
base: Node = Node{ .id = .UndefinedLiteral },
|
base: Node = Node{ .id = .UndefinedLiteral },
|
||||||
token: TokenIndex,
|
token: TokenIndex,
|
||||||
|
|
||||||
pub fn iterate(self: *const UndefinedLiteral) Node.Iterator {
|
pub fn iterate(self: *const UndefinedLiteral, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const UndefinedLiteral, it: *Node.Iterator) ?*Node {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2836,13 +2597,8 @@ pub const Node = struct {
|
||||||
Return: *Node,
|
Return: *Node,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn iterate(self: *const Output) Node.Iterator {
|
pub fn iterate(self: *const Output, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const Output, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < 1) return self.symbolic_name;
|
if (i < 1) return self.symbolic_name;
|
||||||
i -= 1;
|
i -= 1;
|
||||||
|
@ -2880,13 +2636,8 @@ pub const Node = struct {
|
||||||
expr: *Node,
|
expr: *Node,
|
||||||
rparen: TokenIndex,
|
rparen: TokenIndex,
|
||||||
|
|
||||||
pub fn iterate(self: *const Input) Node.Iterator {
|
pub fn iterate(self: *const Input, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const Input, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < 1) return self.symbolic_name;
|
if (i < 1) return self.symbolic_name;
|
||||||
i -= 1;
|
i -= 1;
|
||||||
|
@ -2910,13 +2661,8 @@ pub const Node = struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
pub fn iterate(self: *const Asm) Node.Iterator {
|
pub fn iterate(self: *const Asm, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0};
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const Asm, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < self.outputs.len * 3) switch (i % 3) {
|
if (i < self.outputs.len * 3) switch (i % 3) {
|
||||||
0 => return self.outputs[i / 3].symbolic_name,
|
0 => return self.outputs[i / 3].symbolic_name,
|
||||||
|
@ -2953,11 +2699,7 @@ pub const Node = struct {
|
||||||
base: Node = Node{ .id = .Unreachable },
|
base: Node = Node{ .id = .Unreachable },
|
||||||
token: TokenIndex,
|
token: TokenIndex,
|
||||||
|
|
||||||
pub fn iterate(self: *const Unreachable) Node.Iterator {
|
pub fn iterate(self: *const Unreachable, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const Unreachable, it: *Node.Iterator) ?*Node {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2974,11 +2716,7 @@ pub const Node = struct {
|
||||||
base: Node = Node{ .id = .ErrorType },
|
base: Node = Node{ .id = .ErrorType },
|
||||||
token: TokenIndex,
|
token: TokenIndex,
|
||||||
|
|
||||||
pub fn iterate(self: *const ErrorType) Node.Iterator {
|
pub fn iterate(self: *const ErrorType, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const ErrorType, it: *Node.Iterator) ?*Node {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2995,11 +2733,7 @@ pub const Node = struct {
|
||||||
base: Node = Node{ .id = .VarType },
|
base: Node = Node{ .id = .VarType },
|
||||||
token: TokenIndex,
|
token: TokenIndex,
|
||||||
|
|
||||||
pub fn iterate(self: *const VarType) Node.Iterator {
|
pub fn iterate(self: *const VarType, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const VarType, it: *Node.Iterator) ?*Node {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3019,11 +2753,7 @@ pub const Node = struct {
|
||||||
/// at the first other token.
|
/// at the first other token.
|
||||||
first_line: TokenIndex,
|
first_line: TokenIndex,
|
||||||
|
|
||||||
pub fn iterate(self: *const DocComment) Node.Iterator {
|
pub fn iterate(self: *const DocComment, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const DocComment, it: *Node.Iterator) ?*Node {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3045,13 +2775,8 @@ pub const Node = struct {
|
||||||
name: *Node,
|
name: *Node,
|
||||||
body_node: *Node,
|
body_node: *Node,
|
||||||
|
|
||||||
pub fn iterate(self: *const TestDecl) Node.Iterator {
|
pub fn iterate(self: *const TestDecl, index: usize) ?*Node {
|
||||||
return .{ .parent_node = &self.base, .index = 0 };
|
var i = index;
|
||||||
}
|
|
||||||
|
|
||||||
pub fn iterateNext(self: *const TestDecl, it: *Node.Iterator) ?*Node {
|
|
||||||
var i = it.index;
|
|
||||||
it.index += 1;
|
|
||||||
|
|
||||||
if (i < 1) return self.body_node;
|
if (i < 1) return self.body_node;
|
||||||
i -= 1;
|
i -= 1;
|
||||||
|
@ -3076,6 +2801,5 @@ test "iterate" {
|
||||||
.eof_token = 0,
|
.eof_token = 0,
|
||||||
};
|
};
|
||||||
var base = &root.base;
|
var base = &root.base;
|
||||||
var it = base.iterate();
|
testing.expect(base.iterate(0) == null);
|
||||||
testing.expect(it.next() == null);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue