mie: implemented array value type; restructure const value structures

there are now separate structs for all const types (int, string, etc),
rather than a single mie_const union.
This commit is contained in:
2025-04-23 15:42:58 +01:00
parent 4ea9683880
commit ef4b4d2f66
8 changed files with 156 additions and 47 deletions

View File

@@ -44,11 +44,11 @@ struct mie_func *mie_builder_get_current_func(struct mie_builder *builder)
return block->b_parent;
}
void mie_builder_put_record(
struct mie_record *mie_builder_put_record(
struct mie_builder *builder, struct mie_const *val, const char *name)
{
if (!builder->b_module) {
return;
return NULL;
}
b_queue_iterator it = {};
@@ -57,13 +57,36 @@ void mie_builder_put_record(
= b_unbox(struct mie_value, it.entry, v_entry);
if (!strcmp(rec->v_name.n_str, name)) {
return;
/* TODO what to do about `val` here? */
return MIE_RECORD(rec);
}
}
struct mie_record *rec = mie_record_create(val);
rec->r_base.v_name.n_str = b_strdup(name);
b_queue_push_back(&builder->b_module->m_records, &rec->r_base.v_entry);
return rec;
}
struct mie_record *mie_builder_get_record(
struct mie_builder *builder, const char *name)
{
if (!builder->b_module) {
return NULL;
}
b_queue_iterator it = {};
b_queue_foreach (&it, &builder->b_module->m_records) {
struct mie_value *rec
= b_unbox(struct mie_value, it.entry, v_entry);
if (!strcmp(rec->v_name.n_str, name)) {
return MIE_RECORD(rec);
}
}
return NULL;
}
#if 0