2025-04-17 21:41:58 +01:00
|
|
|
#include <blue/object/string.h>
|
2025-06-02 11:31:19 +01:00
|
|
|
#include <mie/ir/ctx.h>
|
|
|
|
|
#include <mie/ir/data.h>
|
|
|
|
|
#include <mie/ir/type.h>
|
2025-04-17 21:41:58 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
struct mie_data *mie_data_create_extern_global(
|
|
|
|
|
struct mie_type *type, const char *ident)
|
|
|
|
|
{
|
|
|
|
|
struct mie_data *data = malloc(sizeof *data);
|
|
|
|
|
if (!data) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memset(data, 0x0, sizeof *data);
|
|
|
|
|
|
|
|
|
|
mie_value_init(&data->d_base, MIE_VALUE_DATA);
|
|
|
|
|
|
|
|
|
|
data->d_type = MIE_DATA_EXTERN_GLOBAL;
|
|
|
|
|
data->d_extern_global.g_type = type;
|
|
|
|
|
data->d_base.v_name.n_str = b_strdup(ident);
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-17 22:55:17 +01:00
|
|
|
struct mie_data *mie_data_create_const(struct mie_const *value)
|
|
|
|
|
{
|
|
|
|
|
struct mie_data *data = malloc(sizeof *data);
|
|
|
|
|
if (!data) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memset(data, 0x0, sizeof *data);
|
|
|
|
|
|
|
|
|
|
mie_value_init(&data->d_base, MIE_VALUE_DATA);
|
|
|
|
|
|
|
|
|
|
data->d_type = MIE_DATA_CONST;
|
|
|
|
|
data->d_const.c_value = value;
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-28 15:38:25 +01:00
|
|
|
static struct mie_type *get_type(struct mie_value *v, struct mie_ctx *ctx)
|
2025-04-17 21:41:58 +01:00
|
|
|
{
|
2025-04-28 15:38:25 +01:00
|
|
|
return mie_ctx_get_type(ctx, MIE_TYPE_PTR);
|
2025-04-17 21:41:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const struct mie_value_type data_value_type = {
|
|
|
|
|
.t_id = MIE_VALUE_DATA,
|
|
|
|
|
.t_get_type = get_type,
|
|
|
|
|
};
|