2024-11-26 13:08:39 +00:00
|
|
|
#include "node.h"
|
|
|
|
|
|
2026-03-16 14:07:33 +00:00
|
|
|
#include <fx/ds/string.h>
|
2024-11-25 16:46:27 +00:00
|
|
|
#include <ivy/lang/lex.h>
|
2024-11-24 20:50:12 +00:00
|
|
|
#include <stdio.h>
|
2024-11-24 11:10:42 +00:00
|
|
|
|
2026-03-16 14:07:33 +00:00
|
|
|
static void to_string(struct ivy_ast_node *node, fx_string *str)
|
2024-11-24 11:10:42 +00:00
|
|
|
{
|
2024-11-26 13:08:39 +00:00
|
|
|
struct ivy_ast_unit_package_node *unit_package
|
|
|
|
|
= (struct ivy_ast_unit_package_node *)node;
|
2026-03-16 14:07:33 +00:00
|
|
|
fx_string_append_cstr(str, ivy_ast_node_type_to_string(node->n_type));
|
2024-11-24 20:50:12 +00:00
|
|
|
|
2026-03-16 14:07:33 +00:00
|
|
|
fx_string_append_cstr(str, " (");
|
2025-04-23 10:58:22 +01:00
|
|
|
|
|
|
|
|
int i = 0;
|
2026-03-16 14:07:33 +00:00
|
|
|
fx_queue_entry *entry = fx_queue_first(&unit_package->n_ident);
|
2025-11-06 10:38:32 +00:00
|
|
|
while (entry) {
|
2026-03-16 14:07:33 +00:00
|
|
|
struct ivy_token *tok = fx_unbox(struct ivy_token, entry, t_entry);
|
2024-11-24 20:50:12 +00:00
|
|
|
|
2025-04-23 10:58:22 +01:00
|
|
|
if (i > 0) {
|
2026-03-16 14:07:33 +00:00
|
|
|
fx_string_append_cstr(str, ".");
|
2024-11-24 20:50:12 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-16 14:07:33 +00:00
|
|
|
fx_string_append_cstr(str, tok->t_str);
|
2025-04-23 10:58:22 +01:00
|
|
|
i++;
|
2025-11-15 22:49:03 +00:00
|
|
|
|
2026-03-16 14:07:33 +00:00
|
|
|
entry = fx_queue_next(entry);
|
2024-11-24 20:50:12 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-16 14:07:33 +00:00
|
|
|
fx_string_append_cstr(str, ")");
|
2024-11-24 11:10:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ast_node_type unit_package_node_ops = {
|
2024-12-06 20:24:08 +00:00
|
|
|
.n_to_string = to_string,
|
2024-11-24 11:46:42 +00:00
|
|
|
.n_node_size = sizeof(struct ivy_ast_unit_package_node),
|
2024-12-02 07:56:27 +00:00
|
|
|
};
|