mirror of
https://github.com/ziglang/zig.git
synced 2025-12-25 23:53:15 +00:00
add a src() method to AstNode to aid debugging
This commit is contained in:
parent
a7763c06f9
commit
dfe8c5a2e9
@ -1009,6 +1009,10 @@ struct AstNode {
|
||||
AstNodeAnyFrameType anyframe_type;
|
||||
AstNodeEnumLiteral enum_literal;
|
||||
} data;
|
||||
|
||||
// This is a function for use in the debugger to print
|
||||
// the source location.
|
||||
void src();
|
||||
};
|
||||
|
||||
// this struct is allocated with allocate_nonzero
|
||||
|
||||
@ -1186,3 +1186,9 @@ void ast_render(FILE *f, AstNode *node, int indent_size) {
|
||||
|
||||
render_node_grouped(&ar, node);
|
||||
}
|
||||
|
||||
void AstNode::src() {
|
||||
fprintf(stderr, "%s:%" ZIG_PRI_usize ":%" ZIG_PRI_usize "\n",
|
||||
buf_ptr(this->owner->data.structure.root_struct->path),
|
||||
this->line + 1, this->column + 1);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user