2024-12-07 20:56:57 +00:00
|
|
|
#include "block.h"
|
|
|
|
|
#include "iterate.h"
|
|
|
|
|
#include "node.h"
|
|
|
|
|
|
2026-03-16 14:07:33 +00:00
|
|
|
#include <fx/ds/string.h>
|
2024-12-07 20:56:57 +00:00
|
|
|
#include <ivy/lang/lex.h>
|
|
|
|
|
|
|
|
|
|
static void pkg_static_collect_children(
|
|
|
|
|
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
|
|
|
|
|
{
|
2025-11-06 10:38:32 +00:00
|
|
|
struct ivy_ast_pkg_static_node *pkg
|
|
|
|
|
= (struct ivy_ast_pkg_static_node *)node;
|
|
|
|
|
|
2026-03-16 14:07:33 +00:00
|
|
|
fx_queue_entry *entry = fx_queue_first(&pkg->n_items);
|
2025-11-06 10:38:32 +00:00
|
|
|
while (entry) {
|
|
|
|
|
struct ivy_ast_node *item
|
2026-03-16 14:07:33 +00:00
|
|
|
= fx_unbox(struct ivy_ast_node, entry, n_entry);
|
2024-12-07 20:56:57 +00:00
|
|
|
ast_node_iterator_enqueue_node(iterator, node, item);
|
2026-03-16 14:07:33 +00:00
|
|
|
entry = fx_queue_next(entry);
|
2024-12-07 20:56:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-16 14:07:33 +00:00
|
|
|
static void pkg_static_item_to_string(struct ivy_ast_node *node, fx_string *str)
|
2024-12-07 20:56:57 +00:00
|
|
|
{
|
2025-11-06 10:38:32 +00:00
|
|
|
struct ivy_ast_pkg_static_item_node *item
|
|
|
|
|
= (struct ivy_ast_pkg_static_item_node *)node;
|
2024-12-07 20:56:57 +00:00
|
|
|
|
2026-03-16 14:07:33 +00:00
|
|
|
fx_string_append_cstr(str, ivy_ast_node_type_to_string(node->n_type));
|
2024-12-07 20:56:57 +00:00
|
|
|
|
|
|
|
|
if (!item->n_index) {
|
2026-03-16 14:07:33 +00:00
|
|
|
fx_string_append_cstrf(str, " (%u)", item->n_implicit_index);
|
2024-12-07 20:56:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void pkg_static_item_collect_children(
|
|
|
|
|
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
|
|
|
|
|
{
|
2025-11-06 10:38:32 +00:00
|
|
|
struct ivy_ast_pkg_static_item_node *item
|
|
|
|
|
= (struct ivy_ast_pkg_static_item_node *)node;
|
2024-12-07 20:56:57 +00:00
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2025-11-06 10:38:32 +00:00
|
|
|
struct ivy_ast_pkg_dynamic_node *pkg
|
|
|
|
|
= (struct ivy_ast_pkg_dynamic_node *)node;
|
2024-12-07 20:56:57 +00:00
|
|
|
|
|
|
|
|
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),
|
|
|
|
|
};
|