2025-01-16 13:15:18 +00:00
|
|
|
#include "iterate.h"
|
2026-04-06 18:25:43 +01:00
|
|
|
#include "node.h"
|
2024-12-04 16:35:19 +00:00
|
|
|
|
|
|
|
|
static void cond_group_collect_children(
|
|
|
|
|
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
|
|
|
|
|
{
|
|
|
|
|
struct ivy_ast_cond_group_node *group
|
|
|
|
|
= (struct ivy_ast_cond_group_node *)node;
|
|
|
|
|
|
2026-03-16 14:07:33 +00:00
|
|
|
fx_queue_entry *entry = fx_queue_first(&group->n_branches);
|
2025-11-06 10:38:32 +00:00
|
|
|
while (entry) {
|
2025-01-16 13:15:18 +00:00
|
|
|
struct ivy_ast_node *branch
|
2026-03-16 14:07:33 +00:00
|
|
|
= fx_unbox(struct ivy_ast_node, entry, n_entry);
|
2024-12-04 16:35:19 +00:00
|
|
|
ast_node_iterator_enqueue_node(iterator, node, branch);
|
2026-03-16 14:07:33 +00:00
|
|
|
entry = fx_queue_next(entry);
|
2024-12-04 16:35:19 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void cond_collect_children(
|
|
|
|
|
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
|
|
|
|
|
{
|
|
|
|
|
struct ivy_ast_cond_node *cond = (struct ivy_ast_cond_node *)node;
|
|
|
|
|
|
|
|
|
|
if (cond->n_cond) {
|
|
|
|
|
ast_node_iterator_enqueue_node(iterator, node, cond->n_cond);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cond->n_body) {
|
|
|
|
|
ast_node_iterator_enqueue_node(iterator, node, cond->n_body);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ast_node_type cond_group_node_ops = {
|
|
|
|
|
.n_collect_children = cond_group_collect_children,
|
|
|
|
|
.n_node_size = sizeof(struct ivy_ast_cond_group_node),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ast_node_type cond_node_ops = {
|
|
|
|
|
.n_collect_children = cond_collect_children,
|
|
|
|
|
.n_node_size = sizeof(struct ivy_ast_cond_node),
|
|
|
|
|
};
|