mie: implement caching and emitting string data
This commit is contained in:
@@ -27,18 +27,6 @@ enum mie_builder_flags {
|
||||
MIE_BUILDER_IGNORE_RESULT = 0x01u,
|
||||
};
|
||||
|
||||
extern struct mie_ctx *mie_ctx_create(void);
|
||||
extern void mie_ctx_destroy(struct mie_ctx *ctx);
|
||||
|
||||
extern struct mie_type *mie_ctx_get_type(
|
||||
struct mie_ctx *ctx, enum mie_type_id type_id);
|
||||
extern struct mie_type *mie_ctx_get_int_type(
|
||||
struct mie_ctx *ctx, unsigned int nr_bits);
|
||||
extern struct mie_value *mie_ctx_get_bool(struct mie_ctx *ctx, bool val);
|
||||
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_selector(struct mie_ctx *ctx, const char *sel);
|
||||
|
||||
extern struct mie_builder *mie_builder_create(
|
||||
struct mie_ctx *ctx, struct mie_module *mod);
|
||||
extern void mie_builder_destroy(struct mie_builder *builder);
|
||||
@@ -59,6 +47,8 @@ extern void mie_builder_set_insert_point(
|
||||
|
||||
extern struct mie_value *mie_builder_get_data_ptr(
|
||||
struct mie_builder *builder, const char *data_ident);
|
||||
extern struct mie_value *mie_builder_get_string_ptr(
|
||||
struct mie_builder *builder, const char *s);
|
||||
|
||||
extern struct mie_value *mie_builder_ret(
|
||||
struct mie_builder *builder, struct mie_value *val);
|
||||
|
||||
@@ -18,4 +18,6 @@ struct mie_const {
|
||||
} c_v;
|
||||
};
|
||||
|
||||
extern struct mie_const *mie_const_create(struct mie_type *type);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,6 +9,7 @@ struct mie_ctx {
|
||||
struct mie_type *ctx_types[__MIE_TYPE_COUNT];
|
||||
b_btree ctx_int_cache;
|
||||
struct b_hashmap *ctx_sel_cache;
|
||||
struct b_hashmap *ctx_string_cache;
|
||||
};
|
||||
|
||||
extern struct mie_ctx *mie_ctx_create(void);
|
||||
@@ -21,6 +22,7 @@ extern struct mie_type *mie_ctx_get_int_type(
|
||||
extern struct mie_value *mie_ctx_get_bool(struct mie_ctx *ctx, bool val);
|
||||
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);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -16,7 +16,7 @@ struct mie_data {
|
||||
enum mie_data_type d_type;
|
||||
union {
|
||||
struct {
|
||||
struct mie_value *c_value;
|
||||
struct mie_const *c_value;
|
||||
} d_const;
|
||||
|
||||
struct {
|
||||
@@ -27,5 +27,6 @@ struct mie_data {
|
||||
|
||||
extern struct mie_data *mie_data_create_extern_global(
|
||||
struct mie_type *type, const char *ident);
|
||||
extern struct mie_data *mie_data_create_const(struct mie_const *value);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,23 +4,33 @@
|
||||
#define MIE_MODULE(p) ((struct mie_module *)(p))
|
||||
|
||||
#include <blue/core/queue.h>
|
||||
#include <mie/name.h>
|
||||
#include <mie/value.h>
|
||||
|
||||
struct mie_func;
|
||||
struct b_hashmap;
|
||||
|
||||
struct mie_module {
|
||||
struct mie_value m_base;
|
||||
struct mie_name_map *m_names;
|
||||
b_queue m_records;
|
||||
b_queue m_data;
|
||||
b_queue m_types;
|
||||
b_queue m_func;
|
||||
|
||||
struct b_hashmap *m_data;
|
||||
struct b_hashmap *m_data_strings;
|
||||
};
|
||||
|
||||
extern struct mie_module *mie_module_create(void);
|
||||
extern void mie_module_add_function(struct mie_module *mod, struct mie_func *func);
|
||||
extern struct mie_data *mie_module_get_string_ptr(
|
||||
struct mie_module *mod, const char *s);
|
||||
extern struct mie_data *mie_module_get_data(
|
||||
struct mie_module *mod, const char *name);
|
||||
extern enum b_status mie_module_put_data(
|
||||
struct mie_module *mod, struct mie_data *data);
|
||||
struct mie_module *mod, struct mie_data *data, const char *name);
|
||||
|
||||
extern struct mie_value *mie_module_generate_value_name(
|
||||
struct mie_module *mod, struct mie_value *val, const char *hint);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user