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:
19
mie/data.c
19
mie/data.c
@@ -1,19 +1,10 @@
|
||||
#include <blue/object/string.h>
|
||||
#include <mie/ctx.h>
|
||||
#include <mie/data.h>
|
||||
#include <mie/type.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* TODO combine this with the ptr_type defined in instr.c */
|
||||
static struct mie_type ptr_type = {};
|
||||
|
||||
static void init_ptr_type(struct mie_type *out)
|
||||
{
|
||||
mie_value_init(&out->t_base, MIE_VALUE_TYPE);
|
||||
out->t_id = MIE_TYPE_PTR;
|
||||
out->t_width = sizeof(uintptr_t) * 8;
|
||||
}
|
||||
|
||||
struct mie_data *mie_data_create_extern_global(
|
||||
struct mie_type *type, const char *ident)
|
||||
{
|
||||
@@ -50,13 +41,9 @@ struct mie_data *mie_data_create_const(struct mie_const *value)
|
||||
return data;
|
||||
}
|
||||
|
||||
static struct mie_type *get_type(struct mie_value *v)
|
||||
static struct mie_type *get_type(struct mie_value *v, struct mie_ctx *ctx)
|
||||
{
|
||||
if (!ptr_type.t_id) {
|
||||
init_ptr_type(&ptr_type);
|
||||
}
|
||||
|
||||
return &ptr_type;
|
||||
return mie_ctx_get_type(ctx, MIE_TYPE_PTR);
|
||||
}
|
||||
|
||||
const struct mie_value_type data_value_type = {
|
||||
|
||||
Reference in New Issue
Block a user