Files
ivy/lang/ast/class.c
T

43 lines
1.1 KiB
C
Raw Normal View History

2024-11-28 22:04:22 +00:00
#include "iterate.h"
#include "node.h"
2024-11-25 21:31:52 +00:00
2026-03-16 14:07:33 +00:00
#include <fx/ds/string.h>
#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 21:31:52 +00:00
struct ivy_ast_class_node *c = (struct ivy_ast_class_node *)node;
2026-03-16 14:07:33 +00:00
fx_string_append_cstrf(
str, "%s (%s)", ivy_ast_node_type_to_string(node->n_type),
c->n_ident->t_str);
}
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) {
struct ivy_ast_node *child
2026-03-16 14:07:33 +00:00
= fx_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, child);
2026-03-16 14:07:33 +00:00
entry = fx_queue_next(entry);
}
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) {
struct ivy_ast_node *child
2026-03-16 14:07:33 +00:00
= fx_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, child);
2026-03-16 14:07:33 +00:00
entry = fx_queue_next(entry);
}
}
struct ast_node_type class_node_ops = {
.n_to_string = to_string,
.n_collect_children = collect_children,
.n_node_size = sizeof(struct ivy_ast_class_node),
};