fully qualify std.debug.assert references
This commit is contained in:
parent
d15ec06c69
commit
91c8ffb38c
37
src/ast.zig
37
src/ast.zig
@ -6,7 +6,6 @@ const std = @import("std");
|
|||||||
const Ast = std.zig.Ast;
|
const Ast = std.zig.Ast;
|
||||||
const Node = Ast.Node;
|
const Node = Ast.Node;
|
||||||
const full = Ast.full;
|
const full = Ast.full;
|
||||||
const assert = std.debug.assert;
|
|
||||||
|
|
||||||
fn fullPtrType(tree: Ast, info: full.PtrType.Components) full.PtrType {
|
fn fullPtrType(tree: Ast, info: full.PtrType.Components) full.PtrType {
|
||||||
const token_tags = tree.tokens.items(.tag);
|
const token_tags = tree.tokens.items(.tag);
|
||||||
@ -43,9 +42,9 @@ fn fullPtrType(tree: Ast, info: full.PtrType.Components) full.PtrType {
|
|||||||
.keyword_const => result.const_token = i,
|
.keyword_const => result.const_token = i,
|
||||||
.keyword_volatile => result.volatile_token = i,
|
.keyword_volatile => result.volatile_token = i,
|
||||||
.keyword_align => {
|
.keyword_align => {
|
||||||
assert(info.align_node != 0);
|
std.debug.assert(info.align_node != 0);
|
||||||
if (info.bit_range_end != 0) {
|
if (info.bit_range_end != 0) {
|
||||||
assert(info.bit_range_start != 0);
|
std.debug.assert(info.bit_range_start != 0);
|
||||||
i = lastToken(tree, info.bit_range_end) + 1;
|
i = lastToken(tree, info.bit_range_end) + 1;
|
||||||
} else {
|
} else {
|
||||||
i = lastToken(tree, info.align_node) + 1;
|
i = lastToken(tree, info.align_node) + 1;
|
||||||
@ -58,7 +57,7 @@ fn fullPtrType(tree: Ast, info: full.PtrType.Components) full.PtrType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn ptrTypeSimple(tree: Ast, node: Node.Index) full.PtrType {
|
pub fn ptrTypeSimple(tree: Ast, node: Node.Index) full.PtrType {
|
||||||
assert(tree.nodes.items(.tag)[node] == .ptr_type);
|
std.debug.assert(tree.nodes.items(.tag)[node] == .ptr_type);
|
||||||
const data = tree.nodes.items(.data)[node];
|
const data = tree.nodes.items(.data)[node];
|
||||||
const extra = tree.extraData(data.lhs, Node.PtrType);
|
const extra = tree.extraData(data.lhs, Node.PtrType);
|
||||||
return fullPtrType(tree, .{
|
return fullPtrType(tree, .{
|
||||||
@ -73,7 +72,7 @@ pub fn ptrTypeSimple(tree: Ast, node: Node.Index) full.PtrType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn ptrTypeSentinel(tree: Ast, node: Node.Index) full.PtrType {
|
pub fn ptrTypeSentinel(tree: Ast, node: Node.Index) full.PtrType {
|
||||||
assert(tree.nodes.items(.tag)[node] == .ptr_type_sentinel);
|
std.debug.assert(tree.nodes.items(.tag)[node] == .ptr_type_sentinel);
|
||||||
const data = tree.nodes.items(.data)[node];
|
const data = tree.nodes.items(.data)[node];
|
||||||
return fullPtrType(tree, .{
|
return fullPtrType(tree, .{
|
||||||
.main_token = tree.nodes.items(.main_token)[node],
|
.main_token = tree.nodes.items(.main_token)[node],
|
||||||
@ -87,7 +86,7 @@ pub fn ptrTypeSentinel(tree: Ast, node: Node.Index) full.PtrType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn ptrTypeAligned(tree: Ast, node: Node.Index) full.PtrType {
|
pub fn ptrTypeAligned(tree: Ast, node: Node.Index) full.PtrType {
|
||||||
assert(tree.nodes.items(.tag)[node] == .ptr_type_aligned);
|
std.debug.assert(tree.nodes.items(.tag)[node] == .ptr_type_aligned);
|
||||||
const data = tree.nodes.items(.data)[node];
|
const data = tree.nodes.items(.data)[node];
|
||||||
return fullPtrType(tree, .{
|
return fullPtrType(tree, .{
|
||||||
.main_token = tree.nodes.items(.main_token)[node],
|
.main_token = tree.nodes.items(.main_token)[node],
|
||||||
@ -101,7 +100,7 @@ pub fn ptrTypeAligned(tree: Ast, node: Node.Index) full.PtrType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn ptrTypeBitRange(tree: Ast, node: Node.Index) full.PtrType {
|
pub fn ptrTypeBitRange(tree: Ast, node: Node.Index) full.PtrType {
|
||||||
assert(tree.nodes.items(.tag)[node] == .ptr_type_bit_range);
|
std.debug.assert(tree.nodes.items(.tag)[node] == .ptr_type_bit_range);
|
||||||
const data = tree.nodes.items(.data)[node];
|
const data = tree.nodes.items(.data)[node];
|
||||||
const extra = tree.extraData(data.lhs, Node.PtrTypeBitRange);
|
const extra = tree.extraData(data.lhs, Node.PtrTypeBitRange);
|
||||||
return fullPtrType(tree, .{
|
return fullPtrType(tree, .{
|
||||||
@ -151,7 +150,7 @@ pub fn ifFull(tree: Ast, node: Node.Index) full.If {
|
|||||||
.if_token = tree.nodes.items(.main_token)[node],
|
.if_token = tree.nodes.items(.main_token)[node],
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
assert(tree.nodes.items(.tag)[node] == .if_simple);
|
std.debug.assert(tree.nodes.items(.tag)[node] == .if_simple);
|
||||||
return fullIf(tree, .{
|
return fullIf(tree, .{
|
||||||
.cond_expr = data.lhs,
|
.cond_expr = data.lhs,
|
||||||
.then_expr = data.rhs,
|
.then_expr = data.rhs,
|
||||||
@ -525,7 +524,7 @@ pub fn lastToken(tree: Ast, node: Ast.Node.Index) Ast.TokenIndex {
|
|||||||
.struct_init,
|
.struct_init,
|
||||||
=> {
|
=> {
|
||||||
const elements = tree.extraData(datas[n].rhs, Node.SubRange);
|
const elements = tree.extraData(datas[n].rhs, Node.SubRange);
|
||||||
std.debug.assert(elements.end - elements.start > 0);
|
std.debug.std.debug.assert(elements.end - elements.start > 0);
|
||||||
end_offset += 1; // for the rbrace
|
end_offset += 1; // for the rbrace
|
||||||
n = tree.extra_data[elements.end - 1]; // last element
|
n = tree.extra_data[elements.end - 1]; // last element
|
||||||
},
|
},
|
||||||
@ -535,7 +534,7 @@ pub fn lastToken(tree: Ast, node: Ast.Node.Index) Ast.TokenIndex {
|
|||||||
.switch_comma,
|
.switch_comma,
|
||||||
=> {
|
=> {
|
||||||
const members = tree.extraData(datas[n].rhs, Node.SubRange);
|
const members = tree.extraData(datas[n].rhs, Node.SubRange);
|
||||||
std.debug.assert(members.end - members.start > 0);
|
std.debug.std.debug.assert(members.end - members.start > 0);
|
||||||
end_offset += 2; // for the comma + rbrace
|
end_offset += 2; // for the comma + rbrace
|
||||||
n = tree.extra_data[members.end - 1]; // last parameter
|
n = tree.extra_data[members.end - 1]; // last parameter
|
||||||
},
|
},
|
||||||
@ -546,7 +545,7 @@ pub fn lastToken(tree: Ast, node: Ast.Node.Index) Ast.TokenIndex {
|
|||||||
.tagged_union,
|
.tagged_union,
|
||||||
.builtin_call,
|
.builtin_call,
|
||||||
=> {
|
=> {
|
||||||
std.debug.assert(datas[n].rhs - datas[n].lhs > 0);
|
std.debug.std.debug.assert(datas[n].rhs - datas[n].lhs > 0);
|
||||||
end_offset += 1; // for the rbrace
|
end_offset += 1; // for the rbrace
|
||||||
n = tree.extra_data[datas[n].rhs - 1]; // last statement
|
n = tree.extra_data[datas[n].rhs - 1]; // last statement
|
||||||
},
|
},
|
||||||
@ -557,7 +556,7 @@ pub fn lastToken(tree: Ast, node: Ast.Node.Index) Ast.TokenIndex {
|
|||||||
.tagged_union_trailing,
|
.tagged_union_trailing,
|
||||||
.builtin_call_comma,
|
.builtin_call_comma,
|
||||||
=> {
|
=> {
|
||||||
std.debug.assert(datas[n].rhs - datas[n].lhs > 0);
|
std.debug.std.debug.assert(datas[n].rhs - datas[n].lhs > 0);
|
||||||
end_offset += 2; // for the comma/semicolon + rbrace/rparen
|
end_offset += 2; // for the comma/semicolon + rbrace/rparen
|
||||||
n = tree.extra_data[datas[n].rhs - 1]; // last member
|
n = tree.extra_data[datas[n].rhs - 1]; // last member
|
||||||
},
|
},
|
||||||
@ -673,11 +672,11 @@ pub fn lastToken(tree: Ast, node: Ast.Node.Index) Ast.TokenIndex {
|
|||||||
=> {
|
=> {
|
||||||
end_offset += 2; // ellipsis2 + rbracket, or comma + rparen
|
end_offset += 2; // ellipsis2 + rbracket, or comma + rparen
|
||||||
n = datas[n].rhs;
|
n = datas[n].rhs;
|
||||||
std.debug.assert(n != 0);
|
std.debug.std.debug.assert(n != 0);
|
||||||
},
|
},
|
||||||
.slice => {
|
.slice => {
|
||||||
const extra = tree.extraData(datas[n].rhs, Node.Slice);
|
const extra = tree.extraData(datas[n].rhs, Node.Slice);
|
||||||
std.debug.assert(extra.end != 0); // should have used slice_open
|
std.debug.std.debug.assert(extra.end != 0); // should have used slice_open
|
||||||
end_offset += 1; // rbracket
|
end_offset += 1; // rbracket
|
||||||
n = extra.end;
|
n = extra.end;
|
||||||
},
|
},
|
||||||
@ -783,7 +782,7 @@ pub fn lastToken(tree: Ast, node: Ast.Node.Index) Ast.TokenIndex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (max_node == 0) {
|
if (max_node == 0) {
|
||||||
std.debug.assert(max_offset == 0);
|
std.debug.std.debug.assert(max_offset == 0);
|
||||||
// No linksection, callconv, align, return type
|
// No linksection, callconv, align, return type
|
||||||
if (extra.param != 0) {
|
if (extra.param != 0) {
|
||||||
n = extra.param;
|
n = extra.param;
|
||||||
@ -835,7 +834,7 @@ pub fn lastToken(tree: Ast, node: Ast.Node.Index) Ast.TokenIndex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (max_node == 0) {
|
if (max_node == 0) {
|
||||||
std.debug.assert(max_offset == 0);
|
std.debug.std.debug.assert(max_offset == 0);
|
||||||
// No linksection, callconv, align, return type
|
// No linksection, callconv, align, return type
|
||||||
// Use the last parameter and skip one extra token for the right paren
|
// Use the last parameter and skip one extra token for the right paren
|
||||||
n = extra.params_end;
|
n = extra.params_end;
|
||||||
@ -847,17 +846,17 @@ pub fn lastToken(tree: Ast, node: Ast.Node.Index) Ast.TokenIndex {
|
|||||||
},
|
},
|
||||||
.while_cont => {
|
.while_cont => {
|
||||||
const extra = tree.extraData(datas[n].rhs, Node.WhileCont);
|
const extra = tree.extraData(datas[n].rhs, Node.WhileCont);
|
||||||
std.debug.assert(extra.then_expr != 0);
|
std.debug.std.debug.assert(extra.then_expr != 0);
|
||||||
n = extra.then_expr;
|
n = extra.then_expr;
|
||||||
},
|
},
|
||||||
.@"while" => {
|
.@"while" => {
|
||||||
const extra = tree.extraData(datas[n].rhs, Node.While);
|
const extra = tree.extraData(datas[n].rhs, Node.While);
|
||||||
std.debug.assert(extra.else_expr != 0);
|
std.debug.std.debug.assert(extra.else_expr != 0);
|
||||||
n = extra.else_expr;
|
n = extra.else_expr;
|
||||||
},
|
},
|
||||||
.@"if", .@"for" => {
|
.@"if", .@"for" => {
|
||||||
const extra = tree.extraData(datas[n].rhs, Node.If);
|
const extra = tree.extraData(datas[n].rhs, Node.If);
|
||||||
std.debug.assert(extra.else_expr != 0);
|
std.debug.std.debug.assert(extra.else_expr != 0);
|
||||||
n = extra.else_expr;
|
n = extra.else_expr;
|
||||||
},
|
},
|
||||||
.@"suspend" => {
|
.@"suspend" => {
|
||||||
|
Loading…
Reference in New Issue
Block a user