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

@@ -38,8 +38,10 @@ static inline struct mie_block *mie_builder_get_current_block(
return builder->b_current_block;
}
extern void mie_builder_put_record(
extern struct mie_record *mie_builder_put_record(
struct mie_builder *builder, struct mie_const *val, const char *name);
extern struct mie_record *mie_builder_get_record(
struct mie_builder *builder, const char *name);
extern void mie_builder_put_data(struct mie_builder *builder, struct mie_data *data);
extern void mie_builder_put_type(struct mie_builder *builder, struct mie_type *type);
extern void mie_builder_set_insert_point(

View File

@@ -3,21 +3,52 @@
#include <mie/value.h>
#define MIE_CONST(p) ((struct mie_const *)(p))
#define MIE_CONST(p) ((struct mie_const *)(p))
#define MIE_INT(p) ((struct mie_int *)(p))
#define MIE_DOUBLE(p) ((struct mie_double *)(p))
#define MIE_STRING(p) ((struct mie_string *)(p))
#define MIE_ATOM(p) ((struct mie_atom *)(p))
#define MIE_SELECTOR(p) ((struct mie_selector *)(p))
#define MIE_ARRAY(p) ((struct mie_array *)(p))
struct b_list;
struct mie_const {
struct mie_value c_base;
struct mie_type *c_type;
union {
int64_t v_int;
double v_float;
char *v_str;
char *v_atom;
char *v_selector;
} c_v;
};
extern struct mie_const *mie_const_create(struct mie_type *type);
struct mie_int {
struct mie_const i_base;
int64_t i_value;
};
struct mie_double {
struct mie_const d_base;
double d_value;
};
struct mie_string {
struct mie_const s_base;
char *s_value;
};
struct mie_atom {
struct mie_const a_base;
char *a_value;
};
struct mie_selector {
struct mie_const sel_base;
char *sel_value;
};
struct mie_array {
struct mie_const a_base;
struct b_list *a_values;
};
extern void mie_const_init(struct mie_const *c, struct mie_type *type);
#endif

View File

@@ -24,5 +24,6 @@ extern struct mie_value *mie_ctx_get_int(
struct mie_ctx *ctx, long long val, unsigned int nr_bits);
extern struct mie_value *mie_ctx_get_string(struct mie_ctx *ctx, const char *s);
extern struct mie_value *mie_ctx_get_selector(struct mie_ctx *ctx, const char *sel);
extern struct mie_value *mie_ctx_create_array(struct mie_ctx *ctx);
#endif