2024-11-28 22:04:22 +00:00
|
|
|
#include "iterate.h"
|
2024-12-02 07:56:27 +00:00
|
|
|
#include "node.h"
|
2024-11-25 21:31:52 +00:00
|
|
|
|
2026-03-16 14:07:33 +00:00
|
|
|
#include <fx/ds/string.h>
|
2024-11-25 16:50:42 +00:00
|
|
|
#include <ivy/lang/lex.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2026-03-16 14:07:33 +00:00
|
|
|
static void to_string(struct ivy_ast_node *node, fx_string *str)
|
2024-11-25 16:50:42 +00:00
|
|
|
{
|
2024-11-25 21:31:52 +00:00
|
|
|
struct ivy_ast_class_node *c = (struct ivy_ast_class_node *)node;
|
2024-11-25 16:50:42 +00:00
|
|
|
|
2026-03-16 14:07:33 +00:00
|
|
|
fx_string_append_cstrf(
|
2025-04-10 13:04:12 +01:00
|
|
|
str, "%s (%s)", ivy_ast_node_type_to_string(node->n_type),
|
|
|
|
|
c->n_ident->t_str);
|
2024-11-25 16:50:42 +00:00
|
|
|
}
|
|
|
|
|
|
2024-11-28 16:58:01 +00:00
|
|
|
static void collect_children(
|
|
|
|
|
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
|
|
|
|
|
{
|
|
|
|
|
struct ivy_ast_class_node *c = (struct ivy_ast_class_node *)node;
|
2026-03-16 14:07:33 +00:00
|
|
|
fx_queue_entry *entry = fx_queue_first(&c->n_properties);
|
2025-11-06 10:38:32 +00:00
|
|
|
while (entry) {
|
2024-11-28 16:58:01 +00:00
|
|
|
struct ivy_ast_node *child
|
2026-03-16 14:07:33 +00:00
|
|
|
= fx_unbox(struct ivy_ast_node, entry, n_entry);
|
2024-11-28 16:58:01 +00:00
|
|
|
ast_node_iterator_enqueue_node(iterator, node, child);
|
2026-03-16 14:07:33 +00:00
|
|
|
entry = fx_queue_next(entry);
|
2024-11-28 16:58:01 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-16 14:07:33 +00:00
|
|
|
entry = fx_queue_first(&c->n_msg_handlers);
|
2025-11-06 10:38:32 +00:00
|
|
|
while (entry) {
|
2024-11-28 16:58:01 +00:00
|
|
|
struct ivy_ast_node *child
|
2026-03-16 14:07:33 +00:00
|
|
|
= fx_unbox(struct ivy_ast_node, entry, n_entry);
|
2024-11-28 16:58:01 +00:00
|
|
|
ast_node_iterator_enqueue_node(iterator, node, child);
|
2026-03-16 14:07:33 +00:00
|
|
|
entry = fx_queue_next(entry);
|
2024-11-28 16:58:01 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-25 16:50:42 +00:00
|
|
|
struct ast_node_type class_node_ops = {
|
2024-12-06 20:24:08 +00:00
|
|
|
.n_to_string = to_string,
|
2024-11-28 16:58:01 +00:00
|
|
|
.n_collect_children = collect_children,
|
2024-11-25 16:50:42 +00:00
|
|
|
.n_node_size = sizeof(struct ivy_ast_class_node),
|
|
|
|
|
};
|