meta: replace bluelib with fx
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#include "assembler.h"
|
||||
|
||||
#include <blue/core/hash.h>
|
||||
#include <blue/ds/hashmap.h>
|
||||
#include <blue/ds/number.h>
|
||||
#include <blue/ds/string.h>
|
||||
#include <fx/core/hash.h>
|
||||
#include <fx/ds/hashmap.h>
|
||||
#include <fx/ds/number.h>
|
||||
#include <fx/ds/string.h>
|
||||
#include <ivy/asm/bin.h>
|
||||
#include <ivy/asm/instr.h>
|
||||
#include <ivy/asm/lex.h>
|
||||
@@ -19,15 +19,15 @@ enum label_state {
|
||||
|
||||
struct label {
|
||||
enum label_state l_state;
|
||||
b_queue_entry l_entry;
|
||||
fx_queue_entry l_entry;
|
||||
const struct ivy_asm_token *l_name;
|
||||
size_t l_offset;
|
||||
};
|
||||
|
||||
struct block_assembler_scope {
|
||||
struct assembler_scope s_base;
|
||||
b_hashmap *s_labels;
|
||||
b_queue s_label_refs;
|
||||
fx_hashmap *s_labels;
|
||||
fx_queue s_label_refs;
|
||||
size_t s_text_start;
|
||||
};
|
||||
|
||||
@@ -57,10 +57,10 @@ static enum ivy_status init_scope(
|
||||
struct ivy_bin_block header = {0};
|
||||
|
||||
struct block_assembler_scope *c = (struct block_assembler_scope *)scope;
|
||||
c->s_labels = b_hashmap_create(NULL, NULL);
|
||||
c->s_labels = fx_hashmap_create(NULL, NULL);
|
||||
c->s_text_start = ivy_assembler_get_ptr(as);
|
||||
|
||||
header.b_index = b_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_INDEX]);
|
||||
header.b_index = fx_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_INDEX]);
|
||||
assembler_write_data(as, &header, sizeof header);
|
||||
|
||||
return IVY_OK;
|
||||
@@ -68,12 +68,12 @@ static enum ivy_status init_scope(
|
||||
|
||||
static struct label *get_label(struct block_assembler_scope *scope, const char *name)
|
||||
{
|
||||
b_hashmap_key key = {
|
||||
fx_hashmap_key key = {
|
||||
.key_data = name,
|
||||
.key_size = strlen(name),
|
||||
};
|
||||
|
||||
const b_hashmap_value *v = b_hashmap_get(scope->s_labels, &key);
|
||||
const fx_hashmap_value *v = fx_hashmap_get(scope->s_labels, &key);
|
||||
if (!v) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -88,9 +88,9 @@ static enum ivy_status resolve_label_refs(
|
||||
enum ivy_status status = IVY_OK;
|
||||
size_t nr_read = 0;
|
||||
|
||||
b_queue_entry *entry = b_queue_first(&c->s_label_refs);
|
||||
fx_queue_entry *entry = fx_queue_first(&c->s_label_refs);
|
||||
while (entry) {
|
||||
struct label *label_ref = b_unbox(struct label, entry, l_entry);
|
||||
struct label *label_ref = fx_unbox(struct label, entry, l_entry);
|
||||
struct label *label_dest = get_label(c, label_ref->l_name->t_str);
|
||||
|
||||
if (!label_dest) {
|
||||
@@ -99,7 +99,7 @@ static enum ivy_status resolve_label_refs(
|
||||
return IVY_ERR_NO_ENTRY;
|
||||
}
|
||||
|
||||
b_i32 x;
|
||||
fx_i32 x;
|
||||
status = assembler_read_data_at(
|
||||
as, &x, label_ref->l_offset, sizeof x, &nr_read);
|
||||
|
||||
@@ -109,12 +109,12 @@ static enum ivy_status resolve_label_refs(
|
||||
return IVY_ERR_IO_FAILURE;
|
||||
}
|
||||
|
||||
uint32_t instr = b_i32_btoh(x);
|
||||
uint32_t instr = fx_i32_btoh(x);
|
||||
instr = R_SET_D3(instr, label_dest->l_offset);
|
||||
x = b_i32_htob(instr);
|
||||
x = fx_i32_htob(instr);
|
||||
|
||||
assembler_write_data_at(as, &x, label_ref->l_offset, sizeof x);
|
||||
entry = b_queue_next(entry);
|
||||
entry = fx_queue_next(entry);
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -164,7 +164,7 @@ static enum ivy_status put_instr(
|
||||
return IVY_ERR_INTERNAL_FAILURE;
|
||||
}
|
||||
|
||||
b_i32 x = b_i32_htob(v);
|
||||
fx_i32 x = fx_i32_htob(v);
|
||||
assembler_write_data(as, &x, sizeof x);
|
||||
return IVY_OK;
|
||||
}
|
||||
@@ -179,21 +179,21 @@ static enum ivy_status put_label(
|
||||
label->l_name = label_name;
|
||||
label->l_offset = label_offset - c->s_text_start;
|
||||
|
||||
b_hashmap_key key = {
|
||||
fx_hashmap_key key = {
|
||||
.key_data = label_name->t_str,
|
||||
.key_size = strlen(label_name->t_str),
|
||||
};
|
||||
|
||||
b_hashmap_value value = {
|
||||
fx_hashmap_value value = {
|
||||
.value_data = label,
|
||||
.value_size = sizeof *label,
|
||||
};
|
||||
|
||||
if (b_hashmap_get(c->s_labels, &key)) {
|
||||
if (fx_hashmap_get(c->s_labels, &key)) {
|
||||
return IVY_ERR_NAME_EXISTS;
|
||||
}
|
||||
|
||||
b_status status = b_hashmap_put(c->s_labels, &key, &value);
|
||||
fx_status status = fx_hashmap_put(c->s_labels, &key, &value);
|
||||
|
||||
return ivy_status_from_b_status(status);
|
||||
}
|
||||
@@ -208,7 +208,7 @@ static enum ivy_status put_label_ref(
|
||||
label->l_name = label_name;
|
||||
label->l_offset = ref_offset;
|
||||
|
||||
b_queue_push_back(&c->s_label_refs, &label->l_entry);
|
||||
fx_queue_push_back(&c->s_label_refs, &label->l_entry);
|
||||
return IVY_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user