#include "iterate.h" #include "node.h" #include #include #include static void to_string(struct ivy_ast_node *node, fx_string *str) { struct ivy_ast_class_node *c = (struct ivy_ast_class_node *)node; 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; fx_queue_entry *entry = fx_queue_first(&c->n_properties); while (entry) { struct ivy_ast_node *child = fx_unbox(struct ivy_ast_node, entry, n_entry); ast_node_iterator_enqueue_node(iterator, node, child); entry = fx_queue_next(entry); } entry = fx_queue_first(&c->n_msg_handlers); while (entry) { struct ivy_ast_node *child = fx_unbox(struct ivy_ast_node, entry, n_entry); ast_node_iterator_enqueue_node(iterator, node, child); 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), };