meta: replace bluelib with fx

This commit is contained in:
2026-03-16 14:07:33 +00:00
parent d2abb6faa3
commit e5546f97c2
105 changed files with 1668 additions and 1668 deletions

View File

@@ -11,5 +11,5 @@ else ()
endif ()
target_include_directories(ivy-asm PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/)
target_link_libraries(ivy-asm ivy-common mie Bluelib::Core Bluelib::Ds)
target_link_libraries(ivy-asm ivy-common mie FX::Core FX::Ds)
target_compile_definitions(ivy-asm PRIVATE IVY_EXPORT=1 IVY_STATIC=${IVY_STATIC})

View File

@@ -1,6 +1,6 @@
#include "assembler.h"
#include <blue/core/queue.h>
#include <fx/core/queue.h>
#include <ivy/asm/assembler.h>
#include <ivy/asm/bin.h>
#include <stdio.h>
@@ -19,13 +19,13 @@ static const struct assembler_scope_type *scope_types[] = {
static const size_t nr_scope_types = sizeof scope_types / sizeof scope_types[0];
struct asm_table_entry {
b_queue_entry e_entry;
fx_queue_entry e_entry;
struct ivy_bin_table_entry e_data;
};
struct ivy_assembler {
struct assembler_scope *as_scope;
b_queue as_table;
fx_queue as_table;
FILE *as_data;
size_t as_data_offset;
@@ -48,7 +48,7 @@ enum ivy_status ivy_assembler_create(FILE *fp, struct ivy_assembler **as)
out->as_xdat = tmpfile();
struct ivy_bin_header header = {0};
header.h_magic = b_i32_htob(0xAABBCCDD);
header.h_magic = fx_i32_htob(0xAABBCCDD);
fseek(fp, 0, SEEK_SET);
fwrite(&header, sizeof header, 1, fp);
@@ -86,9 +86,9 @@ enum ivy_status ivy_assembler_finish(struct ivy_assembler *as)
pad(as, 16);
struct ivy_bin_table_entry xdat = {0};
xdat.e_offset = b_i64_htob(as->as_data_offset);
xdat.e_size = b_i32_htob((uint32_t)xdat_len);
xdat.e_type = b_i32_htob(IVY_TABLE_XDAT);
xdat.e_offset = fx_i64_htob(as->as_data_offset);
xdat.e_size = fx_i32_htob((uint32_t)xdat_len);
xdat.e_type = fx_i32_htob(IVY_TABLE_XDAT);
while (1) {
size_t r = fread(buf, 1, buf_len, as->as_xdat);
@@ -114,14 +114,14 @@ enum ivy_status ivy_assembler_finish(struct ivy_assembler *as)
pad(as, 16);
struct ivy_bin_header header = {0};
header.h_table_offset = b_i64_htob(as->as_data_offset);
header.h_table_len = b_i16_htob(0);
header.h_magic = b_i32_htob(IVY_BIN_MAGIC);
header.h_table_offset = fx_i64_htob(as->as_data_offset);
header.h_table_len = fx_i16_htob(0);
header.h_magic = fx_i32_htob(IVY_BIN_MAGIC);
b_queue_entry *entry = b_queue_first(&as->as_table);
fx_queue_entry *entry = fx_queue_first(&as->as_table);
while (entry) {
struct asm_table_entry *e
= b_unbox(struct asm_table_entry, entry, e_entry);
= fx_unbox(struct asm_table_entry, entry, e_entry);
size_t w = fwrite(&e->e_data, 1, sizeof e->e_data, as->as_data);
if (w < sizeof e->e_data) {
@@ -129,13 +129,13 @@ enum ivy_status ivy_assembler_finish(struct ivy_assembler *as)
}
nr_table_entries++;
entry = b_queue_next(entry);
entry = fx_queue_next(entry);
}
fwrite(&xdat, 1, sizeof xdat, as->as_data);
nr_table_entries++;
header.h_table_len = b_i16_htob(nr_table_entries);
header.h_table_len = fx_i16_htob(nr_table_entries);
fseek(as->as_data, 0, SEEK_SET);
fwrite(&header, 1, sizeof header, as->as_data);
@@ -257,28 +257,28 @@ enum ivy_status ivy_assembler_end_scope(struct ivy_assembler *as)
memset(entry, 0x0, sizeof *entry);
entry->e_data.e_offset
= b_i64_htob((uint64_t)as->as_scope->s_start_offset);
entry->e_data.e_size = b_i32_htob(
= fx_i64_htob((uint64_t)as->as_scope->s_start_offset);
entry->e_data.e_size = fx_i32_htob(
(uint32_t)(as->as_data_offset - as->as_scope->s_start_offset));
switch (as->as_scope->s_type) {
case IVY_ASM_SCOPE_CLASS:
entry->e_data.e_type = b_i32_htob(IVY_TABLE_CLASS);
entry->e_data.e_type = fx_i32_htob(IVY_TABLE_CLASS);
break;
case IVY_ASM_SCOPE_BLOCK:
entry->e_data.e_type = b_i32_htob(IVY_TABLE_BLOCK);
entry->e_data.e_type = fx_i32_htob(IVY_TABLE_BLOCK);
break;
case IVY_ASM_SCOPE_CONSTPOOL:
entry->e_data.e_type = b_i32_htob(IVY_TABLE_POOL);
entry->e_data.e_type = fx_i32_htob(IVY_TABLE_POOL);
break;
case IVY_ASM_SCOPE_IMPORT:
entry->e_data.e_type = b_i32_htob(IVY_TABLE_IMPORT);
entry->e_data.e_type = fx_i32_htob(IVY_TABLE_IMPORT);
break;
default:
break;
}
b_queue_push_back(&as->as_table, &entry->e_entry);
fx_queue_push_back(&as->as_table, &entry->e_entry);
free(as->as_scope);
as->as_scope = NULL;

View File

@@ -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;
}

View File

@@ -8,7 +8,7 @@ static enum ivy_status init_scope(
{
struct ivy_bin_class header = {0};
header.c_ident = b_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_IDENT]);
header.c_ident = fx_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_IDENT]);
assembler_write_data(as, &header, sizeof header);
@@ -22,27 +22,27 @@ static enum ivy_status put_xval(
struct ivy_bin_class_table_entry entry = {0};
switch (type) {
case IVY_ASM_XVAL_PROPERTY:
entry.e_type = b_i32_htob(IVY_CLASS_TABLE_PROP);
entry.e_type = fx_i32_htob(IVY_CLASS_TABLE_PROP);
entry.e_property.p_ident
= b_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_IDENT]);
= fx_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_IDENT]);
entry.e_property.p_get
= b_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_GET]);
= fx_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_GET]);
entry.e_property.p_set
= b_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_SET]);
= fx_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_SET]);
break;
case IVY_ASM_XVAL_MEMBER_VAR:
entry.e_type = b_i32_htob(IVY_CLASS_TABLE_MVAR);
entry.e_type = fx_i32_htob(IVY_CLASS_TABLE_MVAR);
entry.e_mvar.m_ident
= b_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_IDENT]);
= fx_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_IDENT]);
entry.e_mvar.m_index
= b_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_INDEX]);
= fx_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_INDEX]);
break;
case IVY_ASM_XVAL_MESSAGE_HANDLER:
entry.e_type = b_i32_htob(IVY_CLASS_TABLE_MSGH);
entry.e_type = fx_i32_htob(IVY_CLASS_TABLE_MSGH);
entry.e_msgh.msg_selector
= b_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_SELECTOR]);
= fx_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_SELECTOR]);
entry.e_msgh.msg_block
= b_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_BLOCK]);
= fx_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_BLOCK]);
break;
default:
return IVY_ERR_NOT_SUPPORTED;

