lang: codegen: redesign again to use purely pre-order ast traversal
This commit is contained in:
@@ -212,6 +212,11 @@ token_parse_function get_token_parser(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct ivy_ast_node *ivy_ast_node_create(enum ivy_ast_node_type type)
|
||||
{
|
||||
return ast_node_create(type);
|
||||
}
|
||||
|
||||
struct ivy_ast_node *ast_node_create(enum ivy_ast_node_type type)
|
||||
{
|
||||
const struct ast_node_type *type_info = get_ast_node_type(type);
|
||||
@@ -296,3 +301,18 @@ const char *ivy_ast_node_type_to_string(enum ivy_ast_node_type v)
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
void ivy_ast_unit_add_node(struct ivy_ast_unit_node *unit, struct ivy_ast_node *child)
|
||||
{
|
||||
b_queue_push_back(&unit->n_children, &child->n_entry);
|
||||
}
|
||||
|
||||
struct ivy_ast_node *ivy_ast_unit_dequeue_node(struct ivy_ast_unit_node *unit)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_pop_front(&unit->n_children);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return b_unbox(struct ivy_ast_node, entry, n_entry);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user