42 lines
1.1 KiB
C
42 lines
1.1 KiB
C
#include "iterate.h"
|
|
#include "node.h"
|
|
|
|
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;
|
|
|
|
fx_queue_entry *entry = fx_queue_first(&group->n_branches);
|
|
while (entry) {
|
|
struct ivy_ast_node *branch
|
|
= fx_unbox(struct ivy_ast_node, entry, n_entry);
|
|
ast_node_iterator_enqueue_node(iterator, node, branch);
|
|
entry = fx_queue_next(entry);
|
|
}
|
|
}
|
|
|
|
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),
|
|
};
|