43 lines
1.2 KiB
C
43 lines
1.2 KiB
C
#include "iterate.h"
|
|
#include "node.h"
|
|
|
|
static void try_collect_children(
|
|
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
|
|
{
|
|
struct ivy_ast_try_node *try = (struct ivy_ast_try_node *)node;
|
|
|
|
ast_node_iterator_enqueue_node(iterator, node, try->n_try);
|
|
|
|
fx_queue_entry *entry = fx_queue_first(&try->n_catch);
|
|
while (entry) {
|
|
struct ivy_ast_node *catch
|
|
= fx_unbox(struct ivy_ast_node, entry, n_entry);
|
|
ast_node_iterator_enqueue_node(iterator, node, catch);
|
|
entry = fx_queue_next(entry);
|
|
}
|
|
|
|
if (try->n_finally) {
|
|
ast_node_iterator_enqueue_node(iterator, node, try->n_finally);
|
|
}
|
|
}
|
|
|
|
static void try_catch_collect_children(
|
|
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
|
|
{
|
|
struct ivy_ast_try_catch_node *catch
|
|
= (struct ivy_ast_try_catch_node *)node;
|
|
|
|
ast_node_iterator_enqueue_node(iterator, node, catch->n_pattern);
|
|
ast_node_iterator_enqueue_node(iterator, node, catch->n_block);
|
|
}
|
|
|
|
struct ast_node_type try_node_ops = {
|
|
.n_collect_children = try_collect_children,
|
|
.n_node_size = sizeof(struct ivy_ast_try_node),
|
|
};
|
|
|
|
struct ast_node_type try_catch_node_ops = {
|
|
.n_collect_children = try_catch_collect_children,
|
|
.n_node_size = sizeof(struct ivy_ast_try_catch_node),
|
|
};
|