View File

@@ -1,9 +1,9 @@
#include "assembler.h"
#include <blue/core/hash.h>
#include <blue/ds/dict.h>
#include <blue/ds/number.h>
#include <blue/ds/string.h>
#include <fx/core/hash.h>
#include <fx/ds/dict.h>
#include <fx/ds/number.h>
#include <fx/ds/string.h>
#include <ivy/asm/bin.h>
#include <ivy/ident.h>
#include <ivy/selector.h>
@@ -12,7 +12,7 @@
struct constpool_assembler_scope {
struct assembler_scope s_base;
b_dict *s_strings;
fx_dict *s_strings;
size_t s_next_slot;
};
@@ -26,7 +26,7 @@ static enum ivy_status init_scope(
struct constpool_assembler_scope *c
= (struct constpool_assembler_scope *)scope;
c->s_strings = b_dict_create();
c->s_strings = fx_dict_create();
c->s_next_slot = 0;
return IVY_OK;
@@ -35,19 +35,19 @@ static enum ivy_status init_scope(
static ivy_extended_data_key get_cached_string(
struct constpool_assembler_scope *scope, const char *s)
{
b_number *key = b_dict_at(scope->s_strings, s);
fx_number *key = fx_dict_at(scope->s_strings, s);
if (!key) {
return IVY_EX_DATA_KEY_NULL;
}
return (ivy_extended_data_key)b_number_get_int32(key);
return (ivy_extended_data_key)fx_number_get_int32(key);
}
static void put_cached_string(
struct constpool_assembler_scope *scope, const char *s,
ivy_extended_data_key key)
{
b_dict_put(scope->s_strings, s, B_RV_INT32(key));
fx_dict_put(scope->s_strings, s, FX_RV_INT32(key));
}
static ivy_extended_data_key write_string(struct ivy_assembler *as, const char *s)
@@ -63,8 +63,8 @@ static ivy_extended_data_key write_string(struct ivy_assembler *as, const char *
size_t len = strlen(s);
struct ivy_bin_string str = {0};
str.s_hash = b_i32_htob((uint32_t)b_hash_cstr(s));
str.s_len = b_i32_htob((uint32_t)len);
str.s_hash = fx_i32_htob((uint32_t)fx_hash_cstr(s));
str.s_len = fx_i32_htob((uint32_t)len);
key = assembler_write_extended_data(as, &str, sizeof str);
@@ -90,29 +90,29 @@ static ivy_extended_data_key write_selector(
}
if (sel->sel_name) {
dat.sel_name = b_i32_htob(write_string(as, sel->sel_name));
dat.sel_name = fx_i32_htob(write_string(as, sel->sel_name));
}
size_t i = 0;
size_t nr_args = b_queue_length(&sel->sel_args);
size_t nr_args = fx_queue_length(&sel->sel_args);
dat.sel_nr_args = (uint8_t)nr_args;
/* TODO hash. */
ivy_extended_data_key *arg_handles
= calloc(nr_args, sizeof(ivy_extended_data_key));
b_queue_entry *entry = b_queue_first(&sel->sel_args);
fx_queue_entry *entry = fx_queue_first(&sel->sel_args);
while (entry) {
struct ivy_selector_arg *arg
= b_unbox(struct ivy_selector_arg, entry, arg_entry);
= fx_unbox(struct ivy_selector_arg, entry, arg_entry);
arg_handles[i++] = write_string(as, arg->arg_label);
entry = b_queue_next(entry);
entry = fx_queue_next(entry);
}
ivy_extended_data_key selector_handle
= assembler_write_extended_data(as, &dat, sizeof dat);
for (i = 0; i < nr_args; i++) {
b_i32 arg_handle = b_i32_htob(arg_handles[i]);
fx_i32 arg_handle = fx_i32_htob(arg_handles[i]);
assembler_write_extended_data(as, &arg_handle, sizeof arg_handle);
}
@@ -126,17 +126,17 @@ static ivy_extended_data_key write_ident(
struct ivy_bin_ident dat = {0};
/* TODO hash. */
size_t nr_parts = b_queue_length(&id->id_parts);
size_t nr_parts = fx_queue_length(&id->id_parts);
size_t i = 0;
ivy_extended_data_key *part_handles
= calloc(nr_parts, sizeof(ivy_extended_data_key));
b_queue_entry *entry = b_queue_first(&id->id_parts);
fx_queue_entry *entry = fx_queue_first(&id->id_parts);
while (entry) {
struct ivy_ident_part *arg
= b_unbox(struct ivy_ident_part, entry, p_entry);
= fx_unbox(struct ivy_ident_part, entry, p_entry);
part_handles[i++] = write_string(as, arg->p_str);
entry = b_queue_next(entry);
entry = fx_queue_next(entry);
}
dat.id_nr_parts = (uint8_t)nr_parts;
@@ -145,7 +145,7 @@ static ivy_extended_data_key write_ident(
= assembler_write_extended_data(as, &dat, sizeof dat);
for (i = 0; i < nr_parts; i++) {
b_i32 part_handle = b_i32_htob(part_handles[i]);
fx_i32 part_handle = fx_i32_htob(part_handles[i]);
assembler_write_extended_data(as, &part_handle, sizeof part_handle);
}
@@ -170,32 +170,32 @@ static enum ivy_status put_pval(
switch (type) {
case IVY_ASM_PVAL_STRING:
entry.e_type = b_i32_htob(IVY_CONSTPOOL_TABLE_STRING);
entry.e_type = fx_i32_htob(IVY_CONSTPOOL_TABLE_STRING);
k = write_string(as, val);
entry.e_ex_handle = b_i32_htob(k);
entry.e_ex_handle = fx_i32_htob(k);
break;
case IVY_ASM_PVAL_IDENT:
entry.e_type = b_i32_htob(IVY_CONSTPOOL_TABLE_IDENT);
entry.e_type = fx_i32_htob(IVY_CONSTPOOL_TABLE_IDENT);
k = write_ident(as, val);
entry.e_ex_handle = b_i32_htob(k);
entry.e_ex_handle = fx_i32_htob(k);
break;
case IVY_ASM_PVAL_ATOM:
entry.e_type = b_i32_htob(IVY_CONSTPOOL_TABLE_ATOM);
entry.e_type = fx_i32_htob(IVY_CONSTPOOL_TABLE_ATOM);
k = write_string(as, val);
entry.e_ex_handle = b_i32_htob(k);
entry.e_ex_handle = fx_i32_htob(k);
break;
case IVY_ASM_PVAL_SINT:
entry.e_type = b_i32_htob(IVY_CONSTPOOL_TABLE_INT);
entry.e_int = b_i32_htob((uint32_t)i);
entry.e_type = fx_i32_htob(IVY_CONSTPOOL_TABLE_INT);
entry.e_int = fx_i32_htob((uint32_t)i);
break;
case IVY_ASM_PVAL_UINT:
entry.e_type = b_i32_htob(IVY_CONSTPOOL_TABLE_UINT);
entry.e_int = b_i32_htob((uint32_t)i);
entry.e_type = fx_i32_htob(IVY_CONSTPOOL_TABLE_UINT);
entry.e_int = fx_i32_htob((uint32_t)i);
break;
case IVY_ASM_PVAL_SELECTOR:
entry.e_type = b_i32_htob(IVY_CONSTPOOL_TABLE_SELECTOR);
entry.e_type = fx_i32_htob(IVY_CONSTPOOL_TABLE_SELECTOR);
k = write_selector(as, val);
entry.e_ex_handle = b_i32_htob(k);
entry.e_ex_handle = fx_i32_htob(k);
break;
default:
return IVY_ERR_NOT_SUPPORTED;

View File

@@ -1,7 +1,7 @@
#ifndef IVY_ASM_BIN_H_
#define IVY_ASM_BIN_H_
#include <blue/core/endian.h>
#include <fx/core/endian.h>
#include <stdint.h>
#define IVY_BIN_MAGIC 0x2E495659u
@@ -30,61 +30,61 @@
#define IVY_BIN_NULL_HANDLE ((ivy_bin_data_handle)0)
struct ivy_bin_header {
b_i32 h_magic;
b_i16 h_table_len;
fx_i32 h_magic;
fx_i16 h_table_len;
uint8_t h_reserved[2];
b_i64 h_table_offset;
fx_i64 h_table_offset;
};
struct ivy_bin_table_entry {
b_i32 e_type;
b_i32 e_size;
b_i64 e_offset;
fx_i32 e_type;
fx_i32 e_size;
fx_i64 e_offset;
};
struct ivy_bin_class_table_entry {
b_i32 e_type;
fx_i32 e_type;
union {
struct {
b_i32 p_ident;
b_i32 p_get;
b_i32 p_set;
fx_i32 p_ident;
fx_i32 p_get;
fx_i32 p_set;
} e_property;
struct {
b_i32 m_index;
b_i32 m_ident;
fx_i32 m_index;
fx_i32 m_ident;
uint8_t m_reserved[4];
} e_mvar;
struct {
b_i32 msg_selector;
b_i32 msg_block;
fx_i32 msg_selector;
fx_i32 msg_block;
uint8_t m_reserved[4];
} e_msgh;
};
};
struct ivy_bin_class {
b_i32 c_ident;
fx_i32 c_ident;
uint8_t c_reserved[12];
struct ivy_bin_class_table_entry c_table[];
};
struct ivy_bin_lambda {
b_i32 l_ident;
b_i32 l_instr[];
fx_i32 l_ident;
fx_i32 l_instr[];
};
struct ivy_bin_msgh {
b_i32 msg_recipient;
b_i32 msg_selector;
b_i32 msg_instr[];
fx_i32 msg_recipient;
fx_i32 msg_selector;
fx_i32 msg_instr[];
};
struct ivy_bin_string {
b_i32 s_hash;
b_i32 s_len;
fx_i32 s_hash;
fx_i32 s_len;
char s_chars[];
};
@@ -92,24 +92,24 @@ struct ivy_bin_selector {
uint8_t sel_flags;
uint8_t sel_nr_args;
uint8_t sel_reserved[2];
b_i32 sel_hash;
b_i32 sel_name;
b_i32 sel_args[];
fx_i32 sel_hash;
fx_i32 sel_name;
fx_i32 sel_args[];
};
struct ivy_bin_ident {
b_i32 id_hash;
fx_i32 id_hash;
uint8_t id_nr_parts;
uint8_t id_reserved[3];
b_i32 id_parts[];
fx_i32 id_parts[];
};
struct ivy_bin_constpool_table_entry {
b_i32 e_type;
fx_i32 e_type;
union {
b_i32 e_ex_handle;
b_i32 e_int;
fx_i32 e_ex_handle;
fx_i32 e_int;
};
};
@@ -119,11 +119,11 @@ struct ivy_bin_constpool {
};
struct ivy_bin_block {
b_i32 b_index;
fx_i32 fx_index;
};
struct ivy_bin_import_table_entry {
b_i32 e_ident;
fx_i32 e_ident;
};
#endif

View File

@@ -1,7 +1,7 @@
#ifndef IVY_ASM_INSTR_H_
#define IVY_ASM_INSTR_H_
#include <blue/core/endian.h>
#include <fx/core/endian.h>
#include <ivy/misc.h>
#include <ivy/opcode.h>
#include <ivy/status.h>
@@ -85,6 +85,6 @@ struct ivy_instr {
IVY_API const struct ivy_instr_definition *ivy_instr_find(
enum ivy_instr_id id, const enum ivy_instr_operand_type operands[4]);
IVY_API enum ivy_status ivy_instr_decode(b_i32 instr, struct ivy_instr *out);
IVY_API enum ivy_status ivy_instr_decode(fx_i32 instr, struct ivy_instr *out);
#endif

View File

@@ -1,7 +1,7 @@
#ifndef IVY_ASM_LEX_H_
#define IVY_ASM_LEX_H_
#include <blue/core/queue.h>
#include <fx/core/queue.h>
#include <ivy/line-source.h>
#include <ivy/misc.h>
#include <ivy/status.h>
@@ -64,7 +64,7 @@ enum ivy_asm_symbol {
struct ivy_asm_token {
enum ivy_asm_token_type t_type;
b_queue_entry t_entry;
fx_queue_entry t_entry;
union {
enum ivy_asm_keyword t_keyword;

View File

@@ -139,9 +139,9 @@ const struct ivy_instr_definition *ivy_instr_find(
return NULL;
}
enum ivy_status ivy_instr_decode(b_i32 x, struct ivy_instr *out)
enum ivy_status ivy_instr_decode(fx_i32 x, struct ivy_instr *out)
{
uint32_t instr = b_i32_btoh(x);
uint32_t instr = fx_i32_btoh(x);
unsigned int opcode = R_GET_OPCODE(instr);
if (opcode >= nr_instructions) {
return IVY_ERR_INVALID_VALUE;

128
asm/lex.c
View File

@@ -1,10 +1,10 @@
#include "lex.h"
#include <blue/core/hash.h>
#include <blue/core/queue.h>
#include <blue/ds/dict.h>
#include <blue/ds/number.h>
#include <blue/ds/string.h>
#include <fx/core/hash.h>
#include <fx/core/queue.h>
#include <fx/ds/dict.h>
#include <fx/ds/number.h>
#include <fx/ds/string.h>
#include <ctype.h>
#include <ivy/asm/lex.h>
#include <stdbool.h>
@@ -63,40 +63,40 @@ static struct lexer_state *push_lexer_state(
memset(state, 0x0, sizeof *state);
state->s_type = state_type;
b_queue_push_back(&lex->lex_state, &state->s_entry);
fx_queue_push_back(&lex->lex_state, &state->s_entry);
return state;
}
static void pop_lexer_state(struct ivy_asm_lexer *lex)
{
b_queue_entry *entry = b_queue_pop_back(&lex->lex_state);
fx_queue_entry *entry = fx_queue_pop_back(&lex->lex_state);
if (!entry) {
return;
}
struct lexer_state *state = b_unbox(struct lexer_state, entry, s_entry);
struct lexer_state *state = fx_unbox(struct lexer_state, entry, s_entry);
free(state);
}
static struct lexer_state *get_lexer_state(struct ivy_asm_lexer *lex)
{
b_queue_entry *entry = b_queue_last(&lex->lex_state);
fx_queue_entry *entry = fx_queue_last(&lex->lex_state);
if (!entry) {
return NULL;
}
return b_unbox(struct lexer_state, entry, s_entry);
return fx_unbox(struct lexer_state, entry, s_entry);
}
static void destroy_state_stack(b_queue *state)
static void destroy_state_stack(fx_queue *state)
{
b_queue_entry *entry = b_queue_first(state);
fx_queue_entry *entry = fx_queue_first(state);
while (entry) {
struct lexer_state *node
= b_unbox(struct lexer_state, entry, s_entry);
b_queue_entry *next = b_queue_next(entry);
b_queue_delete(state, entry);
= fx_unbox(struct lexer_state, entry, s_entry);
fx_queue_entry *next = fx_queue_next(entry);
fx_queue_delete(state, entry);
free(node);
@@ -107,27 +107,27 @@ static void destroy_state_stack(b_queue *state)
static struct ivy_asm_lexer_symbol_node *get_symbol_node(
struct ivy_asm_lexer_symbol_node *node, char c)
{
b_queue_entry *entry = b_queue_first(&node->s_children);
fx_queue_entry *entry = fx_queue_first(&node->s_children);
while (entry) {
struct ivy_asm_lexer_symbol_node *child = b_unbox(
struct ivy_asm_lexer_symbol_node *child = fx_unbox(
struct ivy_asm_lexer_symbol_node, entry, s_entry);
if (child->s_char == c) {
return child;
}
entry = b_queue_next(entry);
entry = fx_queue_next(entry);
}
return NULL;
}
static b_string *get_temp_string(struct ivy_asm_lexer *lex)
static fx_string *get_temp_string(struct ivy_asm_lexer *lex)
{
if (!lex->lex_temp) {
lex->lex_temp = b_string_create();
lex->lex_temp = fx_string_create();
}
b_string_clear(lex->lex_temp);
fx_string_clear(lex->lex_temp);
return lex->lex_temp;
}
@@ -152,7 +152,7 @@ static enum ivy_status put_symbol(
child->s_id = IVY_ASM_SYM_NONE;
child->s_char = c;
b_queue_push_back(&tree->s_children, &child->s_entry);
fx_queue_push_back(&tree->s_children, &child->s_entry);
tree = child;
}
@@ -162,12 +162,12 @@ static enum ivy_status put_symbol(
static void destroy_symbol_tree(struct ivy_asm_lexer_symbol_node *tree)
{
b_queue_entry *entry = b_queue_first(&tree->s_children);
fx_queue_entry *entry = fx_queue_first(&tree->s_children);
while (entry) {
struct ivy_asm_lexer_symbol_node *node = b_unbox(
struct ivy_asm_lexer_symbol_node *node = fx_unbox(
struct ivy_asm_lexer_symbol_node, entry, s_entry);
b_queue_entry *next = b_queue_next(entry);
b_queue_delete(&tree->s_children, entry);
fx_queue_entry *next = fx_queue_next(entry);
fx_queue_delete(&tree->s_children, entry);
destroy_symbol_tree(node);
@@ -200,23 +200,23 @@ static struct ivy_asm_lexer_symbol_node *build_symbol_tree(void)
return root;
}
static void init_keywords(b_dict *keyword_dict)
static void init_keywords(fx_dict *keyword_dict)
{
for (size_t i = 0; i < nr_keywords; i++) {
struct lex_token_def *keyword = &keywords[i];
b_dict_put(keyword_dict, keyword->name, B_RV_INT(keyword->id));
fx_dict_put(keyword_dict, keyword->name, FX_RV_INT(keyword->id));
}
}
static enum ivy_asm_keyword find_keyword_by_name(
struct ivy_asm_lexer *lex, const char *s)
{
b_number *id = b_dict_at(lex->lex_keywords, s);
fx_number *id = fx_dict_at(lex->lex_keywords, s);
if (!id) {
return IVY_ASM_KW_NONE;
}
return b_number_get_int(id);
return fx_number_get_int(id);
}
enum ivy_status ivy_asm_lexer_create(struct ivy_asm_lexer **lexp)
@@ -245,7 +245,7 @@ enum ivy_status ivy_asm_lexer_create(struct ivy_asm_lexer **lexp)
return IVY_ERR_NO_MEMORY;
}
lex->lex_keywords = b_dict_create();
lex->lex_keywords = fx_dict_create();
init_keywords(lex->lex_keywords);
*lexp = lex;
@@ -254,13 +254,13 @@ enum ivy_status ivy_asm_lexer_create(struct ivy_asm_lexer **lexp)
void ivy_asm_lexer_destroy(struct ivy_asm_lexer *lex)
{
b_queue_entry *entry = b_queue_first(&lex->lex_queue);
fx_queue_entry *entry = fx_queue_first(&lex->lex_queue);
while (entry) {
struct ivy_asm_token *tok
= b_unbox(struct ivy_asm_token, entry, t_entry);
b_queue_entry *next = b_queue_next(entry);
b_queue_delete(&lex->lex_queue, entry);
= fx_unbox(struct ivy_asm_token, entry, t_entry);
fx_queue_entry *next = fx_queue_next(entry);
fx_queue_delete(&lex->lex_queue, entry);
ivy_asm_token_destroy(tok);
@@ -276,11 +276,11 @@ void ivy_asm_lexer_destroy(struct ivy_asm_lexer *lex)
}
if (lex->lex_temp) {
b_string_unref(lex->lex_temp);
fx_string_unref(lex->lex_temp);
}
if (lex->lex_keywords) {
b_dict_unref(lex->lex_keywords);
fx_dict_unref(lex->lex_keywords);
}
destroy_state_stack(&lex->lex_state);
@@ -411,7 +411,7 @@ static struct ivy_asm_token *create_token(enum ivy_asm_token_type type)
static enum ivy_status push_token(
struct ivy_asm_lexer *lex, struct ivy_asm_token *tok)
{
b_queue_push_back(&lex->lex_queue, &tok->t_entry);
fx_queue_push_back(&lex->lex_queue, &tok->t_entry);
lex->lex_prev_token = tok->t_type;
return IVY_OK;
}
@@ -610,7 +610,7 @@ static enum ivy_status read_dquote_marker(struct ivy_asm_lexer *lex)
static enum ivy_status read_string_content(struct ivy_asm_lexer *lex)
{
int c;
b_string *str = get_temp_string(lex);
fx_string *str = get_temp_string(lex);
struct lexer_state *state = get_lexer_state(lex);
if (!str) {
@@ -629,15 +629,15 @@ static enum ivy_status read_string_content(struct ivy_asm_lexer *lex)
}
char s[2] = {c, 0};
b_string_append_cstr(str, s);
fx_string_append_cstr(str, s);
advance(lex);
}
if (b_string_get_size(str, B_STRLEN_NORMAL) == 0) {
if (fx_string_get_size(str, FX_STRLEN_NORMAL) == 0) {
return IVY_OK;
}
char *s = b_string_steal(str);
char *s = fx_string_steal(str);
enum ivy_status status = push_string_content(lex, s);
if (status != IVY_OK) {
@@ -692,7 +692,7 @@ static enum ivy_status read_number(struct ivy_asm_lexer *lex)
int base = 10;
int dots = 0;
bool neg = false;
b_string *str = get_temp_string(lex);
fx_string *str = get_temp_string(lex);
while (true) {
int c = peek(lex);
@@ -733,7 +733,7 @@ static enum ivy_status read_number(struct ivy_asm_lexer *lex)
token_len++;
dots++;
char s[] = {c, 0};
b_string_append_cstr(str, s);
fx_string_append_cstr(str, s);
advance(lex);
continue;
}
@@ -776,7 +776,7 @@ static enum ivy_status read_number(struct ivy_asm_lexer *lex)
}
char s[] = {c, 0};
b_string_append_cstr(str, s);
fx_string_append_cstr(str, s);
token_len++;
advance(lex);
}
@@ -785,7 +785,7 @@ static enum ivy_status read_number(struct ivy_asm_lexer *lex)
return push_uint(lex, 0);
}
const char *s = b_string_ptr(str);
const char *s = fx_string_ptr(str);
char *ep = NULL;
if (dots > 0) {
@@ -826,8 +826,8 @@ static enum ivy_status read_keyword(struct ivy_asm_lexer *lex)
{
advance(lex);
b_string *str = get_temp_string(lex);
b_string_append_cstr(str, "@");
fx_string *str = get_temp_string(lex);
fx_string_append_cstr(str, "@");
bool label = false;
@@ -843,11 +843,11 @@ static enum ivy_status read_keyword(struct ivy_asm_lexer *lex)
}
char s[2] = {c, 0};
b_string_append_cstr(str, s);
fx_string_append_cstr(str, s);
advance(lex);
}
const char *s = b_string_ptr(str);
const char *s = fx_string_ptr(str);
enum ivy_asm_keyword keyword = find_keyword_by_name(lex, s);
@@ -862,7 +862,7 @@ static enum ivy_status read_label_ref(struct ivy_asm_lexer *lex)
{
advance(lex);
b_string *str = get_temp_string(lex);
fx_string *str = get_temp_string(lex);
bool label = false;
while (true) {
@@ -883,21 +883,21 @@ static enum ivy_status read_label_ref(struct ivy_asm_lexer *lex)
}
char s[2] = {c, 0};
b_string_append_cstr(str, s);
fx_string_append_cstr(str, s);
advance(lex);
}
const char *s = b_string_ptr(str);
const char *s = fx_string_ptr(str);
struct ivy_asm_token *tok = create_token(IVY_ASM_TOK_LABEL_REF);
tok->t_str = b_string_steal(str);
tok->t_str = fx_string_steal(str);
return push_token(lex, tok);
}
static enum ivy_status read_ident(struct ivy_asm_lexer *lex)
{
b_string *str = get_temp_string(lex);
fx_string *str = get_temp_string(lex);
bool label = false;
while (true) {
@@ -918,15 +918,15 @@ static enum ivy_status read_ident(struct ivy_asm_lexer *lex)
}
char s[2] = {c, 0};
b_string_append_cstr(str, s);
fx_string_append_cstr(str, s);
advance(lex);
}
const char *s = b_string_ptr(str);
const char *s = fx_string_ptr(str);
struct ivy_asm_token *tok
= create_token(label ? IVY_ASM_TOK_LABEL : IVY_ASM_TOK_IDENT);
tok->t_str = b_string_steal(str);
tok->t_str = fx_string_steal(str);
return push_token(lex, tok);
}
@@ -1003,7 +1003,7 @@ struct ivy_asm_token *ivy_asm_lexer_peek(struct ivy_asm_lexer *lex)
{
enum ivy_status status = IVY_OK;
while (b_queue_empty(&lex->lex_queue)) {
while (fx_queue_empty(&lex->lex_queue)) {
status = pump_tokens(lex);
if (status != IVY_OK) {
@@ -1013,8 +1013,8 @@ struct ivy_asm_token *ivy_asm_lexer_peek(struct ivy_asm_lexer *lex)
}
lex->lex_status = status;
b_queue_entry *entry = b_queue_first(&lex->lex_queue);
struct ivy_asm_token *tok = b_unbox(struct ivy_asm_token, entry, t_entry);
fx_queue_entry *entry = fx_queue_first(&lex->lex_queue);
struct ivy_asm_token *tok = fx_unbox(struct ivy_asm_token, entry, t_entry);
return tok;
}
@@ -1022,7 +1022,7 @@ struct ivy_asm_token *ivy_asm_lexer_read(struct ivy_asm_lexer *lex)
{
enum ivy_status status = IVY_OK;
while (b_queue_empty(&lex->lex_queue)) {
while (fx_queue_empty(&lex->lex_queue)) {
status = pump_tokens(lex);
if (status != IVY_OK) {
@@ -1031,8 +1031,8 @@ struct ivy_asm_token *ivy_asm_lexer_read(struct ivy_asm_lexer *lex)
}
}
b_queue_entry *entry = b_queue_pop_front(&lex->lex_queue);
struct ivy_asm_token *tok = b_unbox(struct ivy_asm_token, entry, t_entry);
fx_queue_entry *entry = fx_queue_pop_front(&lex->lex_queue);
struct ivy_asm_token *tok = fx_unbox(struct ivy_asm_token, entry, t_entry);
return tok;
}

View File

@@ -1,9 +1,9 @@
#ifndef _LEX_H_
#define _LEX_H_
#include <blue/core/queue.h>
#include <blue/ds/dict.h>
#include <blue/ds/string.h>
#include <fx/core/queue.h>
#include <fx/ds/dict.h>
#include <fx/ds/string.h>
#include <ivy/asm/lex.h>
#include <stdint.h>
@@ -15,15 +15,15 @@ enum lexer_state_type {
struct lexer_state {
enum lexer_state_type s_type;
b_queue_entry s_entry;
fx_queue_entry s_entry;
};
struct ivy_asm_lexer_symbol_node {
char s_char;
enum ivy_asm_symbol s_id;
b_queue_entry s_entry;
b_queue s_children;
fx_queue_entry s_entry;
fx_queue s_children;
};
struct lex_token_def {
@@ -35,14 +35,14 @@ struct lex_token_def {
struct ivy_asm_lexer {
struct ivy_asm_lexer_symbol_node *lex_sym_tree;
struct ivy_line_source *lex_source;
b_dict *lex_keywords;
fx_dict *lex_keywords;
enum ivy_status lex_status;
b_queue lex_queue;
fx_queue lex_queue;
enum ivy_asm_token_type lex_prev_token;
b_string *lex_temp;
b_queue lex_state;
fx_string *lex_temp;
fx_queue lex_state;
unsigned int lex_brace_depth;
char *lex_linebuf;

View File

@@ -98,11 +98,11 @@ static enum mie_status get_selector(
struct mie_type *ptr_type = mie_ctx_get_type(ctx, MIE_TYPE_PTR);
struct mie_select_graph *graph = mie_select_builder_get_graph(builder);
b_queue *nodes = &graph->g_nodes;
b_queue_entry *entry = b_queue_first(nodes);
fx_queue *nodes = &graph->g_nodes;
fx_queue_entry *entry = fx_queue_first(nodes);
while (entry) {
struct mie_select_node *node
= b_unbox(struct mie_select_node, entry, n_entry);
= fx_unbox(struct mie_select_node, entry, n_entry);
if (node->n_target != target) {
goto skip;
@@ -124,7 +124,7 @@ static enum mie_status get_selector(
mie_select_node_get_value(node, ptr_type, 0, out);
return MIE_SUCCESS;
skip:
entry = b_queue_next(entry);
entry = fx_queue_next(entry);
}
struct mie_select_node *sel_node;
@@ -311,7 +311,7 @@ static enum mie_status lower_msg(
struct mie_ctx *ctx = mie_select_builder_get_ctx(builder);
struct mie_select_value **param_chains = calloc(
b_max(size_t, 2, msg->msg_nr_args + 1),
fx_max(size_t, 2, msg->msg_nr_args + 1),
sizeof(struct mie_select_value *));
size_t nr_param_chains = 0;
struct mie_select_value *chain, *recipient, nr_args;
@@ -354,7 +354,7 @@ static enum mie_status lower_msg(
}
struct mie_select_value *stack_chains = calloc(
b_max(size_t, 1, msg->msg_nr_args),
fx_max(size_t, 1, msg->msg_nr_args),
sizeof(struct mie_select_value));
size_t nr_stack_chains = 0;
nr_param_chains = 0;

View File

@@ -1,7 +1,7 @@
#include "parse.h"
#include <blue/core/hash.h>
#include <blue/core/stringstream.h>
#include <fx/core/hash.h>
#include <fx/core/stringstream.h>
#include <ctype.h>
#include <ivy/asm/assembler.h>
#include <ivy/asm/bin.h>
@@ -48,14 +48,14 @@ enum arg_type {
};
struct label {
b_queue_entry l_entry;
fx_queue_entry l_entry;
struct ivy_asm_token *l_name;
unsigned long long l_offset;
};
struct arg {
enum arg_type arg_type;
b_queue_entry arg_entry;
fx_queue_entry arg_entry;
union {
struct ivy_asm_token *arg_const;
@@ -86,11 +86,11 @@ struct block_parser_state {
unsigned int s_prev_token;
enum instr_component s_prev_component;
b_queue s_labels;
fx_queue s_labels;
b_queue s_mnemonic;
fx_queue s_mnemonic;
b_queue s_args;
fx_queue s_args;
struct arg *s_current_arg;
};
@@ -163,7 +163,7 @@ static enum index_base get_index_base(struct ivy_asm_token *tok)
}
const char *s = tok->t_str;
uint64_t hash = b_hash_cstr(s);
uint64_t hash = fx_hash_cstr(s);
switch (hash) {
case HASH_SELF:
@@ -195,28 +195,28 @@ static enum index_base get_index_base(struct ivy_asm_token *tok)
}
}
static enum ivy_instr_id get_instruction_id(b_queue *mnemonic_tokens)
static enum ivy_instr_id get_instruction_id(fx_queue *mnemonic_tokens)
{
char mnemonic[64];
mnemonic[0] = 0;
b_stringstream *s
= b_stringstream_create_with_buffer(mnemonic, sizeof mnemonic);
fx_stringstream *s
= fx_stringstream_create_with_buffer(mnemonic, sizeof mnemonic);
unsigned int i = 0;
b_queue_entry *entry = b_queue_first(mnemonic_tokens);
fx_queue_entry *entry = fx_queue_first(mnemonic_tokens);
while (entry) {
struct ivy_asm_token *tok
= b_unbox(struct ivy_asm_token, entry, t_entry);
b_queue_entry *next = b_queue_next(entry);
b_queue_delete(mnemonic_tokens, entry);
= fx_unbox(struct ivy_asm_token, entry, t_entry);
fx_queue_entry *next = fx_queue_next(entry);
fx_queue_delete(mnemonic_tokens, entry);
if (i > 0) {
b_stream_write_char(s, '.');
fx_stream_write_char(s, '.');
}
b_stream_write_string(s, tok->t_str, NULL);
fx_stream_write_string(s, tok->t_str, NULL);
i++;
ivy_asm_token_destroy(tok);
@@ -224,7 +224,7 @@ static enum ivy_instr_id get_instruction_id(b_queue *mnemonic_tokens)
entry = next;
}
uint64_t hash = b_hash_cstr(mnemonic);
uint64_t hash = fx_hash_cstr(mnemonic);
for (i = 0; i < nr_mnemonics; i++) {
if (hash == mnemonics[i].m_hash
&& !strcmp(mnemonic, mnemonics[i].m_name)) {
@@ -251,9 +251,9 @@ static enum ivy_status write_instruction(
enum ivy_instr_operand_type operand_types[MAX_ARGS] = {0};
b_queue_entry *entry = b_queue_first(&state->s_args);
fx_queue_entry *entry = fx_queue_first(&state->s_args);
while (entry) {
struct arg *arg = b_unbox(struct arg, entry, arg_entry);
struct arg *arg = fx_unbox(struct arg, entry, arg_entry);
if (i >= MAX_ARGS) {
return IVY_ERR_BAD_SYNTAX;
@@ -310,7 +310,7 @@ static enum ivy_status write_instruction(
return IVY_ERR_BAD_SYNTAX;
}
entry = b_queue_next(entry);
entry = fx_queue_next(entry);
}
const struct ivy_instr_definition *instr_info
@@ -323,11 +323,11 @@ static enum ivy_status write_instruction(
instr.i_op = instr_info;
i = 0;
entry = b_queue_first(&state->s_args);
entry = fx_queue_first(&state->s_args);
while (entry) {
struct arg *arg = b_unbox(struct arg, entry, arg_entry);
b_queue_entry *next = b_queue_next(entry);
b_queue_delete(&state->s_args, entry);
struct arg *arg = fx_unbox(struct arg, entry, arg_entry);
fx_queue_entry *next = fx_queue_next(entry);
fx_queue_delete(&state->s_args, entry);
switch (arg->arg_type) {
case ARG_REG:
@@ -381,7 +381,7 @@ static enum ivy_status push_const_arg(
arg->arg_type = ARG_CONST;
arg->arg_const = tok;
b_queue_push_back(&state->s_args, &arg->arg_entry);
fx_queue_push_back(&state->s_args, &arg->arg_entry);
return IVY_OK;
}
@@ -407,7 +407,7 @@ static enum ivy_status push_label_arg(
arg->arg_type = ARG_LABEL;
arg->arg_label = tok;
b_queue_push_back(&state->s_args, &arg->arg_entry);
fx_queue_push_back(&state->s_args, &arg->arg_entry);
return IVY_OK;
}
@@ -426,7 +426,7 @@ static enum ivy_status push_reg_arg(
arg->arg_reg.reg_token = tok;
arg->arg_reg.reg_index = reg_index;
b_queue_push_back(&state->s_args, &arg->arg_entry);
fx_queue_push_back(&state->s_args, &arg->arg_entry);
return IVY_OK;
}
@@ -482,7 +482,7 @@ static enum ivy_status parse_ident(
switch (state->s_prev_component) {
case INSTR_NONE:
case INSTR_OPCODE_DOT:
b_queue_push_back(&state->s_mnemonic, &tok->t_entry);
fx_queue_push_back(&state->s_mnemonic, &tok->t_entry);
state->s_prev_component = INSTR_OPCODE;
return IVY_OK;
case INSTR_OPCODE:
@@ -619,7 +619,7 @@ static enum ivy_status parse_right_bracket(
return IVY_ERR_BAD_SYNTAX;
}
b_queue_push_back(&state->s_args, &state->s_current_arg->arg_entry);
fx_queue_push_back(&state->s_args, &state->s_current_arg->arg_entry);
state->s_current_arg = NULL;
state->s_prev_component = INSTR_OPERAND;

View File

@@ -1,6 +1,6 @@
#include "parse.h"
#include <blue/core/hash.h>
#include <fx/core/hash.h>
#include <ivy/asm/assembler.h>
enum item_type {
@@ -23,7 +23,7 @@ struct class_parser_state {
static enum ivy_status push_attrib(struct class_parser_state *state)
{
uint64_t hash = b_hash_cstr(state->s_attrib_name->t_str);
uint64_t hash = fx_hash_cstr(state->s_attrib_name->t_str);
const char *s = state->s_attrib_name->t_str;
unsigned long long v = state->s_attrib_value->t_int.uv;

View File

@@ -9,7 +9,7 @@ struct ident_parser_state {
struct parser_state s_base;
unsigned int s_prev_token;
b_queue s_parts;
fx_queue s_parts;
};
static void init_state(struct ivy_asm_parser *ctx, struct parser_state *s)
@@ -28,7 +28,7 @@ static enum ivy_status parse_ident(
return IVY_ERR_BAD_SYNTAX;
}
b_queue_push_back(&state->s_parts, &tok->t_entry);
fx_queue_push_back(&state->s_parts, &tok->t_entry);
state->s_prev_token = IVY_ASM_TOK_IDENT;
return IVY_OK;
@@ -61,12 +61,12 @@ static enum ivy_status parse_right_paren(
struct ivy_ident *ident = ivy_ident_create();
b_queue_entry *entry = b_queue_first(&state->s_parts);
fx_queue_entry *entry = fx_queue_first(&state->s_parts);
while (entry) {
struct ivy_asm_token *tok
= b_unbox(struct ivy_asm_token, entry, t_entry);
b_queue_entry *next = b_queue_next(entry);
b_queue_delete(&state->s_parts, entry);
= fx_unbox(struct ivy_asm_token, entry, t_entry);
fx_queue_entry *next = fx_queue_next(entry);
fx_queue_delete(&state->s_parts, entry);
ivy_ident_add_part(ident, tok->t_str);
ivy_asm_token_destroy(tok);

View File

@@ -155,19 +155,19 @@ struct parser_state *asm_parser_push_state(
type_info->n_init_state(parser, state);
}
b_queue_push_back(&parser->p_state, &state->s_entry);
fx_queue_push_back(&parser->p_state, &state->s_entry);
return state;
}
void asm_parser_pop_state(struct ivy_asm_parser *parser, void *ret)
{
b_queue_entry *last = b_queue_pop_back(&parser->p_state);
fx_queue_entry *last = fx_queue_pop_back(&parser->p_state);
if (!last) {
return;
}
struct parser_state *state = b_unbox(struct parser_state, last, s_entry);
struct parser_state *state = fx_unbox(struct parser_state, last, s_entry);
if (state->s_type->n_finish_state) {
state->s_type->n_finish_state(parser, state);
@@ -183,11 +183,11 @@ void asm_parser_pop_state(struct ivy_asm_parser *parser, void *ret)
struct parser_state *asm_parser_get_state(struct ivy_asm_parser *parser)
{
b_queue_entry *last = b_queue_last(&parser->p_state);
fx_queue_entry *last = fx_queue_last(&parser->p_state);
if (!last) {
return NULL;
}
return b_unbox(struct parser_state, last, s_entry);
return fx_unbox(struct parser_state, last, s_entry);
}

View File

@@ -1,7 +1,7 @@
#ifndef _PARSE_PARSE_H_
#define _PARSE_PARSE_H_
#include <blue/core/queue.h>
#include <fx/core/queue.h>
#include <ivy/asm/assembler.h>
#include <ivy/asm/lex.h>
@@ -60,7 +60,7 @@ struct parser_state_type {
};
struct parser_state {
b_queue_entry s_entry;
fx_queue_entry s_entry;
const struct parser_state_type* s_type;
ivy_assembler_attrib_table s_attrib;
void* s_previous_value;
@@ -68,7 +68,7 @@ struct parser_state {
struct ivy_asm_parser {
struct ivy_assembler* p_assembler;
b_queue p_state;
fx_queue p_state;
};
extern struct parser_state* asm_parser_push_state(struct ivy_asm_parser* parser, enum parser_state_type_id type, const ivy_assembler_attrib_table attrib);

View File

@@ -1,6 +1,6 @@
#include "parse.h"
#include <blue/core/hash.h>
#include <fx/core/hash.h>
#include <ivy/asm/assembler.h>
struct unit_parser_state {
@@ -16,7 +16,7 @@ struct unit_parser_state {
static enum ivy_status push_attrib(struct unit_parser_state *state)
{
uint64_t hash = b_hash_cstr(state->s_attrib_name->t_str);
uint64_t hash = fx_hash_cstr(state->s_attrib_name->t_str);
const char *s = state->s_attrib_name->t_str;
unsigned long long v = state->s_attrib_value->t_int.uv;

View File

@@ -12,9 +12,9 @@
static enum ivy_status decode_header(
const struct ivy_bin_header *hdr, struct ivy_asm_object_info *out)
{
out->obj_magic = b_i32_btoh(hdr->h_magic);
out->obj_nr_sections = b_i16_btoh(hdr->h_table_len);
out->obj_table_offset = b_i64_btoh(hdr->h_table_offset);
out->obj_magic = fx_i32_btoh(hdr->h_magic);
out->obj_nr_sections = fx_i16_btoh(hdr->h_table_len);
out->obj_table_offset = fx_i64_btoh(hdr->h_table_offset);
return IVY_OK;
}
@@ -22,9 +22,9 @@ static enum ivy_status decode_header(
static enum ivy_status decode_table_entry(
const struct ivy_bin_table_entry *entry, struct ivy_asm_section_info *out)
{
out->s_type = b_i32_btoh(entry->e_type);
out->s_offset = b_i64_btoh(entry->e_offset);
out->s_length = b_i32_btoh(entry->e_size);
out->s_type = fx_i32_btoh(entry->e_type);
out->s_offset = fx_i64_btoh(entry->e_offset);
out->s_length = fx_i32_btoh(entry->e_size);
return IVY_OK;
}
@@ -258,7 +258,7 @@ static enum ivy_status read_string_xdata(
return IVY_ERR_BAD_FORMAT;
}
size_t str_len = b_i32_btoh(str.s_len);
size_t str_len = fx_i32_btoh(str.s_len);
if (str_len == 0) {
*out = NULL;
return IVY_OK;
@@ -306,7 +306,7 @@ enum ivy_status ivy_asm_constpool_reader_read_value(
return IVY_ERR_BAD_FORMAT;
}
unsigned long type = b_i32_btoh(entry.e_type);
unsigned long type = fx_i32_btoh(entry.e_type);
struct ivy_asm_constpool_value *value = malloc(sizeof *value);
if (!value) {
@@ -319,26 +319,26 @@ enum ivy_status ivy_asm_constpool_reader_read_value(
switch (type) {
case IVY_CONSTPOOL_TABLE_STRING: {
value->v_type = IVY_ASM_CONSTPOOL_TYPE_STRING;
handle = b_i32_btoh(entry.e_ex_handle);
handle = fx_i32_btoh(entry.e_ex_handle);
status = read_string_xdata(reader, handle, &value->v_str);
break;
}
case IVY_CONSTPOOL_TABLE_INT:
value->v_type = IVY_ASM_CONSTPOOL_TYPE_INT;
value->v_int = b_i32_btoh(entry.e_int);
value->v_int = fx_i32_btoh(entry.e_int);
break;
case IVY_CONSTPOOL_TABLE_UINT:
value->v_type = IVY_ASM_CONSTPOOL_TYPE_UINT;
value->v_uint = b_i32_btoh(entry.e_int);
value->v_uint = fx_i32_btoh(entry.e_int);
break;
case IVY_CONSTPOOL_TABLE_ATOM:
value->v_type = IVY_ASM_CONSTPOOL_TYPE_ATOM;
handle = b_i32_btoh(entry.e_ex_handle);
handle = fx_i32_btoh(entry.e_ex_handle);
status = read_string_xdata(reader, handle, &value->v_str);
break;
case IVY_CONSTPOOL_TABLE_SELECTOR: {
value->v_type = IVY_ASM_CONSTPOOL_TYPE_SELECTOR;
handle = b_i32_btoh(entry.e_ex_handle);
handle = fx_i32_btoh(entry.e_ex_handle);
struct ivy_bin_selector sel_entry;
status = ivy_asm_section_reader_read(
@@ -365,7 +365,7 @@ enum ivy_status ivy_asm_constpool_reader_read_value(
ivy_selector_set_recipient(sel, IVY_SEL_CLASS);
}
size_t name_key = b_i32_btoh(sel_entry.sel_name);
size_t name_key = fx_i32_btoh(sel_entry.sel_name);
status = read_string_xdata(reader, name_key, &sel->sel_name);
if (status != IVY_OK) {
ivy_selector_destroy(sel);
@@ -375,7 +375,7 @@ enum ivy_status ivy_asm_constpool_reader_read_value(
handle += sizeof sel_entry;
size_t nr_args = sel_entry.sel_nr_args;
for (size_t i = 0; i < nr_args; i++) {
b_i32 arg;
fx_i32 arg;
status = ivy_asm_section_reader_read(
reader->r_xdat, handle, sizeof arg, &arg, &r);
@@ -388,7 +388,7 @@ enum ivy_status ivy_asm_constpool_reader_read_value(
break;
}
size_t arg_key = b_i32_btoh(arg);
size_t arg_key = fx_i32_btoh(arg);
char *arg_name = NULL;
status = read_string_xdata(reader, arg_key, &arg_name);
if (status != IVY_OK) {
@@ -411,7 +411,7 @@ enum ivy_status ivy_asm_constpool_reader_read_value(
}
case IVY_CONSTPOOL_TABLE_IDENT: {
value->v_type = IVY_ASM_CONSTPOOL_TYPE_IDENT;
handle = b_i32_btoh(entry.e_ex_handle);
handle = fx_i32_btoh(entry.e_ex_handle);
struct ivy_bin_ident id_entry;
status = ivy_asm_section_reader_read(
@@ -436,7 +436,7 @@ enum ivy_status ivy_asm_constpool_reader_read_value(
handle += sizeof id_entry;
size_t nr_parts = id_entry.id_nr_parts;
for (size_t i = 0; i < nr_parts; i++) {
b_i32 part;
fx_i32 part;
status = ivy_asm_section_reader_read(
reader->r_xdat, handle, sizeof part, &part, &r);
@@ -449,7 +449,7 @@ enum ivy_status ivy_asm_constpool_reader_read_value(
break;
}
size_t part_key = b_i32_btoh(part);
size_t part_key = fx_i32_btoh(part);
char *part_name = NULL;
status = read_string_xdata(reader, part_key, &part_name);
if (status != IVY_OK) {
@@ -517,7 +517,7 @@ enum ivy_status ivy_asm_constpool_value_destroy(struct ivy_asm_constpool_value *
bool ivy_asm_section_type_to_string(uint32_t in, char out[5])
{
b_i32 v = b_i32_htob(in);
fx_i32 v = fx_i32_htob(in);
for (size_t i = 0; i < sizeof in; i++) {
char c = v.i_bytes[i];