88 lines
2.3 KiB
C
88 lines
2.3 KiB
C
#include "block.h"
|
|
#include "iterate.h"
|
|
#include "node.h"
|
|
|
|
#include <fx/ds/string.h>
|
|
#include <ivy/lang/lex.h>
|
|
|
|
static void pkg_static_collect_children(
|
|
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
|
|
{
|
|
struct ivy_ast_pkg_static_node *pkg
|
|
= (struct ivy_ast_pkg_static_node *)node;
|
|
|
|
fx_queue_entry *entry = fx_queue_first(&pkg->n_items);
|
|
while (entry) {
|
|
struct ivy_ast_node *item
|
|
= fx_unbox(struct ivy_ast_node, entry, n_entry);
|
|
ast_node_iterator_enqueue_node(iterator, node, item);
|
|
entry = fx_queue_next(entry);
|
|
}
|
|
}
|
|
|
|
static void pkg_static_item_to_string(struct ivy_ast_node *node, fx_string *str)
|
|
{
|
|
struct ivy_ast_pkg_static_item_node *item
|
|
= (struct ivy_ast_pkg_static_item_node *)node;
|
|
|
|
fx_string_append_cstr(str, ivy_ast_node_type_to_string(node->n_type));
|
|
|
|
if (!item->n_index) {
|
|
fx_string_append_cstrf(str, " (%u)", item->n_implicit_index);
|
|
}
|
|
}
|
|
|
|
static void pkg_static_item_collect_children(
|
|
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
|
|
{
|
|
struct ivy_ast_pkg_static_item_node *item
|
|
= (struct ivy_ast_pkg_static_item_node *)node;
|
|
|
|
if (item->n_index) {
|
|
ast_node_iterator_enqueue_node(iterator, node, item->n_index);
|
|
}
|
|
|
|
if (item->n_value) {
|
|
ast_node_iterator_enqueue_node(iterator, node, item->n_value);
|
|
}
|
|
}
|
|
|
|
static void pkg_dynamic_collect_children(
|
|
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
|
|
{
|
|
struct ivy_ast_pkg_dynamic_node *pkg
|
|
= (struct ivy_ast_pkg_dynamic_node *)node;
|
|
|
|
if (pkg->n_transform) {
|
|
ast_node_iterator_enqueue_node(iterator, node, pkg->n_transform);
|
|
}
|
|
|
|
if (pkg->n_item) {
|
|
ast_node_iterator_enqueue_node(iterator, node, pkg->n_item);
|
|
}
|
|
|
|
if (pkg->n_source) {
|
|
ast_node_iterator_enqueue_node(iterator, node, pkg->n_source);
|
|
}
|
|
|
|
if (pkg->n_cond) {
|
|
ast_node_iterator_enqueue_node(iterator, node, pkg->n_cond);
|
|
}
|
|
}
|
|
|
|
struct ast_node_type pkg_static_node_ops = {
|
|
.n_collect_children = pkg_static_collect_children,
|
|
.n_node_size = sizeof(struct ivy_ast_pkg_static_node),
|
|
};
|
|
|
|
struct ast_node_type pkg_static_item_node_ops = {
|
|
.n_to_string = pkg_static_item_to_string,
|
|
.n_collect_children = pkg_static_item_collect_children,
|
|
.n_node_size = sizeof(struct ivy_ast_pkg_static_item_node),
|
|
};
|
|
|
|
struct ast_node_type pkg_dynamic_node_ops = {
|
|
.n_collect_children = pkg_dynamic_collect_children,
|
|
.n_node_size = sizeof(struct ivy_ast_pkg_dynamic_node),
|
|
};
|