lang: update bluelib api usage

This commit is contained in:
2025-11-06 10:38:32 +00:00
parent b26c37c349
commit 4386965cd9
40 changed files with 351 additions and 271 deletions

View File

@@ -2,7 +2,7 @@
#include "var-map.h"
#include <blue/core/stringstream.h>
#include <blue/object/list.h>
#include <blue/ds/list.h>
#include <mie/ir/block.h>
#include <mie/ir/func.h>
#include <mie/ir/module.h>
@@ -144,17 +144,17 @@ static struct code_generator_result gen_while_loop(
static void serialise_package_name(b_queue *parts, b_stringstream *out)
{
b_stringstream_add(out, "_ZN");
b_stream_write_string(out, "_ZN", NULL);
b_queue_iterator it;
b_queue_foreach (&it, parts) {
struct ivy_token *tok
= b_unbox(struct ivy_token, it.entry, t_entry);
b_queue_entry *entry = b_queue_first(parts);
while (entry) {
struct ivy_token *tok = b_unbox(struct ivy_token, entry, t_entry);
size_t len = strlen(tok->t_str);
b_stringstream_addf(out, "%zu%s", len, tok->t_str);
b_stream_write_fmt(out, NULL, "%zu%s", len, tok->t_str);
entry = b_queue_next(entry);
}
b_stringstream_add(out, "E");
b_stream_write_char(out, 'E');
}
static struct code_generator_result gen_unit_package(
@@ -165,10 +165,10 @@ static struct code_generator_result gen_unit_package(
struct ivy_ast_unit_package_node *pkg
= (struct ivy_ast_unit_package_node *)node;
b_stringstream str;
b_stringstream_begin_dynamic(&str);
serialise_package_name(&pkg->n_ident, &str);
char *ident = b_stringstream_end(&str);
b_stringstream *str = b_stringstream_create();
serialise_package_name(&pkg->n_ident, str);
char *ident = b_stringstream_steal(str);
b_stringstream_unref(str);
struct mie_value *ident_val = mie_ctx_get_string(gen->c_ctx, ident);
free(ident);
@@ -198,10 +198,10 @@ static struct code_generator_result gen_unit_import(
import_list = MIE_ARRAY(rec->r_value);
}
b_stringstream str;
b_stringstream_begin_dynamic(&str);
serialise_package_name(&pkg->n_ident, &str);
char *ident = b_stringstream_end(&str);
b_stringstream *str = b_stringstream_create();
serialise_package_name(&pkg->n_ident, str);
char *ident = b_stringstream_steal(str);
b_stringstream_unref(str);
struct mie_value *ident_val = mie_ctx_get_string(gen->c_ctx, ident);
free(ident);