meta: replace bluelib with fx
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
* - each node type (var, msg, expr) gets its own code generator type
|
||||
* - expr code generator is limited to simple operator arithmetic.
|
||||
* - when a code generator encounters a node of an equal or lower depth than
|
||||
* the node that started it, it has reached the end of its subtree.
|
||||
* the node that started it, it has reached the end of its subst.
|
||||
* - depth is supplied by the ast iterator.
|
||||
* - need to devise a way for expression code generator to "return" a
|
||||
* mie_value for its parent generator to use.
|
||||
@@ -21,12 +21,12 @@
|
||||
static struct code_generator_state *get_current_generator_state(
|
||||
struct ivy_codegen *gen)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_last(&gen->c_state);
|
||||
fx_queue_entry *entry = fx_queue_last(&gen->c_state);
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return b_unbox(struct code_generator_state, entry, s_entry);
|
||||
return fx_unbox(struct code_generator_state, entry, s_entry);
|
||||
}
|
||||
|
||||
static void code_generator_state_inherit(
|
||||
@@ -76,7 +76,7 @@ enum ivy_status codegen_push_generator(
|
||||
return status;
|
||||
}
|
||||
|
||||
b_queue_push_back(&gen->c_state, &state->s_entry);
|
||||
fx_queue_push_back(&gen->c_state, &state->s_entry);
|
||||
|
||||
return IVY_OK;
|
||||
}
|
||||
@@ -84,13 +84,13 @@ enum ivy_status codegen_push_generator(
|
||||
enum ivy_status codegen_pop_generator(
|
||||
struct ivy_codegen *gen, struct code_generator_value *result)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_pop_back(&gen->c_state);
|
||||
fx_queue_entry *entry = fx_queue_pop_back(&gen->c_state);
|
||||
if (!entry) {
|
||||
return IVY_ERR_BAD_STATE;
|
||||
}
|
||||
|
||||
struct code_generator_state *state
|
||||
= b_unbox(struct code_generator_state, entry, s_entry);
|
||||
= fx_unbox(struct code_generator_state, entry, s_entry);
|
||||
|
||||
enum ivy_status status = IVY_OK;
|
||||
|
||||
@@ -109,7 +109,7 @@ enum ivy_status codegen_pop_generator(
|
||||
enum ivy_status codegen_define_variable(
|
||||
struct ivy_codegen *gen, const char *ident, const struct codegen_var *var)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_last(&gen->c_state);
|
||||
fx_queue_entry *entry = fx_queue_last(&gen->c_state);
|
||||
if (!entry) {
|
||||
return IVY_ERR_NO_ENTRY;
|
||||
}
|
||||
@@ -118,7 +118,7 @@ enum ivy_status codegen_define_variable(
|
||||
|
||||
while (entry) {
|
||||
struct code_generator_state *state
|
||||
= b_unbox(struct code_generator_state, entry, s_entry);
|
||||
= fx_unbox(struct code_generator_state, entry, s_entry);
|
||||
const struct code_generator *generator = state->s_gen;
|
||||
enum ivy_status status = IVY_ERR_NO_ENTRY;
|
||||
|
||||
@@ -130,7 +130,7 @@ enum ivy_status codegen_define_variable(
|
||||
break;
|
||||
}
|
||||
|
||||
entry = b_queue_prev(entry);
|
||||
entry = fx_queue_prev(entry);
|
||||
}
|
||||
|
||||
return IVY_ERR_NOT_SUPPORTED;
|
||||
@@ -155,7 +155,7 @@ enum ivy_status resolve_global_variable(
|
||||
enum ivy_status codegen_resolve_variable(
|
||||
struct ivy_codegen *gen, const char *ident, struct codegen_var *out)
|
||||
{
|
||||
b_queue_entry *entry = b_queue_last(&gen->c_state);
|
||||
fx_queue_entry *entry = fx_queue_last(&gen->c_state);
|
||||
if (!entry) {
|
||||
return IVY_ERR_NO_ENTRY;
|
||||
}
|
||||
@@ -164,7 +164,7 @@ enum ivy_status codegen_resolve_variable(
|
||||
|
||||
while (entry) {
|
||||
struct code_generator_state *state
|
||||
= b_unbox(struct code_generator_state, entry, s_entry);
|
||||
= fx_unbox(struct code_generator_state, entry, s_entry);
|
||||
const struct code_generator *generator = state->s_gen;
|
||||
enum ivy_status status = IVY_ERR_NO_ENTRY;
|
||||
|
||||
@@ -177,7 +177,7 @@ enum ivy_status codegen_resolve_variable(
|
||||
break;
|
||||
}
|
||||
|
||||
entry = b_queue_prev(entry);
|
||||
entry = fx_queue_prev(entry);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -187,12 +187,12 @@ enum ivy_status codegen_resolve_variable(
|
||||
#endif
|
||||
|
||||
if (entry) {
|
||||
entry = b_queue_next(entry);
|
||||
entry = fx_queue_next(entry);
|
||||
}
|
||||
|
||||
while (entry) {
|
||||
struct code_generator_state *state
|
||||
= b_unbox(struct code_generator_state, entry, s_entry);
|
||||
= fx_unbox(struct code_generator_state, entry, s_entry);
|
||||
const struct code_generator *generator = state->s_gen;
|
||||
enum ivy_status status = IVY_OK;
|
||||
|
||||
@@ -204,7 +204,7 @@ enum ivy_status codegen_resolve_variable(
|
||||
return status;
|
||||
}
|
||||
|
||||
entry = b_queue_next(entry);
|
||||
entry = fx_queue_next(entry);
|
||||
}
|
||||
|
||||
return IVY_OK;
|
||||
@@ -371,7 +371,7 @@ enum ivy_status ivy_codegen_push_node(
|
||||
return IVY_ERR_BAD_STATE;
|
||||
}
|
||||
|
||||
if (b_queue_empty(&gen->c_state)) {
|
||||
if (fx_queue_empty(&gen->c_state)) {
|
||||
const struct code_generator *generator
|
||||
= get_root_code_generator(node->n_type);
|
||||
if (!generator) {
|
||||
@@ -441,7 +441,7 @@ enum ivy_status ivy_codegen_push_eof(struct ivy_codegen *gen)
|
||||
.r_status = IVY_OK,
|
||||
};
|
||||
|
||||
while (!b_queue_empty(&gen->c_state)) {
|
||||
while (!fx_queue_empty(&gen->c_state)) {
|
||||
struct code_generator_value value = {0};
|
||||
status = codegen_pop_generator(gen, &value);
|
||||
if (status != IVY_OK) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "var-map.h"
|
||||
|
||||
#include <blue/core/queue.h>
|
||||
#include <fx/core/queue.h>
|
||||
#include <ivy/lang/ast.h>
|
||||
#include <ivy/lang/lex.h>
|
||||
#include <mie/ctx.h>
|
||||
@@ -124,7 +124,7 @@ struct code_generator {
|
||||
};
|
||||
|
||||
struct code_generator_state {
|
||||
b_queue_entry s_entry;
|
||||
fx_queue_entry s_entry;
|
||||
uintptr_t s_argv;
|
||||
void *s_argp;
|
||||
const struct code_generator *s_gen;
|
||||
@@ -135,9 +135,9 @@ struct code_generator_state {
|
||||
};
|
||||
|
||||
struct ivy_codegen {
|
||||
b_queue c_values;
|
||||
b_queue c_state;
|
||||
b_queue c_scope;
|
||||
fx_queue c_values;
|
||||
fx_queue c_state;
|
||||
fx_queue c_scope;
|
||||
struct mie_builder *c_builder;
|
||||
struct mie_ctx *c_ctx;
|
||||
struct mie_module *c_module;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
struct cond_group_codegen_state {
|
||||
struct code_generator_state s_base;
|
||||
struct mie_block *s_end;
|
||||
b_queue s_edges;
|
||||
fx_queue s_edges;
|
||||
};
|
||||
|
||||
static struct code_generator_result gen_cond_group(
|
||||
@@ -55,10 +55,10 @@ static enum ivy_status get_eval_type(
|
||||
{
|
||||
struct mie_type *type = NULL;
|
||||
|
||||
b_queue_entry *entry = b_queue_first(&state->s_edges);
|
||||
fx_queue_entry *entry = fx_queue_first(&state->s_edges);
|
||||
while (entry) {
|
||||
struct mie_phi_edge *edge
|
||||
= b_unbox(struct mie_phi_edge, entry, e_entry);
|
||||
= fx_unbox(struct mie_phi_edge, entry, e_entry);
|
||||
if (!edge->e_value) {
|
||||
goto next;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ static enum ivy_status get_eval_type(
|
||||
}
|
||||
|
||||
next:
|
||||
entry = b_queue_next(entry);
|
||||
entry = fx_queue_next(entry);
|
||||
}
|
||||
|
||||
*out = type;
|
||||
@@ -82,7 +82,7 @@ static enum ivy_status emit_phi_instr(
|
||||
struct ivy_codegen *gen, struct cond_group_codegen_state *state,
|
||||
struct mie_type *type, struct mie_value **result)
|
||||
{
|
||||
size_t nr_edges = b_queue_length(&state->s_edges);
|
||||
size_t nr_edges = fx_queue_length(&state->s_edges);
|
||||
if (!nr_edges) {
|
||||
return IVY_OK;
|
||||
}
|
||||
@@ -94,14 +94,14 @@ static enum ivy_status emit_phi_instr(
|
||||
|
||||
size_t i = 0;
|
||||
|
||||
b_queue_entry *entry = b_queue_first(&state->s_edges);
|
||||
fx_queue_entry *entry = fx_queue_first(&state->s_edges);
|
||||
while (entry) {
|
||||
struct mie_phi_edge *edge
|
||||
= b_unbox(struct mie_phi_edge, entry, e_entry);
|
||||
= fx_unbox(struct mie_phi_edge, entry, e_entry);
|
||||
|
||||
memcpy(&edges[i], edge, sizeof *edge);
|
||||
i++;
|
||||
entry = b_queue_next(entry);
|
||||
entry = fx_queue_next(entry);
|
||||
}
|
||||
|
||||
struct mie_value *phi = mie_builder_phi(
|
||||
@@ -159,7 +159,7 @@ static struct code_generator_result value_received(
|
||||
assert(value->v_type == CODE_GENERATOR_VALUE_PHI_EDGE);
|
||||
|
||||
struct mie_phi_edge *edge = code_generator_value_get_phi_edge(value);
|
||||
b_queue_push_back(&cond->s_edges, &edge->e_entry);
|
||||
fx_queue_push_back(&cond->s_edges, &edge->e_entry);
|
||||
|
||||
return CODEGEN_RESULT_OK(0);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ enum expr_operand_type {
|
||||
};
|
||||
|
||||
struct expr_item {
|
||||
b_queue_entry i_entry;
|
||||
fx_queue_entry i_entry;
|
||||
enum expr_item_type i_type;
|
||||
enum expr_operand_type i_operand_type;
|
||||
struct ivy_ast_node *i_node;
|
||||
@@ -29,7 +29,7 @@ struct expr_codegen_state {
|
||||
struct code_generator_state s_base;
|
||||
struct ivy_ast_node *s_expr_root;
|
||||
uintptr_t s_flags;
|
||||
b_queue s_item_queue;
|
||||
fx_queue s_item_queue;
|
||||
};
|
||||
|
||||
#if 0
|
||||
@@ -66,7 +66,7 @@ static enum ivy_status push_operand(
|
||||
item->i_operand_type = EXPR_OPERAND_VAR;
|
||||
}
|
||||
|
||||
b_queue_push_back(&expr->s_item_queue, &item->i_entry);
|
||||
fx_queue_push_back(&expr->s_item_queue, &item->i_entry);
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ static enum ivy_status push_operator(
|
||||
item->i_type = EXPR_OPERATOR;
|
||||
item->i_node = node;
|
||||
|
||||
b_queue_push_back(&expr->s_item_queue, &item->i_entry);
|
||||
fx_queue_push_back(&expr->s_item_queue, &item->i_entry);
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
@@ -543,24 +543,24 @@ static enum ivy_status state_fini(
|
||||
|
||||
struct expr_codegen_state *expr = (struct expr_codegen_state *)state;
|
||||
enum ivy_status status = IVY_OK;
|
||||
b_queue stack = B_QUEUE_INIT;
|
||||
fx_queue stack = FX_QUEUE_INIT;
|
||||
|
||||
b_queue_entry *cur = NULL;
|
||||
while ((cur = b_queue_pop_back(&expr->s_item_queue))) {
|
||||
struct expr_item *item = b_unbox(struct expr_item, cur, i_entry);
|
||||
fx_queue_entry *cur = NULL;
|
||||
while ((cur = fx_queue_pop_back(&expr->s_item_queue))) {
|
||||
struct expr_item *item = fx_unbox(struct expr_item, cur, i_entry);
|
||||
|
||||
if (item->i_type == EXPR_OPERAND) {
|
||||
b_queue_push_back(&stack, &item->i_entry);
|
||||
fx_queue_push_back(&stack, &item->i_entry);
|
||||
continue;
|
||||
}
|
||||
|
||||
struct ivy_ast_op_node *op = (struct ivy_ast_op_node *)item->i_node;
|
||||
b_queue_entry *left_entry = b_queue_pop_back(&stack);
|
||||
b_queue_entry *right_entry = b_queue_pop_back(&stack);
|
||||
fx_queue_entry *left_entry = fx_queue_pop_back(&stack);
|
||||
fx_queue_entry *right_entry = fx_queue_pop_back(&stack);
|
||||
struct expr_item *left
|
||||
= b_unbox(struct expr_item, left_entry, i_entry);
|
||||
= fx_unbox(struct expr_item, left_entry, i_entry);
|
||||
struct expr_item *right
|
||||
= b_unbox(struct expr_item, right_entry, i_entry);
|
||||
= fx_unbox(struct expr_item, right_entry, i_entry);
|
||||
|
||||
struct mie_value *left_value = left->i_value;
|
||||
struct mie_value *right_value = right->i_value;
|
||||
@@ -670,19 +670,19 @@ static enum ivy_status state_fini(
|
||||
|
||||
skip_op:
|
||||
item->i_value = op_value;
|
||||
b_queue_push_back(&stack, &item->i_entry);
|
||||
fx_queue_push_back(&stack, &item->i_entry);
|
||||
}
|
||||
|
||||
if (status != IVY_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
cur = b_queue_pop_back(&stack);
|
||||
cur = fx_queue_pop_back(&stack);
|
||||
if (!cur) {
|
||||
return IVY_ERR_INTERNAL_FAILURE;
|
||||
}
|
||||
|
||||
struct expr_item *result_item = b_unbox(struct expr_item, cur, i_entry);
|
||||
struct expr_item *result_item = fx_unbox(struct expr_item, cur, i_entry);
|
||||
struct mie_value *result_value;
|
||||
if (result_item->i_operand_type == EXPR_OPERAND_VAR) {
|
||||
result_value = load_variable(gen, &result_item->i_var);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "../debug.h"
|
||||
#include "codegen.h"
|
||||
|
||||
#include <blue/core/stringstream.h>
|
||||
#include <fx/core/stringstream.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -98,7 +98,7 @@ static struct code_generator_result gen_selector(
|
||||
msg->s_prev_part = MSG_SELECTOR;
|
||||
|
||||
msg->s_nr_args = 0;
|
||||
msg->s_max_args = b_queue_length(&msg->s_selector->n_arg_labels);
|
||||
msg->s_max_args = fx_queue_length(&msg->s_selector->n_arg_labels);
|
||||
msg->s_args = calloc(msg->s_max_args, sizeof(struct mie_value *));
|
||||
|
||||
if (!msg->s_args) {
|
||||
@@ -126,38 +126,38 @@ static enum ivy_status state_init(
|
||||
}
|
||||
|
||||
static void serialise_selector(
|
||||
struct ivy_ast_selector_node *sel, b_stringstream *out)
|
||||
struct ivy_ast_selector_node *sel, fx_stringstream *out)
|
||||
{
|
||||
b_stream_write_string(out, "_M", NULL);
|
||||
fx_stream_write_string(out, "_M", NULL);
|
||||
|
||||
if (sel->n_msg_name) {
|
||||
const char *msg_name = sel->n_msg_name->t_str;
|
||||
b_stream_write_fmt(out, NULL, "%zu%s", strlen(msg_name), msg_name);
|
||||
fx_stream_write_fmt(out, NULL, "%zu%s", strlen(msg_name), msg_name);
|
||||
} else {
|
||||
b_stream_write_char(out, '0');
|
||||
fx_stream_write_char(out, '0');
|
||||
}
|
||||
|
||||
b_queue_entry *entry = b_queue_first(&sel->n_arg_labels);
|
||||
fx_queue_entry *entry = fx_queue_first(&sel->n_arg_labels);
|
||||
while (entry) {
|
||||
struct ivy_token *arg = b_unbox(struct ivy_token, entry, t_entry);
|
||||
struct ivy_token *arg = fx_unbox(struct ivy_token, entry, t_entry);
|
||||
|
||||
if (arg->t_type != IVY_TOK_IDENT && arg->t_type != IVY_TOK_LABEL) {
|
||||
b_stream_write_char(out, '0');
|
||||
fx_stream_write_char(out, '0');
|
||||
goto next;
|
||||
}
|
||||
|
||||
const char *label = arg->t_str;
|
||||
|
||||
if (label) {
|
||||
b_stream_write_fmt(out, NULL, "%zu%s", strlen(label), label);
|
||||
fx_stream_write_fmt(out, NULL, "%zu%s", strlen(label), label);
|
||||
} else {
|
||||
b_stream_write_char(out, '0');
|
||||
fx_stream_write_char(out, '0');
|
||||
}
|
||||
next:
|
||||
entry = b_queue_next(entry);
|
||||
entry = fx_queue_next(entry);
|
||||
}
|
||||
|
||||
b_stream_write_char(out, 'E');
|
||||
fx_stream_write_char(out, 'E');
|
||||
}
|
||||
|
||||
static enum ivy_status state_fini(
|
||||
@@ -168,10 +168,10 @@ static enum ivy_status state_fini(
|
||||
|
||||
struct msg_codegen_state *msg = (struct msg_codegen_state *)state;
|
||||
|
||||
b_stringstream *str = b_stringstream_create();
|
||||
fx_stringstream *str = fx_stringstream_create();
|
||||
serialise_selector(msg->s_selector, str);
|
||||
char *sel = b_stringstream_steal(str);
|
||||
b_stringstream_unref(str);
|
||||
char *sel = fx_stringstream_steal(str);
|
||||
fx_stringstream_unref(str);
|
||||
|
||||
struct mie_value *sel_value = mie_ctx_get_selector(gen->c_ctx, sel);
|
||||
free(sel);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "codegen.h"
|
||||
#include "var-map.h"
|
||||
|
||||
#include <blue/core/stringstream.h>
|
||||
#include <blue/ds/list.h>
|
||||
#include <fx/core/stringstream.h>
|
||||
#include <fx/ds/list.h>
|
||||
#include <mie/ir/block.h>
|
||||
#include <mie/ir/func.h>
|
||||
#include <mie/ir/module.h>
|
||||
@@ -142,19 +142,19 @@ static struct code_generator_result gen_while_loop(
|
||||
return CODEGEN_RESULT_OK(CODEGEN_R_REPEAT_NODE);
|
||||
}
|
||||
|
||||
static void serialise_package_name(b_queue *parts, b_stringstream *out)
|
||||
static void serialise_package_name(fx_queue *parts, fx_stringstream *out)
|
||||
{
|
||||
b_stream_write_string(out, "_ZN", NULL);
|
||||
fx_stream_write_string(out, "_ZN", NULL);
|
||||
|
||||
b_queue_entry *entry = b_queue_first(parts);
|
||||
fx_queue_entry *entry = fx_queue_first(parts);
|
||||
while (entry) {
|
||||
struct ivy_token *tok = b_unbox(struct ivy_token, entry, t_entry);
|
||||
struct ivy_token *tok = fx_unbox(struct ivy_token, entry, t_entry);
|
||||
size_t len = strlen(tok->t_str);
|
||||
b_stream_write_fmt(out, NULL, "%zu%s", len, tok->t_str);
|
||||
entry = b_queue_next(entry);
|
||||
fx_stream_write_fmt(out, NULL, "%zu%s", len, tok->t_str);
|
||||
entry = fx_queue_next(entry);
|
||||
}
|
||||
|
||||
b_stream_write_char(out, 'E');
|
||||
fx_stream_write_char(out, 'E');
|
||||
}
|
||||
|
||||
static struct code_generator_result gen_unit_package(
|
||||
@@ -165,10 +165,10 @@ static struct code_generator_result gen_unit_package(
|
||||
struct ivy_ast_unit_package_node *pkg
|
||||
= (struct ivy_ast_unit_package_node *)node;
|
||||
|
||||
b_stringstream *str = b_stringstream_create();
|
||||
fx_stringstream *str = fx_stringstream_create();
|
||||
serialise_package_name(&pkg->n_ident, str);
|
||||
char *ident = b_stringstream_steal(str);
|
||||
b_stringstream_unref(str);
|
||||
char *ident = fx_stringstream_steal(str);
|
||||
fx_stringstream_unref(str);
|
||||
struct mie_value *ident_val = mie_ctx_get_string(gen->c_ctx, ident);
|
||||
free(ident);
|
||||
|
||||
@@ -198,14 +198,14 @@ static struct code_generator_result gen_unit_import(
|
||||
import_list = MIE_ARRAY(rec->r_value);
|
||||
}
|
||||
|
||||
b_stringstream *str = b_stringstream_create();
|
||||
fx_stringstream *str = fx_stringstream_create();
|
||||
serialise_package_name(&pkg->n_ident, str);
|
||||
char *ident = b_stringstream_steal(str);
|
||||
b_stringstream_unref(str);
|
||||
char *ident = fx_stringstream_steal(str);
|
||||
fx_stringstream_unref(str);
|
||||
struct mie_value *ident_val = mie_ctx_get_string(gen->c_ctx, ident);
|
||||
free(ident);
|
||||
|
||||
b_list_push_back(import_list->a_values, ident_val);
|
||||
fx_list_push_back(import_list->a_values, ident_val);
|
||||
|
||||
return CODEGEN_RESULT_OK(0);
|
||||
}
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
#include "var-map.h"
|
||||
|
||||
#include <blue/ds/hashmap.h>
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/ds/hashmap.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
enum ivy_status codegen_var_map_init(struct codegen_var_map *map)
|
||||
{
|
||||
memset(map, 0x0, sizeof *map);
|
||||
map->m_map = b_hashmap_create(free, free);
|
||||
map->m_map = fx_hashmap_create(free, free);
|
||||
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
enum ivy_status codegen_var_map_fini(struct codegen_var_map *map)
|
||||
{
|
||||
b_hashmap_unref(map->m_map);
|
||||
fx_hashmap_unref(map->m_map);
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
enum ivy_status codegen_var_map_get(
|
||||
struct codegen_var_map *map, const char *ident, struct codegen_var **out)
|
||||
{
|
||||
b_hashmap_key key = {
|
||||
fx_hashmap_key key = {
|
||||
.key_data = ident,
|
||||
.key_size = strlen(ident),
|
||||
};
|
||||
|
||||
const b_hashmap_value *value = b_hashmap_get(map->m_map, &key);
|
||||
const fx_hashmap_value *value = fx_hashmap_get(map->m_map, &key);
|
||||
|
||||
if (!value) {
|
||||
return IVY_ERR_NO_ENTRY;
|
||||
@@ -42,8 +42,8 @@ enum ivy_status codegen_var_map_put(
|
||||
struct codegen_var_map *map, const char *ident,
|
||||
const struct codegen_var *var)
|
||||
{
|
||||
b_hashmap_key key = {
|
||||
.key_data = b_strdup(ident),
|
||||
fx_hashmap_key key = {
|
||||
.key_data = fx_strdup(ident),
|
||||
.key_size = strlen(ident),
|
||||
};
|
||||
|
||||
@@ -51,7 +51,7 @@ enum ivy_status codegen_var_map_put(
|
||||
return IVY_ERR_NO_MEMORY;
|
||||
}
|
||||
|
||||
b_hashmap_value value = {
|
||||
fx_hashmap_value value = {
|
||||
.value_data = malloc(sizeof *var),
|
||||
.value_size = sizeof *var,
|
||||
};
|
||||
@@ -63,8 +63,8 @@ enum ivy_status codegen_var_map_put(
|
||||
|
||||
memcpy(value.value_data, var, sizeof *var);
|
||||
|
||||
b_status status = b_hashmap_put(map->m_map, &key, &value);
|
||||
if (!B_OK(status)) {
|
||||
fx_status status = fx_hashmap_put(map->m_map, &key, &value);
|
||||
if (!FX_OK(status)) {
|
||||
free((void *)key.key_data);
|
||||
free(value.value_data);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef CODEGEN_VAR_MAP_H_
|
||||
#define CODEGEN_VAR_MAP_H_
|
||||
|
||||
#include <blue/ds/hashmap.h>
|
||||
#include <fx/ds/hashmap.h>
|
||||
#include <ivy/status.h>
|
||||
|
||||
struct mie_value;
|
||||
@@ -20,7 +20,7 @@ struct codegen_var {
|
||||
};
|
||||
|
||||
struct codegen_var_map {
|
||||
b_hashmap *m_map;
|
||||
fx_hashmap *m_map;
|
||||
};
|
||||
|
||||
extern enum ivy_status codegen_var_map_init(struct codegen_var_map *map);
|
||||
|
||||
Reference in New Issue
Block a user