mie: ctx is now used to query the type of a value

this allows value get_type callbacks to use mie_ctx to obtain mie_type pointers,
rather than having to define their own static versions of the type structs.
This commit is contained in:
2025-04-28 15:38:25 +01:00
parent cbec21b90f
commit 1431cb7b47
14 changed files with 34 additions and 64 deletions

View File

@@ -1,11 +1,10 @@
#include <mie/block.h>
#include <mie/ctx.h>
#include <mie/func.h>
#include <mie/instr.h>
#include <mie/type.h>
#include <stdlib.h>
static struct mie_type label_type = {};
struct mie_block *mie_block_create(struct mie_func *parent, const char *name)
{
struct mie_block *out = malloc(sizeof *out);
@@ -62,20 +61,9 @@ bool mie_block_add_instr(struct mie_block *block, struct mie_instr *instr)
}
}
static void init_label_type(struct mie_type *out)
static struct mie_type *get_type(struct mie_value *v, struct mie_ctx *ctx)
{
mie_value_init(&out->t_base, MIE_VALUE_TYPE);
out->t_id = MIE_TYPE_LABEL;
out->t_width = sizeof(uintptr_t) * 8;
}
static struct mie_type *get_type(struct mie_value *v)
{
if (!label_type.t_id) {
init_label_type(&label_type);
}
return &label_type;
return mie_ctx_get_type(ctx, MIE_TYPE_LABEL);
}
static void cleanup(struct mie_value *value)