lang: ast: replace ast node print callback with to_string
This commit is contained in:
@@ -349,29 +349,29 @@ static void collect_children(
|
||||
}
|
||||
}
|
||||
|
||||
static void print(struct ivy_ast_node *node)
|
||||
static void to_string(struct ivy_ast_node *node, b_string *str)
|
||||
{
|
||||
struct ivy_ast_property_node *prop = (struct ivy_ast_property_node *)node;
|
||||
|
||||
printf("%s (%s) [", ivy_ast_node_type_to_string(node->n_type), prop->n_ident->t_str);
|
||||
b_string_append_cstrf(str, "%s (%s) [", ivy_ast_node_type_to_string(node->n_type), prop->n_ident->t_str);
|
||||
|
||||
if (prop->n_flags & IVY_AST_PROPERTY_GET) {
|
||||
puts("get");
|
||||
b_string_append_cstr(str, "get");
|
||||
}
|
||||
|
||||
if ((prop->n_flags & IVY_AST_PROPERTY_GET) && prop->n_flags & IVY_AST_PROPERTY_SET) {
|
||||
puts(", ");
|
||||
b_string_append_cstr(str, ", ");
|
||||
}
|
||||
|
||||
if (prop->n_flags & IVY_AST_PROPERTY_SET) {
|
||||
puts("set");
|
||||
b_string_append_cstr(str, "set");
|
||||
}
|
||||
|
||||
puts("]\n");
|
||||
b_string_append_cstr(str, "]");
|
||||
}
|
||||
|
||||
struct ast_node_type property_node_ops = {
|
||||
.n_print = print,
|
||||
.n_to_string = to_string,
|
||||
.n_add_child = add_child,
|
||||
.n_init_state = init_state,
|
||||
.n_collect_children = collect_children,
|
||||
|
||||
Reference in New Issue
Block a user