2024-11-28 16:56:25 +00:00
|
|
|
#include "block.h"
|
2024-12-02 07:56:27 +00:00
|
|
|
|
2024-11-28 16:56:25 +00:00
|
|
|
#include "iterate.h"
|
2024-12-02 07:56:27 +00:00
|
|
|
#include "node.h"
|
2024-11-28 10:26:53 +00:00
|
|
|
|
2026-03-16 14:07:33 +00:00
|
|
|
#include <fx/ds/string.h>
|
2024-11-28 10:26:53 +00:00
|
|
|
#include <ivy/lang/lex.h>
|
|
|
|
|
|
2024-11-28 16:56:25 +00:00
|
|
|
static void collect_children(
|
|
|
|
|
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
|
|
|
|
|
{
|
|
|
|
|
struct ivy_ast_block_node *block = (struct ivy_ast_block_node *)node;
|
2026-04-06 18:25:43 +01:00
|
|
|
fx_queue_entry *entry = fx_queue_first(&block->n_arg);
|
|
|
|
|
while (entry) {
|
|
|
|
|
struct ivy_ast_node *expr
|
|
|
|
|
= fx_unbox(struct ivy_ast_node, entry, n_entry);
|
|
|
|
|
ast_node_iterator_enqueue_node(iterator, node, expr);
|
|
|
|
|
entry = fx_queue_next(entry);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
entry = fx_queue_first(&block->n_expr);
|
2025-11-06 10:38:32 +00:00
|
|
|
while (entry) {
|
2024-11-28 16:56:25 +00:00
|
|
|
struct ivy_ast_node *expr
|
2026-03-16 14:07:33 +00:00
|
|
|
= fx_unbox(struct ivy_ast_node, entry, n_entry);
|
2024-11-28 16:56:25 +00:00
|
|
|
ast_node_iterator_enqueue_node(iterator, node, expr);
|
2026-03-16 14:07:33 +00:00
|
|
|
entry = fx_queue_next(entry);
|
2024-11-28 16:56:25 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-28 10:26:53 +00:00
|
|
|
struct ast_node_type block_node_ops = {
|
2024-11-28 16:56:25 +00:00
|
|
|
.n_collect_children = collect_children,
|
2024-11-28 10:26:53 +00:00
|
|
|
.n_node_size = sizeof(struct ivy_ast_block_node),
|
|
|
|
|
};
|