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

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.14)
project(ivy C) project(ivy C)
if (WIN32) if (WIN32)
@@ -24,10 +24,10 @@ if (NOT IVY_STATIC)
endif () endif ()
if (IVY_STATIC) if (IVY_STATIC)
set(Bluelib_STATIC TRUE) set(FX_STATIC TRUE)
endif () endif ()
find_package(Bluelib REQUIRED) find_package(FX REQUIRED)
add_subdirectory(common) add_subdirectory(common)
add_subdirectory(diag) add_subdirectory(diag)

View File

@@ -11,5 +11,5 @@ else ()
endif () endif ()
target_include_directories(ivy-asm PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/) 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}) target_compile_definitions(ivy-asm PRIVATE IVY_EXPORT=1 IVY_STATIC=${IVY_STATIC})

View File

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

View File

@@ -1,9 +1,9 @@
#include "assembler.h" #include "assembler.h"
#include <blue/core/hash.h> #include <fx/core/hash.h>
#include <blue/ds/hashmap.h> #include <fx/ds/hashmap.h>
#include <blue/ds/number.h> #include <fx/ds/number.h>
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <ivy/asm/bin.h> #include <ivy/asm/bin.h>
#include <ivy/asm/instr.h> #include <ivy/asm/instr.h>
#include <ivy/asm/lex.h> #include <ivy/asm/lex.h>
@@ -19,15 +19,15 @@ enum label_state {
struct label { struct label {
enum label_state l_state; enum label_state l_state;
b_queue_entry l_entry; fx_queue_entry l_entry;
const struct ivy_asm_token *l_name; const struct ivy_asm_token *l_name;
size_t l_offset; size_t l_offset;
}; };
struct block_assembler_scope { struct block_assembler_scope {
struct assembler_scope s_base; struct assembler_scope s_base;
b_hashmap *s_labels; fx_hashmap *s_labels;
b_queue s_label_refs; fx_queue s_label_refs;
size_t s_text_start; size_t s_text_start;
}; };
@@ -57,10 +57,10 @@ static enum ivy_status init_scope(
struct ivy_bin_block header = {0}; struct ivy_bin_block header = {0};
struct block_assembler_scope *c = (struct block_assembler_scope *)scope; 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); 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); assembler_write_data(as, &header, sizeof header);
return IVY_OK; 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) 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_data = name,
.key_size = strlen(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) { if (!v) {
return NULL; return NULL;
} }
@@ -88,9 +88,9 @@ static enum ivy_status resolve_label_refs(
enum ivy_status status = IVY_OK; enum ivy_status status = IVY_OK;
size_t nr_read = 0; 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) { 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); struct label *label_dest = get_label(c, label_ref->l_name->t_str);
if (!label_dest) { if (!label_dest) {
@@ -99,7 +99,7 @@ static enum ivy_status resolve_label_refs(
return IVY_ERR_NO_ENTRY; return IVY_ERR_NO_ENTRY;
} }
b_i32 x; fx_i32 x;
status = assembler_read_data_at( status = assembler_read_data_at(
as, &x, label_ref->l_offset, sizeof x, &nr_read); 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; 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); 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); assembler_write_data_at(as, &x, label_ref->l_offset, sizeof x);
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
return status; return status;
@@ -164,7 +164,7 @@ static enum ivy_status put_instr(
return IVY_ERR_INTERNAL_FAILURE; 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); assembler_write_data(as, &x, sizeof x);
return IVY_OK; return IVY_OK;
} }
@@ -179,21 +179,21 @@ static enum ivy_status put_label(
label->l_name = label_name; label->l_name = label_name;
label->l_offset = label_offset - c->s_text_start; label->l_offset = label_offset - c->s_text_start;
b_hashmap_key key = { fx_hashmap_key key = {
.key_data = label_name->t_str, .key_data = label_name->t_str,
.key_size = strlen(label_name->t_str), .key_size = strlen(label_name->t_str),
}; };
b_hashmap_value value = { fx_hashmap_value value = {
.value_data = label, .value_data = label,
.value_size = sizeof *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; 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); 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_name = label_name;
label->l_offset = ref_offset; 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; return IVY_OK;
} }

View File

@@ -8,7 +8,7 @@ static enum ivy_status init_scope(
{ {
struct ivy_bin_class header = {0}; 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); 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}; struct ivy_bin_class_table_entry entry = {0};
switch (type) { switch (type) {
case IVY_ASM_XVAL_PROPERTY: 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 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 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 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; break;
case IVY_ASM_XVAL_MEMBER_VAR: 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 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 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; break;
case IVY_ASM_XVAL_MESSAGE_HANDLER: 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 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 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; break;
default: default:
return IVY_ERR_NOT_SUPPORTED; return IVY_ERR_NOT_SUPPORTED;

View File

@@ -1,9 +1,9 @@
#include "assembler.h" #include "assembler.h"
#include <blue/core/hash.h> #include <fx/core/hash.h>
#include <blue/ds/dict.h> #include <fx/ds/dict.h>
#include <blue/ds/number.h> #include <fx/ds/number.h>
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <ivy/asm/bin.h> #include <ivy/asm/bin.h>
#include <ivy/ident.h> #include <ivy/ident.h>
#include <ivy/selector.h> #include <ivy/selector.h>
@@ -12,7 +12,7 @@
struct constpool_assembler_scope { struct constpool_assembler_scope {
struct assembler_scope s_base; struct assembler_scope s_base;
b_dict *s_strings; fx_dict *s_strings;
size_t s_next_slot; size_t s_next_slot;
}; };
@@ -26,7 +26,7 @@ static enum ivy_status init_scope(
struct constpool_assembler_scope *c struct constpool_assembler_scope *c
= (struct constpool_assembler_scope *)scope; = (struct constpool_assembler_scope *)scope;
c->s_strings = b_dict_create(); c->s_strings = fx_dict_create();
c->s_next_slot = 0; c->s_next_slot = 0;
return IVY_OK; return IVY_OK;
@@ -35,19 +35,19 @@ static enum ivy_status init_scope(
static ivy_extended_data_key get_cached_string( static ivy_extended_data_key get_cached_string(
struct constpool_assembler_scope *scope, const char *s) 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) { if (!key) {
return IVY_EX_DATA_KEY_NULL; 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( static void put_cached_string(
struct constpool_assembler_scope *scope, const char *s, struct constpool_assembler_scope *scope, const char *s,
ivy_extended_data_key key) 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) 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); size_t len = strlen(s);
struct ivy_bin_string str = {0}; struct ivy_bin_string str = {0};
str.s_hash = b_i32_htob((uint32_t)b_hash_cstr(s)); str.s_hash = fx_i32_htob((uint32_t)fx_hash_cstr(s));
str.s_len = b_i32_htob((uint32_t)len); str.s_len = fx_i32_htob((uint32_t)len);
key = assembler_write_extended_data(as, &str, sizeof str); key = assembler_write_extended_data(as, &str, sizeof str);
@@ -90,29 +90,29 @@ static ivy_extended_data_key write_selector(
} }
if (sel->sel_name) { 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 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; dat.sel_nr_args = (uint8_t)nr_args;
/* TODO hash. */ /* TODO hash. */
ivy_extended_data_key *arg_handles ivy_extended_data_key *arg_handles
= calloc(nr_args, sizeof(ivy_extended_data_key)); = 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) { while (entry) {
struct ivy_selector_arg *arg 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); 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 ivy_extended_data_key selector_handle
= assembler_write_extended_data(as, &dat, sizeof dat); = assembler_write_extended_data(as, &dat, sizeof dat);
for (i = 0; i < nr_args; i++) { 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); 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}; struct ivy_bin_ident dat = {0};
/* TODO hash. */ /* 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; size_t i = 0;
ivy_extended_data_key *part_handles ivy_extended_data_key *part_handles
= calloc(nr_parts, sizeof(ivy_extended_data_key)); = 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) { while (entry) {
struct ivy_ident_part *arg 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); 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; 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); = assembler_write_extended_data(as, &dat, sizeof dat);
for (i = 0; i < nr_parts; i++) { 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); assembler_write_extended_data(as, &part_handle, sizeof part_handle);
} }
@@ -170,32 +170,32 @@ static enum ivy_status put_pval(
switch (type) { switch (type) {
case IVY_ASM_PVAL_STRING: 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); k = write_string(as, val);
entry.e_ex_handle = b_i32_htob(k); entry.e_ex_handle = fx_i32_htob(k);
break; break;
case IVY_ASM_PVAL_IDENT: 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); k = write_ident(as, val);
entry.e_ex_handle = b_i32_htob(k); entry.e_ex_handle = fx_i32_htob(k);
break; break;
case IVY_ASM_PVAL_ATOM: 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); k = write_string(as, val);
entry.e_ex_handle = b_i32_htob(k); entry.e_ex_handle = fx_i32_htob(k);
break; break;
case IVY_ASM_PVAL_SINT: case IVY_ASM_PVAL_SINT:
entry.e_type = b_i32_htob(IVY_CONSTPOOL_TABLE_INT); entry.e_type = fx_i32_htob(IVY_CONSTPOOL_TABLE_INT);
entry.e_int = b_i32_htob((uint32_t)i); entry.e_int = fx_i32_htob((uint32_t)i);
break; break;
case IVY_ASM_PVAL_UINT: case IVY_ASM_PVAL_UINT:
entry.e_type = b_i32_htob(IVY_CONSTPOOL_TABLE_UINT); entry.e_type = fx_i32_htob(IVY_CONSTPOOL_TABLE_UINT);
entry.e_int = b_i32_htob((uint32_t)i); entry.e_int = fx_i32_htob((uint32_t)i);
break; break;
case IVY_ASM_PVAL_SELECTOR: 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); k = write_selector(as, val);
entry.e_ex_handle = b_i32_htob(k); entry.e_ex_handle = fx_i32_htob(k);
break; break;
default: default:
return IVY_ERR_NOT_SUPPORTED; return IVY_ERR_NOT_SUPPORTED;

View File

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

View File

@@ -1,7 +1,7 @@
#ifndef IVY_ASM_INSTR_H_ #ifndef IVY_ASM_INSTR_H_
#define 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/misc.h>
#include <ivy/opcode.h> #include <ivy/opcode.h>
#include <ivy/status.h> #include <ivy/status.h>
@@ -85,6 +85,6 @@ struct ivy_instr {
IVY_API const struct ivy_instr_definition *ivy_instr_find( IVY_API const struct ivy_instr_definition *ivy_instr_find(
enum ivy_instr_id id, const enum ivy_instr_operand_type operands[4]); 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 #endif

View File

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

View File

@@ -139,9 +139,9 @@ const struct ivy_instr_definition *ivy_instr_find(
return NULL; 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); unsigned int opcode = R_GET_OPCODE(instr);
if (opcode >= nr_instructions) { if (opcode >= nr_instructions) {
return IVY_ERR_INVALID_VALUE; return IVY_ERR_INVALID_VALUE;

128
asm/lex.c
View File

@@ -1,10 +1,10 @@
#include "lex.h" #include "lex.h"
#include <blue/core/hash.h> #include <fx/core/hash.h>
#include <blue/core/queue.h> #include <fx/core/queue.h>
#include <blue/ds/dict.h> #include <fx/ds/dict.h>
#include <blue/ds/number.h> #include <fx/ds/number.h>
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <ctype.h> #include <ctype.h>
#include <ivy/asm/lex.h> #include <ivy/asm/lex.h>
#include <stdbool.h> #include <stdbool.h>
@@ -63,40 +63,40 @@ static struct lexer_state *push_lexer_state(
memset(state, 0x0, sizeof *state); memset(state, 0x0, sizeof *state);
state->s_type = state_type; 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; return state;
} }
static void pop_lexer_state(struct ivy_asm_lexer *lex) 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) { if (!entry) {
return; 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); free(state);
} }
static struct lexer_state *get_lexer_state(struct ivy_asm_lexer *lex) 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) { if (!entry) {
return NULL; 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) { while (entry) {
struct lexer_state *node struct lexer_state *node
= b_unbox(struct lexer_state, entry, s_entry); = fx_unbox(struct lexer_state, entry, s_entry);
b_queue_entry *next = b_queue_next(entry); fx_queue_entry *next = fx_queue_next(entry);
b_queue_delete(state, entry); fx_queue_delete(state, entry);
free(node); free(node);
@@ -107,27 +107,27 @@ static void destroy_state_stack(b_queue *state)
static struct ivy_asm_lexer_symbol_node *get_symbol_node( static struct ivy_asm_lexer_symbol_node *get_symbol_node(
struct ivy_asm_lexer_symbol_node *node, char c) 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) { 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); struct ivy_asm_lexer_symbol_node, entry, s_entry);
if (child->s_char == c) { if (child->s_char == c) {
return child; return child;
} }
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
return NULL; 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) { 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; return lex->lex_temp;
} }
@@ -152,7 +152,7 @@ static enum ivy_status put_symbol(
child->s_id = IVY_ASM_SYM_NONE; child->s_id = IVY_ASM_SYM_NONE;
child->s_char = c; 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; tree = child;
} }
@@ -162,12 +162,12 @@ static enum ivy_status put_symbol(
static void destroy_symbol_tree(struct ivy_asm_lexer_symbol_node *tree) 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) { 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); struct ivy_asm_lexer_symbol_node, entry, s_entry);
b_queue_entry *next = b_queue_next(entry); fx_queue_entry *next = fx_queue_next(entry);
b_queue_delete(&tree->s_children, entry); fx_queue_delete(&tree->s_children, entry);
destroy_symbol_tree(node); destroy_symbol_tree(node);
@@ -200,23 +200,23 @@ static struct ivy_asm_lexer_symbol_node *build_symbol_tree(void)
return root; 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++) { for (size_t i = 0; i < nr_keywords; i++) {
struct lex_token_def *keyword = &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( static enum ivy_asm_keyword find_keyword_by_name(
struct ivy_asm_lexer *lex, const char *s) 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) { if (!id) {
return IVY_ASM_KW_NONE; 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) 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; return IVY_ERR_NO_MEMORY;
} }
lex->lex_keywords = b_dict_create(); lex->lex_keywords = fx_dict_create();
init_keywords(lex->lex_keywords); init_keywords(lex->lex_keywords);
*lexp = lex; *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) 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) { while (entry) {
struct ivy_asm_token *tok struct ivy_asm_token *tok
= b_unbox(struct ivy_asm_token, entry, t_entry); = fx_unbox(struct ivy_asm_token, entry, t_entry);
b_queue_entry *next = b_queue_next(entry); fx_queue_entry *next = fx_queue_next(entry);
b_queue_delete(&lex->lex_queue, entry); fx_queue_delete(&lex->lex_queue, entry);
ivy_asm_token_destroy(tok); ivy_asm_token_destroy(tok);
@@ -276,11 +276,11 @@ void ivy_asm_lexer_destroy(struct ivy_asm_lexer *lex)
} }
if (lex->lex_temp) { if (lex->lex_temp) {
b_string_unref(lex->lex_temp); fx_string_unref(lex->lex_temp);
} }
if (lex->lex_keywords) { if (lex->lex_keywords) {
b_dict_unref(lex->lex_keywords); fx_dict_unref(lex->lex_keywords);
} }
destroy_state_stack(&lex->lex_state); 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( static enum ivy_status push_token(
struct ivy_asm_lexer *lex, struct ivy_asm_token *tok) 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; lex->lex_prev_token = tok->t_type;
return IVY_OK; 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) static enum ivy_status read_string_content(struct ivy_asm_lexer *lex)
{ {
int c; int c;
b_string *str = get_temp_string(lex); fx_string *str = get_temp_string(lex);
struct lexer_state *state = get_lexer_state(lex); struct lexer_state *state = get_lexer_state(lex);
if (!str) { if (!str) {
@@ -629,15 +629,15 @@ static enum ivy_status read_string_content(struct ivy_asm_lexer *lex)
} }
char s[2] = {c, 0}; char s[2] = {c, 0};
b_string_append_cstr(str, s); fx_string_append_cstr(str, s);
advance(lex); 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; return IVY_OK;
} }
char *s = b_string_steal(str); char *s = fx_string_steal(str);
enum ivy_status status = push_string_content(lex, s); enum ivy_status status = push_string_content(lex, s);
if (status != IVY_OK) { if (status != IVY_OK) {
@@ -692,7 +692,7 @@ static enum ivy_status read_number(struct ivy_asm_lexer *lex)
int base = 10; int base = 10;
int dots = 0; int dots = 0;
bool neg = false; bool neg = false;
b_string *str = get_temp_string(lex); fx_string *str = get_temp_string(lex);
while (true) { while (true) {
int c = peek(lex); int c = peek(lex);
@@ -733,7 +733,7 @@ static enum ivy_status read_number(struct ivy_asm_lexer *lex)
token_len++; token_len++;
dots++; dots++;
char s[] = {c, 0}; char s[] = {c, 0};
b_string_append_cstr(str, s); fx_string_append_cstr(str, s);
advance(lex); advance(lex);
continue; continue;
} }
@@ -776,7 +776,7 @@ static enum ivy_status read_number(struct ivy_asm_lexer *lex)
} }
char s[] = {c, 0}; char s[] = {c, 0};
b_string_append_cstr(str, s); fx_string_append_cstr(str, s);
token_len++; token_len++;
advance(lex); advance(lex);
} }
@@ -785,7 +785,7 @@ static enum ivy_status read_number(struct ivy_asm_lexer *lex)
return push_uint(lex, 0); return push_uint(lex, 0);
} }
const char *s = b_string_ptr(str); const char *s = fx_string_ptr(str);
char *ep = NULL; char *ep = NULL;
if (dots > 0) { if (dots > 0) {
@@ -826,8 +826,8 @@ static enum ivy_status read_keyword(struct ivy_asm_lexer *lex)
{ {
advance(lex); advance(lex);
b_string *str = get_temp_string(lex); fx_string *str = get_temp_string(lex);
b_string_append_cstr(str, "@"); fx_string_append_cstr(str, "@");
bool label = false; bool label = false;
@@ -843,11 +843,11 @@ static enum ivy_status read_keyword(struct ivy_asm_lexer *lex)
} }
char s[2] = {c, 0}; char s[2] = {c, 0};
b_string_append_cstr(str, s); fx_string_append_cstr(str, s);
advance(lex); 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); 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); advance(lex);
b_string *str = get_temp_string(lex); fx_string *str = get_temp_string(lex);
bool label = false; bool label = false;
while (true) { while (true) {
@@ -883,21 +883,21 @@ static enum ivy_status read_label_ref(struct ivy_asm_lexer *lex)
} }
char s[2] = {c, 0}; char s[2] = {c, 0};
b_string_append_cstr(str, s); fx_string_append_cstr(str, s);
advance(lex); 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); 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); return push_token(lex, tok);
} }
static enum ivy_status read_ident(struct ivy_asm_lexer *lex) 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; bool label = false;
while (true) { while (true) {
@@ -918,15 +918,15 @@ static enum ivy_status read_ident(struct ivy_asm_lexer *lex)
} }
char s[2] = {c, 0}; char s[2] = {c, 0};
b_string_append_cstr(str, s); fx_string_append_cstr(str, s);
advance(lex); advance(lex);
} }
const char *s = b_string_ptr(str); const char *s = fx_string_ptr(str);
struct ivy_asm_token *tok struct ivy_asm_token *tok
= create_token(label ? IVY_ASM_TOK_LABEL : IVY_ASM_TOK_IDENT); = 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); 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; enum ivy_status status = IVY_OK;
while (b_queue_empty(&lex->lex_queue)) { while (fx_queue_empty(&lex->lex_queue)) {
status = pump_tokens(lex); status = pump_tokens(lex);
if (status != IVY_OK) { 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; lex->lex_status = status;
b_queue_entry *entry = b_queue_first(&lex->lex_queue); fx_queue_entry *entry = fx_queue_first(&lex->lex_queue);
struct ivy_asm_token *tok = b_unbox(struct ivy_asm_token, entry, t_entry); struct ivy_asm_token *tok = fx_unbox(struct ivy_asm_token, entry, t_entry);
return tok; 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; enum ivy_status status = IVY_OK;
while (b_queue_empty(&lex->lex_queue)) { while (fx_queue_empty(&lex->lex_queue)) {
status = pump_tokens(lex); status = pump_tokens(lex);
if (status != IVY_OK) { 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); fx_queue_entry *entry = fx_queue_pop_front(&lex->lex_queue);
struct ivy_asm_token *tok = b_unbox(struct ivy_asm_token, entry, t_entry); struct ivy_asm_token *tok = fx_unbox(struct ivy_asm_token, entry, t_entry);
return tok; return tok;
} }

View File

@@ -1,9 +1,9 @@
#ifndef _LEX_H_ #ifndef _LEX_H_
#define _LEX_H_ #define _LEX_H_
#include <blue/core/queue.h> #include <fx/core/queue.h>
#include <blue/ds/dict.h> #include <fx/ds/dict.h>
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <ivy/asm/lex.h> #include <ivy/asm/lex.h>
#include <stdint.h> #include <stdint.h>
@@ -15,15 +15,15 @@ enum lexer_state_type {
struct lexer_state { struct lexer_state {
enum lexer_state_type s_type; enum lexer_state_type s_type;
b_queue_entry s_entry; fx_queue_entry s_entry;
}; };
struct ivy_asm_lexer_symbol_node { struct ivy_asm_lexer_symbol_node {
char s_char; char s_char;
enum ivy_asm_symbol s_id; enum ivy_asm_symbol s_id;
b_queue_entry s_entry; fx_queue_entry s_entry;
b_queue s_children; fx_queue s_children;
}; };
struct lex_token_def { struct lex_token_def {
@@ -35,14 +35,14 @@ struct lex_token_def {
struct ivy_asm_lexer { struct ivy_asm_lexer {
struct ivy_asm_lexer_symbol_node *lex_sym_tree; struct ivy_asm_lexer_symbol_node *lex_sym_tree;
struct ivy_line_source *lex_source; struct ivy_line_source *lex_source;
b_dict *lex_keywords; fx_dict *lex_keywords;
enum ivy_status lex_status; enum ivy_status lex_status;
b_queue lex_queue; fx_queue lex_queue;
enum ivy_asm_token_type lex_prev_token; enum ivy_asm_token_type lex_prev_token;
b_string *lex_temp; fx_string *lex_temp;
b_queue lex_state; fx_queue lex_state;
unsigned int lex_brace_depth; unsigned int lex_brace_depth;
char *lex_linebuf; 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_type *ptr_type = mie_ctx_get_type(ctx, MIE_TYPE_PTR);
struct mie_select_graph *graph = mie_select_builder_get_graph(builder); struct mie_select_graph *graph = mie_select_builder_get_graph(builder);
b_queue *nodes = &graph->g_nodes; fx_queue *nodes = &graph->g_nodes;
b_queue_entry *entry = b_queue_first(nodes); fx_queue_entry *entry = fx_queue_first(nodes);
while (entry) { while (entry) {
struct mie_select_node *node 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) { if (node->n_target != target) {
goto skip; goto skip;
@@ -124,7 +124,7 @@ static enum mie_status get_selector(
mie_select_node_get_value(node, ptr_type, 0, out); mie_select_node_get_value(node, ptr_type, 0, out);
return MIE_SUCCESS; return MIE_SUCCESS;
skip: skip:
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
struct mie_select_node *sel_node; 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_ctx *ctx = mie_select_builder_get_ctx(builder);
struct mie_select_value **param_chains = calloc( 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 *)); sizeof(struct mie_select_value *));
size_t nr_param_chains = 0; size_t nr_param_chains = 0;
struct mie_select_value *chain, *recipient, nr_args; 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( 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)); sizeof(struct mie_select_value));
size_t nr_stack_chains = 0; size_t nr_stack_chains = 0;
nr_param_chains = 0; nr_param_chains = 0;

View File

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

View File

@@ -1,6 +1,6 @@
#include "parse.h" #include "parse.h"
#include <blue/core/hash.h> #include <fx/core/hash.h>
#include <ivy/asm/assembler.h> #include <ivy/asm/assembler.h>
enum item_type { enum item_type {
@@ -23,7 +23,7 @@ struct class_parser_state {
static enum ivy_status push_attrib(struct class_parser_state *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; const char *s = state->s_attrib_name->t_str;
unsigned long long v = state->s_attrib_value->t_int.uv; 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; struct parser_state s_base;
unsigned int s_prev_token; 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) 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; 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; state->s_prev_token = IVY_ASM_TOK_IDENT;
return IVY_OK; return IVY_OK;
@@ -61,12 +61,12 @@ static enum ivy_status parse_right_paren(
struct ivy_ident *ident = ivy_ident_create(); 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) { while (entry) {
struct ivy_asm_token *tok struct ivy_asm_token *tok
= b_unbox(struct ivy_asm_token, entry, t_entry); = fx_unbox(struct ivy_asm_token, entry, t_entry);
b_queue_entry *next = b_queue_next(entry); fx_queue_entry *next = fx_queue_next(entry);
b_queue_delete(&state->s_parts, entry); fx_queue_delete(&state->s_parts, entry);
ivy_ident_add_part(ident, tok->t_str); ivy_ident_add_part(ident, tok->t_str);
ivy_asm_token_destroy(tok); 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); 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; return state;
} }
void asm_parser_pop_state(struct ivy_asm_parser *parser, void *ret) 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) { if (!last) {
return; 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) { if (state->s_type->n_finish_state) {
state->s_type->n_finish_state(parser, 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) 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) { if (!last) {
return NULL; 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_ #ifndef _PARSE_PARSE_H_
#define _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/assembler.h>
#include <ivy/asm/lex.h> #include <ivy/asm/lex.h>
@@ -60,7 +60,7 @@ struct parser_state_type {
}; };
struct parser_state { struct parser_state {
b_queue_entry s_entry; fx_queue_entry s_entry;
const struct parser_state_type* s_type; const struct parser_state_type* s_type;
ivy_assembler_attrib_table s_attrib; ivy_assembler_attrib_table s_attrib;
void* s_previous_value; void* s_previous_value;
@@ -68,7 +68,7 @@ struct parser_state {
struct ivy_asm_parser { struct ivy_asm_parser {
struct ivy_assembler* p_assembler; 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); 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 "parse.h"
#include <blue/core/hash.h> #include <fx/core/hash.h>
#include <ivy/asm/assembler.h> #include <ivy/asm/assembler.h>
struct unit_parser_state { struct unit_parser_state {
@@ -16,7 +16,7 @@ struct unit_parser_state {
static enum ivy_status push_attrib(struct unit_parser_state *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; const char *s = state->s_attrib_name->t_str;
unsigned long long v = state->s_attrib_value->t_int.uv; unsigned long long v = state->s_attrib_value->t_int.uv;

View File

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

View File

@@ -1,189 +0,0 @@
#[=======================================================================[.rst:
FindBluelib
------------
Find the Bluelib library and header directories
Imported Targets
^^^^^^^^^^^^^^^^
This module defines the following :prop_tgt:`IMPORTED` target:
``Bluelib::Bluelib``
The Bluelib library, if found
Result Variables
^^^^^^^^^^^^^^^^
This module will set the following variables in your project:
``Bluelib_FOUND``
true if the Bluelib C headers and libraries were found
``Bluelib_INCLUDE_DIR``
directories containing the Bluelib C headers.
``Bluelib_LIBRARY``
the C library to link against
Hints
^^^^^
The user may set the environment variable ``Bluelib_PREFIX`` to the root
directory of a Bluelib library installation.
#]=======================================================================]
set (Bluelib_SEARCH_PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr/local/share
/usr
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
${Bluelib_PREFIX}
$ENV{Bluelib_PREFIX})
if (Bluelib_STATIC)
set(_lib_suffix "-s")
endif ()
set(supported_components Core Ds Term Cmd Io Serial Compress)
set(components ${Bluelib_FIND_COMPONENTS})
string(REPLACE ";" ", " supported_components_string_list "${supported_components}")
if (NOT components)
set(components ${supported_components})
endif ()
set(required_vars)
foreach (component ${components})
if (NOT "${component}" IN_LIST supported_components)
message(FATAL_ERROR "'${component}' is not a valid Bluelib module.\nSupported modules: ${supported_components_string_list}")
endif ()
string(TOLOWER ${component} header_name)
set(lib_name ${header_name}${_lib_suffix})
if (NOT Bluelib_${component}_INCLUDE_DIR)
find_path(Bluelib_${component}_INCLUDE_DIR
NAMES blue/${header_name}.h ${Bluelib_FIND_ARGS}
PATH_SUFFIXES include
PATHS ${Bluelib_SEARCH_PATHS})
endif ()
if (NOT Bluelib_${component}_LIBRARY)
find_library(Bluelib_${component}_LIBRARY
NAMES blue-${lib_name} ${Bluelib_FIND_ARGS}
PATH_SUFFIXES lib
PATHS ${Bluelib_SEARCH_PATHS})
else ()
# on Windows, ensure paths are in canonical format (forward slahes):
file(TO_CMAKE_PATH "${Bluelib_${component}_LIBRARY}" Bluelib_${component}_LIBRARY)
endif()
list(APPEND required_vars Bluelib_${component}_INCLUDE_DIR Bluelib_${component}_LIBRARY)
endforeach (component)
unset(Bluelib_FIND_ARGS)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Bluelib
REQUIRED_VARS ${required_vars})
if (Bluelib_FOUND)
set(created_targets)
foreach (component ${components})
string(TOLOWER ${component} header_name)
set(lib_name ${header_name}${_lib_suffix})
if(NOT TARGET Bluelib::${component})
add_library(Bluelib::${component} UNKNOWN IMPORTED)
set_target_properties(Bluelib::${component} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Bluelib_${component}_INCLUDE_DIR}")
target_compile_definitions(Bluelib::${component} INTERFACE _CRT_SECURE_NO_WARNINGS=1)
if (Bluelib_STATIC)
target_compile_definitions(Bluelib::${component} INTERFACE BLUELIB_STATIC=1)
endif ()
set_target_properties(Bluelib::${component} PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${Bluelib_${component}_LIBRARY}")
set(created_targets ${created_targets} ${component})
endif ()
endforeach (component)
foreach (component ${created_targets})
if ("${component}" STREQUAL "Ds")
if (NOT TARGET Bluelib::Core)
message(FATAL_ERROR "Bluelib: Module 'Ds' depends on 'Core', which was not specified in find_package()")
endif ()
target_link_libraries(Bluelib::Ds INTERFACE Bluelib::Core)
endif ()
if ("${component}" STREQUAL "Term")
if (NOT TARGET Bluelib::Core)
message(FATAL_ERROR "Bluelib: Module 'Term' depends on 'Core', which was not specified in find_package()")
endif ()
if (NOT TARGET Bluelib::Ds)
message(FATAL_ERROR "Bluelib: Module 'Term' depends on 'Ds', which was not specified in find_package()")
endif ()
target_link_libraries(Bluelib::Term INTERFACE Bluelib::Core Bluelib::Ds)
endif ()
if ("${component}" STREQUAL "Serial")
if (NOT TARGET Bluelib::Core)
message(FATAL_ERROR "Bluelib: Module 'Serial' depends on 'Core', which was not specified in find_package()")
endif ()
if (NOT TARGET Bluelib::Ds)
message(FATAL_ERROR "Bluelib: Module 'Serial' depends on 'Ds', which was not specified in find_package()")
endif ()
target_link_libraries(Bluelib::Serial INTERFACE Bluelib::Core Bluelib::Ds)
endif ()
if ("${component}" STREQUAL "Cmd")
if (NOT TARGET Bluelib::Core)
message(FATAL_ERROR "Bluelib: Module 'Cmd' depends on 'Core', which was not specified in find_package()")
endif ()
if (NOT TARGET Bluelib::Ds)
message(FATAL_ERROR "Bluelib: Module 'Cmd' depends on 'Ds', which was not specified in find_package()")
endif ()
if (NOT TARGET Bluelib::Term)
message(FATAL_ERROR "Bluelib: Module 'Cmd' depends on 'Term', which was not specified in find_package()")
endif ()
target_link_libraries(Bluelib::Cmd INTERFACE Bluelib::Core Bluelib::Ds Bluelib::Term)
endif ()
if ("${component}" STREQUAL "Io")
if (NOT TARGET Bluelib::Core)
message(FATAL_ERROR "Bluelib: Module 'Io' depends on 'Core', which was not specified in find_package()")
endif ()
if (NOT TARGET Bluelib::Ds)
message(FATAL_ERROR "Bluelib: Module 'Io' depends on 'Ds', which was not specified in find_package()")
endif ()
target_link_libraries(Bluelib::Io INTERFACE Bluelib::Core Bluelib::Ds)
endif ()
if ("${component}" STREQUAL "Compress")
if (NOT TARGET Bluelib::Core)
message(FATAL_ERROR "Bluelib: Module 'Compress' depends on 'Core', which was not specified in find_package()")
endif ()
target_link_libraries(Bluelib::Compress INTERFACE Bluelib::Core Bluelib::Ds)
endif ()
endforeach (component)
endif()

189
cmake/FindFX.cmake Normal file
View File

@@ -0,0 +1,189 @@
#[=======================================================================[.rst:
FindFX
------------
Find the FX library and header directories
Imported Targets
^^^^^^^^^^^^^^^^
This module defines the following :prop_tgt:`IMPORTED` target:
``FX::FX``
The FX library, if found
Result Variables
^^^^^^^^^^^^^^^^
This module will set the following variables in your project:
``FX_FOUND``
true if the FX C headers and libraries were found
``FX_INCLUDE_DIR``
directories containing the FX C headers.
``FX_LIBRARY``
the C library to link against
Hints
^^^^^
The user may set the environment variable ``FX_PREFIX`` to the root
directory of a FX library installation.
#]=======================================================================]
set (FX_SEARCH_PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr/local/share
/usr
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
${FX_PREFIX}
$ENV{FX_PREFIX})
if (FX_STATIC)
set(_lib_suffix "-s")
endif ()
set(supported_components Core Ds Term Cmd Io Serial Compress)
set(components ${FX_FIND_COMPONENTS})
string(REPLACE ";" ", " supported_components_string_list "${supported_components}")
if (NOT components)
set(components ${supported_components})
endif ()
set(required_vars)
foreach (component ${components})
if (NOT "${component}" IN_LIST supported_components)
message(FATAL_ERROR "'${component}' is not a valid FX module.\nSupported modules: ${supported_components_string_list}")
endif ()
string(TOLOWER ${component} header_name)
set(lib_name ${header_name}${_lib_suffix})
if (NOT FX_${component}_INCLUDE_DIR)
find_path(FX_${component}_INCLUDE_DIR
NAMES fx/${header_name}.h ${FX_FIND_ARGS}
PATH_SUFFIXES include
PATHS ${FX_SEARCH_PATHS})
endif ()
if (NOT FX_${component}_LIBRARY)
find_library(FX_${component}_LIBRARY
NAMES fx-${lib_name} ${FX_FIND_ARGS}
PATH_SUFFIXES lib
PATHS ${FX_SEARCH_PATHS})
else ()
# on Windows, ensure paths are in canonical format (forward slahes):
file(TO_CMAKE_PATH "${FX_${component}_LIBRARY}" FX_${component}_LIBRARY)
endif()
list(APPEND required_vars FX_${component}_INCLUDE_DIR FX_${component}_LIBRARY)
endforeach (component)
unset(FX_FIND_ARGS)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FX
REQUIRED_VARS ${required_vars})
if (FX_FOUND)
set(created_targets)
foreach (component ${components})
string(TOLOWER ${component} header_name)
set(lib_name ${header_name}${_lib_suffix})
if(NOT TARGET FX::${component})
add_library(FX::${component} UNKNOWN IMPORTED)
set_target_properties(FX::${component} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${FX_${component}_INCLUDE_DIR}")
target_compile_definitions(FX::${component} INTERFACE _CRT_SECURE_NO_WARNINGS=1)
if (FX_STATIC)
target_compile_definitions(FX::${component} INTERFACE FX_STATIC=1)
endif ()
set_target_properties(FX::${component} PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${FX_${component}_LIBRARY}")
set(created_targets ${created_targets} ${component})
endif ()
endforeach (component)
foreach (component ${created_targets})
if ("${component}" STREQUAL "Ds")
if (NOT TARGET FX::Core)
message(FATAL_ERROR "FX: Module 'Ds' depends on 'Core', which was not specified in find_package()")
endif ()
target_link_libraries(FX::Ds INTERFACE FX::Core)
endif ()
if ("${component}" STREQUAL "Term")
if (NOT TARGET FX::Core)
message(FATAL_ERROR "FX: Module 'Term' depends on 'Core', which was not specified in find_package()")
endif ()
if (NOT TARGET FX::Ds)
message(FATAL_ERROR "FX: Module 'Term' depends on 'Ds', which was not specified in find_package()")
endif ()
target_link_libraries(FX::Term INTERFACE FX::Core FX::Ds)
endif ()
if ("${component}" STREQUAL "Serial")
if (NOT TARGET FX::Core)
message(FATAL_ERROR "FX: Module 'Serial' depends on 'Core', which was not specified in find_package()")
endif ()
if (NOT TARGET FX::Ds)
message(FATAL_ERROR "FX: Module 'Serial' depends on 'Ds', which was not specified in find_package()")
endif ()
target_link_libraries(FX::Serial INTERFACE FX::Core FX::Ds)
endif ()
if ("${component}" STREQUAL "Cmd")
if (NOT TARGET FX::Core)
message(FATAL_ERROR "FX: Module 'Cmd' depends on 'Core', which was not specified in find_package()")
endif ()
if (NOT TARGET FX::Ds)
message(FATAL_ERROR "FX: Module 'Cmd' depends on 'Ds', which was not specified in find_package()")
endif ()
if (NOT TARGET FX::Term)
message(FATAL_ERROR "FX: Module 'Cmd' depends on 'Term', which was not specified in find_package()")
endif ()
target_link_libraries(FX::Cmd INTERFACE FX::Core FX::Ds FX::Term)
endif ()
if ("${component}" STREQUAL "Io")
if (NOT TARGET FX::Core)
message(FATAL_ERROR "FX: Module 'Io' depends on 'Core', which was not specified in find_package()")
endif ()
if (NOT TARGET FX::Ds)
message(FATAL_ERROR "FX: Module 'Io' depends on 'Ds', which was not specified in find_package()")
endif ()
target_link_libraries(FX::Io INTERFACE FX::Core FX::Ds)
endif ()
if ("${component}" STREQUAL "Compress")
if (NOT TARGET FX::Core)
message(FATAL_ERROR "FX: Module 'Compress' depends on 'Core', which was not specified in find_package()")
endif ()
target_link_libraries(FX::Compress INTERFACE FX::Core FX::Ds)
endif ()
endforeach (component)
endif()

View File

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

View File

@@ -1,5 +1,5 @@
#include <blue/ds/array.h> #include <fx/ds/array.h>
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <errno.h> #include <errno.h>
#include <ivy/file.h> #include <ivy/file.h>
#include <stdlib.h> #include <stdlib.h>
@@ -18,17 +18,17 @@ static enum ivy_status get_row(
size_t *nr_read) size_t *nr_read)
{ {
struct ivy_file *f = (struct ivy_file *)src; struct ivy_file *f = (struct ivy_file *)src;
size_t nr_rows = b_array_size(f->f_lines); size_t nr_rows = fx_array_size(f->f_lines);
if (row > nr_rows) { if (row > nr_rows) {
return IVY_ERR_EOF; return IVY_ERR_EOF;
} }
b_string *line = b_array_at(f->f_lines, row - 1); fx_string *line = fx_array_at(f->f_lines, row - 1);
const char *line_str = b_string_ptr(line); const char *line_str = fx_string_ptr(line);
size_t line_len = b_string_get_size(line, B_STRLEN_NORMAL); size_t line_len = fx_string_get_size(line, FX_STRLEN_NORMAL);
size_t copy_len = b_min(ulong, count, line_len); size_t copy_len = fx_min(ulong, count, line_len);
memcpy(buf, line_str, copy_len); memcpy(buf, line_str, copy_len);
buf[copy_len] = 0; buf[copy_len] = 0;
@@ -52,9 +52,9 @@ static enum ivy_status readline(
return feof(f->f_fp) ? IVY_ERR_EOF : IVY_ERR_IO_FAILURE; return feof(f->f_fp) ? IVY_ERR_EOF : IVY_ERR_IO_FAILURE;
} }
b_string *line_str = b_string_create_from_cstr(buf); fx_string *line_str = fx_string_create_from_cstr(buf);
b_array_append(f->f_lines, B_OBJECT(line_str)); fx_array_append(f->f_lines, FX_OBJECT(line_str));
b_string_unref(line_str); fx_string_unref(line_str);
*nr_read = strlen(buf); *nr_read = strlen(buf);
return IVY_OK; return IVY_OK;
@@ -79,8 +79,8 @@ enum ivy_status ivy_file_open(const char *path, struct ivy_file **out)
file->f_base.s_get_row = get_row; file->f_base.s_get_row = get_row;
file->f_base.s_readline = readline; file->f_base.s_readline = readline;
file->f_fp = fp; file->f_fp = fp;
file->f_path = b_strdup(path); file->f_path = fx_strdup(path);
file->f_lines = b_array_create(); file->f_lines = fx_array_create();
*out = file; *out = file;
@@ -89,7 +89,7 @@ enum ivy_status ivy_file_open(const char *path, struct ivy_file **out)
void ivy_file_close(struct ivy_file *file) void ivy_file_close(struct ivy_file *file)
{ {
b_array_unref(file->f_lines); fx_array_unref(file->f_lines);
free(file->f_path); free(file->f_path);
fclose(file->f_fp); fclose(file->f_fp);
free(file); free(file);

View File

@@ -1,6 +1,6 @@
#include <blue/core/queue.h> #include <fx/core/queue.h>
#include <blue/core/stringstream.h> #include <fx/core/stringstream.h>
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <ivy/ident.h> #include <ivy/ident.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -20,12 +20,12 @@ struct ivy_ident *ivy_ident_create(void)
void ivy_ident_destroy(struct ivy_ident *ident) void ivy_ident_destroy(struct ivy_ident *ident)
{ {
b_queue_entry *entry = b_queue_first(&ident->id_parts); fx_queue_entry *entry = fx_queue_first(&ident->id_parts);
while (entry) { while (entry) {
struct ivy_ident_part *part struct ivy_ident_part *part
= b_unbox(struct ivy_ident_part, entry, p_entry); = fx_unbox(struct ivy_ident_part, entry, p_entry);
b_queue_entry *next = b_queue_next(entry); fx_queue_entry *next = fx_queue_next(entry);
b_queue_delete(&ident->id_parts, entry); fx_queue_delete(&ident->id_parts, entry);
free(part->p_str); free(part->p_str);
free(part); free(part);
@@ -45,25 +45,25 @@ void ivy_ident_add_part(struct ivy_ident *ident, const char *s)
memset(part, 0x0, sizeof *part); memset(part, 0x0, sizeof *part);
part->p_str = b_strdup(s); part->p_str = fx_strdup(s);
b_queue_push_back(&ident->id_parts, &part->p_entry); fx_queue_push_back(&ident->id_parts, &part->p_entry);
} }
size_t ivy_ident_to_string(const struct ivy_ident *ident, char *out, size_t max) size_t ivy_ident_to_string(const struct ivy_ident *ident, char *out, size_t max)
{ {
b_stringstream *strv = b_stringstream_create_with_buffer(out, max); fx_stringstream *strv = fx_stringstream_create_with_buffer(out, max);
int i = 0; int i = 0;
b_queue_entry *entry = b_queue_first(&ident->id_parts); fx_queue_entry *entry = fx_queue_first(&ident->id_parts);
while (entry) { while (entry) {
if (i > 0) { if (i > 0) {
b_stream_write_char(strv, '.'); fx_stream_write_char(strv, '.');
} }
struct ivy_ident_part *part struct ivy_ident_part *part
= b_unbox(struct ivy_ident_part, entry, p_entry); = fx_unbox(struct ivy_ident_part, entry, p_entry);
b_stream_write_string(strv, part->p_str, NULL); fx_stream_write_string(strv, part->p_str, NULL);
i++; i++;
} }

View File

@@ -1,14 +1,14 @@
#ifndef IVY_COMMON_FILE_H_ #ifndef IVY_COMMON_FILE_H_
#define IVY_COMMON_FILE_H_ #define IVY_COMMON_FILE_H_
#include <blue/ds/array.h> #include <fx/ds/array.h>
#include <ivy/line-source.h> #include <ivy/line-source.h>
#include <ivy/misc.h> #include <ivy/misc.h>
#include <stdio.h> #include <stdio.h>
struct ivy_file { struct ivy_file {
struct ivy_line_source f_base; struct ivy_line_source f_base;
b_array *f_lines; fx_array *f_lines;
char *f_path; char *f_path;
FILE *f_fp; FILE *f_fp;
}; };

View File

@@ -1,17 +1,17 @@
#ifndef IVY_IDENT_H_ #ifndef IVY_IDENT_H_
#define IVY_IDENT_H_ #define IVY_IDENT_H_
#include <blue/core/queue.h> #include <fx/core/queue.h>
#include <ivy/misc.h> #include <ivy/misc.h>
#include <stddef.h> #include <stddef.h>
struct ivy_ident_part { struct ivy_ident_part {
char *p_str; char *p_str;
b_queue_entry p_entry; fx_queue_entry p_entry;
}; };
struct ivy_ident { struct ivy_ident {
b_queue id_parts; fx_queue id_parts;
}; };
IVY_API struct ivy_ident *ivy_ident_create(void); IVY_API struct ivy_ident *ivy_ident_create(void);

View File

@@ -1,7 +1,7 @@
#ifndef IVY_SELECTOR_H_ #ifndef IVY_SELECTOR_H_
#define IVY_SELECTOR_H_ #define IVY_SELECTOR_H_
#include <blue/core/queue.h> #include <fx/core/queue.h>
#include <ivy/status.h> #include <ivy/status.h>
enum ivy_selector_recipient { enum ivy_selector_recipient {
@@ -13,13 +13,13 @@ enum ivy_selector_recipient {
struct ivy_selector { struct ivy_selector {
enum ivy_selector_recipient sel_recipient; enum ivy_selector_recipient sel_recipient;
char *sel_name; char *sel_name;
b_queue sel_args; fx_queue sel_args;
}; };
struct ivy_selector_arg { struct ivy_selector_arg {
char *arg_label; char *arg_label;
char *arg_name; char *arg_name;
b_queue_entry arg_entry; fx_queue_entry arg_entry;
}; };
IVY_API enum ivy_status ivy_selector_create(struct ivy_selector **sel); IVY_API enum ivy_status ivy_selector_create(struct ivy_selector **sel);

View File

@@ -5,9 +5,9 @@
#define IVY_ERROR_VENDOR (ivy_error_vendor()) #define IVY_ERROR_VENDOR (ivy_error_vendor())
enum b_status; enum fx_status;
struct b_error_vendor; struct fx_error_vendor;
enum ivy_status { enum ivy_status {
IVY_OK = 0, IVY_OK = 0,
@@ -28,8 +28,8 @@ enum ivy_status {
}; };
IVY_API const char *ivy_status_to_string(enum ivy_status status); IVY_API const char *ivy_status_to_string(enum ivy_status status);
IVY_API const struct b_error_vendor *ivy_error_vendor(void); IVY_API const struct fx_error_vendor *ivy_error_vendor(void);
IVY_API enum ivy_status ivy_status_from_b_status(enum b_status status); IVY_API enum ivy_status ivy_status_from_b_status(enum fx_status status);
IVY_API enum ivy_status ivy_status_from_errno(int err); IVY_API enum ivy_status ivy_status_from_errno(int err);
#endif #endif

View File

@@ -1,6 +1,6 @@
#include <blue/core/queue.h> #include <fx/core/queue.h>
#include <blue/core/stringstream.h> #include <fx/core/stringstream.h>
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <ivy/selector.h> #include <ivy/selector.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -25,12 +25,12 @@ void ivy_selector_destroy(struct ivy_selector *sel)
free(sel->sel_name); free(sel->sel_name);
} }
b_queue_entry *entry = b_queue_first(&sel->sel_args); fx_queue_entry *entry = fx_queue_first(&sel->sel_args);
while (entry) { while (entry) {
struct ivy_selector_arg *arg struct ivy_selector_arg *arg
= b_unbox(struct ivy_selector_arg, entry, arg_entry); = fx_unbox(struct ivy_selector_arg, entry, arg_entry);
b_queue_entry *next = b_queue_next(entry); fx_queue_entry *next = fx_queue_next(entry);
b_queue_delete(&sel->sel_args, entry); fx_queue_delete(&sel->sel_args, entry);
if (arg->arg_label) { if (arg->arg_label) {
free(arg->arg_label); free(arg->arg_label);
@@ -56,7 +56,7 @@ void ivy_selector_set_recipient(
enum ivy_status ivy_selector_set_name(struct ivy_selector *sel, const char *name) enum ivy_status ivy_selector_set_name(struct ivy_selector *sel, const char *name)
{ {
sel->sel_name = b_strdup(name); sel->sel_name = fx_strdup(name);
return sel->sel_name ? IVY_OK : IVY_ERR_NO_MEMORY; return sel->sel_name ? IVY_OK : IVY_ERR_NO_MEMORY;
} }
@@ -71,7 +71,7 @@ enum ivy_status ivy_selector_add_arg(
memset(arg, 0x0, sizeof *arg); memset(arg, 0x0, sizeof *arg);
if (label) { if (label) {
arg->arg_label = b_strdup(label); arg->arg_label = fx_strdup(label);
if (!arg->arg_label) { if (!arg->arg_label) {
free(arg); free(arg);
@@ -80,7 +80,7 @@ enum ivy_status ivy_selector_add_arg(
} }
if (name) { if (name) {
arg->arg_name = b_strdup(name); arg->arg_name = fx_strdup(name);
if (!arg->arg_name) { if (!arg->arg_name) {
free(arg->arg_label); free(arg->arg_label);
@@ -89,49 +89,49 @@ enum ivy_status ivy_selector_add_arg(
} }
} }
b_queue_push_back(&sel->sel_args, &arg->arg_entry); fx_queue_push_back(&sel->sel_args, &arg->arg_entry);
return IVY_OK; return IVY_OK;
} }
size_t ivy_selector_to_string(const struct ivy_selector *sel, char *out, size_t max) size_t ivy_selector_to_string(const struct ivy_selector *sel, char *out, size_t max)
{ {
b_stringstream *str = b_stringstream_create_with_buffer(out, max); fx_stringstream *str = fx_stringstream_create_with_buffer(out, max);
switch (sel->sel_recipient) { switch (sel->sel_recipient) {
case IVY_SEL_OBJECT: case IVY_SEL_OBJECT:
b_stream_write_char(str, '-'); fx_stream_write_char(str, '-');
break; break;
case IVY_SEL_CLASS: case IVY_SEL_CLASS:
b_stream_write_char(str, '+'); fx_stream_write_char(str, '+');
break; break;
default: default:
break; break;
} }
if (sel->sel_name) { if (sel->sel_name) {
b_stream_write_string(str, sel->sel_name, NULL); fx_stream_write_string(str, sel->sel_name, NULL);
} }
if (sel->sel_name && !b_queue_empty(&sel->sel_args)) { if (sel->sel_name && !fx_queue_empty(&sel->sel_args)) {
b_stream_write_char(str, '('); fx_stream_write_char(str, '(');
} }
b_queue_entry *entry = b_queue_first(&sel->sel_args); fx_queue_entry *entry = fx_queue_first(&sel->sel_args);
while (entry) { while (entry) {
struct ivy_selector_arg *arg struct ivy_selector_arg *arg
= b_unbox(struct ivy_selector_arg, entry, arg_entry); = fx_unbox(struct ivy_selector_arg, entry, arg_entry);
b_stream_write_fmt( fx_stream_write_fmt(
str, NULL, "%s:", arg->arg_label ? arg->arg_label : "_"); str, NULL, "%s:", arg->arg_label ? arg->arg_label : "_");
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
if (sel->sel_name && !b_queue_empty(&sel->sel_args)) { if (sel->sel_name && !fx_queue_empty(&sel->sel_args)) {
b_stream_write_char(str, ')'); fx_stream_write_char(str, ')');
} }
size_t len = b_stringstream_get_length(str); size_t len = fx_stringstream_get_length(str);
b_stringstream_unref(str); fx_stringstream_unref(str);
return len; return len;
} }

View File

@@ -1,34 +1,34 @@
#include <blue/core/error.h> #include <fx/core/error.h>
#include <errno.h> #include <errno.h>
#include <ivy/status.h> #include <ivy/status.h>
static const b_error_definition error_defs[] = { static const fx_error_definition error_defs[] = {
B_ERROR_DEFINITION(IVY_OK, "OK", "Success"), FX_ERROR_DEFINITION(IVY_OK, "OK", "Success"),
B_ERROR_DEFINITION(IVY_ERR_EOF, "EOF", "Unexpected end of file"), FX_ERROR_DEFINITION(IVY_ERR_EOF, "EOF", "Unexpected end of file"),
B_ERROR_DEFINITION(IVY_ERR_IO_FAILURE, "IO_FAILURE", "I/O failure"), FX_ERROR_DEFINITION(IVY_ERR_IO_FAILURE, "IO_FAILURE", "I/O failure"),
B_ERROR_DEFINITION(IVY_ERR_BAD_SYNTAX, "BAD_SYNTAX", "Invalid syntax"), FX_ERROR_DEFINITION(IVY_ERR_BAD_SYNTAX, "BAD_SYNTAX", "Invalid syntax"),
B_ERROR_DEFINITION(IVY_ERR_NO_MEMORY, "NO_MEMORY", "Out of memory"), FX_ERROR_DEFINITION(IVY_ERR_NO_MEMORY, "NO_MEMORY", "Out of memory"),
B_ERROR_DEFINITION( FX_ERROR_DEFINITION(
IVY_ERR_NOT_SUPPORTED, "NOT_SUPPORTED", IVY_ERR_NOT_SUPPORTED, "NOT_SUPPORTED",
"Operation not supported"), "Operation not supported"),
B_ERROR_DEFINITION( FX_ERROR_DEFINITION(
IVY_ERR_INTERNAL_FAILURE, "INTERNAL_FAILURE", IVY_ERR_INTERNAL_FAILURE, "INTERNAL_FAILURE",
"Internal failure"), "Internal failure"),
B_ERROR_DEFINITION(IVY_ERR_BAD_STATE, "BAD_STATE", "Bad state"), FX_ERROR_DEFINITION(IVY_ERR_BAD_STATE, "BAD_STATE", "Bad state"),
B_ERROR_DEFINITION( FX_ERROR_DEFINITION(
IVY_ERR_INVALID_VALUE, "INVALID_VALUE", "Invalid value"), IVY_ERR_INVALID_VALUE, "INVALID_VALUE", "Invalid value"),
B_ERROR_DEFINITION(IVY_ERR_NO_ENTRY, "NO_ENTRY", "Name does not exist"), FX_ERROR_DEFINITION(IVY_ERR_NO_ENTRY, "NO_ENTRY", "Name does not exist"),
B_ERROR_DEFINITION( FX_ERROR_DEFINITION(
IVY_ERR_NAME_EXISTS, "NAME_EXISTS", "Name already exists"), IVY_ERR_NAME_EXISTS, "NAME_EXISTS", "Name already exists"),
B_ERROR_DEFINITION(IVY_ERR_BAD_FORMAT, "BAD_FORMAT", "Bad format"), FX_ERROR_DEFINITION(IVY_ERR_BAD_FORMAT, "BAD_FORMAT", "Bad format"),
B_ERROR_DEFINITION( FX_ERROR_DEFINITION(
IVY_ERR_PARSE_FAILURE, "PARSE_FAILURE", "Parse failure"), IVY_ERR_PARSE_FAILURE, "PARSE_FAILURE", "Parse failure"),
B_ERROR_DEFINITION( FX_ERROR_DEFINITION(
IVY_ERR_CODEGEN_FAILURE, "CODEGEN_FAILURE", IVY_ERR_CODEGEN_FAILURE, "CODEGEN_FAILURE",
"Code generation failure"), "Code generation failure"),
}; };
static const b_error_vendor error_vendor = { static const fx_error_vendor error_vendor = {
.v_name = "Ivy", .v_name = "Ivy",
.v_error_definitions = error_defs, .v_error_definitions = error_defs,
.v_error_definitions_length = sizeof error_defs, .v_error_definitions_length = sizeof error_defs,
@@ -39,7 +39,7 @@ const char *ivy_status_to_string(enum ivy_status status)
return error_defs[status].err_message; return error_defs[status].err_message;
} }
const struct b_error_vendor *ivy_error_vendor(void) const struct fx_error_vendor *ivy_error_vendor(void)
{ {
return &error_vendor; return &error_vendor;
} }
@@ -48,12 +48,12 @@ const struct b_error_vendor *ivy_error_vendor(void)
case (from): \ case (from): \
return (to) return (to)
enum ivy_status ivy_status_from_b_status(enum b_status status) enum ivy_status ivy_status_from_b_status(enum fx_status status)
{ {
switch (status) { switch (status) {
ENUM_CONVERT(B_SUCCESS, IVY_OK); ENUM_CONVERT(FX_SUCCESS, IVY_OK);
ENUM_CONVERT(B_ERR_NAME_EXISTS, IVY_ERR_NAME_EXISTS); ENUM_CONVERT(FX_ERR_NAME_EXISTS, IVY_ERR_NAME_EXISTS);
ENUM_CONVERT(B_ERR_NO_MEMORY, IVY_ERR_NO_MEMORY); ENUM_CONVERT(FX_ERR_NO_MEMORY, IVY_ERR_NO_MEMORY);
default: default:
return IVY_ERR_INTERNAL_FAILURE; return IVY_ERR_INTERNAL_FAILURE;
} }

View File

@@ -12,4 +12,4 @@ endif ()
target_include_directories(ivy-diag PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/) target_include_directories(ivy-diag PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/)
target_compile_definitions(ivy-diag PRIVATE IVY_EXPORT=1 IVY_STATIC=${IVY_STATIC}) target_compile_definitions(ivy-diag PRIVATE IVY_EXPORT=1 IVY_STATIC=${IVY_STATIC})
target_link_libraries(ivy-diag ivy-common Bluelib::Core Bluelib::Ds Bluelib::Term) target_link_libraries(ivy-diag ivy-common FX::Core FX::Ds FX::Term)

View File

@@ -52,12 +52,12 @@ void ivy_diag_ctx_write(
struct ivy_diag_ctx *ctx, enum ivy_diag_format format, struct ivy_diag_ctx *ctx, enum ivy_diag_format format,
struct ivy_diag_stream *stream) struct ivy_diag_stream *stream)
{ {
b_queue_entry *entry = b_queue_first(&ctx->ctx_diags); fx_queue_entry *entry = fx_queue_first(&ctx->ctx_diags);
while (entry) { while (entry) {
struct ivy_diag *diag struct ivy_diag *diag
= b_unbox(struct ivy_diag, entry, diag_entry); = fx_unbox(struct ivy_diag, entry, diag_entry);
diag_write(ctx, diag, format, stream); diag_write(ctx, diag, format, stream);
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
} }
@@ -73,7 +73,7 @@ struct ivy_diag *ivy_diag_ctx_create_diag(
out->diag_class = diag_class; out->diag_class = diag_class;
out->diag_parent = ctx; out->diag_parent = ctx;
b_queue_push_back(&ctx->ctx_diags, &out->diag_entry); fx_queue_push_back(&ctx->ctx_diags, &out->diag_entry);
return out; return out;
} }

View File

@@ -1,7 +1,7 @@
#ifndef _DIAG_CTX_H_ #ifndef _DIAG_CTX_H_
#define _DIAG_CTX_H_ #define _DIAG_CTX_H_
#include <blue/core/queue.h> #include <fx/core/queue.h>
#include <ivy/diag.h> #include <ivy/diag.h>
struct ivy_line_source; struct ivy_line_source;
@@ -15,7 +15,7 @@ struct ivy_diag_ctx {
const struct ivy_diag_msg *ctx_msg; const struct ivy_diag_msg *ctx_msg;
size_t ctx_nr_msg; size_t ctx_nr_msg;
b_queue ctx_diags; fx_queue ctx_diags;
}; };
extern const struct ivy_diag_class *diag_ctx_get_class( extern const struct ivy_diag_class *diag_ctx_get_class(

View File

@@ -3,7 +3,7 @@
#include "ctx.h" #include "ctx.h"
#include <assert.h> #include <assert.h>
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <ivy/diag.h> #include <ivy/diag.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -18,7 +18,7 @@ struct diag_c_msg *diag_msg_create(const struct ivy_diag_msg *content)
memset(out, 0x0, sizeof *out); memset(out, 0x0, sizeof *out);
out->msg_base.c_type = DIAG_COMPONENT_MSG; out->msg_base.c_type = DIAG_COMPONENT_MSG;
out->msg_content = b_strdup(content->msg_content); out->msg_content = fx_strdup(content->msg_content);
return out; return out;
} }
@@ -77,7 +77,7 @@ void ivy_diag_push_msg(struct ivy_diag *diag, unsigned long msg, ...)
return; return;
} }
b_queue_push_back(&diag->diag_components, &c_msg->msg_base.c_entry); fx_queue_push_back(&diag->diag_components, &c_msg->msg_base.c_entry);
} }
void ivy_diag_push_snippet( void ivy_diag_push_snippet(
@@ -92,5 +92,5 @@ void ivy_diag_push_snippet(
return; return;
} }
b_queue_push_back(&diag->diag_components, &c_snippet->s_base.c_entry); fx_queue_push_back(&diag->diag_components, &c_snippet->s_base.c_entry);
} }

View File

@@ -1,7 +1,7 @@
#ifndef _DIAG_DIAG_H_ #ifndef _DIAG_DIAG_H_
#define _DIAG_DIAG_H_ #define _DIAG_DIAG_H_
#include <blue/core/queue.h> #include <fx/core/queue.h>
#include <stddef.h> #include <stddef.h>
struct ivy_diag_msg; struct ivy_diag_msg;
@@ -14,7 +14,7 @@ enum diag_component_type {
struct diag_component { struct diag_component {
enum diag_component_type c_type; enum diag_component_type c_type;
b_queue_entry c_entry; fx_queue_entry c_entry;
}; };
struct diag_c_msg { struct diag_c_msg {
@@ -38,8 +38,8 @@ struct ivy_diag {
unsigned long diag_class; unsigned long diag_class;
unsigned long diag_row, diag_col; unsigned long diag_row, diag_col;
b_queue_entry diag_entry; fx_queue_entry diag_entry;
b_queue diag_components; fx_queue diag_components;
}; };
extern struct diag_c_msg *diag_msg_create(const struct ivy_diag_msg *content); extern struct diag_c_msg *diag_msg_create(const struct ivy_diag_msg *content);

View File

@@ -44,7 +44,7 @@ struct ivy_line_source;
struct ivy_diag_ctx; struct ivy_diag_ctx;
struct ivy_diag; struct ivy_diag;
struct b_tty; struct fx_tty;
enum ivy_diag_stream_flags { enum ivy_diag_stream_flags {
IVY_DIAG_STREAM_F_NONE = 0x00u, IVY_DIAG_STREAM_F_NONE = 0x00u,
@@ -64,7 +64,7 @@ struct ivy_diag_stream {
int s_esc; int s_esc;
union { union {
struct b_tty *s_tty; struct fx_tty *s_tty;
FILE *s_fp; FILE *s_fp;
}; };
}; };
@@ -136,7 +136,7 @@ struct ivy_diag_msg {
extern void ivy_diag_stream_init_file(struct ivy_diag_stream *stream, FILE *fp); extern void ivy_diag_stream_init_file(struct ivy_diag_stream *stream, FILE *fp);
extern void ivy_diag_stream_init_tty( extern void ivy_diag_stream_init_tty(
struct ivy_diag_stream *stream, struct b_tty *tty); struct ivy_diag_stream *stream, struct fx_tty *tty);
extern enum ivy_status ivy_diag_ctx_create(struct ivy_diag_ctx **out); extern enum ivy_status ivy_diag_ctx_create(struct ivy_diag_ctx **out);
extern void ivy_diag_ctx_destroy(struct ivy_diag_ctx *ctx); extern void ivy_diag_ctx_destroy(struct ivy_diag_ctx *ctx);

View File

@@ -1,6 +1,6 @@
#include "stream.h" #include "stream.h"
#include <blue/term/tty.h> #include <fx/term/tty.h>
#include <string.h> #include <string.h>
void ivy_diag_stream_init_file(struct ivy_diag_stream *stream, FILE *fp) void ivy_diag_stream_init_file(struct ivy_diag_stream *stream, FILE *fp)
@@ -14,7 +14,7 @@ void ivy_diag_stream_init_file(struct ivy_diag_stream *stream, FILE *fp)
stream->s_col = 1; stream->s_col = 1;
} }
void ivy_diag_stream_init_tty(struct ivy_diag_stream *stream, struct b_tty *tty) void ivy_diag_stream_init_tty(struct ivy_diag_stream *stream, struct fx_tty *tty)
{ {
memset(stream, 0x0, sizeof *stream); memset(stream, 0x0, sizeof *stream);
@@ -41,7 +41,7 @@ enum ivy_status diag_stream_get_dimensions(
break; break;
case IVY_DIAG_STREAM_TTY: { case IVY_DIAG_STREAM_TTY: {
unsigned int w, h; unsigned int w, h;
b_tty_get_dimensions(stream->s_tty, &w, &h); fx_tty_get_dimensions(stream->s_tty, &w, &h);
if (out_rows) { if (out_rows) {
*out_rows = h; *out_rows = h;
} }
@@ -69,7 +69,7 @@ enum ivy_status diag_stream_putc(struct ivy_diag_stream *stream, char c)
status = (ferror(stream->s_fp)) ? IVY_ERR_IO_FAILURE : IVY_OK; status = (ferror(stream->s_fp)) ? IVY_ERR_IO_FAILURE : IVY_OK;
break; break;
case IVY_DIAG_STREAM_TTY: case IVY_DIAG_STREAM_TTY:
b_tty_putc(stream->s_tty, 0, c); fx_tty_putc(stream->s_tty, 0, c);
status = IVY_OK; status = IVY_OK;
break; break;
default: default:

View File

@@ -4,9 +4,9 @@
#include "../write.h" #include "../write.h"
#include <assert.h> #include <assert.h>
#include <blue/core/stringstream.h> #include <fx/core/stringstream.h>
#include <blue/term/print.h> #include <fx/term/print.h>
#include <blue/term/tty.h> #include <fx/term/tty.h>
#include <ctype.h> #include <ctype.h>
#include <ivy/line-source.h> #include <ivy/line-source.h>
#include <stdlib.h> #include <stdlib.h>
@@ -25,7 +25,7 @@ struct snippet_print_ctx {
size_t ctx_line_buf_ptr; size_t ctx_line_buf_ptr;
bool ctx_has_underline; bool ctx_has_underline;
b_stringstream *ctx_underline; fx_stringstream *ctx_underline;
struct diag_c_snippet *ctx_snippet; struct diag_c_snippet *ctx_snippet;
@@ -67,23 +67,23 @@ struct snippet_print_ctx {
#define STREAM_COLOUR_ERROR_B(stream, str) \ #define STREAM_COLOUR_ERROR_B(stream, str) \
if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \ if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \
b_stream_write_string(str, __STREAM_COLOUR_ERROR, NULL); \ fx_stream_write_string(str, __STREAM_COLOUR_ERROR, NULL); \
} }
#define STREAM_COLOUR_WARN_B(stream, str) \ #define STREAM_COLOUR_WARN_B(stream, str) \
if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \ if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \
b_stream_write_string(str, __STREAM_COLOUR_WARN, NULL); \ fx_stream_write_string(str, __STREAM_COLOUR_WARN, NULL); \
} }
#define STREAM_COLOUR_HINT_B(stream, str) \ #define STREAM_COLOUR_HINT_B(stream, str) \
if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \ if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \
b_stream_write_string(str, __STREAM_COLOUR_HINT, NULL); \ fx_stream_write_string(str, __STREAM_COLOUR_HINT, NULL); \
} }
#define STREAM_COLOUR_ACCENT_B(stream, str) \ #define STREAM_COLOUR_ACCENT_B(stream, str) \
if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \ if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \
b_stream_write_string(str, __STREAM_COLOUR_ACCENT, NULL); \ fx_stream_write_string(str, __STREAM_COLOUR_ACCENT, NULL); \
} }
#define STREAM_COLOUR_RESET_B(stream, str) \ #define STREAM_COLOUR_RESET_B(stream, str) \
if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \ if (DIAG_STREAM_FLAG_SET(stream, IVY_DIAG_STREAM_F_COLOUR)) { \
b_stream_write_string(str, __STREAM_COLOUR_RESET, NULL); \ fx_stream_write_string(str, __STREAM_COLOUR_RESET, NULL); \
} }
static void print_header( static void print_header(
@@ -143,12 +143,12 @@ static void print_msg(
struct ivy_diag_stream *stream) struct ivy_diag_stream *stream)
{ {
if (stream->s_type == IVY_DIAG_STREAM_TTY) { if (stream->s_type == IVY_DIAG_STREAM_TTY) {
b_paragraph_format format = { fx_paragraph_format format = {
.p_left_margin = 2, .p_left_margin = 2,
.p_right_margin = 2, .p_right_margin = 2,
}; };
b_print_paragraph(msg->msg_content, stream->s_tty, &format); fx_print_paragraph(msg->msg_content, stream->s_tty, &format);
} else { } else {
diag_stream_puts(stream, " "); diag_stream_puts(stream, " ");
diag_stream_puts(stream, msg->msg_content); diag_stream_puts(stream, msg->msg_content);
@@ -218,7 +218,7 @@ static bool amendment_contains_cell(
} }
limit = a->a_replace.a_col limit = a->a_replace.a_col
+ b_max(ulong, a->a_replace.a_length, a->__x) - 1; + fx_max(ulong, a->a_replace.a_length, a->__x) - 1;
if (col > limit) { if (col > limit) {
return false; return false;
@@ -316,7 +316,7 @@ static enum ivy_status read_row(struct snippet_print_ctx *ctx, size_t row)
ctx->ctx_line_buf_ptr = 0; ctx->ctx_line_buf_ptr = 0;
ctx->ctx_has_underline = false; ctx->ctx_has_underline = false;
ctx->ctx_underline = b_stringstream_create_with_buffer( ctx->ctx_underline = fx_stringstream_create_with_buffer(
ctx->ctx_underline_buf, sizeof ctx->ctx_underline_buf); ctx->ctx_underline_buf, sizeof ctx->ctx_underline_buf);
size_t nr_read; size_t nr_read;
@@ -380,7 +380,7 @@ static int get_char(struct snippet_print_ctx *ctx)
static void update_underline(struct snippet_print_ctx *ctx) static void update_underline(struct snippet_print_ctx *ctx)
{ {
if (!ctx->ctx_hl) { if (!ctx->ctx_hl) {
b_stream_write_char(ctx->ctx_underline, ' '); fx_stream_write_char(ctx->ctx_underline, ' ');
return; return;
} }
@@ -388,10 +388,10 @@ static void update_underline(struct snippet_print_ctx *ctx)
case IVY_DIAG_HIGHLIGHT_ERROR: case IVY_DIAG_HIGHLIGHT_ERROR:
case IVY_DIAG_HIGHLIGHT_WARNING: case IVY_DIAG_HIGHLIGHT_WARNING:
case IVY_DIAG_HIGHLIGHT_HINT: case IVY_DIAG_HIGHLIGHT_HINT:
b_stream_write_char(ctx->ctx_underline, '^'); fx_stream_write_char(ctx->ctx_underline, '^');
break; break;
default: default:
b_stream_write_char(ctx->ctx_underline, ' '); fx_stream_write_char(ctx->ctx_underline, ' ');
break; break;
} }
} }
@@ -481,15 +481,15 @@ static enum ivy_status write(
print_header(ctx, diag, stream); print_header(ctx, diag, stream);
print_location(ctx, diag, stream); print_location(ctx, diag, stream);
b_queue_entry *entry = b_queue_first(&diag->diag_components); fx_queue_entry *entry = fx_queue_first(&diag->diag_components);
while (entry) { while (entry) {
struct diag_component *c struct diag_component *c
= b_unbox(struct diag_component, entry, c_entry); = fx_unbox(struct diag_component, entry, c_entry);
diag_stream_putc(stream, '\n'); diag_stream_putc(stream, '\n');
print_component(ctx, diag, c, stream); print_component(ctx, diag, c, stream);
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
return IVY_OK; return IVY_OK;

View File

@@ -20,8 +20,8 @@ target_link_libraries(
ivy-asm ivy-asm
ivy-lang ivy-lang
ivy-common ivy-common
Bluelib::Core FX::Core
Bluelib::Ds FX::Ds
Bluelib::Cmd) FX::Cmd)
target_compile_definitions(ivy PRIVATE IVY_STATIC=${IVY_STATIC}) target_compile_definitions(ivy PRIVATE IVY_STATIC=${IVY_STATIC})

View File

@@ -1,9 +1,9 @@
#include "../debug.h" #include "../debug.h"
#include "cmd.h" #include "cmd.h"
#include <blue/cmd.h> #include <fx/cmd.h>
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <blue/term.h> #include <fx/term.h>
#include <errno.h> #include <errno.h>
#include <ivy/asm/assembler.h> #include <ivy/asm/assembler.h>
#include <ivy/asm/lex.h> #include <ivy/asm/lex.h>
@@ -24,15 +24,15 @@ static int assemble_file(const char *in_path, const char *out_path)
struct ivy_file *src = NULL; struct ivy_file *src = NULL;
status = ivy_file_open(in_path, &src); status = ivy_file_open(in_path, &src);
if (!src) { if (!src) {
b_err("cannot open source file '%s'", in_path); fx_err("cannot open source file '%s'", in_path);
b_i("reason: %s", ivy_status_to_string(status)); fx_i("reason: %s", ivy_status_to_string(status));
return -1; return -1;
} }
FILE *out = fopen(out_path, "w+b"); FILE *out = fopen(out_path, "w+b");
if (!out) { if (!out) {
b_err("cannot open output file '%s'", out_path); fx_err("cannot open output file '%s'", out_path);
b_i("reason: %s", strerror(errno)); fx_i("reason: %s", strerror(errno));
return -1; return -1;
} }
@@ -40,8 +40,8 @@ static int assemble_file(const char *in_path, const char *out_path)
status = ivy_assembler_create(out, &as); status = ivy_assembler_create(out, &as);
if (status != IVY_OK) { if (status != IVY_OK) {
b_err("failed to initialise Ivy assembler"); fx_err("failed to initialise Ivy assembler");
b_i("reason: %s", ivy_status_to_string(status)); fx_i("reason: %s", ivy_status_to_string(status));
ivy_file_close(src); ivy_file_close(src);
fclose(out); fclose(out);
@@ -51,8 +51,8 @@ static int assemble_file(const char *in_path, const char *out_path)
struct ivy_asm_lexer *lex; struct ivy_asm_lexer *lex;
status = ivy_asm_lexer_create(&lex); status = ivy_asm_lexer_create(&lex);
if (status != IVY_OK) { if (status != IVY_OK) {
b_err("failed to initialise Ivy assembly lexer"); fx_err("failed to initialise Ivy assembly lexer");
b_i("reason: %s", ivy_status_to_string(status)); fx_i("reason: %s", ivy_status_to_string(status));
ivy_file_close(src); ivy_file_close(src);
fclose(out); fclose(out);
@@ -63,8 +63,8 @@ static int assemble_file(const char *in_path, const char *out_path)
struct ivy_asm_parser *parser; struct ivy_asm_parser *parser;
status = ivy_asm_parser_create(&parser); status = ivy_asm_parser_create(&parser);
if (status != IVY_OK) { if (status != IVY_OK) {
b_err("failed to initialise Ivy assembly parser"); fx_err("failed to initialise Ivy assembly parser");
b_i("reason: %s", ivy_status_to_string(status)); fx_i("reason: %s", ivy_status_to_string(status));
ivy_asm_lexer_destroy(lex); ivy_asm_lexer_destroy(lex);
ivy_file_close(src); ivy_file_close(src);
@@ -85,8 +85,8 @@ static int assemble_file(const char *in_path, const char *out_path)
} }
if (status != IVY_OK) { if (status != IVY_OK) {
b_err("failed to parse '%s'", in_path); fx_err("failed to parse '%s'", in_path);
b_i("reason: lex error (%s)", fx_i("reason: lex error (%s)",
ivy_status_to_string(ivy_asm_lexer_get_status(lex))); ivy_status_to_string(ivy_asm_lexer_get_status(lex)));
break; break;
} }
@@ -95,8 +95,8 @@ static int assemble_file(const char *in_path, const char *out_path)
status = ivy_asm_parser_push_token(parser, tok); status = ivy_asm_parser_push_token(parser, tok);
if (status != IVY_OK) { if (status != IVY_OK) {
b_err("failed to parse '%s'", in_path); fx_err("failed to parse '%s'", in_path);
b_i("reason: parse error (%s)", fx_i("reason: parse error (%s)",
ivy_status_to_string(status)); ivy_status_to_string(status));
break; break;
} }
@@ -112,31 +112,31 @@ static int assemble_file(const char *in_path, const char *out_path)
return r; return r;
} }
static b_string *get_source_filename(const char *src_path) static fx_string *get_source_filename(const char *src_path)
{ {
b_string *name = b_string_create(); fx_string *name = fx_string_create();
for (unsigned int i = 0; src_path[i]; i++) { for (unsigned int i = 0; src_path[i]; i++) {
if (src_path[i] == '/' || src_path[i] == '\\') { if (src_path[i] == '/' || src_path[i] == '\\') {
b_string_clear(name); fx_string_clear(name);
continue; continue;
} }
char s[] = {src_path[i], 0}; char s[] = {src_path[i], 0};
b_string_append_cstr(name, s); fx_string_append_cstr(name, s);
} }
if (b_string_get_size(name, B_STRLEN_NORMAL) == 0) { if (fx_string_get_size(name, FX_STRLEN_NORMAL) == 0) {
b_string_unref(name); fx_string_unref(name);
name = NULL; name = NULL;
} }
return name; return name;
} }
static b_string *generate_object_filename(const char *src_filename) static fx_string *generate_object_filename(const char *src_filename)
{ {
b_string *name = b_string_create(); fx_string *name = fx_string_create();
for (unsigned int i = 0; src_filename[i]; i++) { for (unsigned int i = 0; src_filename[i]; i++) {
if (src_filename[i] == '.') { if (src_filename[i] == '.') {
@@ -144,53 +144,53 @@ static b_string *generate_object_filename(const char *src_filename)
} }
char s[] = {src_filename[i], 0}; char s[] = {src_filename[i], 0};
b_string_append_cstr(name, s); fx_string_append_cstr(name, s);
} }
if (b_string_get_size(name, B_STRLEN_NORMAL) == 0) { if (fx_string_get_size(name, FX_STRLEN_NORMAL) == 0) {
b_string_append_cstr(name, "out"); fx_string_append_cstr(name, "out");
} }
b_string_append_cstr(name, ".io"); fx_string_append_cstr(name, ".io");
return name; return name;
} }
static int assemble(const b_command *cmd, const b_arglist *args, const b_array *_) static int assemble(const fx_command *cmd, const fx_arglist *args, const fx_array *_)
{ {
const char *in_path = NULL; const char *in_path = NULL;
const char *out_path = NULL; const char *out_path = NULL;
b_string *in_name = NULL; fx_string *in_name = NULL;
b_string *out_name = NULL; fx_string *out_name = NULL;
b_arglist_get_string( fx_arglist_get_string(
args, B_COMMAND_INVALID_ID, ARG_SOURCE_FILE, 0, &in_path); args, FX_COMMAND_INVALID_ID, ARG_SOURCE_FILE, 0, &in_path);
if (!in_path) { if (!in_path) {
b_err("no source file specified."); fx_err("no source file specified.");
return -1; return -1;
} }
in_name = get_source_filename(in_path); in_name = get_source_filename(in_path);
if (!in_path) { if (!in_path) {
b_err("source filepath is not a file."); fx_err("source filepath is not a file.");
return -1; return -1;
} }
b_arglist_get_string(args, OPT_OUT_FILE, ARG_OUT_FILE, 0, &out_path); fx_arglist_get_string(args, OPT_OUT_FILE, ARG_OUT_FILE, 0, &out_path);
if (!out_path) { if (!out_path) {
out_name = generate_object_filename(b_string_ptr(in_name)); out_name = generate_object_filename(fx_string_ptr(in_name));
out_path = b_string_ptr(out_name); out_path = fx_string_ptr(out_name);
} }
int r = assemble_file(in_path, out_path); int r = assemble_file(in_path, out_path);
b_string_unref(in_name); fx_string_unref(in_name);
b_string_unref(out_name); fx_string_unref(out_name);
return r; return r;
#if 0 #if 0
const char *path = NULL; const char *path = NULL;
b_arglist_get_string(args, OPT_OUT_FILE, ARG_OUT_FILE, 0, &path); fx_arglist_get_string(args, OPT_OUT_FILE, ARG_OUT_FILE, 0, &path);
if (!path) { if (!path) {
printf("no output path specified.\n"); printf("no output path specified.\n");
@@ -202,8 +202,8 @@ static int assemble(const b_command *cmd, const b_arglist *args, const b_array *
enum ivy_status status = ivy_assembler_create(out, &as); enum ivy_status status = ivy_assembler_create(out, &as);
if (status != IVY_OK) { if (status != IVY_OK) {
b_err("failed to initialise assembler"); fx_err("failed to initialise assembler");
b_i("reason: ", ivy_status_to_string(status)); fx_i("reason: ", ivy_status_to_string(status));
fclose(out); fclose(out);
return -1; return -1;
} }
@@ -231,32 +231,32 @@ static int assemble(const b_command *cmd, const b_arglist *args, const b_array *
B_COMMAND(CMD_ASSEMBLE, CMD_ROOT) B_COMMAND(CMD_ASSEMBLE, CMD_ROOT)
{ {
B_COMMAND_NAME("assemble"); FX_COMMAND_NAME("assemble");
B_COMMAND_SHORT_NAME('A'); FX_COMMAND_SHORT_NAME('A');
B_COMMAND_DESC( FX_COMMAND_DESC(
"assemble one or more Ivy assembly source files into Ivy " "assemble one or more Ivy assembly source files into Ivy "
"object files."); "object files.");
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT); FX_COMMAND_FLAGS(FX_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_FUNCTION(assemble); FX_COMMAND_FUNCTION(assemble);
B_COMMAND_ARG(ARG_SOURCE_FILE) FX_COMMAND_ARG(ARG_SOURCE_FILE)
{ {
B_ARG_NAME("source file"); FX_ARG_NAME("source file");
B_ARG_DESC("the .iasm assembly file to compile."); FX_ARG_DESC("the .iasm assembly file to compile.");
B_ARG_NR_VALUES(1); FX_ARG_NR_VALUES(1);
} }
B_COMMAND_OPTION(OPT_OUT_FILE) FX_COMMAND_OPTION(OPT_OUT_FILE)
{ {
B_OPTION_SHORT_NAME('o'); FX_OPTION_SHORT_NAME('o');
B_OPTION_LONG_NAME("out"); FX_OPTION_LONG_NAME("out");
B_OPTION_DESC("the path to write the output binary file to."); FX_OPTION_DESC("the path to write the output binary file to.");
B_OPTION_ARG(ARG_OUT_FILE) FX_OPTION_ARG(ARG_OUT_FILE)
{ {
B_ARG_NAME("path"); FX_ARG_NAME("path");
B_ARG_NR_VALUES(1); FX_ARG_NR_VALUES(1);
} }
} }
B_COMMAND_HELP_OPTION(); FX_COMMAND_HELP_OPTION();
} }

View File

@@ -2,9 +2,9 @@
#include "cmd.h" #include "cmd.h"
#include "mie/select/builder.h" #include "mie/select/builder.h"
#include <blue/cmd.h> #include <fx/cmd.h>
#include <blue/core/error.h> #include <fx/core/error.h>
#include <blue/term.h> #include <fx/term.h>
#include <errno.h> #include <errno.h>
#include <ivy/asm/mie.h> #include <ivy/asm/mie.h>
#include <ivy/diag.h> #include <ivy/diag.h>
@@ -68,19 +68,19 @@ static enum ivy_status node_codegen(
return ivy_codegen_push_node(ctx->codegen, node, node->n_it.it_depth); return ivy_codegen_push_node(ctx->codegen, node, node->n_it.it_depth);
} }
static b_result compile_ctx_init(struct compile_ctx *ctx, const b_arglist *args) static fx_result compile_ctx_init(struct compile_ctx *ctx, const fx_arglist *args)
{ {
memset(ctx, 0x0, sizeof *ctx); memset(ctx, 0x0, sizeof *ctx);
b_arglist_get_count(args, OPT_SHOW_LEX_TOKENS, B_COMMAND_INVALID_ID) fx_arglist_get_count(args, OPT_SHOW_LEX_TOKENS, FX_COMMAND_INVALID_ID)
&& (ctx->flags |= FLAG_SHOW_LEX_TOKENS); && (ctx->flags |= FLAG_SHOW_LEX_TOKENS);
b_arglist_get_count(args, OPT_SHOW_AST_NODES, B_COMMAND_INVALID_ID) fx_arglist_get_count(args, OPT_SHOW_AST_NODES, FX_COMMAND_INVALID_ID)
&& (ctx->flags |= FLAG_SHOW_AST_NODES); && (ctx->flags |= FLAG_SHOW_AST_NODES);
b_arglist_get_count(args, OPT_SHOW_IR, B_COMMAND_INVALID_ID) fx_arglist_get_count(args, OPT_SHOW_IR, FX_COMMAND_INVALID_ID)
&& (ctx->flags |= FLAG_SHOW_IR); && (ctx->flags |= FLAG_SHOW_IR);
b_arglist_get_count(args, OPT_SHOW_ISEL_PRE, B_COMMAND_INVALID_ID) fx_arglist_get_count(args, OPT_SHOW_ISEL_PRE, FX_COMMAND_INVALID_ID)
&& (ctx->flags |= FLAG_SHOW_PRE_SELECT_GRAPH); && (ctx->flags |= FLAG_SHOW_PRE_SELECT_GRAPH);
b_arglist_get_count(args, OPT_SHOW_ISEL_POST, B_COMMAND_INVALID_ID) fx_arglist_get_count(args, OPT_SHOW_ISEL_POST, FX_COMMAND_INVALID_ID)
&& (ctx->flags |= FLAG_SHOW_POST_SELECT_GRAPH); && (ctx->flags |= FLAG_SHOW_POST_SELECT_GRAPH);
enum mie_status mie_status = MIE_SUCCESS; enum mie_status mie_status = MIE_SUCCESS;
@@ -96,14 +96,14 @@ static b_result compile_ctx_init(struct compile_ctx *ctx, const b_arglist *args)
= mie_select_builder_create(ctx->mie_ctx, ivy_asm_mie_target()); = mie_select_builder_create(ctx->mie_ctx, ivy_asm_mie_target());
ivy_lang_diag_ctx_init(ctx->diag); ivy_lang_diag_ctx_init(ctx->diag);
ivy_diag_stream_init_tty(&ctx->diag_stream, b_stdtty); ivy_diag_stream_init_tty(&ctx->diag_stream, fx_stdtty);
ivy_lexer_set_diag_ctx(ctx->lex, ctx->diag); ivy_lexer_set_diag_ctx(ctx->lex, ctx->diag);
ivy_parser_set_diag_ctx(ctx->parser, ctx->diag); ivy_parser_set_diag_ctx(ctx->parser, ctx->diag);
return B_RESULT_SUCCESS; return FX_RESULT_SUCCESS;
} }
static b_result compile_ctx_cleanup(struct compile_ctx *ctx) static fx_result compile_ctx_cleanup(struct compile_ctx *ctx)
{ {
if (ctx->mod) { if (ctx->mod) {
mie_value_destroy(MIE_VALUE(ctx->mod)); mie_value_destroy(MIE_VALUE(ctx->mod));
@@ -139,10 +139,10 @@ static b_result compile_ctx_cleanup(struct compile_ctx *ctx)
mie_ctx_destroy(ctx->mie_ctx); mie_ctx_destroy(ctx->mie_ctx);
} }
return B_RESULT_SUCCESS; return FX_RESULT_SUCCESS;
} }
static b_result open_file(struct compile_ctx *ctx, const char *path) static fx_result open_file(struct compile_ctx *ctx, const char *path)
{ {
enum ivy_status status = ivy_file_open(path, &ctx->src); enum ivy_status status = ivy_file_open(path, &ctx->src);
@@ -151,10 +151,10 @@ static b_result open_file(struct compile_ctx *ctx, const char *path)
ctx->src_path = path; ctx->src_path = path;
return B_RESULT_SUCCESS; return FX_RESULT_SUCCESS;
} }
static b_result parse_file_tokens(struct compile_ctx *ctx) static fx_result parse_file_tokens(struct compile_ctx *ctx)
{ {
enum ivy_status status = IVY_OK; enum ivy_status status = IVY_OK;
@@ -166,7 +166,7 @@ static b_result parse_file_tokens(struct compile_ctx *ctx)
ivy_diag_ctx_write( ivy_diag_ctx_write(
ctx->diag, IVY_DIAG_FORMAT_PRETTY, ctx->diag, IVY_DIAG_FORMAT_PRETTY,
&ctx->diag_stream); &ctx->diag_stream);
return b_error_with_code( return fx_error_with_code(
IVY_ERROR_VENDOR, IVY_ERR_BAD_SYNTAX); IVY_ERROR_VENDOR, IVY_ERR_BAD_SYNTAX);
} }
@@ -181,12 +181,12 @@ static b_result parse_file_tokens(struct compile_ctx *ctx)
ctx->diag, IVY_DIAG_FORMAT_PRETTY, ctx->diag, IVY_DIAG_FORMAT_PRETTY,
&ctx->diag_stream); &ctx->diag_stream);
ivy_token_destroy(tok); ivy_token_destroy(tok);
return b_error_with_code( return fx_error_with_code(
IVY_ERROR_VENDOR, IVY_ERR_BAD_SYNTAX); IVY_ERROR_VENDOR, IVY_ERR_BAD_SYNTAX);
} }
if (status != IVY_OK) { if (status != IVY_OK) {
return b_error_caused_by_code( return fx_error_caused_by_code(
IVY_ERROR_VENDOR, IVY_ERR_PARSE_FAILURE, IVY_ERROR_VENDOR, IVY_ERR_PARSE_FAILURE,
IVY_ERROR_VENDOR, status); IVY_ERROR_VENDOR, status);
} }
@@ -196,10 +196,10 @@ static b_result parse_file_tokens(struct compile_ctx *ctx)
} }
} }
return B_RESULT_SUCCESS; return FX_RESULT_SUCCESS;
} }
static b_result generate_mie_ir(struct compile_ctx *ctx) static fx_result generate_mie_ir(struct compile_ctx *ctx)
{ {
ivy_codegen_start_module(ctx->codegen); ivy_codegen_start_module(ctx->codegen);
@@ -209,45 +209,45 @@ static b_result generate_mie_ir(struct compile_ctx *ctx)
enum ivy_status status enum ivy_status status
= ivy_ast_node_iterate(node, &it, node_codegen, ctx); = ivy_ast_node_iterate(node, &it, node_codegen, ctx);
if (status != IVY_OK) { if (status != IVY_OK) {
return b_error_caused_by_code( return fx_error_caused_by_code(
IVY_ERROR_VENDOR, IVY_ERR_CODEGEN_FAILURE, IVY_ERROR_VENDOR, IVY_ERR_CODEGEN_FAILURE,
IVY_ERROR_VENDOR, status); IVY_ERROR_VENDOR, status);
} }
status = ivy_codegen_push_eof(ctx->codegen); status = ivy_codegen_push_eof(ctx->codegen);
if (status != IVY_OK) { if (status != IVY_OK) {
return b_error_caused_by_code( return fx_error_caused_by_code(
IVY_ERROR_VENDOR, IVY_ERR_CODEGEN_FAILURE, IVY_ERROR_VENDOR, IVY_ERR_CODEGEN_FAILURE,
IVY_ERROR_VENDOR, status); IVY_ERROR_VENDOR, status);
} }
ivy_codegen_end_module(ctx->codegen, &ctx->mod); ivy_codegen_end_module(ctx->codegen, &ctx->mod);
return B_RESULT_SUCCESS; return FX_RESULT_SUCCESS;
} }
static b_result build_block_isel_graph( static fx_result build_block_isel_graph(
struct compile_ctx *ctx, struct mie_func *func, struct mie_block *block) struct compile_ctx *ctx, struct mie_func *func, struct mie_block *block)
{ {
printf("selecting %s.%s...\n", func->f_base.v_name.n_str, printf("selecting %s.%s...\n", func->f_base.v_name.n_str,
block->b_base.v_name.n_str); block->b_base.v_name.n_str);
b_queue_entry *entry = b_queue_first(&block->b_phi); fx_queue_entry *entry = fx_queue_first(&block->b_phi);
while (entry) { while (entry) {
struct mie_value *instr_v struct mie_value *instr_v
= b_unbox(struct mie_value, entry, v_entry); = fx_unbox(struct mie_value, entry, v_entry);
mie_select_builder_push_instr( mie_select_builder_push_instr(
ctx->select, (struct mie_instr *)instr_v); ctx->select, (struct mie_instr *)instr_v);
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
entry = b_queue_first(&block->b_instr); entry = fx_queue_first(&block->b_instr);
while (entry) { while (entry) {
struct mie_value *instr_v struct mie_value *instr_v
= b_unbox(struct mie_value, entry, v_entry); = fx_unbox(struct mie_value, entry, v_entry);
mie_select_builder_push_instr( mie_select_builder_push_instr(
ctx->select, (struct mie_instr *)instr_v); ctx->select, (struct mie_instr *)instr_v);
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
if (block->b_terminator) { if (block->b_terminator) {
@@ -267,48 +267,48 @@ static b_result build_block_isel_graph(
mie_select_graph_destroy(graph); mie_select_graph_destroy(graph);
} }
return B_RESULT_SUCCESS; return FX_RESULT_SUCCESS;
} }
static b_result build_func_isel_graph(struct compile_ctx *ctx, struct mie_func *func) static fx_result build_func_isel_graph(struct compile_ctx *ctx, struct mie_func *func)
{ {
b_queue_entry *entry = b_queue_first(&func->f_blocks); fx_queue_entry *entry = fx_queue_first(&func->f_blocks);
while (entry) { while (entry) {
struct mie_value *block_v struct mie_value *block_v
= b_unbox(struct mie_value, entry, v_entry); = fx_unbox(struct mie_value, entry, v_entry);
struct mie_block *block = (struct mie_block *)block_v; struct mie_block *block = (struct mie_block *)block_v;
b_result result = build_block_isel_graph(ctx, func, block); fx_result result = build_block_isel_graph(ctx, func, block);
if (b_result_is_error(result)) { if (fx_result_is_error(result)) {
return b_result_propagate(result); return fx_result_propagate(result);
} }
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
return B_RESULT_SUCCESS; return FX_RESULT_SUCCESS;
} }
static b_result build_isel_graph(struct compile_ctx *ctx) static fx_result build_isel_graph(struct compile_ctx *ctx)
{ {
b_queue_entry *entry = b_queue_first(&ctx->mod->m_func); fx_queue_entry *entry = fx_queue_first(&ctx->mod->m_func);
while (entry) { while (entry) {
struct mie_value *func_v struct mie_value *func_v
= b_unbox(struct mie_value, entry, v_entry); = fx_unbox(struct mie_value, entry, v_entry);
struct mie_func *func = (struct mie_func *)func_v; struct mie_func *func = (struct mie_func *)func_v;
b_result result = build_func_isel_graph(ctx, func); fx_result result = build_func_isel_graph(ctx, func);
if (b_result_is_error(result)) { if (fx_result_is_error(result)) {
return b_result_propagate(result); return fx_result_propagate(result);
} }
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
return B_RESULT_SUCCESS; return FX_RESULT_SUCCESS;
} }
static b_result dump_ast(struct compile_ctx *ctx) static fx_result dump_ast(struct compile_ctx *ctx)
{ {
struct ivy_ast_node *node = ivy_parser_root_node(ctx->parser); struct ivy_ast_node *node = ivy_parser_root_node(ctx->parser);
struct ivy_ast_node_iterator it = {0}; struct ivy_ast_node_iterator it = {0};
@@ -318,10 +318,10 @@ static b_result dump_ast(struct compile_ctx *ctx)
ivy_ast_node_iterate(node, &it, print_ast_node, &args); ivy_ast_node_iterate(node, &it, print_ast_node, &args);
return B_RESULT_SUCCESS; return FX_RESULT_SUCCESS;
} }
static b_result dump_ir(struct compile_ctx *ctx) static fx_result dump_ir(struct compile_ctx *ctx)
{ {
struct mie_ir_converter *convert struct mie_ir_converter *convert
= mie_ir_converter_create(ctx->mie_ctx, MIE_IR_MEM, MIE_IR_TEXT); = mie_ir_converter_create(ctx->mie_ctx, MIE_IR_MEM, MIE_IR_TEXT);
@@ -331,24 +331,24 @@ static b_result dump_ir(struct compile_ctx *ctx)
mie_ir_converter_destroy(convert); mie_ir_converter_destroy(convert);
return B_RESULT_SUCCESS; return FX_RESULT_SUCCESS;
} }
static int compile_file(const char *path, const b_arglist *args) static int compile_file(const char *path, const fx_arglist *args)
{ {
#define THROW_AND_RETURN(result, error_code) \ #define THROW_AND_RETURN(result, error_code) \
do { \ do { \
if (b_result_is(result, IVY_ERROR_VENDOR, IVY_ERR_BAD_SYNTAX)) { \ if (fx_result_is(result, IVY_ERROR_VENDOR, IVY_ERR_BAD_SYNTAX)) { \
return error_code; \ return error_code; \
} \ } \
if (b_result_is_error(result)) { \ if (fx_result_is_error(result)) { \
b_throw(result); \ fx_throw(result); \
return error_code; \ return error_code; \
} \ } \
} while (0) } while (0)
struct compile_ctx ctx; struct compile_ctx ctx;
b_result result = compile_ctx_init(&ctx, args); fx_result result = compile_ctx_init(&ctx, args);
THROW_AND_RETURN(result, -1); THROW_AND_RETURN(result, -1);
int progress = 0; int progress = 0;
@@ -397,13 +397,13 @@ end:
return 0; return 0;
} }
static int compile(const b_command *cmd, const b_arglist *args, const b_array *_) static int compile(const fx_command *cmd, const fx_arglist *args, const fx_array *_)
{ {
b_arglist_iterator it; fx_arglist_iterator it;
b_arglist_foreach_filtered(&it, args, B_COMMAND_INVALID_ID, ARG_SOURCE_FILE) fx_arglist_foreach_filtered(&it, args, FX_COMMAND_INVALID_ID, ARG_SOURCE_FILE)
{ {
b_arglist_value *path = it.value; fx_arglist_value *path = it.value;
if (path->val_type != B_COMMAND_ARG_STRING) { if (path->val_type != FX_COMMAND_ARG_STRING) {
continue; continue;
} }
@@ -418,64 +418,64 @@ static int compile(const b_command *cmd, const b_arglist *args, const b_array *_
B_COMMAND(CMD_COMPILE, CMD_ROOT) B_COMMAND(CMD_COMPILE, CMD_ROOT)
{ {
B_COMMAND_NAME("compile"); FX_COMMAND_NAME("compile");
B_COMMAND_SHORT_NAME('C'); FX_COMMAND_SHORT_NAME('C');
B_COMMAND_DESC( FX_COMMAND_DESC(
"compile one or more Ivy source files into Ivy object files."); "compile one or more Ivy source files into Ivy object files.");
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT); FX_COMMAND_FLAGS(FX_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_FUNCTION(compile); FX_COMMAND_FUNCTION(compile);
B_COMMAND_OPTION(OPT_SHOW_LEX_TOKENS) FX_COMMAND_OPTION(OPT_SHOW_LEX_TOKENS)
{ {
B_OPTION_LONG_NAME("show-lex"); FX_OPTION_LONG_NAME("show-lex");
B_OPTION_SHORT_NAME('l'); FX_OPTION_SHORT_NAME('l');
B_OPTION_DESC( FX_OPTION_DESC(
"print the lexical tokens generated from the input " "print the lexical tokens generated from the input "
"files."); "files.");
} }
B_COMMAND_OPTION(OPT_SHOW_AST_NODES) FX_COMMAND_OPTION(OPT_SHOW_AST_NODES)
{ {
B_OPTION_LONG_NAME("show-ast"); FX_OPTION_LONG_NAME("show-ast");
B_OPTION_SHORT_NAME('a'); FX_OPTION_SHORT_NAME('a');
B_OPTION_DESC( FX_OPTION_DESC(
"print the abstract syntax tree generated from the " "print the abstract syntax tree generated from the "
"input files."); "input files.");
} }
B_COMMAND_OPTION(OPT_SHOW_IR) FX_COMMAND_OPTION(OPT_SHOW_IR)
{ {
B_OPTION_LONG_NAME("show-ir"); FX_OPTION_LONG_NAME("show-ir");
B_OPTION_SHORT_NAME('i'); FX_OPTION_SHORT_NAME('i');
B_OPTION_DESC( FX_OPTION_DESC(
"print the Mie IR generated from the " "print the Mie IR generated from the "
"input files."); "input files.");
} }
B_COMMAND_OPTION(OPT_SHOW_ISEL_PRE) FX_COMMAND_OPTION(OPT_SHOW_ISEL_PRE)
{ {
B_OPTION_LONG_NAME("show-isel-pre"); FX_OPTION_LONG_NAME("show-isel-pre");
B_OPTION_SHORT_NAME('s'); FX_OPTION_SHORT_NAME('s');
B_OPTION_DESC( FX_OPTION_DESC(
"print the instruction selection graph before " "print the instruction selection graph before "
"selection has taken place."); "selection has taken place.");
} }
B_COMMAND_OPTION(OPT_SHOW_ISEL_POST) FX_COMMAND_OPTION(OPT_SHOW_ISEL_POST)
{ {
B_OPTION_LONG_NAME("show-isel-post"); FX_OPTION_LONG_NAME("show-isel-post");
B_OPTION_SHORT_NAME('m'); FX_OPTION_SHORT_NAME('m');
B_OPTION_DESC( FX_OPTION_DESC(
"print the instruction selection graph after " "print the instruction selection graph after "
"selection has taken place."); "selection has taken place.");
} }
B_COMMAND_ARG(ARG_SOURCE_FILE) FX_COMMAND_ARG(ARG_SOURCE_FILE)
{ {
B_ARG_NAME("source file"); FX_ARG_NAME("source file");
B_ARG_DESC("the .im source files to compile."); FX_ARG_DESC("the .im source files to compile.");
B_ARG_NR_VALUES(B_ARG_1_OR_MORE_VALUES); FX_ARG_NR_VALUES(FX_ARG_1_OR_MORE_VALUES);
} }
B_COMMAND_HELP_OPTION(); FX_COMMAND_HELP_OPTION();
} }

View File

@@ -1,8 +1,8 @@
#include "cmd.h" #include "cmd.h"
#include <blue/cmd.h> #include <fx/cmd.h>
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <blue/term.h> #include <fx/term.h>
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#include <inttypes.h> #include <inttypes.h>
@@ -30,7 +30,7 @@ enum {
OPT_CONSTPOOL, OPT_CONSTPOOL,
}; };
static void dump_instruction(b_i32 x) static void dump_instruction(fx_i32 x)
{ {
struct ivy_instr instr = {}; struct ivy_instr instr = {};
enum ivy_status status = ivy_instr_decode(x, &instr); enum ivy_status status = ivy_instr_decode(x, &instr);
@@ -226,7 +226,7 @@ static enum ivy_status dump_class(
} }
status = ivy_asm_constpool_reader_read_value( status = ivy_asm_constpool_reader_read_value(
pool, b_i32_btoh(class_header.c_ident), &class_ident); pool, fx_i32_btoh(class_header.c_ident), &class_ident);
if (status != IVY_OK) { if (status != IVY_OK) {
goto cleanup; goto cleanup;
} }
@@ -262,13 +262,13 @@ static enum ivy_status dump_class(
printf(" [%03zu] ", i); printf(" [%03zu] ", i);
char s[256]; char s[256];
uint32_t type = b_i32_btoh(entry.e_type); uint32_t type = fx_i32_btoh(entry.e_type);
switch (type) { switch (type) {
case IVY_CLASS_TABLE_PROP: { case IVY_CLASS_TABLE_PROP: {
printf("type:property\n"); printf("type:property\n");
struct ivy_asm_constpool_value *prop_ident = NULL; struct ivy_asm_constpool_value *prop_ident = NULL;
status = ivy_asm_constpool_reader_read_value( status = ivy_asm_constpool_reader_read_value(
pool, b_i32_btoh(entry.e_property.p_ident), pool, fx_i32_btoh(entry.e_property.p_ident),
&prop_ident); &prop_ident);
if (status != IVY_OK) { if (status != IVY_OK) {
break; break;
@@ -279,8 +279,8 @@ static enum ivy_status dump_class(
break; break;
} }
uint32_t get = b_i32_btoh(entry.e_property.p_get); uint32_t get = fx_i32_btoh(entry.e_property.p_get);
uint32_t set = b_i32_btoh(entry.e_property.p_set); uint32_t set = fx_i32_btoh(entry.e_property.p_set);
ivy_ident_to_string(prop_ident->v_ident, s, sizeof s); ivy_ident_to_string(prop_ident->v_ident, s, sizeof s);
ivy_asm_constpool_value_destroy(prop_ident); ivy_asm_constpool_value_destroy(prop_ident);
@@ -305,7 +305,7 @@ static enum ivy_status dump_class(
printf("type:variable\n"); printf("type:variable\n");
struct ivy_asm_constpool_value *var_ident = NULL; struct ivy_asm_constpool_value *var_ident = NULL;
status = ivy_asm_constpool_reader_read_value( status = ivy_asm_constpool_reader_read_value(
pool, b_i32_btoh(entry.e_mvar.m_ident), &var_ident); pool, fx_i32_btoh(entry.e_mvar.m_ident), &var_ident);
if (status != IVY_OK) { if (status != IVY_OK) {
break; break;
} }
@@ -315,7 +315,7 @@ static enum ivy_status dump_class(
break; break;
} }
uint32_t index = b_i32_btoh(entry.e_mvar.m_index); uint32_t index = fx_i32_btoh(entry.e_mvar.m_index);
ivy_ident_to_string(var_ident->v_ident, s, sizeof s); ivy_ident_to_string(var_ident->v_ident, s, sizeof s);
ivy_asm_constpool_value_destroy(var_ident); ivy_asm_constpool_value_destroy(var_ident);
printf(" ident:%s, index:0x%" PRIx32 printf(" ident:%s, index:0x%" PRIx32
@@ -328,7 +328,7 @@ static enum ivy_status dump_class(
printf("type:method\n"); printf("type:method\n");
struct ivy_asm_constpool_value *sel = NULL; struct ivy_asm_constpool_value *sel = NULL;
status = ivy_asm_constpool_reader_read_value( status = ivy_asm_constpool_reader_read_value(
pool, b_i32_btoh(entry.e_msgh.msg_selector), &sel); pool, fx_i32_btoh(entry.e_msgh.msg_selector), &sel);
if (status != IVY_OK) { if (status != IVY_OK) {
break; break;
} }
@@ -338,7 +338,7 @@ static enum ivy_status dump_class(
break; break;
} }
uint32_t block = b_i32_btoh(entry.e_msgh.msg_block); uint32_t block = fx_i32_btoh(entry.e_msgh.msg_block);
ivy_selector_to_string(sel->v_sel, s, sizeof s); ivy_selector_to_string(sel->v_sel, s, sizeof s);
ivy_asm_constpool_value_destroy(sel); ivy_asm_constpool_value_destroy(sel);
@@ -399,7 +399,7 @@ static enum ivy_status dump_constpool(struct ivy_asm_reader *object)
enum ivy_status status enum ivy_status status
= ivy_asm_reader_open_constpool(object, 0, 0, &pool); = ivy_asm_reader_open_constpool(object, 0, 0, &pool);
if (status == IVY_ERR_NO_ENTRY) { if (status == IVY_ERR_NO_ENTRY) {
b_err("object file has no constpool.\n"); fx_err("object file has no constpool.\n");
return status; return status;
} }
@@ -409,8 +409,8 @@ static enum ivy_status dump_constpool(struct ivy_asm_reader *object)
struct ivy_asm_constpool_value *v; struct ivy_asm_constpool_value *v;
status = ivy_asm_constpool_reader_read_value(pool, i, &v); status = ivy_asm_constpool_reader_read_value(pool, i, &v);
if (status != IVY_OK) { if (status != IVY_OK) {
b_err("cannot read constpool value"); fx_err("cannot read constpool value");
b_i("reason: %s", ivy_status_to_string(status)); fx_i("reason: %s", ivy_status_to_string(status));
break; break;
} }
@@ -455,7 +455,7 @@ static enum ivy_status dump_constpool(struct ivy_asm_reader *object)
return status; return status;
} }
static void dump_instructions(b_i32 *x, size_t buffer_size) static void dump_instructions(fx_i32 *x, size_t buffer_size)
{ {
size_t nr_instr = buffer_size / sizeof *x; size_t nr_instr = buffer_size / sizeof *x;
@@ -503,7 +503,7 @@ static enum ivy_status dump_header(
break; break;
} }
printf(" ident=0x%04x\n", b_i32_btoh(xcls.c_ident)); printf(" ident=0x%04x\n", fx_i32_btoh(xcls.c_ident));
*dump_offset = sizeof xcls; *dump_offset = sizeof xcls;
break; break;
} }
@@ -520,7 +520,7 @@ static enum ivy_status dump_header(
break; break;
} }
long index = b_i32_btoh(text.b_index); long index = fx_i32_btoh(text.b_index);
printf(" index=0x%04lx [%ld]\n", index, index); printf(" index=0x%04lx [%ld]\n", index, index);
*dump_offset = sizeof text; *dump_offset = sizeof text;
break; break;
@@ -584,7 +584,7 @@ static enum ivy_status dump_section(
printf(" | "); printf(" | ");
if (flags & DUMP_INSTRUCTIONS) { if (flags & DUMP_INSTRUCTIONS) {
dump_instructions((b_i32 *)x, buffer_size); dump_instructions((fx_i32 *)x, buffer_size);
} else { } else {
dump_strings(x, buffer_size); dump_strings(x, buffer_size);
} }
@@ -649,31 +649,31 @@ static enum ivy_status dump_section_table(struct ivy_asm_reader *reader, bool du
} }
static int disassemble( static int disassemble(
const b_command *cmd, const b_arglist *args, const b_array *_) const fx_command *cmd, const fx_arglist *args, const fx_array *_)
{ {
bool header = b_arglist_get_count(args, OPT_HEADER, B_COMMAND_INVALID_ID) bool header = fx_arglist_get_count(args, OPT_HEADER, FX_COMMAND_INVALID_ID)
> 0; > 0;
bool sections bool sections
= b_arglist_get_count(args, OPT_SECTIONS, B_COMMAND_INVALID_ID) > 0; = fx_arglist_get_count(args, OPT_SECTIONS, FX_COMMAND_INVALID_ID) > 0;
bool dump = b_arglist_get_count(args, OPT_DUMP, B_COMMAND_INVALID_ID) > 0; bool dump = fx_arglist_get_count(args, OPT_DUMP, FX_COMMAND_INVALID_ID) > 0;
bool constpool bool constpool
= b_arglist_get_count(args, OPT_CONSTPOOL, B_COMMAND_INVALID_ID) = fx_arglist_get_count(args, OPT_CONSTPOOL, FX_COMMAND_INVALID_ID)
> 0; > 0;
bool classes bool classes
= b_arglist_get_count(args, OPT_CLASSES, B_COMMAND_INVALID_ID) > 0; = fx_arglist_get_count(args, OPT_CLASSES, FX_COMMAND_INVALID_ID) > 0;
const char *in_path = NULL; const char *in_path = NULL;
b_arglist_get_string(args, B_COMMAND_INVALID_ID, ARG_BIN_FILE, 0, &in_path); fx_arglist_get_string(args, FX_COMMAND_INVALID_ID, ARG_BIN_FILE, 0, &in_path);
if (!in_path) { if (!in_path) {
b_err("no input file specified."); fx_err("no input file specified.");
return -1; return -1;
} }
FILE *in = fopen(in_path, "rb"); FILE *in = fopen(in_path, "rb");
if (!in) { if (!in) {
b_err("cannot open object file"); fx_err("cannot open object file");
b_i("reason: %s", strerror(errno)); fx_i("reason: %s", strerror(errno));
return -1; return -1;
} }
@@ -682,8 +682,8 @@ static int disassemble(
enum ivy_status status = ivy_asm_reader_open(in, &reader); enum ivy_status status = ivy_asm_reader_open(in, &reader);
if (status != IVY_OK) { if (status != IVY_OK) {
b_err("cannot open object file"); fx_err("cannot open object file");
b_i("reason: %s", ivy_status_to_string(status)); fx_i("reason: %s", ivy_status_to_string(status));
fclose(in); fclose(in);
return -1; return -1;
@@ -719,59 +719,59 @@ static int disassemble(
B_COMMAND(CMD_DISASSEMBLE, CMD_ROOT) B_COMMAND(CMD_DISASSEMBLE, CMD_ROOT)
{ {
B_COMMAND_NAME("disassemble"); FX_COMMAND_NAME("disassemble");
B_COMMAND_SHORT_NAME('D'); FX_COMMAND_SHORT_NAME('D');
B_COMMAND_DESC("disassemble an Ivy object file."); FX_COMMAND_DESC("disassemble an Ivy object file.");
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT); FX_COMMAND_FLAGS(FX_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_FUNCTION(disassemble); FX_COMMAND_FUNCTION(disassemble);
B_COMMAND_ARG(ARG_BIN_FILE) FX_COMMAND_ARG(ARG_BIN_FILE)
{ {
B_ARG_NAME("input file"); FX_ARG_NAME("input file");
B_ARG_DESC("the Ivy object file to disassemble."); FX_ARG_DESC("the Ivy object file to disassemble.");
B_ARG_NR_VALUES(1); FX_ARG_NR_VALUES(1);
} }
B_COMMAND_OPTION(OPT_HEADER) FX_COMMAND_OPTION(OPT_HEADER)
{ {
B_OPTION_SHORT_NAME('h'); FX_OPTION_SHORT_NAME('h');
B_OPTION_LONG_NAME("header"); FX_OPTION_LONG_NAME("header");
B_OPTION_DESC("print the object file header."); FX_OPTION_DESC("print the object file header.");
} }
B_COMMAND_OPTION(OPT_SECTIONS) FX_COMMAND_OPTION(OPT_SECTIONS)
{ {
B_OPTION_SHORT_NAME('s'); FX_OPTION_SHORT_NAME('s');
B_OPTION_LONG_NAME("section-table"); FX_OPTION_LONG_NAME("section-table");
B_OPTION_DESC("print the object file section table."); FX_OPTION_DESC("print the object file section table.");
} }
B_COMMAND_OPTION(OPT_DUMP) FX_COMMAND_OPTION(OPT_DUMP)
{ {
B_OPTION_SHORT_NAME('d'); FX_OPTION_SHORT_NAME('d');
B_OPTION_LONG_NAME("dump"); FX_OPTION_LONG_NAME("dump");
B_OPTION_DESC( FX_OPTION_DESC(
"decode and print the contents of each object " "decode and print the contents of each object "
"section."); "section.");
} }
B_COMMAND_OPTION(OPT_CLASSES) FX_COMMAND_OPTION(OPT_CLASSES)
{ {
B_OPTION_SHORT_NAME('c'); FX_OPTION_SHORT_NAME('c');
B_OPTION_LONG_NAME("classes"); FX_OPTION_LONG_NAME("classes");
B_OPTION_DESC( FX_OPTION_DESC(
"print the classes contained in the object " "print the classes contained in the object "
"file."); "file.");
} }
B_COMMAND_OPTION(OPT_CONSTPOOL) FX_COMMAND_OPTION(OPT_CONSTPOOL)
{ {
B_OPTION_SHORT_NAME('p'); FX_OPTION_SHORT_NAME('p');
B_OPTION_LONG_NAME("pool-data"); FX_OPTION_LONG_NAME("pool-data");
B_OPTION_DESC( FX_OPTION_DESC(
"print the constant pool data in the object " "print the constant pool data in the object "
"file."); "file.");
} }
B_COMMAND_HELP_OPTION(); FX_COMMAND_HELP_OPTION();
} }

View File

@@ -1,41 +1,41 @@
#include "cmd.h" #include "cmd.h"
#include <blue/cmd.h> #include <fx/cmd.h>
enum { enum {
ARG_FILE ARG_FILE
}; };
static int exec(const b_command *cmd, const b_arglist *args, const b_array *_) static int exec(const fx_command *cmd, const fx_arglist *args, const fx_array *_)
{ {
return 0; return 0;
} }
B_COMMAND(CMD_ROOT, B_COMMAND_INVALID_ID) B_COMMAND(CMD_ROOT, FX_COMMAND_INVALID_ID)
{ {
B_COMMAND_NAME("ivy"); FX_COMMAND_NAME("ivy");
B_COMMAND_DESC("evaluate an Ivy source file or Ivy object file."); FX_COMMAND_DESC("evaluate an Ivy source file or Ivy object file.");
B_COMMAND_HELP_OPTION(); FX_COMMAND_HELP_OPTION();
B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT); FX_COMMAND_FLAGS(FX_COMMAND_SHOW_HELP_BY_DEFAULT);
B_COMMAND_FUNCTION(exec); FX_COMMAND_FUNCTION(exec);
B_COMMAND_ARG(ARG_FILE) FX_COMMAND_ARG(ARG_FILE)
{ {
B_ARG_NAME("file"); FX_ARG_NAME("file");
B_ARG_DESC("The file to execute."); FX_ARG_DESC("The file to execute.");
B_ARG_NR_VALUES(1); FX_ARG_NR_VALUES(1);
} }
B_COMMAND_USAGE() FX_COMMAND_USAGE()
{ {
B_COMMAND_USAGE_OPT_PLACEHOLDER(); FX_COMMAND_USAGE_OPT_PLACEHOLDER();
B_COMMAND_USAGE_ARG(ARG_FILE); FX_COMMAND_USAGE_ARG(ARG_FILE);
} }
B_COMMAND_USAGE() FX_COMMAND_USAGE()
{ {
B_COMMAND_USAGE_COMMAND_PLACEHOLDER(); FX_COMMAND_USAGE_COMMAND_PLACEHOLDER();
B_COMMAND_USAGE_OPT_PLACEHOLDER(); FX_COMMAND_USAGE_OPT_PLACEHOLDER();
B_COMMAND_USAGE_ARG_PLACEHOLDER(); FX_COMMAND_USAGE_ARG_PLACEHOLDER();
} }
} }

View File

@@ -1,30 +1,30 @@
#include <blue/cmd.h> #include <fx/cmd.h>
#include "cmd.h" #include "cmd.h"
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
#include <ivy/lang/internal.h> #include <ivy/lang/internal.h>
#include <blue/term.h> #include <fx/term.h>
enum { enum {
OPT_PRINT_SYMBOLS = 0x1000, OPT_PRINT_SYMBOLS = 0x1000,
OPT_PRINT_KEYWORDS, OPT_PRINT_KEYWORDS,
}; };
static int internal(const b_command *cmd, const b_arglist *args, const b_array *_) static int internal(const fx_command *cmd, const fx_arglist *args, const fx_array *_)
{ {
struct ivy_lexer *lex; struct ivy_lexer *lex;
enum ivy_status status = ivy_lexer_create(&lex); enum ivy_status status = ivy_lexer_create(&lex);
if (status != IVY_OK) { if (status != IVY_OK) {
b_err("failed to initialise lexer (error %s)", fx_err("failed to initialise lexer (error %s)",
ivy_status_to_string(status)); ivy_status_to_string(status));
return -1; return -1;
} }
if (b_arglist_get_count(args, OPT_PRINT_SYMBOLS, B_COMMAND_INVALID_ID)) { if (fx_arglist_get_count(args, OPT_PRINT_SYMBOLS, FX_COMMAND_INVALID_ID)) {
internal_lexer_print_symbol_tree(lex); internal_lexer_print_symbol_tree(lex);
} }
if (b_arglist_get_count(args, OPT_PRINT_KEYWORDS, B_COMMAND_INVALID_ID)) { if (fx_arglist_get_count(args, OPT_PRINT_KEYWORDS, FX_COMMAND_INVALID_ID)) {
internal_lexer_print_keyword_dict(lex); internal_lexer_print_keyword_dict(lex);
} }
@@ -35,26 +35,26 @@ static int internal(const b_command *cmd, const b_arglist *args, const b_array *
B_COMMAND(CMD_INTERNAL, CMD_ROOT) B_COMMAND(CMD_INTERNAL, CMD_ROOT)
{ {
B_COMMAND_NAME("internal"); FX_COMMAND_NAME("internal");
B_COMMAND_SHORT_NAME('X'); FX_COMMAND_SHORT_NAME('X');
B_COMMAND_DESC("internal frontend debugging tools."); FX_COMMAND_DESC("internal frontend debugging tools.");
B_COMMAND_FUNCTION(internal); FX_COMMAND_FUNCTION(internal);
B_COMMAND_OPTION(OPT_PRINT_SYMBOLS) FX_COMMAND_OPTION(OPT_PRINT_SYMBOLS)
{ {
B_OPTION_LONG_NAME("print-symbols"); FX_OPTION_LONG_NAME("print-symbols");
B_OPTION_SHORT_NAME('s'); FX_OPTION_SHORT_NAME('s');
B_OPTION_DESC( FX_OPTION_DESC(
"print the symbol tree used by the language lexer."); "print the symbol tree used by the language lexer.");
} }
B_COMMAND_OPTION(OPT_PRINT_KEYWORDS) FX_COMMAND_OPTION(OPT_PRINT_KEYWORDS)
{ {
B_OPTION_LONG_NAME("print-keywords"); FX_OPTION_LONG_NAME("print-keywords");
B_OPTION_SHORT_NAME('k'); FX_OPTION_SHORT_NAME('k');
B_OPTION_DESC( FX_OPTION_DESC(
"print the keyword dictionary used by the language lexer."); "print the keyword dictionary used by the language lexer.");
} }
B_COMMAND_HELP_OPTION(); FX_COMMAND_HELP_OPTION();
} }

View File

@@ -2,8 +2,8 @@
#include "../line-ed/line-ed.h" #include "../line-ed/line-ed.h"
#include "cmd.h" #include "cmd.h"
#include <blue/cmd.h> #include <fx/cmd.h>
#include <blue/term.h> #include <fx/term.h>
#include <ivy/lang/ast.h> #include <ivy/lang/ast.h>
#include <ivy/lang/codegen.h> #include <ivy/lang/codegen.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
@@ -180,26 +180,26 @@ static enum ivy_status repl_create(struct repl **out)
return IVY_OK; return IVY_OK;
} }
int repl(const b_command *cmd, const b_arglist *args, const b_array *_) int repl(const fx_command *cmd, const fx_arglist *args, const fx_array *_)
{ {
#if 0 #if 0
b_printf( fx_printf(
"[bold,bright_red]error[[E0384][reset,bold,white]: cannot " "[bold,bright_red]error[[E0384][reset,bold,white]: cannot "
"assign twice to immutable variable `i`[reset]\n"); "assign twice to immutable variable `i`[reset]\n");
b_printf("[bold,bright_blue] -->[reset] src/main.rs:7:3\n"); fx_printf("[bold,bright_blue] -->[reset] src/main.rs:7:3\n");
b_printf("[bold,bright_blue] |[reset]\n"); fx_printf("[bold,bright_blue] |[reset]\n");
b_printf("[bold,bright_blue]4 |[reset] let i = 0;\n"); fx_printf("[bold,bright_blue]4 |[reset] let i = 0;\n");
b_printf("[bold,bright_blue] | -[reset]\n"); fx_printf("[bold,bright_blue] | -[reset]\n");
b_printf("[bold,bright_blue] | |[reset]\n"); fx_printf("[bold,bright_blue] | |[reset]\n");
b_printf( fx_printf(
"[bold,bright_blue] | first assignment to " "[bold,bright_blue] | first assignment to "
"`i`[reset]\n"); "`i`[reset]\n");
b_printf( fx_printf(
"[bold,bright_blue] | help: make this binding " "[bold,bright_blue] | help: make this binding "
"mutable: `mut i`[reset]\n"); "mutable: `mut i`[reset]\n");
b_printf("[bold,bright_blue]...[reset]\n"); fx_printf("[bold,bright_blue]...[reset]\n");
b_printf("[bold,bright_blue]7 |[reset] i += 1;\n"); fx_printf("[bold,bright_blue]7 |[reset] i += 1;\n");
b_printf( fx_printf(
"[bold,bright_blue] |[bold,bright_red] ^^^^^^ cannot " "[bold,bright_blue] |[bold,bright_red] ^^^^^^ cannot "
"assign twice to immutable variable[reset]\n"); "assign twice to immutable variable[reset]\n");
#endif #endif
@@ -210,14 +210,14 @@ int repl(const b_command *cmd, const b_arglist *args, const b_array *_)
return -1; return -1;
} }
repl->r_show_lex = b_arglist_get_count( repl->r_show_lex = fx_arglist_get_count(
args, OPT_SHOW_LEX_TOKENS, B_COMMAND_INVALID_ID) args, OPT_SHOW_LEX_TOKENS, FX_COMMAND_INVALID_ID)
> 0; > 0;
repl->r_show_ast = b_arglist_get_count( repl->r_show_ast = fx_arglist_get_count(
args, OPT_SHOW_AST_NODES, B_COMMAND_INVALID_ID) args, OPT_SHOW_AST_NODES, FX_COMMAND_INVALID_ID)
> 0; > 0;
repl->r_show_ir repl->r_show_ir
= b_arglist_get_count(args, OPT_SHOW_IR, B_COMMAND_INVALID_ID) > 0; = fx_arglist_get_count(args, OPT_SHOW_IR, FX_COMMAND_INVALID_ID) > 0;
while (true) { while (true) {
struct ivy_token *tok = ivy_lexer_read(repl->r_lex); struct ivy_token *tok = ivy_lexer_read(repl->r_lex);
@@ -227,7 +227,7 @@ int repl(const b_command *cmd, const b_arglist *args, const b_array *_)
} }
if (status != IVY_OK) { if (status != IVY_OK) {
b_err("lex error (%s)", fx_err("lex error (%s)",
ivy_status_to_string( ivy_status_to_string(
ivy_lexer_get_status(repl->r_lex))); ivy_lexer_get_status(repl->r_lex)));
continue; continue;
@@ -240,7 +240,7 @@ int repl(const b_command *cmd, const b_arglist *args, const b_array *_)
status = ivy_parser_push_token(repl->r_parse, tok); status = ivy_parser_push_token(repl->r_parse, tok);
if (status != IVY_OK) { if (status != IVY_OK) {
b_err("parse error (%s)", ivy_status_to_string(status)); fx_err("parse error (%s)", ivy_status_to_string(status));
ivy_token_destroy(tok); ivy_token_destroy(tok);
skip_line(repl->r_lex); skip_line(repl->r_lex);
continue; continue;
@@ -273,33 +273,33 @@ int repl(const b_command *cmd, const b_arglist *args, const b_array *_)
B_COMMAND(CMD_REPL, CMD_ROOT) B_COMMAND(CMD_REPL, CMD_ROOT)
{ {
B_COMMAND_NAME("shell"); FX_COMMAND_NAME("shell");
B_COMMAND_SHORT_NAME('S'); FX_COMMAND_SHORT_NAME('S');
B_COMMAND_DESC("start an interactive Ivy shell."); FX_COMMAND_DESC("start an interactive Ivy shell.");
B_COMMAND_HELP_OPTION(); FX_COMMAND_HELP_OPTION();
B_COMMAND_FUNCTION(repl); FX_COMMAND_FUNCTION(repl);
B_COMMAND_OPTION(OPT_SHOW_LEX_TOKENS) FX_COMMAND_OPTION(OPT_SHOW_LEX_TOKENS)
{ {
B_OPTION_LONG_NAME("show-lex"); FX_OPTION_LONG_NAME("show-lex");
B_OPTION_SHORT_NAME('l'); FX_OPTION_SHORT_NAME('l');
B_OPTION_DESC( FX_OPTION_DESC(
"print the lexical tokens generated from the input."); "print the lexical tokens generated from the input.");
} }
B_COMMAND_OPTION(OPT_SHOW_AST_NODES) FX_COMMAND_OPTION(OPT_SHOW_AST_NODES)
{ {
B_OPTION_LONG_NAME("show-ast"); FX_OPTION_LONG_NAME("show-ast");
B_OPTION_SHORT_NAME('a'); FX_OPTION_SHORT_NAME('a');
B_OPTION_DESC( FX_OPTION_DESC(
"print the abstract syntax tree generated from the " "print the abstract syntax tree generated from the "
"input."); "input.");
} }
B_COMMAND_OPTION(OPT_SHOW_IR) FX_COMMAND_OPTION(OPT_SHOW_IR)
{ {
B_OPTION_LONG_NAME("show-ir"); FX_OPTION_LONG_NAME("show-ir");
B_OPTION_SHORT_NAME('i'); FX_OPTION_SHORT_NAME('i');
B_OPTION_DESC("print the Mie IR generated from the input."); FX_OPTION_DESC("print the Mie IR generated from the input.");
} }
} }

View File

@@ -1,7 +1,7 @@
#include "debug.h" #include "debug.h"
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <blue/term.h> #include <fx/term.h>
#include <ivy/asm/lex.h> #include <ivy/asm/lex.h>
#include <ivy/lang/ast.h> #include <ivy/lang/ast.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
@@ -14,41 +14,41 @@ extern void print_lex_token(struct ivy_token *tok)
switch (tok->t_type) { switch (tok->t_type) {
case IVY_TOK_KEYWORD: case IVY_TOK_KEYWORD:
b_puts("[magenta]"); fx_puts("[magenta]");
break; break;
case IVY_TOK_SYMBOL: case IVY_TOK_SYMBOL:
b_puts("[blue]"); fx_puts("[blue]");
break; break;
case IVY_TOK_ATOM: case IVY_TOK_ATOM:
b_puts("[yellow]"); fx_puts("[yellow]");
break; break;
case IVY_TOK_INT: case IVY_TOK_INT:
case IVY_TOK_DOUBLE: case IVY_TOK_DOUBLE:
b_puts("[yellow]"); fx_puts("[yellow]");
break; break;
case IVY_TOK_LABEL: case IVY_TOK_LABEL:
b_puts("[red]"); fx_puts("[red]");
break; break;
case IVY_TOK_IDENT: case IVY_TOK_IDENT:
b_puts("[cyan]"); fx_puts("[cyan]");
break; break;
case IVY_TOK_STRING: case IVY_TOK_STRING:
b_puts("[green]"); fx_puts("[green]");
break; break;
case IVY_TOK_STR_START: case IVY_TOK_STR_START:
b_puts("[green]"); fx_puts("[green]");
break; break;
case IVY_TOK_STR_END: case IVY_TOK_STR_END:
b_puts("[green]"); fx_puts("[green]");
break; break;
case IVY_TOK_LINEFEED: case IVY_TOK_LINEFEED:
b_puts("[dark_grey]"); fx_puts("[dark_grey]");
break; break;
default: default:
break; break;
} }
b_puts(ivy_lex_token_type_to_string(tok->t_type)); fx_puts(ivy_lex_token_type_to_string(tok->t_type));
switch (tok->t_type) { switch (tok->t_type) {
case IVY_TOK_IDENT: case IVY_TOK_IDENT:
@@ -73,40 +73,40 @@ extern void print_lex_token(struct ivy_token *tok)
break; break;
} }
b_puts("[reset]\n"); fx_puts("[reset]\n");
} }
extern void print_asm_lex_token(struct ivy_asm_token *tok) extern void print_asm_lex_token(struct ivy_asm_token *tok)
{ {
switch (tok->t_type) { switch (tok->t_type) {
case IVY_ASM_TOK_KEYWORD: case IVY_ASM_TOK_KEYWORD:
b_puts("[magenta]"); fx_puts("[magenta]");
break; break;
case IVY_ASM_TOK_SYMBOL: case IVY_ASM_TOK_SYMBOL:
b_puts("[blue]"); fx_puts("[blue]");
break; break;
case IVY_ASM_TOK_INT: case IVY_ASM_TOK_INT:
case IVY_ASM_TOK_DOUBLE: case IVY_ASM_TOK_DOUBLE:
case IVY_ASM_TOK_LABEL_REF: case IVY_ASM_TOK_LABEL_REF:
b_puts("[yellow]"); fx_puts("[yellow]");
break; break;
case IVY_ASM_TOK_LABEL: case IVY_ASM_TOK_LABEL:
b_puts("[red]"); fx_puts("[red]");
break; break;
case IVY_ASM_TOK_IDENT: case IVY_ASM_TOK_IDENT:
b_puts("[cyan]"); fx_puts("[cyan]");
break; break;
case IVY_ASM_TOK_STRING: case IVY_ASM_TOK_STRING:
b_puts("[green]"); fx_puts("[green]");
break; break;
case IVY_ASM_TOK_LINEFEED: case IVY_ASM_TOK_LINEFEED:
b_puts("[dark_grey]"); fx_puts("[dark_grey]");
break; break;
default: default:
break; break;
} }
b_puts(ivy_asm_token_type_to_string(tok->t_type)); fx_puts(ivy_asm_token_type_to_string(tok->t_type));
switch (tok->t_type) { switch (tok->t_type) {
case IVY_ASM_TOK_IDENT: case IVY_ASM_TOK_IDENT:
@@ -135,7 +135,7 @@ extern void print_asm_lex_token(struct ivy_asm_token *tok)
break; break;
} }
b_puts("[reset]\n"); fx_puts("[reset]\n");
} }
extern enum ivy_status print_ast_node( extern enum ivy_status print_ast_node(
@@ -154,7 +154,7 @@ extern enum ivy_status print_ast_node(
if (!args || (args && args->indent)) { if (!args || (args && args->indent)) {
for (unsigned int i = 0; i < node->n_it.it_depth; i++) { for (unsigned int i = 0; i < node->n_it.it_depth; i++) {
b_puts(" "); fx_puts(" ");
} }
} }
@@ -172,13 +172,13 @@ extern enum ivy_status print_ast_node(
case IVY_AST_TRY: case IVY_AST_TRY:
case IVY_AST_RETURN: case IVY_AST_RETURN:
case IVY_AST_GLOBAL: case IVY_AST_GLOBAL:
b_puts("[magenta]"); fx_puts("[magenta]");
break; break;
case IVY_AST_OP: case IVY_AST_OP:
b_puts("[blue]"); fx_puts("[blue]");
break; break;
case IVY_AST_MSG: case IVY_AST_MSG:
b_puts("[red]"); fx_puts("[red]");
break; break;
case IVY_AST_INT: case IVY_AST_INT:
case IVY_AST_DOUBLE: case IVY_AST_DOUBLE:
@@ -187,73 +187,73 @@ extern enum ivy_status print_ast_node(
case IVY_AST_C_TRUE: case IVY_AST_C_TRUE:
case IVY_AST_C_FALSE: case IVY_AST_C_FALSE:
case IVY_AST_C_NULL: case IVY_AST_C_NULL:
b_puts("[yellow]"); fx_puts("[yellow]");
break; break;
case IVY_AST_COND: case IVY_AST_COND:
case IVY_AST_BLOCK: case IVY_AST_BLOCK:
case IVY_AST_TRY_CATCH: case IVY_AST_TRY_CATCH:
b_puts("[red]"); fx_puts("[red]");
break; break;
case IVY_AST_IDENT: case IVY_AST_IDENT:
case IVY_AST_SELECTOR: case IVY_AST_SELECTOR:
b_puts("[cyan]"); fx_puts("[cyan]");
break; break;
case IVY_AST_STRING: case IVY_AST_STRING:
case IVY_AST_FSTRING: case IVY_AST_FSTRING:
b_puts("[green]"); fx_puts("[green]");
break; break;
case IVY_AST_DISCARD: case IVY_AST_DISCARD:
b_puts("[dark_grey]"); fx_puts("[dark_grey]");
break; break;
default: default:
break; break;
} }
b_string *str = b_string_create(); fx_string *str = fx_string_create();
ivy_ast_node_to_string(node, str); ivy_ast_node_to_string(node, str);
b_printf("%s", b_string_ptr(str)); fx_printf("%s", fx_string_ptr(str));
b_string_unref(str); fx_string_unref(str);
#if 0 #if 0
b_puts(ivy_ast_node_type_to_string(node->n_type)); fx_puts(ivy_ast_node_type_to_string(node->n_type));
switch (node->n_type) { switch (node->n_type) {
case IVY_AST_INT: { case IVY_AST_INT: {
struct ivy_ast_int_node *v = (struct ivy_ast_int_node *)node; struct ivy_ast_int_node *v = (struct ivy_ast_int_node *)node;
b_printf(" (%llu)", v->n_value->t_int); fx_printf(" (%llu)", v->n_value->t_int);
break; break;
} }
case IVY_AST_DOUBLE: { case IVY_AST_DOUBLE: {
struct ivy_ast_double_node *v = (struct ivy_ast_double_node *)node; struct ivy_ast_double_node *v = (struct ivy_ast_double_node *)node;
b_printf(" (%.2lf)", v->n_value->t_double); fx_printf(" (%.2lf)", v->n_value->t_double);
break; break;
} }
case IVY_AST_IDENT: { case IVY_AST_IDENT: {
struct ivy_ast_ident_node *v = (struct ivy_ast_ident_node *)node; struct ivy_ast_ident_node *v = (struct ivy_ast_ident_node *)node;
b_printf(" (%s)", v->n_content->t_str); fx_printf(" (%s)", v->n_content->t_str);
break; break;
} }
case IVY_AST_STRING: { case IVY_AST_STRING: {
struct ivy_ast_string_node *v = (struct ivy_ast_string_node *)node; struct ivy_ast_string_node *v = (struct ivy_ast_string_node *)node;
b_printf(" (\"%s\")", v->n_value->t_str); fx_printf(" (\"%s\")", v->n_value->t_str);
break; break;
} }
case IVY_AST_ATOM: { case IVY_AST_ATOM: {
struct ivy_ast_atom_node *v = (struct ivy_ast_atom_node *)node; struct ivy_ast_atom_node *v = (struct ivy_ast_atom_node *)node;
b_printf(" (%s)", v->n_content->t_str); fx_printf(" (%s)", v->n_content->t_str);
break; break;
} }
case IVY_AST_SELECTOR: { case IVY_AST_SELECTOR: {
struct ivy_ast_selector_node *v struct ivy_ast_selector_node *v
= (struct ivy_ast_selector_node *)node; = (struct ivy_ast_selector_node *)node;
b_printf(" [["); fx_printf(" [[");
switch (v->n_recipient) { switch (v->n_recipient) {
case IVY_SELECTOR_RECIPIENT_CLASS: case IVY_SELECTOR_RECIPIENT_CLASS:
b_putc('+'); fx_putc('+');
break; break;
case IVY_SELECTOR_RECIPIENT_OBJECT: case IVY_SELECTOR_RECIPIENT_OBJECT:
b_putc('-'); fx_putc('-');
break; break;
default: default:
/* this will occur if the selector is being used to send /* this will occur if the selector is being used to send
@@ -263,101 +263,101 @@ extern enum ivy_status print_ast_node(
} }
if (v->n_msg_name) { if (v->n_msg_name) {
b_printf("%s", v->n_msg_name->t_str); fx_printf("%s", v->n_msg_name->t_str);
} }
if (v->n_msg_name && !b_queue_empty(&v->n_arg_labels)) { if (v->n_msg_name && !fx_queue_empty(&v->n_arg_labels)) {
b_putc('('); fx_putc('(');
} }
b_queue_iterator label_it = {0}; fx_queue_iterator label_it = {0};
b_queue_iterator name_it = {0}; fx_queue_iterator name_it = {0};
b_queue_iterator_begin(&v->n_arg_labels, &label_it); fx_queue_iterator_begin(&v->n_arg_labels, &label_it);
b_queue_iterator_begin(&v->n_arg_names, &name_it); fx_queue_iterator_begin(&v->n_arg_names, &name_it);
bool name_present = false; bool name_present = false;
int i = 0; int i = 0;
while (b_queue_iterator_is_valid(&label_it)) { while (fx_queue_iterator_is_valid(&label_it)) {
if (i > 0 && name_present) { if (i > 0 && name_present) {
fputc(' ', stdout); fputc(' ', stdout);
} }
struct ivy_token *label = b_unbox( struct ivy_token *label = fx_unbox(
struct ivy_token, label_it.entry, t_entry); struct ivy_token, label_it.entry, t_entry);
struct ivy_token *name = b_unbox( struct ivy_token *name = fx_unbox(
struct ivy_token, name_it.entry, t_entry); struct ivy_token, name_it.entry, t_entry);
if (label) { if (label) {
b_printf("%s:", label->t_str); fx_printf("%s:", label->t_str);
} }
if (name) { if (name) {
b_printf("%s", name->t_str); fx_printf("%s", name->t_str);
} }
name_present = (name != NULL); name_present = (name != NULL);
i++; i++;
b_queue_iterator_next(&label_it); fx_queue_iterator_next(&label_it);
b_queue_iterator_next(&name_it); fx_queue_iterator_next(&name_it);
} }
if (v->n_msg_name && !b_queue_empty(&v->n_arg_labels)) { if (v->n_msg_name && !fx_queue_empty(&v->n_arg_labels)) {
b_putc(')'); fx_putc(')');
} }
b_puts("]"); fx_puts("]");
break; break;
} }
case IVY_AST_OP: { case IVY_AST_OP: {
struct ivy_ast_op_node *v = (struct ivy_ast_op_node *)node; struct ivy_ast_op_node *v = (struct ivy_ast_op_node *)node;
b_printf(" (%s)", ivy_operator_id_to_string(v->n_op->op_id)); fx_printf(" (%s)", ivy_operator_id_to_string(v->n_op->op_id));
break; break;
} }
case IVY_AST_CLASS: { case IVY_AST_CLASS: {
struct ivy_ast_class_node *v = (struct ivy_ast_class_node *)node; struct ivy_ast_class_node *v = (struct ivy_ast_class_node *)node;
b_printf(" (%s)", v->n_ident->t_str); fx_printf(" (%s)", v->n_ident->t_str);
break; break;
} }
case IVY_AST_UNIT_PACKAGE: { case IVY_AST_UNIT_PACKAGE: {
struct ivy_ast_unit_package_node *v struct ivy_ast_unit_package_node *v
= (struct ivy_ast_unit_package_node *)node; = (struct ivy_ast_unit_package_node *)node;
b_printf(" ("); fx_printf(" (");
b_queue_iterator it = {0}; fx_queue_iterator it = {0};
int i = 0; int i = 0;
b_queue_foreach (&it, &v->n_ident) { fx_queue_foreach (&it, &v->n_ident) {
struct ivy_token *tok struct ivy_token *tok
= b_unbox(struct ivy_token, it.entry, t_entry); = fx_unbox(struct ivy_token, it.entry, t_entry);
if (i > 0) { if (i > 0) {
b_printf("."); fx_printf(".");
} }
b_printf("%s", tok->t_str); fx_printf("%s", tok->t_str);
i++; i++;
} }
b_printf(")"); fx_printf(")");
break; break;
} }
case IVY_AST_UNIT_IMPORT: { case IVY_AST_UNIT_IMPORT: {
struct ivy_ast_unit_import_node *v struct ivy_ast_unit_import_node *v
= (struct ivy_ast_unit_import_node *)node; = (struct ivy_ast_unit_import_node *)node;
b_printf(" ("); fx_printf(" (");
b_queue_iterator it = {0}; fx_queue_iterator it = {0};
int i = 0; int i = 0;
b_queue_foreach (&it, &v->n_ident) { fx_queue_foreach (&it, &v->n_ident) {
struct ivy_token *tok struct ivy_token *tok
= b_unbox(struct ivy_token, it.entry, t_entry); = fx_unbox(struct ivy_token, it.entry, t_entry);
if (i > 0) { if (i > 0) {
b_printf("."); fx_printf(".");
} }
b_printf("%s", tok->t_str); fx_printf("%s", tok->t_str);
i++; i++;
} }
b_printf(")"); fx_printf(")");
break; break;
} }
default: default:
@@ -389,6 +389,6 @@ extern enum ivy_status print_ast_node(
} }
#endif #endif
b_puts("[reset]\n"); fx_puts("[reset]\n");
return IVY_OK; return IVY_OK;
} }

View File

@@ -1,42 +1,42 @@
#include "line-ed.h" #include "line-ed.h"
#include <blue/ds/array.h> #include <fx/ds/array.h>
#include <blue/ds/string.h> #include <fx/ds/string.h>
void alloc_empty_history_entry(struct line_ed *ed) void alloc_empty_history_entry(struct line_ed *ed)
{ {
b_string *str = (b_string *)b_array_at( fx_string *str = (fx_string *)fx_array_at(
ed->l_history, b_array_size(ed->l_history) - 1); ed->l_history, fx_array_size(ed->l_history) - 1);
if (!str || b_string_get_size(str, B_STRLEN_NORMAL) > 0) { if (!str || fx_string_get_size(str, FX_STRLEN_NORMAL) > 0) {
str = b_string_create(); str = fx_string_create();
b_array_append(ed->l_history, (b_object *)str); fx_array_append(ed->l_history, (fx_object *)str);
} }
ed->l_history_pos = b_array_size(ed->l_history) - 1; ed->l_history_pos = fx_array_size(ed->l_history) - 1;
} }
void save_buf_to_history(struct line_ed *ed) void save_buf_to_history(struct line_ed *ed)
{ {
b_string *cur = (b_string *)b_array_get(ed->l_history, ed->l_history_pos); fx_string *cur = (fx_string *)fx_array_get(ed->l_history, ed->l_history_pos);
b_string_replace_all(cur, ed->l_buf); fx_string_replace_all(cur, ed->l_buf);
} }
void append_buf_to_history(struct line_ed *ed) void append_buf_to_history(struct line_ed *ed)
{ {
b_string *cur = (b_string *)b_array_get(ed->l_history, ed->l_history_pos); fx_string *cur = (fx_string *)fx_array_get(ed->l_history, ed->l_history_pos);
char s[] = {'\n', 0}; char s[] = {'\n', 0};
b_string_append_cstr(cur, s); fx_string_append_cstr(cur, s);
b_string_append_cstr(cur, ed->l_buf); fx_string_append_cstr(cur, ed->l_buf);
} }
void load_buf_from_history(struct line_ed *ed) void load_buf_from_history(struct line_ed *ed)
{ {
b_string *cur = (b_string *)b_array_at(ed->l_history, ed->l_history_pos); fx_string *cur = (fx_string *)fx_array_at(ed->l_history, ed->l_history_pos);
size_t len size_t len
= MIN((size_t)(ed->l_buf_end - ed->l_buf - 1), = MIN((size_t)(ed->l_buf_end - ed->l_buf - 1),
b_string_get_size(cur, B_STRLEN_NORMAL)); fx_string_get_size(cur, FX_STRLEN_NORMAL));
memcpy(ed->l_buf, b_string_ptr(cur), len); memcpy(ed->l_buf, fx_string_ptr(cur), len);
ed->l_buf[len] = '\0'; ed->l_buf[len] = '\0';
unsigned int x = 0, y = 0; unsigned int x = 0, y = 0;
@@ -57,11 +57,11 @@ void load_buf_from_history(struct line_ed *ed)
const char *last_history_line(struct line_ed *ed) const char *last_history_line(struct line_ed *ed)
{ {
size_t nlines = b_array_size(ed->l_history); size_t nlines = fx_array_size(ed->l_history);
if (nlines < 2) { if (nlines < 2) {
return NULL; return NULL;
} }
b_string *last = (b_string *)b_array_at(ed->l_history, nlines - 2); fx_string *last = (fx_string *)fx_array_at(ed->l_history, nlines - 2);
return b_string_ptr(last); return fx_string_ptr(last);
} }

View File

@@ -30,22 +30,22 @@ int compare_coords(size_t ax, size_t ay, size_t bx, size_t by)
struct hl_range *get_hl_range(struct line_ed *ed, size_t x, size_t y) struct hl_range *get_hl_range(struct line_ed *ed, size_t x, size_t y)
{ {
if (b_queue_empty(&ed->l_hl_ranges)) { if (fx_queue_empty(&ed->l_hl_ranges)) {
return NULL; return NULL;
} }
struct hl_range *best_match = NULL; struct hl_range *best_match = NULL;
b_queue_entry *entry = b_queue_first(&ed->l_hl_ranges); fx_queue_entry *entry = fx_queue_first(&ed->l_hl_ranges);
while (entry) { while (entry) {
struct hl_range *cur = b_unbox(struct hl_range, entry, h_entry); struct hl_range *cur = fx_unbox(struct hl_range, entry, h_entry);
int cmp_end = compare_coords(x, y, cur->h_end_x, cur->h_end_y); int cmp_end = compare_coords(x, y, cur->h_end_x, cur->h_end_y);
if (cmp_end != 1) { if (cmp_end != 1) {
return cur; return cur;
} }
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
return NULL; return NULL;
@@ -53,20 +53,20 @@ struct hl_range *get_hl_range(struct line_ed *ed, size_t x, size_t y)
struct hl_range *get_next_hl_range(struct hl_range *range) struct hl_range *get_next_hl_range(struct hl_range *range)
{ {
b_queue_entry *entry = &range->h_entry; fx_queue_entry *entry = &range->h_entry;
entry = b_queue_next(entry); entry = fx_queue_next(entry);
if (!entry) { if (!entry) {
return NULL; return NULL;
} }
range = b_unbox(struct hl_range, entry, h_entry); range = fx_unbox(struct hl_range, entry, h_entry);
return range; return range;
} }
int apply_hl_range(struct hl_range *range, b_tty *tty, size_t x, size_t y) int apply_hl_range(struct hl_range *range, fx_tty *tty, size_t x, size_t y)
{ {
if (!range) { if (!range) {
b_tty_reset_vmode(tty); fx_tty_reset_vmode(tty);
return 0; return 0;
} }
@@ -74,11 +74,11 @@ int apply_hl_range(struct hl_range *range, b_tty *tty, size_t x, size_t y)
int cmp_end = compare_coords(x, y, range->h_end_x, range->h_end_y); int cmp_end = compare_coords(x, y, range->h_end_x, range->h_end_y);
if (cmp_start < 0) { if (cmp_start < 0) {
b_tty_reset_vmode(tty); fx_tty_reset_vmode(tty);
} }
if (cmp_start >= 0 && cmp_end <= 0) { if (cmp_start >= 0 && cmp_end <= 0) {
b_tty_set_vmode(tty, &range->h_vmode); fx_tty_set_vmode(tty, &range->h_vmode);
} }
if (cmp_end == 1) { if (cmp_end == 1) {
@@ -90,7 +90,7 @@ int apply_hl_range(struct hl_range *range, b_tty *tty, size_t x, size_t y)
struct hl_range *create_highlight( struct hl_range *create_highlight(
size_t start_x, size_t start_y, size_t end_x, size_t end_y, size_t start_x, size_t start_y, size_t end_x, size_t end_y,
const b_tty_vmode *vmode) const fx_tty_vmode *vmode)
{ {
struct hl_range *out = malloc(sizeof *out); struct hl_range *out = malloc(sizeof *out);
if (!out) { if (!out) {
@@ -179,7 +179,7 @@ static void move_start_to_meet_end(
void line_ed_put_highlight( void line_ed_put_highlight(
struct line_ed *ed, unsigned long start_x, unsigned long start_y, struct line_ed *ed, unsigned long start_x, unsigned long start_y,
unsigned long end_x, unsigned long end_y, const struct b_tty_vmode *vmode) unsigned long end_x, unsigned long end_y, const struct fx_tty_vmode *vmode)
{ {
struct hl_range *highlight struct hl_range *highlight
= create_highlight(start_x, start_y, end_x, end_y, vmode); = create_highlight(start_x, start_y, end_x, end_y, vmode);
@@ -189,30 +189,30 @@ void line_ed_put_highlight(
struct hl_range *h2 = NULL; struct hl_range *h2 = NULL;
b_queue_entry *entry = NULL; fx_queue_entry *entry = NULL;
entry = b_queue_first(&ed->l_hl_ranges); entry = fx_queue_first(&ed->l_hl_ranges);
if (!entry) { if (!entry) {
b_queue_push_back(&ed->l_hl_ranges, &highlight->h_entry); fx_queue_push_back(&ed->l_hl_ranges, &highlight->h_entry);
return; return;
} }
struct hl_range *cur = NULL; struct hl_range *cur = NULL;
enum hl_range_comparison prev_cmp = -1; enum hl_range_comparison prev_cmp = -1;
b_queue_entry *insert_before = NULL; fx_queue_entry *insert_before = NULL;
b_queue_entry *insert_after = NULL; fx_queue_entry *insert_after = NULL;
bool end = false; bool end = false;
while (entry) { while (entry) {
b_queue_entry *next = b_queue_next(entry); fx_queue_entry *next = fx_queue_next(entry);
cur = b_unbox(struct hl_range, entry, h_entry); cur = fx_unbox(struct hl_range, entry, h_entry);
enum hl_range_comparison cmp = compare_hl_ranges(cur, highlight); enum hl_range_comparison cmp = compare_hl_ranges(cur, highlight);
switch (cmp) { switch (cmp) {
case HL_RANGE_A_IN_B: case HL_RANGE_A_IN_B:
b_queue_delete(&ed->l_hl_ranges, entry); fx_queue_delete(&ed->l_hl_ranges, entry);
free(cur); free(cur);
break; break;
case HL_RANGE_B_IN_A: case HL_RANGE_B_IN_A:
@@ -220,10 +220,10 @@ void line_ed_put_highlight(
h2 = create_highlight( h2 = create_highlight(
0, 0, cur->h_end_x, cur->h_end_y, &cur->h_vmode); 0, 0, cur->h_end_x, cur->h_end_y, &cur->h_vmode);
move_start_to_meet_end(h2, highlight); move_start_to_meet_end(h2, highlight);
b_queue_insert_after( fx_queue_insert_after(
&ed->l_hl_ranges, &highlight->h_entry, &ed->l_hl_ranges, &highlight->h_entry,
&cur->h_entry); &cur->h_entry);
b_queue_insert_after( fx_queue_insert_after(
&ed->l_hl_ranges, &h2->h_entry, &ed->l_hl_ranges, &h2->h_entry,
&highlight->h_entry); &highlight->h_entry);
insert_before = insert_after = NULL; insert_before = insert_after = NULL;
@@ -239,7 +239,7 @@ void line_ed_put_highlight(
insert_before = entry; insert_before = entry;
break; break;
case HL_RANGE_GREATER: case HL_RANGE_GREATER:
b_queue_insert_before( fx_queue_insert_before(
&ed->l_hl_ranges, &highlight->h_entry, entry); &ed->l_hl_ranges, &highlight->h_entry, entry);
insert_before = insert_after = NULL; insert_before = insert_after = NULL;
end = true; end = true;
@@ -255,32 +255,32 @@ void line_ed_put_highlight(
} }
if (insert_before) { if (insert_before) {
b_queue_insert_before( fx_queue_insert_before(
&ed->l_hl_ranges, &highlight->h_entry, insert_before); &ed->l_hl_ranges, &highlight->h_entry, insert_before);
} else if (insert_after) { } else if (insert_after) {
b_queue_insert_after( fx_queue_insert_after(
&ed->l_hl_ranges, &highlight->h_entry, insert_after); &ed->l_hl_ranges, &highlight->h_entry, insert_after);
} }
} }
void line_ed_clear_highlights(struct line_ed *ed) void line_ed_clear_highlights(struct line_ed *ed)
{ {
b_queue_entry *entry = b_queue_pop_front(&ed->l_hl_ranges); fx_queue_entry *entry = fx_queue_pop_front(&ed->l_hl_ranges);
while (entry) { while (entry) {
struct hl_range *range = b_unbox(struct hl_range, entry, h_entry); struct hl_range *range = fx_unbox(struct hl_range, entry, h_entry);
free(range); free(range);
entry = b_queue_pop_front(&ed->l_hl_ranges); entry = fx_queue_pop_front(&ed->l_hl_ranges);
} }
} }
void line_ed_print_highlights(struct line_ed *ed) void line_ed_print_highlights(struct line_ed *ed)
{ {
b_queue_entry *entry = b_queue_first(&ed->l_hl_ranges); fx_queue_entry *entry = fx_queue_first(&ed->l_hl_ranges);
while (entry) { while (entry) {
struct hl_range *h = b_unbox(struct hl_range, entry, h_entry); struct hl_range *h = fx_unbox(struct hl_range, entry, h_entry);
printf("(%zu, %zu) -> (%zu, %zu)\n", h->h_start_x, h->h_start_y, printf("(%zu, %zu) -> (%zu, %zu)\n", h->h_start_x, h->h_start_y,
h->h_end_x, h->h_end_y); h->h_end_x, h->h_end_y);
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
} }

View File

@@ -1,9 +1,9 @@
#ifndef LINE_ED_HL_RANGE_H_ #ifndef LINE_ED_HL_RANGE_H_
#define LINE_ED_HL_RANGE_H_ #define LINE_ED_HL_RANGE_H_
#include <blue/term/tty.h> #include <fx/term/tty.h>
#include <blue/core/queue.h> #include <fx/core/queue.h>
struct line_ed; struct line_ed;
@@ -20,18 +20,18 @@ enum hl_range_comparison {
struct hl_range { struct hl_range {
size_t h_start_x, h_start_y; size_t h_start_x, h_start_y;
size_t h_end_x, h_end_y; size_t h_end_x, h_end_y;
b_tty_vmode h_vmode; fx_tty_vmode h_vmode;
b_queue_entry h_entry; fx_queue_entry h_entry;
}; };
extern int compare_coords(size_t ax, size_t ay, size_t bx, size_t by); extern int compare_coords(size_t ax, size_t ay, size_t bx, size_t by);
extern struct hl_range *get_hl_range(struct line_ed *ed, size_t x, size_t y); extern struct hl_range *get_hl_range(struct line_ed *ed, size_t x, size_t y);
extern struct hl_range *get_next_hl_range(struct hl_range *range); extern struct hl_range *get_next_hl_range(struct hl_range *range);
extern int apply_hl_range(struct hl_range *range, b_tty *tty, size_t x, size_t y); extern int apply_hl_range(struct hl_range *range, fx_tty *tty, size_t x, size_t y);
extern struct hl_range *create_highlight( extern struct hl_range *create_highlight(
size_t start_x, size_t start_y, size_t end_x, size_t end_y, size_t start_x, size_t start_y, size_t end_x, size_t end_y,
const struct b_tty_vmode *vmode); const struct fx_tty_vmode *vmode);
extern enum hl_range_comparison compare_hl_ranges( extern enum hl_range_comparison compare_hl_ranges(
const struct hl_range *a, const struct hl_range *b); const struct hl_range *a, const struct hl_range *b);

View File

@@ -4,38 +4,38 @@
void line_ed_add_hook(struct line_ed *ed, struct line_ed_hook *hook) void line_ed_add_hook(struct line_ed *ed, struct line_ed_hook *hook)
{ {
b_queue_push_back(&ed->l_hooks, &hook->hook_entry); fx_queue_push_back(&ed->l_hooks, &hook->hook_entry);
} }
void line_ed_remove_hook(struct line_ed *ed, struct line_ed_hook *hook) void line_ed_remove_hook(struct line_ed *ed, struct line_ed_hook *hook)
{ {
b_queue_delete(&ed->l_hooks, &hook->hook_entry); fx_queue_delete(&ed->l_hooks, &hook->hook_entry);
} }
void hook_keypress(struct line_ed *ed, b_keycode key) void hook_keypress(struct line_ed *ed, fx_keycode key)
{ {
b_queue_entry *entry = b_queue_first(&ed->l_hooks); fx_queue_entry *entry = fx_queue_first(&ed->l_hooks);
while (entry) { while (entry) {
struct line_ed_hook *hook struct line_ed_hook *hook
= b_unbox(struct line_ed_hook, entry, hook_entry); = fx_unbox(struct line_ed_hook, entry, hook_entry);
if (hook->hook_keypress) { if (hook->hook_keypress) {
hook->hook_keypress(ed, hook, key); hook->hook_keypress(ed, hook, key);
} }
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
} }
void hook_buffer_modified(struct line_ed *ed) void hook_buffer_modified(struct line_ed *ed)
{ {
b_queue_entry *entry = b_queue_first(&ed->l_hooks); fx_queue_entry *entry = fx_queue_first(&ed->l_hooks);
while (entry) { while (entry) {
struct line_ed_hook *hook struct line_ed_hook *hook
= b_unbox(struct line_ed_hook, entry, hook_entry); = fx_unbox(struct line_ed_hook, entry, hook_entry);
if (hook->hook_buffer_modified) { if (hook->hook_buffer_modified) {
hook->hook_buffer_modified(ed, hook); hook->hook_buffer_modified(ed, hook);
} }
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
} }

View File

@@ -1,7 +1,7 @@
#ifndef LINE_ED_HOOK_H_ #ifndef LINE_ED_HOOK_H_
#define LINE_ED_HOOK_H_ #define LINE_ED_HOOK_H_
#include <blue/term/tty.h> #include <fx/term/tty.h>
enum hook_id { enum hook_id {
HOOK_KEYPRESS, HOOK_KEYPRESS,
@@ -10,7 +10,7 @@ enum hook_id {
struct line_ed; struct line_ed;
extern void hook_keypress(struct line_ed *ed, b_keycode key); extern void hook_keypress(struct line_ed *ed, fx_keycode key);
extern void hook_buffer_modified(struct line_ed *ed); extern void hook_buffer_modified(struct line_ed *ed);
#endif #endif

View File

@@ -113,7 +113,7 @@ void cursor_left(struct line_ed *ed)
{ {
if (ed->l_cursor_x != 0) { if (ed->l_cursor_x != 0) {
//fputs("\010", stdout); //fputs("\010", stdout);
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_CURSOR, -1); fx_tty_move_cursor_x(ed->l_tty, FX_TTY_POS_CURSOR, -1);
fflush(stdout); fflush(stdout);
ed->l_cursor_x--; ed->l_cursor_x--;
ed->l_buf_ptr--; ed->l_buf_ptr--;
@@ -135,8 +135,8 @@ void cursor_left(struct line_ed *ed)
ed->l_cursor_x = len - 1; ed->l_cursor_x = len - 1;
//printf("\033[A\033[%dG", len + prompt_len); //printf("\033[A\033[%dG", len + prompt_len);
b_tty_move_cursor_y(ed->l_tty, B_TTY_POS_CURSOR, -1); fx_tty_move_cursor_y(ed->l_tty, FX_TTY_POS_CURSOR, -1);
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_START, (int)(len + prompt_len)); fx_tty_move_cursor_x(ed->l_tty, FX_TTY_POS_START, (int)(len + prompt_len));
fflush(stdout); fflush(stdout);
} }
@@ -151,7 +151,7 @@ void cursor_right(struct line_ed *ed)
ed->l_cursor_x++; ed->l_cursor_x++;
ed->l_buf_ptr++; ed->l_buf_ptr++;
//fputs("\033[C", stdout); //fputs("\033[C", stdout);
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_CURSOR, 1); fx_tty_move_cursor_x(ed->l_tty, FX_TTY_POS_CURSOR, 1);
fflush(stdout); fflush(stdout);
return; return;
} }
@@ -165,8 +165,8 @@ void cursor_right(struct line_ed *ed)
ed->l_buf_ptr++; ed->l_buf_ptr++;
//printf("\033[B\033[G"); //printf("\033[B\033[G");
b_tty_move_cursor_y(ed->l_tty, B_TTY_POS_CURSOR, 1); fx_tty_move_cursor_y(ed->l_tty, FX_TTY_POS_CURSOR, 1);
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_START, 0); fx_tty_move_cursor_x(ed->l_tty, FX_TTY_POS_START, 0);
fflush(stdout); fflush(stdout);
} }
@@ -178,13 +178,13 @@ void arrow_up(struct line_ed *ed)
if (ed->l_cursor_y > 0) { if (ed->l_cursor_y > 0) {
//printf("\033[%uA", ed->l_cursor_y); //printf("\033[%uA", ed->l_cursor_y);
b_tty_move_cursor_y(ed->l_tty, B_TTY_POS_CURSOR, (long long)ed->l_cursor_y); fx_tty_move_cursor_y(ed->l_tty, FX_TTY_POS_CURSOR, (long long)ed->l_cursor_y);
} }
//printf("\033[%zuG\033[J", prompt_length(ed, PROMPT_MAIN) + 1); //printf("\033[%zuG\033[J", prompt_length(ed, PROMPT_MAIN) + 1);
b_tty_move_cursor_x( fx_tty_move_cursor_x(
ed->l_tty, B_TTY_POS_START, (long long)prompt_length(ed, PROMPT_MAIN)); ed->l_tty, FX_TTY_POS_START, (long long)prompt_length(ed, PROMPT_MAIN));
b_tty_clear(ed->l_tty, B_TTY_CLEAR_SCREEN | B_TTY_CLEAR_FROM_CURSOR); fx_tty_clear(ed->l_tty, FX_TTY_CLEAR_SCREEN | FX_TTY_CLEAR_FROM_CURSOR);
save_buf_to_history(ed); save_buf_to_history(ed);
ed->l_history_pos--; ed->l_history_pos--;
@@ -196,18 +196,18 @@ void arrow_up(struct line_ed *ed)
void arrow_down(struct line_ed *ed) void arrow_down(struct line_ed *ed)
{ {
if (ed->l_history_pos == b_array_size(ed->l_history) - 1) { if (ed->l_history_pos == fx_array_size(ed->l_history) - 1) {
return; return;
} }
if (ed->l_cursor_y > 0) { if (ed->l_cursor_y > 0) {
//printf("\033[%uA", ed->l_cursor_y); //printf("\033[%uA", ed->l_cursor_y);
b_tty_move_cursor_y(ed->l_tty, B_TTY_POS_CURSOR, (int)ed->l_cursor_y); fx_tty_move_cursor_y(ed->l_tty, FX_TTY_POS_CURSOR, (int)ed->l_cursor_y);
} }
//printf("\033[%zuG\033[J", prompt_length(ed, PROMPT_MAIN) + 1); //printf("\033[%zuG\033[J", prompt_length(ed, PROMPT_MAIN) + 1);
b_tty_move_cursor_x( fx_tty_move_cursor_x(
ed->l_tty, B_TTY_POS_START, prompt_length(ed, PROMPT_MAIN) + 1); ed->l_tty, FX_TTY_POS_START, prompt_length(ed, PROMPT_MAIN) + 1);
save_buf_to_history(ed); save_buf_to_history(ed);
ed->l_history_pos++; ed->l_history_pos++;

View File

@@ -5,7 +5,7 @@
#include "input.h" #include "input.h"
#include "prompt.h" #include "prompt.h"
#include <blue/term/tty.h> #include <fx/term/tty.h>
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -49,14 +49,14 @@ struct line_ed *line_ed_create(void)
return NULL; return NULL;
} }
out->l_history = b_array_create(); out->l_history = fx_array_create();
if (!out->l_history) { if (!out->l_history) {
free(out->l_buf); free(out->l_buf);
free(out); free(out);
return NULL; return NULL;
} }
out->l_tty = b_stdtty; out->l_tty = fx_stdtty;
out->l_buf_end = out->l_buf + LINE_MAX; out->l_buf_end = out->l_buf + LINE_MAX;
out->l_buf_ptr = out->l_buf; out->l_buf_ptr = out->l_buf;
out->l_line_end = out->l_buf; out->l_line_end = out->l_buf;
@@ -71,7 +71,7 @@ struct line_ed *line_ed_create(void)
void line_ed_destroy(struct line_ed *ed) void line_ed_destroy(struct line_ed *ed)
{ {
b_array_unref(ed->l_history); fx_array_unref(ed->l_history);
line_ed_clear_highlights(ed); line_ed_clear_highlights(ed);
free(ed->l_buf); free(ed->l_buf);
free(ed); free(ed);
@@ -181,8 +181,8 @@ size_t line_ed_readline(struct line_ed *ed, char *out, size_t max)
append_to_index = ed->l_history_pos; append_to_index = ed->l_history_pos;
} }
b_tty *tty = ed->l_tty; fx_tty *tty = ed->l_tty;
b_tty_set_mode(tty, B_TTY_RAW); fx_tty_set_mode(tty, FX_TTY_RAW);
show_prompt(ed); show_prompt(ed);
for (int i = 0; ed->l_buf[i]; i++) { for (int i = 0; ed->l_buf[i]; i++) {
@@ -198,10 +198,10 @@ size_t line_ed_readline(struct line_ed *ed, char *out, size_t max)
bool eof = false; bool eof = false;
while (!end) { while (!end) {
b_keycode key = b_tty_read_key(tty); fx_keycode key = fx_tty_read_key(tty);
hook_keypress(ed, key); hook_keypress(ed, key);
if (key == B_TTY_CTRL_KEY('d')) { if (key == FX_TTY_CTRL_KEY('d')) {
if (!input_is_empty(ed)) { if (!input_is_empty(ed)) {
continue; continue;
} }
@@ -210,13 +210,13 @@ size_t line_ed_readline(struct line_ed *ed, char *out, size_t max)
break; break;
} }
if (key & B_MOD_CTRL) { if (key & FX_MOD_CTRL) {
continue; continue;
} }
switch (key) { switch (key) {
case B_KEY_RETURN: case FX_KEY_RETURN:
b_tty_reset_vmode(tty); fx_tty_reset_vmode(tty);
if (ed->l_line_end > ed->l_buf if (ed->l_line_end > ed->l_buf
&& *(ed->l_line_end - 1) != '\\') { && *(ed->l_line_end - 1) != '\\') {
end = true; end = true;
@@ -243,19 +243,19 @@ size_t line_ed_readline(struct line_ed *ed, char *out, size_t max)
// fputs("\033[G\n", stdout); // fputs("\033[G\n", stdout);
show_prompt(ed); show_prompt(ed);
break; break;
case B_KEY_BACKSPACE: case FX_KEY_BACKSPACE:
backspace(ed); backspace(ed);
break; break;
case B_KEY_ARROW_LEFT: case FX_KEY_ARROW_LEFT:
cursor_left(ed); cursor_left(ed);
break; break;
case B_KEY_ARROW_RIGHT: case FX_KEY_ARROW_RIGHT:
cursor_right(ed); cursor_right(ed);
break; break;
case B_KEY_ARROW_UP: case FX_KEY_ARROW_UP:
arrow_up(ed); arrow_up(ed);
break; break;
case B_KEY_ARROW_DOWN: case FX_KEY_ARROW_DOWN:
arrow_down(ed); arrow_down(ed);
break; break;
default: default:
@@ -266,7 +266,7 @@ size_t line_ed_readline(struct line_ed *ed, char *out, size_t max)
} }
} }
b_tty_set_mode(tty, B_TTY_CANONICAL); fx_tty_set_mode(tty, FX_TTY_CANONICAL);
fputc('\n', stdout); fputc('\n', stdout);
if (*ed->l_buf == '\0') { if (*ed->l_buf == '\0') {
@@ -277,7 +277,7 @@ size_t line_ed_readline(struct line_ed *ed, char *out, size_t max)
ed->l_history_pos = append_to_index; ed->l_history_pos = append_to_index;
append_buf_to_history(ed); append_buf_to_history(ed);
} else { } else {
ed->l_history_pos = b_array_size(ed->l_history) - 1; ed->l_history_pos = fx_array_size(ed->l_history) - 1;
const char *last = last_history_line(ed); const char *last = last_history_line(ed);
if (!last || strcmp(last, ed->l_buf) != 0) { if (!last || strcmp(last, ed->l_buf) != 0) {

View File

@@ -3,21 +3,21 @@
#define LINE_MAX 4096 #define LINE_MAX 4096
#include <blue/term/tty.h> #include <fx/term/tty.h>
#include <blue/core/queue.h> #include <fx/core/queue.h>
#include <blue/ds/array.h> #include <fx/ds/array.h>
#include <ivy/line-source.h> #include <ivy/line-source.h>
#include <stddef.h> #include <stddef.h>
struct s_tty; struct s_tty;
struct b_tty_vmode; struct fx_tty_vmode;
struct line_ed; struct line_ed;
struct line_ed_hook { struct line_ed_hook {
void (*hook_keypress)(struct line_ed *, struct line_ed_hook *, b_keycode); void (*hook_keypress)(struct line_ed *, struct line_ed_hook *, fx_keycode);
void (*hook_buffer_modified)(struct line_ed *, struct line_ed_hook *); void (*hook_buffer_modified)(struct line_ed *, struct line_ed_hook *);
b_queue_entry hook_entry; fx_queue_entry hook_entry;
}; };
enum line_ed_flags { enum line_ed_flags {
@@ -57,7 +57,7 @@ struct line_ed {
struct ivy_line_source l_line_source; struct ivy_line_source l_line_source;
/* pointer to tty interface */ /* pointer to tty interface */
b_tty *l_tty; fx_tty *l_tty;
/* the lexical scope that we are currently in. /* the lexical scope that we are currently in.
* this is provided by components further up the input pipeline, * this is provided by components further up the input pipeline,
@@ -65,14 +65,14 @@ struct line_ed {
const char *l_scope_type; const char *l_scope_type;
/* array of previously entered commands */ /* array of previously entered commands */
b_array *l_history; fx_array *l_history;
/* index of the currently selected history entry */ /* index of the currently selected history entry */
size_t l_history_pos; size_t l_history_pos;
/* list of defined highlight ranges */ /* list of defined highlight ranges */
b_queue l_hl_ranges; fx_queue l_hl_ranges;
/* list of installed hooks */ /* list of installed hooks */
b_queue l_hooks; fx_queue l_hooks;
}; };
extern struct line_ed *line_ed_create(void); extern struct line_ed *line_ed_create(void);
@@ -82,7 +82,7 @@ extern void line_ed_set_scope_type(struct line_ed *ed, const char *scope_type);
extern void line_ed_put_highlight( extern void line_ed_put_highlight(
struct line_ed *ed, unsigned long start_x, unsigned long start_y, struct line_ed *ed, unsigned long start_x, unsigned long start_y,
unsigned long end_x, unsigned long end_y, const struct b_tty_vmode *vmode); unsigned long end_x, unsigned long end_y, const struct fx_tty_vmode *vmode);
extern void line_ed_clear_highlights(struct line_ed *ed); extern void line_ed_clear_highlights(struct line_ed *ed);
extern void line_ed_print_highlights(struct line_ed *ed); extern void line_ed_print_highlights(struct line_ed *ed);

View File

@@ -5,7 +5,7 @@
#include "buffer.h" #include "buffer.h"
#include "cursor.h" #include "cursor.h"
#include "hl-range.h" #include "hl-range.h"
#include <blue/term/tty.h> #include <fx/term/tty.h>
/* prints the provided string to the terminal, applying any relevant highlight ranges. /* prints the provided string to the terminal, applying any relevant highlight ranges.
* this function prints all characters in `s` until it encounters a null char (\0) or * this function prints all characters in `s` until it encounters a null char (\0) or
@@ -16,12 +16,12 @@
*/ */
void print_text(struct line_ed *ed, size_t x, size_t y, const char *s) void print_text(struct line_ed *ed, size_t x, size_t y, const char *s)
{ {
b_tty *tty = ed->l_tty; fx_tty *tty = ed->l_tty;
struct hl_range *cur_range = get_hl_range(ed, x, y); struct hl_range *cur_range = get_hl_range(ed, x, y);
for (size_t i = 0; s[i] != '\n' && s[i] != '\0'; i++) { for (size_t i = 0; s[i] != '\n' && s[i] != '\0'; i++) {
if (!cur_range) { if (!cur_range) {
b_tty_reset_vmode(tty); fx_tty_reset_vmode(tty);
fputc(s[i], stdout); fputc(s[i], stdout);
continue; continue;
} }
@@ -107,7 +107,7 @@ void put_refresh(struct line_ed *ed, struct refresh_state *state)
if (ed->l_flags & LINE_ED_FULL_REPRINT) { if (ed->l_flags & LINE_ED_FULL_REPRINT) {
if (start_x) { if (start_x) {
//fprintf(stdout, "\033[%uD", start_x); //fprintf(stdout, "\033[%uD", start_x);
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_CURSOR, -(long long)start_x); fx_tty_move_cursor_x(ed->l_tty, FX_TTY_POS_CURSOR, -(long long)start_x);
} }
start_x = 0; start_x = 0;
@@ -119,7 +119,7 @@ void put_refresh(struct line_ed *ed, struct refresh_state *state)
* so that the physical cursor will be placed AFTER the character that * so that the physical cursor will be placed AFTER the character that
* was just inserted. */ * was just inserted. */
cursor_rdelta--; cursor_rdelta--;
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_CURSOR, -cursor_rdelta); fx_tty_move_cursor_x(ed->l_tty, FX_TTY_POS_CURSOR, -cursor_rdelta);
#if 0 #if 0
for (unsigned int i = 0; i < cursor_rdelta; i++) { for (unsigned int i = 0; i < cursor_rdelta; i++) {
@@ -162,21 +162,21 @@ void backspace_nl_refresh(struct line_ed *ed, struct refresh_state *state)
* has just been moved up. from here, clear this line and the rest * has just been moved up. from here, clear this line and the rest
* from the screen. */ * from the screen. */
//fputs("\033[J", stdout); //fputs("\033[J", stdout);
b_tty_clear(ed->l_tty, B_TTY_CLEAR_SCREEN | B_TTY_CLEAR_FROM_CURSOR); fx_tty_clear(ed->l_tty, FX_TTY_CLEAR_SCREEN | FX_TTY_CLEAR_FROM_CURSOR);
if (ed->l_flags & LINE_ED_FULL_REPRINT) { if (ed->l_flags & LINE_ED_FULL_REPRINT) {
/* next, move the physical cursor up and to the beginning of the previous line */ /* next, move the physical cursor up and to the beginning of the previous line */
size_t tmp_x; size_t tmp_x;
line_ed_coords_to_physical_coords(ed, 0, ed->l_cursor_y, &tmp_x, NULL); line_ed_coords_to_physical_coords(ed, 0, ed->l_cursor_y, &tmp_x, NULL);
b_tty_move_cursor_y(ed->l_tty, B_TTY_POS_CURSOR, -1); fx_tty_move_cursor_y(ed->l_tty, FX_TTY_POS_CURSOR, -1);
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_START, tmp_x); fx_tty_move_cursor_x(ed->l_tty, FX_TTY_POS_START, tmp_x);
//fprintf(stdout, "\033[A\033[%uG", tmp_x + 1); //fprintf(stdout, "\033[A\033[%uG", tmp_x + 1);
start_x = 0; start_x = 0;
} else { } else {
/* next, move the physical cursor up and to the end of the previous line */ /* next, move the physical cursor up and to the end of the previous line */
//fprintf(stdout, "\033[A\033[%uG", new_x); //fprintf(stdout, "\033[A\033[%uG", new_x);
b_tty_move_cursor_y(ed->l_tty, B_TTY_POS_CURSOR, -1); fx_tty_move_cursor_y(ed->l_tty, FX_TTY_POS_CURSOR, -1);
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_START, new_x); fx_tty_move_cursor_x(ed->l_tty, FX_TTY_POS_START, new_x);
} }
/* now reprint all of the buffer lines, starting with the first of the /* now reprint all of the buffer lines, starting with the first of the
@@ -202,11 +202,11 @@ void backspace_nl_refresh(struct line_ed *ed, struct refresh_state *state)
* were concatenated. */ * were concatenated. */
if (ydiff) { if (ydiff) {
//fprintf(stdout, "\033[%uA", ydiff); //fprintf(stdout, "\033[%uA", ydiff);
b_tty_move_cursor_y(ed->l_tty, B_TTY_POS_CURSOR, ydiff); fx_tty_move_cursor_y(ed->l_tty, FX_TTY_POS_CURSOR, ydiff);
} }
//fprintf(stdout, "\033[%uG", new_x); //fprintf(stdout, "\033[%uG", new_x);
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_START, new_x); fx_tty_move_cursor_x(ed->l_tty, FX_TTY_POS_START, new_x);
fflush(stdout); fflush(stdout);
} }
@@ -232,14 +232,14 @@ void backspace_simple_refresh(struct line_ed *ed, struct refresh_state *state)
if (ed->l_flags & LINE_ED_FULL_REPRINT) { if (ed->l_flags & LINE_ED_FULL_REPRINT) {
if (start_x) { if (start_x) {
//fprintf(stdout, "\033[%uD", start_x); //fprintf(stdout, "\033[%uD", start_x);
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_CURSOR, -(long long)start_x); fx_tty_move_cursor_x(ed->l_tty, FX_TTY_POS_CURSOR, -(long long)start_x);
} }
start_x = 0; start_x = 0;
} }
//fputc('\010', stdout); //fputc('\010', stdout);
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_CURSOR, -1); fx_tty_move_cursor_x(ed->l_tty, FX_TTY_POS_CURSOR, -1);
print_text(ed, start_x, ed->l_cursor_y, line_buf + start_x); print_text(ed, start_x, ed->l_cursor_y, line_buf + start_x);
fputc(' ', stdout); fputc(' ', stdout);
@@ -248,7 +248,7 @@ void backspace_simple_refresh(struct line_ed *ed, struct refresh_state *state)
* the fact that backspace was just pressed) */ * the fact that backspace was just pressed) */
cursor_rdelta++; cursor_rdelta++;
b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_CURSOR, -cursor_rdelta); fx_tty_move_cursor_x(ed->l_tty, FX_TTY_POS_CURSOR, -cursor_rdelta);
#if 0 #if 0
for (unsigned int i = 0; i < cursor_rdelta; i++) { for (unsigned int i = 0; i < cursor_rdelta; i++) {

View File

@@ -1,8 +1,8 @@
#include "cmd/cmd.h" #include "cmd/cmd.h"
#include <blue/cmd.h> #include <fx/cmd.h>
int main(int argc, const char **argv) int main(int argc, const char **argv)
{ {
return b_command_dispatch(CMD_ROOT, argc, argv); return fx_command_dispatch(CMD_ROOT, argc, argv);
} }

View File

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

View File

@@ -1,13 +1,13 @@
#include "ctx.h" #include "ctx.h"
#include "node.h" #include "node.h"
#include <blue/ds/string.h> #include <fx/ds/string.h>
static void to_string(struct ivy_ast_node *node, b_string *str) static void to_string(struct ivy_ast_node *node, fx_string *str)
{ {
struct ivy_ast_atom_node *v = (struct ivy_ast_atom_node *)node; struct ivy_ast_atom_node *v = (struct ivy_ast_atom_node *)node;
b_string_append_cstrf( fx_string_append_cstrf(
str, "%s (%s)", ivy_ast_node_type_to_string(node->n_type), str, "%s (%s)", ivy_ast_node_type_to_string(node->n_type),
v->n_content->t_str); v->n_content->t_str);
} }

View File

@@ -5,7 +5,7 @@
#include "iterate.h" #include "iterate.h"
#include "node.h" #include "node.h"
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
void block_add_terminator(struct block_parser_state *state, unsigned short tok) void block_add_terminator(struct block_parser_state *state, unsigned short tok)
@@ -134,7 +134,7 @@ static enum ivy_status add_child(
struct ivy_ast_block_node *block struct ivy_ast_block_node *block
= (struct ivy_ast_block_node *)parent->s_node; = (struct ivy_ast_block_node *)parent->s_node;
b_queue_push_back(&block->n_expr, &child->n_entry); fx_queue_push_back(&block->n_expr, &child->n_entry);
return IVY_OK; return IVY_OK;
} }
@@ -143,12 +143,12 @@ static void collect_children(
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator) struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
{ {
struct ivy_ast_block_node *block = (struct ivy_ast_block_node *)node; struct ivy_ast_block_node *block = (struct ivy_ast_block_node *)node;
b_queue_entry *entry = b_queue_first(&block->n_expr); fx_queue_entry *entry = fx_queue_first(&block->n_expr);
while (entry) { while (entry) {
struct ivy_ast_node *expr struct ivy_ast_node *expr
= b_unbox(struct ivy_ast_node, entry, n_entry); = fx_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, expr); ast_node_iterator_enqueue_node(iterator, node, expr);
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
} }

View File

@@ -11,12 +11,12 @@ static void collect_children(
ast_node_iterator_enqueue_node(iterator, node, cascade->n_recipient); ast_node_iterator_enqueue_node(iterator, node, cascade->n_recipient);
} }
b_queue_entry *entry = b_queue_first(&cascade->n_msg); fx_queue_entry *entry = fx_queue_first(&cascade->n_msg);
while (entry) { while (entry) {
struct ivy_ast_node *arg struct ivy_ast_node *arg
= b_unbox(struct ivy_ast_node, entry, n_entry); = fx_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, arg); ast_node_iterator_enqueue_node(iterator, node, arg);
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
} }

View File

@@ -2,7 +2,7 @@
#include "iterate.h" #include "iterate.h"
#include "node.h" #include "node.h"
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
#include <stdio.h> #include <stdio.h>
@@ -130,10 +130,10 @@ static enum ivy_status add_child(
switch (child->n_type) { switch (child->n_type) {
case IVY_AST_MSGH: case IVY_AST_MSGH:
b_queue_push_back(&c->n_msg_handlers, &child->n_entry); fx_queue_push_back(&c->n_msg_handlers, &child->n_entry);
break; break;
case IVY_AST_PROPERTY: case IVY_AST_PROPERTY:
b_queue_push_back(&c->n_properties, &child->n_entry); fx_queue_push_back(&c->n_properties, &child->n_entry);
break; break;
default: default:
return IVY_ERR_NOT_SUPPORTED; return IVY_ERR_NOT_SUPPORTED;
@@ -142,11 +142,11 @@ static enum ivy_status add_child(
return IVY_OK; return IVY_OK;
} }
static void to_string(struct ivy_ast_node *node, b_string *str) static void to_string(struct ivy_ast_node *node, fx_string *str)
{ {
struct ivy_ast_class_node *c = (struct ivy_ast_class_node *)node; struct ivy_ast_class_node *c = (struct ivy_ast_class_node *)node;
b_string_append_cstrf( fx_string_append_cstrf(
str, "%s (%s)", ivy_ast_node_type_to_string(node->n_type), str, "%s (%s)", ivy_ast_node_type_to_string(node->n_type),
c->n_ident->t_str); c->n_ident->t_str);
} }
@@ -162,20 +162,20 @@ static void collect_children(
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator) struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
{ {
struct ivy_ast_class_node *c = (struct ivy_ast_class_node *)node; struct ivy_ast_class_node *c = (struct ivy_ast_class_node *)node;
b_queue_entry *entry = b_queue_first(&c->n_properties); fx_queue_entry *entry = fx_queue_first(&c->n_properties);
while (entry) { while (entry) {
struct ivy_ast_node *child struct ivy_ast_node *child
= b_unbox(struct ivy_ast_node, entry, n_entry); = fx_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, child); ast_node_iterator_enqueue_node(iterator, node, child);
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
entry = b_queue_first(&c->n_msg_handlers); entry = fx_queue_first(&c->n_msg_handlers);
while (entry) { while (entry) {
struct ivy_ast_node *child struct ivy_ast_node *child
= b_unbox(struct ivy_ast_node, entry, n_entry); = fx_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, child); ast_node_iterator_enqueue_node(iterator, node, child);
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
} }

View File

@@ -8,7 +8,7 @@ struct cond_group_parser_state {
unsigned int s_prev_token; unsigned int s_prev_token;
struct ivy_ast_cond_node *s_cur_branch; struct ivy_ast_cond_node *s_cur_branch;
b_queue s_branches; fx_queue s_branches;
struct ivy_ast_node *s_prev_node; struct ivy_ast_node *s_prev_node;
}; };
@@ -26,7 +26,7 @@ static enum ivy_status flush_current_branch(struct cond_group_parser_state *stat
return IVY_ERR_INTERNAL_FAILURE; return IVY_ERR_INTERNAL_FAILURE;
} }
b_queue_push_back(&state->s_branches, &state->s_cur_branch->n_base.n_entry); fx_queue_push_back(&state->s_branches, &state->s_cur_branch->n_base.n_entry);
state->s_cur_branch state->s_cur_branch
= (struct ivy_ast_cond_node *)ast_node_create(IVY_AST_COND); = (struct ivy_ast_cond_node *)ast_node_create(IVY_AST_COND);
@@ -255,7 +255,7 @@ static enum ivy_status finalise_cond_group(struct cond_group_parser_state *state
flush_current_branch(state); flush_current_branch(state);
group->n_branches = state->s_branches; group->n_branches = state->s_branches;
state->s_branches = B_QUEUE_INIT; state->s_branches = FX_QUEUE_INIT;
return IVY_OK; return IVY_OK;
} else { } else {
/* we have just reached the 'end' keyword. */ /* we have just reached the 'end' keyword. */
@@ -274,7 +274,7 @@ static enum ivy_status finalise_cond_group(struct cond_group_parser_state *state
flush_current_branch(state); flush_current_branch(state);
group->n_branches = state->s_branches; group->n_branches = state->s_branches;
state->s_branches = B_QUEUE_INIT; state->s_branches = FX_QUEUE_INIT;
return IVY_OK; return IVY_OK;
} }
} }
@@ -339,12 +339,12 @@ static void cond_group_collect_children(
struct ivy_ast_cond_group_node *group struct ivy_ast_cond_group_node *group
= (struct ivy_ast_cond_group_node *)node; = (struct ivy_ast_cond_group_node *)node;
b_queue_entry *entry = b_queue_first(&group->n_branches); fx_queue_entry *entry = fx_queue_first(&group->n_branches);
while (entry) { while (entry) {
struct ivy_ast_node *branch struct ivy_ast_node *branch
= b_unbox(struct ivy_ast_node, entry, n_entry); = fx_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, branch); ast_node_iterator_enqueue_node(iterator, node, branch);
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
} }

View File

@@ -3,7 +3,7 @@
#include "../debug.h" #include "../debug.h"
#include "node.h" #include "node.h"
#include <blue/core/queue.h> #include <fx/core/queue.h>
#include <ivy/diag.h> #include <ivy/diag.h>
#include <ivy/lang/ast.h> #include <ivy/lang/ast.h>
#include <stddef.h> #include <stddef.h>
@@ -14,10 +14,10 @@
#ifdef IVY_LANG_DEBUG #ifdef IVY_LANG_DEBUG
static void print_state_stack(struct ivy_parser *parser) static void print_state_stack(struct ivy_parser *parser)
{ {
b_queue_iterator it = {0}; fx_queue_iterator it = {0};
b_queue_foreach (&it, &parser->p_state) { fx_queue_foreach (&it, &parser->p_state) {
struct parser_state *state struct parser_state *state
= b_unbox(struct parser_state, it.entry, s_entry); = fx_unbox(struct parser_state, it.entry, s_entry);
debug_printf( debug_printf(
" %s\n", " %s\n",
ivy_ast_node_type_to_string(state->s_node->n_type)); ivy_ast_node_type_to_string(state->s_node->n_type));
@@ -44,13 +44,13 @@ void ivy_parser_destroy(struct ivy_parser *parser, struct ivy_ast_node **result)
{ {
struct ivy_ast_node *root = NULL; struct ivy_ast_node *root = NULL;
b_queue_entry *entry = b_queue_first(&parser->p_state); fx_queue_entry *entry = fx_queue_first(&parser->p_state);
; ;
while (entry) { while (entry) {
struct parser_state *state struct parser_state *state
= b_unbox(struct parser_state, entry, s_entry); = fx_unbox(struct parser_state, entry, s_entry);
b_queue_entry *next = b_queue_next(entry); fx_queue_entry *next = fx_queue_next(entry);
b_queue_delete(&parser->p_state, entry); fx_queue_delete(&parser->p_state, entry);
if (root) { if (root) {
ivy_ast_node_destroy(root); ivy_ast_node_destroy(root);
@@ -173,29 +173,29 @@ enum ivy_status ivy_parser_push_eof(struct ivy_parser *parser)
struct parser_state *parser_get_state_generic(struct ivy_parser *parser) struct parser_state *parser_get_state_generic(struct ivy_parser *parser)
{ {
b_queue_entry *entry = b_queue_last(&parser->p_state); fx_queue_entry *entry = fx_queue_last(&parser->p_state);
if (!entry) { if (!entry) {
return NULL; return NULL;
} }
struct parser_state *state = b_unbox(struct parser_state, entry, s_entry); struct parser_state *state = fx_unbox(struct parser_state, entry, s_entry);
return state; return state;
} }
struct parser_state *parser_get_parent_state_generic( struct parser_state *parser_get_parent_state_generic(
struct ivy_parser *parser, enum ivy_ast_node_type type) struct ivy_parser *parser, enum ivy_ast_node_type type)
{ {
b_queue_entry *entry = b_queue_last(&parser->p_state); fx_queue_entry *entry = fx_queue_last(&parser->p_state);
if (!entry) { if (!entry) {
return NULL; return NULL;
} }
entry = b_queue_prev(entry); entry = fx_queue_prev(entry);
if (!entry) { if (!entry) {
return NULL; return NULL;
} }
struct parser_state *state = b_unbox(struct parser_state, entry, s_entry); struct parser_state *state = fx_unbox(struct parser_state, entry, s_entry);
if (state->s_node->n_type != type) { if (state->s_node->n_type != type) {
return NULL; return NULL;
@@ -219,15 +219,15 @@ struct parser_state *parser_push_state(
memset(state, 0x0, node_type->n_state_size); memset(state, 0x0, node_type->n_state_size);
b_queue_entry *current_state_entry = b_queue_last(&parser->p_state); fx_queue_entry *current_state_entry = fx_queue_last(&parser->p_state);
if (current_state_entry) { if (current_state_entry) {
struct parser_state *current_state = b_unbox( struct parser_state *current_state = fx_unbox(
struct parser_state, current_state_entry, s_entry); struct parser_state, current_state_entry, s_entry);
state->s_parent = current_state->s_node; state->s_parent = current_state->s_node;
} }
state->s_node = ast_node_create(type); state->s_node = ast_node_create(type);
b_queue_push_back(&parser->p_state, &state->s_entry); fx_queue_push_back(&parser->p_state, &state->s_entry);
if (node_type->n_init_state) { if (node_type->n_init_state) {
node_type->n_init_state(parser, state, arg); node_type->n_init_state(parser, state, arg);
@@ -246,9 +246,9 @@ void parser_pop_state(struct ivy_parser *parser, enum pop_state_flags flags)
return; return;
} }
b_queue_entry *entry = b_queue_last(&parser->p_state); fx_queue_entry *entry = fx_queue_last(&parser->p_state);
struct parser_state *state = b_unbox(struct parser_state, entry, s_entry); struct parser_state *state = fx_unbox(struct parser_state, entry, s_entry);
b_queue_pop_back(&parser->p_state); fx_queue_pop_back(&parser->p_state);
if (state && state->s_node && (flags & STATE_ADD_NODE_TO_PARENT)) { if (state && state->s_node && (flags & STATE_ADD_NODE_TO_PARENT)) {
parser_add_child(parser, state->s_node); parser_add_child(parser, state->s_node);
@@ -298,15 +298,15 @@ bool ivy_parser_is_node_complete(struct ivy_parser *parser)
struct ivy_ast_node *ivy_parser_root_node(struct ivy_parser *parser) struct ivy_ast_node *ivy_parser_root_node(struct ivy_parser *parser)
{ {
b_queue_entry *entry = b_queue_first(&parser->p_state); fx_queue_entry *entry = fx_queue_first(&parser->p_state);
struct parser_state *state = b_unbox(struct parser_state, entry, s_entry); struct parser_state *state = fx_unbox(struct parser_state, entry, s_entry);
return state ? state->s_node : NULL; return state ? state->s_node : NULL;
} }
struct ivy_ast_node *ivy_parser_dequeue_node(struct ivy_parser *parser) struct ivy_ast_node *ivy_parser_dequeue_node(struct ivy_parser *parser)
{ {
b_queue_entry *entry = b_queue_first(&parser->p_state); fx_queue_entry *entry = fx_queue_first(&parser->p_state);
struct parser_state *state = b_unbox(struct parser_state, entry, s_entry); struct parser_state *state = fx_unbox(struct parser_state, entry, s_entry);
if (!state) { if (!state) {
return NULL; return NULL;
@@ -318,13 +318,13 @@ struct ivy_ast_node *ivy_parser_dequeue_node(struct ivy_parser *parser)
struct ivy_ast_unit_node *unit = (struct ivy_ast_unit_node *)state->s_node; struct ivy_ast_unit_node *unit = (struct ivy_ast_unit_node *)state->s_node;
entry = b_queue_pop_front(&unit->n_children); entry = fx_queue_pop_front(&unit->n_children);
if (!entry) { if (!entry) {
return NULL; return NULL;
} }
return b_unbox(struct ivy_ast_node, entry, n_entry); return fx_unbox(struct ivy_ast_node, entry, n_entry);
} }
struct ivy_diag *parser_push_diag( struct ivy_diag *parser_push_diag(

View File

@@ -1,7 +1,7 @@
#ifndef _AST_CTX_H_ #ifndef _AST_CTX_H_
#define _AST_CTX_H_ #define _AST_CTX_H_
#include <blue/core/queue.h> #include <fx/core/queue.h>
#include <ivy/diag.h> #include <ivy/diag.h>
#include <ivy/lang/ast.h> #include <ivy/lang/ast.h>
#include <ivy/lang/diag.h> #include <ivy/lang/diag.h>
@@ -14,7 +14,7 @@
((state_type *)parser_get_parent_state_generic(parser, type_id)) ((state_type *)parser_get_parent_state_generic(parser, type_id))
struct parser_state { struct parser_state {
b_queue_entry s_entry; fx_queue_entry s_entry;
struct ivy_ast_node *s_parent; struct ivy_ast_node *s_parent;
struct ivy_ast_node *s_node; struct ivy_ast_node *s_node;
}; };
@@ -22,9 +22,9 @@ struct parser_state {
struct ivy_parser { struct ivy_parser {
enum ivy_status p_status; enum ivy_status p_status;
struct ivy_diag_ctx *p_diag_ctx; struct ivy_diag_ctx *p_diag_ctx;
b_queue p_state; fx_queue p_state;
b_queue p_token_queue; fx_queue p_token_queue;
b_queue p_node_queue; fx_queue p_node_queue;
}; };
enum pop_state_flags { enum pop_state_flags {

View File

@@ -1,13 +1,13 @@
#include "ctx.h" #include "ctx.h"
#include "node.h" #include "node.h"
#include <blue/ds/string.h> #include <fx/ds/string.h>
static void to_string(struct ivy_ast_node *node, b_string *str) static void to_string(struct ivy_ast_node *node, fx_string *str)
{ {
struct ivy_ast_double_node *v = (struct ivy_ast_double_node *)node; struct ivy_ast_double_node *v = (struct ivy_ast_double_node *)node;
b_string_append_cstrf( fx_string_append_cstrf(
str, "%s (%.2lf)", ivy_ast_node_type_to_string(node->n_type), str, "%s (%.2lf)", ivy_ast_node_type_to_string(node->n_type),
v->n_value->t_double); v->n_value->t_double);
} }

View File

@@ -3,7 +3,7 @@
#include "../node.h" #include "../node.h"
#include "expr.h" #include "expr.h"
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
#include <ivy/lang/operator.h> #include <ivy/lang/operator.h>
#include <stdio.h> #include <stdio.h>
@@ -63,7 +63,7 @@ enum ivy_status arith_push_operand(
IVY_AST_IDENT); IVY_AST_IDENT);
v->n_content = tok; v->n_content = tok;
ivy_ast_node_set_bounds_from_token((struct ivy_ast_node *)v, tok); ivy_ast_node_set_bounds_from_token((struct ivy_ast_node *)v, tok);
b_queue_push_back(&state->s_output_queue, &v->n_base.n_entry); fx_queue_push_back(&state->s_output_queue, &v->n_base.n_entry);
break; break;
} }
case IVY_TOK_INT: { case IVY_TOK_INT: {
@@ -71,7 +71,7 @@ enum ivy_status arith_push_operand(
= (struct ivy_ast_int_node *)ast_node_create(IVY_AST_INT); = (struct ivy_ast_int_node *)ast_node_create(IVY_AST_INT);
v->n_value = tok; v->n_value = tok;
ivy_ast_node_set_bounds_from_token((struct ivy_ast_node *)v, tok); ivy_ast_node_set_bounds_from_token((struct ivy_ast_node *)v, tok);
b_queue_push_back(&state->s_output_queue, &v->n_base.n_entry); fx_queue_push_back(&state->s_output_queue, &v->n_base.n_entry);
break; break;
} }
case IVY_TOK_DOUBLE: { case IVY_TOK_DOUBLE: {
@@ -80,7 +80,7 @@ enum ivy_status arith_push_operand(
IVY_AST_DOUBLE); IVY_AST_DOUBLE);
v->n_value = tok; v->n_value = tok;
ivy_ast_node_set_bounds_from_token((struct ivy_ast_node *)v, tok); ivy_ast_node_set_bounds_from_token((struct ivy_ast_node *)v, tok);
b_queue_push_back(&state->s_output_queue, &v->n_base.n_entry); fx_queue_push_back(&state->s_output_queue, &v->n_base.n_entry);
break; break;
} }
case IVY_TOK_ATOM: { case IVY_TOK_ATOM: {
@@ -88,7 +88,7 @@ enum ivy_status arith_push_operand(
= (struct ivy_ast_atom_node *)ast_node_create(IVY_AST_ATOM); = (struct ivy_ast_atom_node *)ast_node_create(IVY_AST_ATOM);
v->n_content = tok; v->n_content = tok;
ivy_ast_node_set_bounds_from_token((struct ivy_ast_node *)v, tok); ivy_ast_node_set_bounds_from_token((struct ivy_ast_node *)v, tok);
b_queue_push_back(&state->s_output_queue, &v->n_base.n_entry); fx_queue_push_back(&state->s_output_queue, &v->n_base.n_entry);
break; break;
} }
case IVY_TOK_STRING: { case IVY_TOK_STRING: {
@@ -97,7 +97,7 @@ enum ivy_status arith_push_operand(
IVY_AST_STRING); IVY_AST_STRING);
v->n_value = tok; v->n_value = tok;
ivy_ast_node_set_bounds_from_token((struct ivy_ast_node *)v, tok); ivy_ast_node_set_bounds_from_token((struct ivy_ast_node *)v, tok);
b_queue_push_back(&state->s_output_queue, &v->n_base.n_entry); fx_queue_push_back(&state->s_output_queue, &v->n_base.n_entry);
break; break;
} }
case IVY_TOK_SYMBOL: { case IVY_TOK_SYMBOL: {
@@ -107,7 +107,7 @@ enum ivy_status arith_push_operand(
struct ivy_ast_node *v = ast_node_create(IVY_AST_DISCARD); struct ivy_ast_node *v = ast_node_create(IVY_AST_DISCARD);
ivy_ast_node_set_bounds_from_token((struct ivy_ast_node *)v, tok); ivy_ast_node_set_bounds_from_token((struct ivy_ast_node *)v, tok);
b_queue_push_back(&state->s_output_queue, &v->n_entry); fx_queue_push_back(&state->s_output_queue, &v->n_entry);
break; break;
} }
case IVY_TOK_KEYWORD: { case IVY_TOK_KEYWORD: {
@@ -133,7 +133,7 @@ enum ivy_status arith_push_operand(
} }
ivy_ast_node_set_bounds_from_token((struct ivy_ast_node *)v, tok); ivy_ast_node_set_bounds_from_token((struct ivy_ast_node *)v, tok);
b_queue_push_back(&state->s_output_queue, &v->n_entry); fx_queue_push_back(&state->s_output_queue, &v->n_entry);
break; break;
} }
default: default:
@@ -204,20 +204,20 @@ static struct ivy_ast_node *create_operator_node_from_token(struct ivy_token *to
#ifdef IVY_LANG_DEBUG #ifdef IVY_LANG_DEBUG
static void print_expr_queues(struct expr_parser_state *state) static void print_expr_queues(struct expr_parser_state *state)
{ {
b_queue_iterator it = {0}; fx_queue_iterator it = {0};
debug_printf("operators:"); debug_printf("operators:");
b_queue_foreach (&it, &state->s_operator_stack) { fx_queue_foreach (&it, &state->s_operator_stack) {
struct ivy_ast_node *n struct ivy_ast_node *n
= b_unbox(struct ivy_ast_node, it.entry, n_entry); = fx_unbox(struct ivy_ast_node, it.entry, n_entry);
debug_printf(" "); debug_printf(" ");
print_operand(n); print_operand(n);
} }
debug_printf("\noperands:"); debug_printf("\noperands:");
b_queue_foreach (&it, &state->s_output_queue) { fx_queue_foreach (&it, &state->s_output_queue) {
struct ivy_ast_node *n struct ivy_ast_node *n
= b_unbox(struct ivy_ast_node, it.entry, n_entry); = fx_unbox(struct ivy_ast_node, it.entry, n_entry);
debug_printf(" "); debug_printf(" ");
print_operand(n); print_operand(n);
} }
@@ -234,13 +234,13 @@ void arith_push_operator(struct expr_parser_state *state, struct ivy_ast_node *n
} }
while (true) { while (true) {
b_queue_entry *top = b_queue_last(&state->s_operator_stack); fx_queue_entry *top = fx_queue_last(&state->s_operator_stack);
if (!top) { if (!top) {
break; break;
} }
struct ivy_ast_node *top_node struct ivy_ast_node *top_node
= b_unbox(struct ivy_ast_node, top, n_entry); = fx_unbox(struct ivy_ast_node, top, n_entry);
const struct ivy_operator *top_op = NULL; const struct ivy_operator *top_op = NULL;
switch (top_node->n_type) { switch (top_node->n_type) {
@@ -266,11 +266,11 @@ void arith_push_operator(struct expr_parser_state *state, struct ivy_ast_node *n
break; break;
} }
b_queue_delete(&state->s_operator_stack, top); fx_queue_delete(&state->s_operator_stack, top);
b_queue_push_back(&state->s_output_queue, top); fx_queue_push_back(&state->s_output_queue, top);
} }
b_queue_push_back(&state->s_operator_stack, &node->n_entry); fx_queue_push_back(&state->s_operator_stack, &node->n_entry);
#ifdef IVY_LANG_DEBUG #ifdef IVY_LANG_DEBUG
print_expr_queues(state); print_expr_queues(state);
#endif #endif
@@ -296,7 +296,7 @@ enum ivy_status expr_finalise_arith(
struct expr_parser_state *state, struct ivy_ast_node **expr_tree, struct expr_parser_state *state, struct ivy_ast_node **expr_tree,
enum ivy_operator_precedence minimum_precedence) enum ivy_operator_precedence minimum_precedence)
{ {
b_queue_entry *entry = NULL; fx_queue_entry *entry = NULL;
/* first, take all the operators still left on the operator stack and /* first, take all the operators still left on the operator stack and
* add them to the output queue. * add them to the output queue.
@@ -304,13 +304,13 @@ enum ivy_status expr_finalise_arith(
* since each set of parentheses has its own expression context, * since each set of parentheses has its own expression context,
* we don't have to handle parentheses here */ * we don't have to handle parentheses here */
while (true) { while (true) {
entry = b_queue_pop_back(&state->s_operator_stack); entry = fx_queue_pop_back(&state->s_operator_stack);
if (!entry) { if (!entry) {
break; break;
} }
struct ivy_ast_node *node struct ivy_ast_node *node
= b_unbox(struct ivy_ast_node, entry, n_entry); = fx_unbox(struct ivy_ast_node, entry, n_entry);
if (!node) { if (!node) {
/* this should never happen */ /* this should never happen */
return IVY_ERR_INTERNAL_FAILURE; return IVY_ERR_INTERNAL_FAILURE;
@@ -336,11 +336,11 @@ enum ivy_status expr_finalise_arith(
/* if we aren't processing operators below a certain precedence /* if we aren't processing operators below a certain precedence
* then leave them on the stack and stop here. */ * then leave them on the stack and stop here. */
if (op->op_precedence < minimum_precedence) { if (op->op_precedence < minimum_precedence) {
b_queue_push_back(&state->s_operator_stack, entry); fx_queue_push_back(&state->s_operator_stack, entry);
break; break;
} }
b_queue_push_back(&state->s_output_queue, entry); fx_queue_push_back(&state->s_output_queue, entry);
} }
#if 0 #if 0
@@ -353,22 +353,22 @@ enum ivy_status expr_finalise_arith(
* always follow their operands, so a queue of operands is needed * always follow their operands, so a queue of operands is needed
* for the conversion. */ * for the conversion. */
b_queue q = B_QUEUE_INIT; fx_queue q = FX_QUEUE_INIT;
b_queue_entry *tmp = NULL; fx_queue_entry *tmp = NULL;
entry = b_queue_first(&state->s_output_queue); entry = fx_queue_first(&state->s_output_queue);
int i = 0; int i = 0;
while (entry) { while (entry) {
struct ivy_ast_node *item struct ivy_ast_node *item
= b_unbox(struct ivy_ast_node, entry, n_entry); = fx_unbox(struct ivy_ast_node, entry, n_entry);
b_queue_entry *next = b_queue_next(entry); fx_queue_entry *next = fx_queue_next(entry);
b_queue_delete(&state->s_output_queue, entry); fx_queue_delete(&state->s_output_queue, entry);
/* if the node is an operand, just push it to a temporary queue /* if the node is an operand, just push it to a temporary queue
* and come back to it later. */ * and come back to it later. */
if (item->n_type != IVY_AST_OP && item->n_type != IVY_AST_MSG) { if (item->n_type != IVY_AST_OP && item->n_type != IVY_AST_MSG) {
/* operand */ /* operand */
b_queue_push_back(&q, &item->n_entry); fx_queue_push_back(&q, &item->n_entry);
goto next; goto next;
} }
@@ -384,11 +384,11 @@ enum ivy_status expr_finalise_arith(
* self-contained keyword message, and can be pushed to * self-contained keyword message, and can be pushed to
* the operand queue as-is. */ * the operand queue as-is. */
if (!msg->n_recipient) { if (!msg->n_recipient) {
tmp = b_queue_pop_back(&q); tmp = fx_queue_pop_back(&q);
msg->n_recipient = b_unbox( msg->n_recipient = fx_unbox(
struct ivy_ast_node, tmp, n_entry); struct ivy_ast_node, tmp, n_entry);
} }
b_queue_push_back(&q, &msg->n_base.n_entry); fx_queue_push_back(&q, &msg->n_base.n_entry);
goto next; goto next;
} }
@@ -397,15 +397,15 @@ enum ivy_status expr_finalise_arith(
* all the operands it needs, it can be pushed to the operand * all the operands it needs, it can be pushed to the operand
* queue as-is */ * queue as-is */
if (op_node_is_complete(op_node)) { if (op_node_is_complete(op_node)) {
b_queue_push_back(&q, &item->n_entry); fx_queue_push_back(&q, &item->n_entry);
goto next; goto next;
} }
/* otherwise, pop the relevant operands from the operand /* otherwise, pop the relevant operands from the operand
* queue... */ * queue... */
op = op_node->n_op; op = op_node->n_op;
tmp = b_queue_pop_back(&q); tmp = fx_queue_pop_back(&q);
op_node->n_right = b_unbox(struct ivy_ast_node, tmp, n_entry); op_node->n_right = fx_unbox(struct ivy_ast_node, tmp, n_entry);
if (op_node->n_right) { if (op_node->n_right) {
op_node->n_right->n_parent = (struct ivy_ast_node *)op_node; op_node->n_right->n_parent = (struct ivy_ast_node *)op_node;
@@ -416,9 +416,9 @@ enum ivy_status expr_finalise_arith(
} }
if (op->op_arity == IVY_OP_BINARY) { if (op->op_arity == IVY_OP_BINARY) {
tmp = b_queue_pop_back(&q); tmp = fx_queue_pop_back(&q);
op_node->n_left op_node->n_left
= b_unbox(struct ivy_ast_node, tmp, n_entry); = fx_unbox(struct ivy_ast_node, tmp, n_entry);
if (op_node->n_left) { if (op_node->n_left) {
op_node->n_left->n_parent op_node->n_left->n_parent
@@ -432,7 +432,7 @@ enum ivy_status expr_finalise_arith(
/* ...and push the newly-completed operator node to the operand /* ...and push the newly-completed operator node to the operand
* queue */ * queue */
b_queue_push_back(&q, &op_node->n_base.n_entry); fx_queue_push_back(&q, &op_node->n_base.n_entry);
next: next:
entry = next; entry = next;
} }
@@ -448,15 +448,15 @@ enum ivy_status expr_finalise_arith(
* their operands have just been moved to the temporary operand stack * their operands have just been moved to the temporary operand stack
* used above. move them back to the parser state's output queue here * used above. move them back to the parser state's output queue here
* so they can be used later. */ * so they can be used later. */
entry = b_queue_first(&state->s_operator_stack); entry = fx_queue_first(&state->s_operator_stack);
while (entry) { while (entry) {
b_queue_entry *entry2 = b_queue_pop_front(&q); fx_queue_entry *entry2 = fx_queue_pop_front(&q);
if (!entry2) { if (!entry2) {
return IVY_ERR_INTERNAL_FAILURE; return IVY_ERR_INTERNAL_FAILURE;
} }
b_queue_push_back(&state->s_output_queue, entry2); fx_queue_push_back(&state->s_output_queue, entry2);
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
#if 0 #if 0
@@ -468,8 +468,8 @@ enum ivy_status expr_finalise_arith(
/* the final node remaining on the temp operand stack is the root node /* the final node remaining on the temp operand stack is the root node
* of the new expression tree */ * of the new expression tree */
tmp = b_queue_pop_back(&q); tmp = fx_queue_pop_back(&q);
*expr_tree = b_unbox(struct ivy_ast_node, tmp, n_entry); *expr_tree = fx_unbox(struct ivy_ast_node, tmp, n_entry);
return IVY_OK; return IVY_OK;
} }
@@ -521,7 +521,7 @@ struct token_parse_result arith_parse_operand(
memset(empty_label, 0x0, sizeof *empty_label); memset(empty_label, 0x0, sizeof *empty_label);
empty_label->t_type = IVY_TOK_LABEL; empty_label->t_type = IVY_TOK_LABEL;
b_queue_push_back(&state->s_labels, &empty_label->t_entry); fx_queue_push_back(&state->s_labels, &empty_label->t_entry);
struct expr_parser_state *arg_expr struct expr_parser_state *arg_expr
= (struct expr_parser_state *)parser_push_state( = (struct expr_parser_state *)parser_push_state(
@@ -695,9 +695,9 @@ struct token_parse_result arith_parse_left_paren(
if (state->s_prev_token == IVY_TOK_IDENT) { if (state->s_prev_token == IVY_TOK_IDENT) {
/* this might be the opening parenthesis for a complex message. */ /* this might be the opening parenthesis for a complex message. */
b_queue_entry *msg_entry = b_queue_last(&state->s_operator_stack); fx_queue_entry *msg_entry = fx_queue_last(&state->s_operator_stack);
struct ivy_ast_node *msg struct ivy_ast_node *msg
= b_unbox(struct ivy_ast_node, msg_entry, n_entry); = fx_unbox(struct ivy_ast_node, msg_entry, n_entry);
if (!msg || msg->n_type != IVY_AST_MSG) { if (!msg || msg->n_type != IVY_AST_MSG) {
/* this is not a complex message, it's probably a /* this is not a complex message, it's probably a
@@ -705,7 +705,7 @@ struct token_parse_result arith_parse_left_paren(
goto not_complex_msg; goto not_complex_msg;
} }
b_queue_pop_back(&state->s_operator_stack); fx_queue_pop_back(&state->s_operator_stack);
struct expr_parser_state *msg_expr struct expr_parser_state *msg_expr
= (struct expr_parser_state *)parser_push_state( = (struct expr_parser_state *)parser_push_state(
@@ -761,7 +761,7 @@ not_complex_msg:
memset(empty_label, 0x0, sizeof *empty_label); memset(empty_label, 0x0, sizeof *empty_label);
empty_label->t_type = IVY_TOK_LABEL; empty_label->t_type = IVY_TOK_LABEL;
b_queue_push_back(&state->s_labels, &empty_label->t_entry); fx_queue_push_back(&state->s_labels, &empty_label->t_entry);
struct expr_parser_state *arg_expr struct expr_parser_state *arg_expr
= (struct expr_parser_state *)parser_push_state( = (struct expr_parser_state *)parser_push_state(
@@ -908,21 +908,21 @@ struct token_parse_result arith_parse_right_bracket(
return result; return result;
} }
static struct ivy_ast_selector_node *keyword_selector_from_label_list(b_queue *labels) static struct ivy_ast_selector_node *keyword_selector_from_label_list(fx_queue *labels)
{ {
struct ivy_ast_selector_node *sel struct ivy_ast_selector_node *sel
= (struct ivy_ast_selector_node *)ast_node_create(IVY_AST_SELECTOR); = (struct ivy_ast_selector_node *)ast_node_create(IVY_AST_SELECTOR);
b_queue_entry *entry = b_queue_first(labels); fx_queue_entry *entry = fx_queue_first(labels);
b_queue_entry *next = NULL; fx_queue_entry *next = NULL;
while (entry) { while (entry) {
struct ivy_token *label struct ivy_token *label
= b_unbox(struct ivy_token, entry, t_entry); = fx_unbox(struct ivy_token, entry, t_entry);
next = b_queue_next(entry); next = fx_queue_next(entry);
b_queue_delete(labels, entry); fx_queue_delete(labels, entry);
b_queue_push_back(&sel->n_arg_labels, &label->t_entry); fx_queue_push_back(&sel->n_arg_labels, &label->t_entry);
entry = next; entry = next;
} }
@@ -937,16 +937,16 @@ static struct ivy_ast_cascade_node *expr_finalise_cascade(
cascade->n_recipient = state->s_recipient; cascade->n_recipient = state->s_recipient;
b_queue_entry *entry = b_queue_first(&state->s_cascade_msg); fx_queue_entry *entry = fx_queue_first(&state->s_cascade_msg);
b_queue_entry *next = NULL; fx_queue_entry *next = NULL;
while (entry) { while (entry) {
struct ivy_ast_node *msg struct ivy_ast_node *msg
= b_unbox(struct ivy_ast_node, entry, n_entry); = fx_unbox(struct ivy_ast_node, entry, n_entry);
next = b_queue_next(entry); next = fx_queue_next(entry);
b_queue_delete(&state->s_cascade_msg, entry); fx_queue_delete(&state->s_cascade_msg, entry);
b_queue_push_back(&cascade->n_msg, &msg->n_entry); fx_queue_push_back(&cascade->n_msg, &msg->n_entry);
entry = next; entry = next;
} }
@@ -962,16 +962,16 @@ static struct ivy_ast_msg_node *expr_finalise_keyword_msg(
msg->n_recipient = state->s_recipient; msg->n_recipient = state->s_recipient;
msg->n_sel = keyword_selector_from_label_list(&state->s_labels); msg->n_sel = keyword_selector_from_label_list(&state->s_labels);
b_queue_entry *entry = b_queue_first(&state->s_args); fx_queue_entry *entry = fx_queue_first(&state->s_args);
b_queue_entry *next = NULL; fx_queue_entry *next = NULL;
while (entry) { while (entry) {
struct ivy_ast_node *arg struct ivy_ast_node *arg
= b_unbox(struct ivy_ast_node, entry, n_entry); = fx_unbox(struct ivy_ast_node, entry, n_entry);
next = b_queue_next(entry); next = fx_queue_next(entry);
b_queue_delete(&state->s_args, entry); fx_queue_delete(&state->s_args, entry);
b_queue_push_back(&msg->n_arg, &arg->n_entry); fx_queue_push_back(&msg->n_arg, &arg->n_entry);
entry = next; entry = next;
} }
@@ -988,26 +988,26 @@ static struct ivy_ast_msg_node *expr_finalise_complex_msg(
state->s_msg = NULL; state->s_msg = NULL;
b_queue_entry *entry = b_queue_first(&state->s_labels); fx_queue_entry *entry = fx_queue_first(&state->s_labels);
b_queue_entry *next = NULL; fx_queue_entry *next = NULL;
while (entry) { while (entry) {
struct ivy_token *label struct ivy_token *label
= b_unbox(struct ivy_token, entry, t_entry); = fx_unbox(struct ivy_token, entry, t_entry);
next = b_queue_next(entry); next = fx_queue_next(entry);
b_queue_delete(&state->s_labels, entry); fx_queue_delete(&state->s_labels, entry);
b_queue_push_back(&msg->n_sel->n_arg_labels, &label->t_entry); fx_queue_push_back(&msg->n_sel->n_arg_labels, &label->t_entry);
entry = next; entry = next;
} }
entry = b_queue_first(&state->s_args); entry = fx_queue_first(&state->s_args);
while (entry) { while (entry) {
struct ivy_ast_node *arg struct ivy_ast_node *arg
= b_unbox(struct ivy_ast_node, entry, n_entry); = fx_unbox(struct ivy_ast_node, entry, n_entry);
next = b_queue_next(entry); next = fx_queue_next(entry);
b_queue_delete(&state->s_args, entry); fx_queue_delete(&state->s_args, entry);
b_queue_push_back(&msg->n_arg, &arg->n_entry); fx_queue_push_back(&msg->n_arg, &arg->n_entry);
entry = next; entry = next;
} }
@@ -1032,9 +1032,9 @@ static enum ivy_status begin_cascade_operation(struct ivy_parser *ctx)
enum ivy_operator_precedence min_precedence enum ivy_operator_precedence min_precedence
= IVY_PRECEDENCE_CASCADE; = IVY_PRECEDENCE_CASCADE;
struct ivy_ast_node *prev = b_unbox( struct ivy_ast_node *prev = fx_unbox(
struct ivy_ast_node, struct ivy_ast_node,
b_queue_last(&state->s_operator_stack), n_entry); fx_queue_last(&state->s_operator_stack), n_entry);
if (prev && prev->n_type == IVY_AST_MSG) { if (prev && prev->n_type == IVY_AST_MSG) {
/* unary complex messages (which will be found on the /* unary complex messages (which will be found on the
* operator stack) have a very high precedence (much * operator stack) have a very high precedence (much
@@ -1079,7 +1079,7 @@ static enum ivy_status begin_cascade_operation(struct ivy_parser *ctx)
cascade_expr->s_type = EXPR_TYPE_ARITH; cascade_expr->s_type = EXPR_TYPE_ARITH;
cascade_expr->s_subexpr_depth = state->s_subexpr_depth + 1; cascade_expr->s_subexpr_depth = state->s_subexpr_depth + 1;
b_queue_push_back(&cascade_expr->s_cascade_msg, &first_msg->n_base.n_entry); fx_queue_push_back(&cascade_expr->s_cascade_msg, &first_msg->n_base.n_entry);
struct expr_parser_state *msg_expr struct expr_parser_state *msg_expr
= (struct expr_parser_state *)parser_push_state( = (struct expr_parser_state *)parser_push_state(
@@ -1338,8 +1338,8 @@ struct token_parse_result arith_parse_caret(
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
} }
if (!b_queue_empty(&state->s_operator_stack) if (!fx_queue_empty(&state->s_operator_stack)
|| !b_queue_empty(&state->s_output_queue)) { || !fx_queue_empty(&state->s_output_queue)) {
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
} }
@@ -1388,8 +1388,8 @@ struct token_parse_result arith_parse_comma(
} }
if (state->s_sub_type == EXPR_SUBTYPE_PAREN if (state->s_sub_type == EXPR_SUBTYPE_PAREN
&& b_queue_empty(&state->s_output_queue) && fx_queue_empty(&state->s_output_queue)
&& b_queue_empty(&state->s_operator_stack)) { && fx_queue_empty(&state->s_operator_stack)) {
parser_pop_state(ctx, 0); parser_pop_state(ctx, 0);
} else { } else {
/* the tuple parser will handle the parentheses for us. */ /* the tuple parser will handle the parentheses for us. */
@@ -1452,8 +1452,8 @@ struct token_parse_result arith_parse_label(
struct expr_parser_state *msg_expr; struct expr_parser_state *msg_expr;
bool new_parser = true; bool new_parser = true;
if (b_queue_empty(&state->s_operator_stack) if (fx_queue_empty(&state->s_operator_stack)
&& b_queue_empty(&state->s_output_queue)) { && fx_queue_empty(&state->s_output_queue)) {
new_parser = false; new_parser = false;
} }
@@ -1498,7 +1498,7 @@ struct token_parse_result arith_parse_label(
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
} }
b_queue_push_back(&state->s_labels, &tok->t_entry); fx_queue_push_back(&state->s_labels, &tok->t_entry);
struct expr_parser_state *arg_expr struct expr_parser_state *arg_expr
= (struct expr_parser_state *)parser_push_state( = (struct expr_parser_state *)parser_push_state(
@@ -1511,7 +1511,7 @@ struct token_parse_result arith_parse_label(
/* we may have just finished parsing a keyword-message argument, /* we may have just finished parsing a keyword-message argument,
* and this label marks the start of a new one. store the label * and this label marks the start of a new one. store the label
* and create a new argument parsing context. */ * and create a new argument parsing context. */
b_queue_push_back(&state->s_labels, &tok->t_entry); fx_queue_push_back(&state->s_labels, &tok->t_entry);
struct expr_parser_state *arg_expr struct expr_parser_state *arg_expr
= (struct expr_parser_state *)parser_push_state( = (struct expr_parser_state *)parser_push_state(
@@ -1532,16 +1532,16 @@ enum ivy_status arith_add_child(
if (state->s_sub_type == EXPR_SUBTYPE_CASCADE) { if (state->s_sub_type == EXPR_SUBTYPE_CASCADE) {
/* treat the child node as a cascaded message */ /* treat the child node as a cascaded message */
b_queue_push_back(&state->s_cascade_msg, &child->n_entry); fx_queue_push_back(&state->s_cascade_msg, &child->n_entry);
} else if ( } else if (
state->s_sub_type == EXPR_SUBTYPE_KEYWORD_MSG state->s_sub_type == EXPR_SUBTYPE_KEYWORD_MSG
|| state->s_sub_type == EXPR_SUBTYPE_COMPLEX_MSG) { || state->s_sub_type == EXPR_SUBTYPE_COMPLEX_MSG) {
/* treat the child node as a keyword-message argument */ /* treat the child node as a keyword-message argument */
b_queue_push_back(&state->s_args, &child->n_entry); fx_queue_push_back(&state->s_args, &child->n_entry);
} else if (state->s_sub_type == EXPR_SUBTYPE_KEYWORD_ARG) { } else if (state->s_sub_type == EXPR_SUBTYPE_KEYWORD_ARG) {
/* treat the child node as a sub-expression enclosed in /* treat the child node as a sub-expression enclosed in
* parentheses (i.e. an operand). */ * parentheses (i.e. an operand). */
b_queue_push_back(&state->s_output_queue, &child->n_entry); fx_queue_push_back(&state->s_output_queue, &child->n_entry);
state->s_prev_component = EXPR_CMP_OPERAND; state->s_prev_component = EXPR_CMP_OPERAND;
} else if (child->n_type == IVY_AST_MSG) { } else if (child->n_type == IVY_AST_MSG) {
arith_push_operator(state, child); arith_push_operator(state, child);
@@ -1549,7 +1549,7 @@ enum ivy_status arith_add_child(
} else { } else {
/* treat the child node as a sub-expression enclosed in /* treat the child node as a sub-expression enclosed in
* parentheses (i.e. an operand). */ * parentheses (i.e. an operand). */
b_queue_push_back(&state->s_output_queue, &child->n_entry); fx_queue_push_back(&state->s_output_queue, &child->n_entry);
state->s_prev_component = EXPR_CMP_OPERAND; state->s_prev_component = EXPR_CMP_OPERAND;
} }

View File

@@ -4,7 +4,7 @@
#include "../ctx.h" #include "../ctx.h"
#include "../node.h" #include "../node.h"
#include <blue/core/queue.h> #include <fx/core/queue.h>
#define EXPR_TERMINATOR_MAX 8 #define EXPR_TERMINATOR_MAX 8
@@ -76,19 +76,19 @@ struct expr_parser_state {
unsigned short s_terminators[EXPR_TERMINATOR_MAX]; unsigned short s_terminators[EXPR_TERMINATOR_MAX];
unsigned short s_nr_terminators; unsigned short s_nr_terminators;
b_queue s_output_queue; fx_queue s_output_queue;
b_queue s_operator_stack; fx_queue s_operator_stack;
/* these variables are for keyword-message expressions */ /* these variables are for keyword-message expressions */
struct ivy_ast_node *s_recipient; struct ivy_ast_node *s_recipient;
struct ivy_ast_msg_node *s_msg; struct ivy_ast_msg_node *s_msg;
b_queue s_labels; fx_queue s_labels;
union { union {
/* for keyword-messages, this is a list of arg values. */ /* for keyword-messages, this is a list of arg values. */
b_queue s_args; fx_queue s_args;
/* for cascade operators, this is a list of messages to send to the recipient. */ /* for cascade operators, this is a list of messages to send to the recipient. */
b_queue s_cascade_msg; fx_queue s_cascade_msg;
}; };
}; };

View File

@@ -1,7 +1,7 @@
#include "../node.h" #include "../node.h"
#include "expr.h" #include "expr.h"
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
#include <ivy/lang/operator.h> #include <ivy/lang/operator.h>
#include <stdio.h> #include <stdio.h>
@@ -27,8 +27,8 @@ struct token_parse_result stmt_parse_try(
state->s_prev_token = IVY_KW_TRY; state->s_prev_token = IVY_KW_TRY;
if (b_queue_empty(&state->s_operator_stack) if (fx_queue_empty(&state->s_operator_stack)
&& b_queue_empty(&state->s_output_queue)) { && fx_queue_empty(&state->s_output_queue)) {
parser_pop_state(ctx, 0); parser_pop_state(ctx, 0);
} }
@@ -71,8 +71,8 @@ struct token_parse_result stmt_parse_for(
state->s_prev_token = IVY_KW_FOR; state->s_prev_token = IVY_KW_FOR;
if (b_queue_empty(&state->s_operator_stack) if (fx_queue_empty(&state->s_operator_stack)
&& b_queue_empty(&state->s_output_queue)) { && fx_queue_empty(&state->s_output_queue)) {
parser_pop_state(ctx, 0); parser_pop_state(ctx, 0);
} }
@@ -107,8 +107,8 @@ struct token_parse_result stmt_parse_while(
state->s_prev_token = IVY_KW_WHILE; state->s_prev_token = IVY_KW_WHILE;
if (b_queue_empty(&state->s_operator_stack) if (fx_queue_empty(&state->s_operator_stack)
&& b_queue_empty(&state->s_output_queue)) { && fx_queue_empty(&state->s_output_queue)) {
parser_pop_state(ctx, 0); parser_pop_state(ctx, 0);
} }
@@ -140,8 +140,8 @@ struct token_parse_result stmt_parse_match(
state->s_prev_token = IVY_KW_MATCH; state->s_prev_token = IVY_KW_MATCH;
if (b_queue_empty(&state->s_operator_stack) if (fx_queue_empty(&state->s_operator_stack)
&& b_queue_empty(&state->s_output_queue)) { && fx_queue_empty(&state->s_output_queue)) {
parser_pop_state(ctx, 0); parser_pop_state(ctx, 0);
} }
@@ -186,8 +186,8 @@ struct token_parse_result stmt_parse_if(
state->s_prev_token = IVY_KW_IF; state->s_prev_token = IVY_KW_IF;
if (b_queue_empty(&state->s_operator_stack) if (fx_queue_empty(&state->s_operator_stack)
&& b_queue_empty(&state->s_output_queue)) { && fx_queue_empty(&state->s_output_queue)) {
parser_pop_state(ctx, 0); parser_pop_state(ctx, 0);
} }

View File

@@ -1,13 +1,13 @@
#include "ctx.h" #include "ctx.h"
#include "node.h" #include "node.h"
#include <blue/ds/string.h> #include <fx/ds/string.h>
static void to_string(struct ivy_ast_node *node, b_string *str) static void to_string(struct ivy_ast_node *node, fx_string *str)
{ {
struct ivy_ast_ident_node *ident = (struct ivy_ast_ident_node *)node; struct ivy_ast_ident_node *ident = (struct ivy_ast_ident_node *)node;
b_string_append_cstrf( fx_string_append_cstrf(
str, "%s (%s)", ivy_ast_node_type_to_string(node->n_type), str, "%s (%s)", ivy_ast_node_type_to_string(node->n_type),
ident->n_content->t_str); ident->n_content->t_str);
} }

View File

@@ -1,13 +1,13 @@
#include "ctx.h" #include "ctx.h"
#include "node.h" #include "node.h"
#include <blue/ds/string.h> #include <fx/ds/string.h>
static void to_string(struct ivy_ast_node *node, b_string *str) static void to_string(struct ivy_ast_node *node, fx_string *str)
{ {
struct ivy_ast_int_node *v = (struct ivy_ast_int_node *)node; struct ivy_ast_int_node *v = (struct ivy_ast_int_node *)node;
b_string_append_cstrf( fx_string_append_cstrf(
str, "%s (%llu)", ivy_ast_node_type_to_string(node->n_type), str, "%s (%llu)", ivy_ast_node_type_to_string(node->n_type),
v->n_value->t_int); v->n_value->t_int);
} }

View File

@@ -7,14 +7,14 @@ enum ivy_status iterate_regular(
ivy_ast_node_iteration_callback callback) ivy_ast_node_iteration_callback callback)
{ {
#if 0 #if 0
b_queue_push_back(&it->it_queue, &node->n_it.it_entry); fx_queue_push_back(&it->it_queue, &node->n_it.it_entry);
node->n_it.it_depth = 0; node->n_it.it_depth = 0;
while (!b_queue_empty(&it->it_queue)) { while (!fx_queue_empty(&it->it_queue)) {
b_queue_entry *entry = b_queue_first(&it->it_queue); fx_queue_entry *entry = fx_queue_first(&it->it_queue);
struct ivy_ast_node_iterator_entry *it_entry = b_unbox( struct ivy_ast_node_iterator_entry *it_entry = fx_unbox(
struct ivy_ast_node_iterator_entry, entry, it_entry); struct ivy_ast_node_iterator_entry, entry, it_entry);
node = b_unbox(struct ivy_ast_node, it_entry, n_it); node = fx_unbox(struct ivy_ast_node, it_entry, n_it);
if (!node) { if (!node) {
/* this should never happen. */ /* this should never happen. */
@@ -32,7 +32,7 @@ enum ivy_status iterate_regular(
type->n_collect_children(node, it); type->n_collect_children(node, it);
} }
b_queue_delete(&it->it_queue, entry); fx_queue_delete(&it->it_queue, entry);
} }
#endif #endif
@@ -60,15 +60,15 @@ enum ivy_status iterate_postorder(
* - should probably use this just for the executable parts of the AST, * - should probably use this just for the executable parts of the AST,
* not for nodes defining classes, function metadata, etc. * not for nodes defining classes, function metadata, etc.
*/ */
b_queue_push_back(&it->it_queue, &node->n_it.it_entry); fx_queue_push_back(&it->it_queue, &node->n_it.it_entry);
node->n_it.it_depth = 0; node->n_it.it_depth = 0;
b_queue_entry *entry = b_queue_first(&it->it_queue); fx_queue_entry *entry = fx_queue_first(&it->it_queue);
while (entry) { while (entry) {
struct ivy_ast_node_iterator_entry *it_entry = b_unbox( struct ivy_ast_node_iterator_entry *it_entry = fx_unbox(
struct ivy_ast_node_iterator_entry, entry, it_entry); struct ivy_ast_node_iterator_entry, entry, it_entry);
node = b_unbox(struct ivy_ast_node, it_entry, n_it); node = fx_unbox(struct ivy_ast_node, it_entry, n_it);
if (!node) { if (!node) {
/* this should never happen. */ /* this should never happen. */
@@ -81,16 +81,16 @@ enum ivy_status iterate_postorder(
type->n_collect_children(node, it); type->n_collect_children(node, it);
} }
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
while (!b_queue_empty(&it->it_queue)) { while (!fx_queue_empty(&it->it_queue)) {
b_queue_entry *entry = b_queue_pop_back(&it->it_queue); fx_queue_entry *entry = fx_queue_pop_back(&it->it_queue);
if (!entry) { if (!entry) {
break; break;
} }
node = b_unbox(struct ivy_ast_node, entry, n_it); node = fx_unbox(struct ivy_ast_node, entry, n_it);
if (!node) { if (!node) {
/* this should never happen. */ /* this should never happen. */
@@ -107,15 +107,15 @@ enum ivy_status ivy_ast_node_iterate(
struct ivy_ast_node *node, struct ivy_ast_node_iterator *it, struct ivy_ast_node *node, struct ivy_ast_node_iterator *it,
ivy_ast_node_iteration_callback callback, void *arg) ivy_ast_node_iteration_callback callback, void *arg)
{ {
b_queue_push_back(&it->it_queue, &node->n_it.it_entry); fx_queue_push_back(&it->it_queue, &node->n_it.it_entry);
node->n_it.it_depth = 0; node->n_it.it_depth = 0;
b_queue_entry *entry = b_queue_first(&it->it_queue); fx_queue_entry *entry = fx_queue_first(&it->it_queue);
while (entry) { while (entry) {
struct ivy_ast_node_iterator_entry *it_entry = b_unbox( struct ivy_ast_node_iterator_entry *it_entry = fx_unbox(
struct ivy_ast_node_iterator_entry, entry, it_entry); struct ivy_ast_node_iterator_entry, entry, it_entry);
node = b_unbox(struct ivy_ast_node, it_entry, n_it); node = fx_unbox(struct ivy_ast_node, it_entry, n_it);
if (!node) { if (!node) {
/* this should never happen. */ /* this should never happen. */
@@ -134,16 +134,16 @@ enum ivy_status ivy_ast_node_iterate(
type->n_collect_children(node, it); type->n_collect_children(node, it);
} }
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
while (!b_queue_empty(&it->it_queue)) { while (!fx_queue_empty(&it->it_queue)) {
b_queue_entry *entry = b_queue_pop_back(&it->it_queue); fx_queue_entry *entry = fx_queue_pop_back(&it->it_queue);
if (!entry) { if (!entry) {
break; break;
} }
node = b_unbox(struct ivy_ast_node, entry, n_it); node = fx_unbox(struct ivy_ast_node, entry, n_it);
if (!node) { if (!node) {
/* this should never happen. */ /* this should never happen. */
@@ -165,10 +165,10 @@ void ast_node_iterator_enqueue_node(
struct ivy_ast_node *node) struct ivy_ast_node *node)
{ {
if (it->it_insert_after) { if (it->it_insert_after) {
b_queue_insert_after( fx_queue_insert_after(
&it->it_queue, &node->n_it.it_entry, it->it_insert_after); &it->it_queue, &node->n_it.it_entry, it->it_insert_after);
} else { } else {
b_queue_push_back(&it->it_queue, &node->n_it.it_entry); fx_queue_push_back(&it->it_queue, &node->n_it.it_entry);
} }
node->n_it.it_depth = parent->n_it.it_depth + 1; node->n_it.it_depth = parent->n_it.it_depth + 1;

View File

@@ -11,7 +11,7 @@ struct lambda_parser_state {
struct ivy_ast_node *s_prev_node; struct ivy_ast_node *s_prev_node;
unsigned int s_prev; unsigned int s_prev;
b_queue s_args; fx_queue s_args;
struct ivy_ast_node *s_body; struct ivy_ast_node *s_body;
}; };
@@ -56,7 +56,7 @@ static struct token_parse_result parse_ident(
} }
arg->n_content = tok; arg->n_content = tok;
b_queue_push_back(&state->s_args, &arg->n_base.n_entry); fx_queue_push_back(&state->s_args, &arg->n_base.n_entry);
state->s_prev = IVY_TOK_IDENT; state->s_prev = IVY_TOK_IDENT;
return PARSE_RESULT(IVY_OK, 0); return PARSE_RESULT(IVY_OK, 0);
@@ -101,7 +101,7 @@ static void finalise_lambda(struct lambda_parser_state *state)
lambda->n_arg = state->s_args; lambda->n_arg = state->s_args;
lambda->n_body = state->s_body; lambda->n_body = state->s_body;
state->s_args = B_QUEUE_INIT; state->s_args = FX_QUEUE_INIT;
state->s_body = NULL; state->s_body = NULL;
} }
@@ -147,12 +147,12 @@ static void collect_children(
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator) struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
{ {
struct ivy_ast_lambda_node *lambda = (struct ivy_ast_lambda_node *)node; struct ivy_ast_lambda_node *lambda = (struct ivy_ast_lambda_node *)node;
b_queue_entry *entry = b_queue_first(&lambda->n_arg); fx_queue_entry *entry = fx_queue_first(&lambda->n_arg);
while (entry) { while (entry) {
struct ivy_ast_node *expr struct ivy_ast_node *expr
= b_unbox(struct ivy_ast_node, entry, n_entry); = fx_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, expr); ast_node_iterator_enqueue_node(iterator, node, expr);
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
if (lambda->n_body) { if (lambda->n_body) {

View File

@@ -1,11 +1,11 @@
#include "ctx.h" #include "ctx.h"
#include "node.h" #include "node.h"
#include <blue/ds/string.h> #include <fx/ds/string.h>
static void to_string(struct ivy_ast_node *node, b_string *str) static void to_string(struct ivy_ast_node *node, fx_string *str)
{ {
b_string_append_cstrf(str, "%s", ivy_ast_node_type_to_string(node->n_type)); fx_string_append_cstrf(str, "%s", ivy_ast_node_type_to_string(node->n_type));
} }
struct ast_node_type loop_break_node_ops = { struct ast_node_type loop_break_node_ops = {

View File

@@ -9,7 +9,7 @@ struct match_parser_state {
struct ivy_ast_node *s_cond; struct ivy_ast_node *s_cond;
struct ivy_ast_cond_node *s_cur_branch; struct ivy_ast_cond_node *s_cur_branch;
b_queue s_branches; fx_queue s_branches;
struct ivy_ast_node *s_prev_node; struct ivy_ast_node *s_prev_node;
}; };
@@ -52,7 +52,7 @@ static enum ivy_status flush_current_branch(struct match_parser_state *state)
return IVY_ERR_INTERNAL_FAILURE; return IVY_ERR_INTERNAL_FAILURE;
} }
b_queue_push_back(&state->s_branches, &state->s_cur_branch->n_base.n_entry); fx_queue_push_back(&state->s_branches, &state->s_cur_branch->n_base.n_entry);
state->s_cur_branch state->s_cur_branch
= (struct ivy_ast_cond_node *)ast_node_create(IVY_AST_COND); = (struct ivy_ast_cond_node *)ast_node_create(IVY_AST_COND);
@@ -107,7 +107,7 @@ static enum ivy_status finalise_match(struct match_parser_state *state)
match->n_cond = state->s_cond; match->n_cond = state->s_cond;
match->n_branches = state->s_branches; match->n_branches = state->s_branches;
state->s_branches = B_QUEUE_INIT; state->s_branches = FX_QUEUE_INIT;
return IVY_OK; return IVY_OK;
} }
@@ -262,10 +262,10 @@ static void match_collect_children(
ast_node_iterator_enqueue_node(iterator, node, match->n_cond); ast_node_iterator_enqueue_node(iterator, node, match->n_cond);
b_queue_entry *entry = b_queue_first(&match->n_branches); fx_queue_entry *entry = fx_queue_first(&match->n_branches);
while (entry) { while (entry) {
struct ivy_ast_node *branch struct ivy_ast_node *branch
= b_unbox(struct ivy_ast_node, entry, n_entry); = fx_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, branch); ast_node_iterator_enqueue_node(iterator, node, branch);
} }
} }

View File

@@ -16,12 +16,12 @@ static void collect_children(
iterator, node, (struct ivy_ast_node *)msg->n_sel); iterator, node, (struct ivy_ast_node *)msg->n_sel);
} }
b_queue_entry *entry = b_queue_first(&msg->n_arg); fx_queue_entry *entry = fx_queue_first(&msg->n_arg);
while (entry) { while (entry) {
struct ivy_ast_node *arg struct ivy_ast_node *arg
= b_unbox(struct ivy_ast_node, entry, n_entry); = fx_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, arg); ast_node_iterator_enqueue_node(iterator, node, arg);
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
} }

View File

@@ -4,7 +4,7 @@
#include "ivy/status.h" #include "ivy/status.h"
#include "node.h" #include "node.h"
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
struct msgh_parser_state { struct msgh_parser_state {

View File

@@ -1,6 +1,6 @@
#include "node.h" #include "node.h"
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <ivy/lang/ast.h> #include <ivy/lang/ast.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -250,7 +250,7 @@ struct ivy_ast_node *ast_node_create(enum ivy_ast_node_type type)
return node; return node;
} }
void ivy_ast_node_to_string(struct ivy_ast_node *node, b_string *out) void ivy_ast_node_to_string(struct ivy_ast_node *node, fx_string *out)
{ {
const struct ast_node_type *type_info = get_ast_node_type(node->n_type); const struct ast_node_type *type_info = get_ast_node_type(node->n_type);
if (!type_info) { if (!type_info) {
@@ -260,7 +260,7 @@ void ivy_ast_node_to_string(struct ivy_ast_node *node, b_string *out)
if (type_info->n_to_string) { if (type_info->n_to_string) {
type_info->n_to_string(node, out); type_info->n_to_string(node, out);
} else { } else {
b_string_append_cstr( fx_string_append_cstr(
out, ivy_ast_node_type_to_string(node->n_type)); out, ivy_ast_node_type_to_string(node->n_type));
} }
} }
@@ -301,15 +301,15 @@ void ivy_ast_node_extend_bounds_recursive(
void ivy_ast_node_destroy(struct ivy_ast_node *node) void ivy_ast_node_destroy(struct ivy_ast_node *node)
{ {
struct ivy_ast_node_iterator it = {}; struct ivy_ast_node_iterator it = {};
b_queue_push_back(&it.it_queue, &node->n_it.it_entry); fx_queue_push_back(&it.it_queue, &node->n_it.it_entry);
node->n_it.it_depth = 0; node->n_it.it_depth = 0;
b_queue_entry *entry = b_queue_first(&it.it_queue); fx_queue_entry *entry = fx_queue_first(&it.it_queue);
while (entry) { while (entry) {
struct ivy_ast_node_iterator_entry *it_entry = b_unbox( struct ivy_ast_node_iterator_entry *it_entry = fx_unbox(
struct ivy_ast_node_iterator_entry, entry, it_entry); struct ivy_ast_node_iterator_entry, entry, it_entry);
node = b_unbox(struct ivy_ast_node, it_entry, n_it); node = fx_unbox(struct ivy_ast_node, it_entry, n_it);
if (!node) { if (!node) {
/* this should never happen. */ /* this should never happen. */
@@ -322,16 +322,16 @@ void ivy_ast_node_destroy(struct ivy_ast_node *node)
type->n_collect_children(node, &it); type->n_collect_children(node, &it);
} }
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
while (!b_queue_empty(&it.it_queue)) { while (!fx_queue_empty(&it.it_queue)) {
b_queue_entry *entry = b_queue_pop_back(&it.it_queue); fx_queue_entry *entry = fx_queue_pop_back(&it.it_queue);
if (!entry) { if (!entry) {
break; break;
} }
node = b_unbox(struct ivy_ast_node, entry, n_it); node = fx_unbox(struct ivy_ast_node, entry, n_it);
const struct ast_node_type *type = get_ast_node_type(node->n_type); const struct ast_node_type *type = get_ast_node_type(node->n_type);
if (type && type->n_destroy) { if (type && type->n_destroy) {
@@ -397,15 +397,15 @@ const char *ivy_ast_node_type_to_string(enum ivy_ast_node_type v)
void ivy_ast_unit_add_node(struct ivy_ast_unit_node *unit, struct ivy_ast_node *child) void ivy_ast_unit_add_node(struct ivy_ast_unit_node *unit, struct ivy_ast_node *child)
{ {
b_queue_push_back(&unit->n_children, &child->n_entry); fx_queue_push_back(&unit->n_children, &child->n_entry);
} }
struct ivy_ast_node *ivy_ast_unit_dequeue_node(struct ivy_ast_unit_node *unit) struct ivy_ast_node *ivy_ast_unit_dequeue_node(struct ivy_ast_unit_node *unit)
{ {
b_queue_entry *entry = b_queue_pop_front(&unit->n_children); fx_queue_entry *entry = fx_queue_pop_front(&unit->n_children);
if (!entry) { if (!entry) {
return NULL; return NULL;
} }
return b_unbox(struct ivy_ast_node, entry, n_entry); return fx_unbox(struct ivy_ast_node, entry, n_entry);
} }

View File

@@ -1,7 +1,7 @@
#ifndef _AST_NODE_H_ #ifndef _AST_NODE_H_
#define _AST_NODE_H_ #define _AST_NODE_H_
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <ivy/lang/ast.h> #include <ivy/lang/ast.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
@@ -47,7 +47,7 @@ typedef struct token_parse_result (*token_parse_function)(
struct ast_node_type { struct ast_node_type {
enum ivy_status (*n_add_child)( enum ivy_status (*n_add_child)(
struct parser_state *, struct ivy_ast_node *); struct parser_state *, struct ivy_ast_node *);
void (*n_to_string)(struct ivy_ast_node *, b_string *); void (*n_to_string)(struct ivy_ast_node *, fx_string *);
void (*n_init_state)(struct ivy_parser *, struct parser_state *, uintptr_t); void (*n_init_state)(struct ivy_parser *, struct parser_state *, uintptr_t);
void (*n_collect_children)( void (*n_collect_children)(
struct ivy_ast_node *, struct ivy_ast_node_iterator *); struct ivy_ast_node *, struct ivy_ast_node_iterator *);

View File

@@ -2,13 +2,13 @@
#include "iterate.h" #include "iterate.h"
#include "node.h" #include "node.h"
#include <blue/ds/string.h> #include <fx/ds/string.h>
static void to_string(struct ivy_ast_node *node, b_string *str) static void to_string(struct ivy_ast_node *node, fx_string *str)
{ {
struct ivy_ast_op_node *op = (struct ivy_ast_op_node *)node; struct ivy_ast_op_node *op = (struct ivy_ast_op_node *)node;
b_string_append_cstrf( fx_string_append_cstrf(
str, "%s (%s)", ivy_ast_node_type_to_string(node->n_type), str, "%s (%s)", ivy_ast_node_type_to_string(node->n_type),
ivy_operator_id_to_string(op->n_op->op_id)); ivy_operator_id_to_string(op->n_op->op_id));
} }

View File

@@ -4,7 +4,7 @@
#include "iterate.h" #include "iterate.h"
#include "node.h" #include "node.h"
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
enum package_type { enum package_type {
@@ -23,7 +23,7 @@ struct package_parser_state {
unsigned int s_prev; unsigned int s_prev;
/* only used for PACKAGE_STATIC */ /* only used for PACKAGE_STATIC */
b_queue s_items; fx_queue s_items;
struct ivy_ast_node *s_next_index; struct ivy_ast_node *s_next_index;
unsigned int s_next_implicit_index; unsigned int s_next_implicit_index;
@@ -53,7 +53,7 @@ static enum ivy_status add_package_item(
item->n_implicit_index = state->s_next_implicit_index++; item->n_implicit_index = state->s_next_implicit_index++;
} }
b_queue_push_back(&state->s_items, &item->n_base.n_entry); fx_queue_push_back(&state->s_items, &item->n_base.n_entry);
state->s_next_index = NULL; state->s_next_index = NULL;
state->s_prev_node = NULL; state->s_prev_node = NULL;
@@ -76,7 +76,7 @@ static struct ivy_ast_node *finalise_package(struct package_parser_state *state)
} }
s->n_items = state->s_items; s->n_items = state->s_items;
state->s_items = B_QUEUE_INIT; state->s_items = FX_QUEUE_INIT;
return (struct ivy_ast_node *)s; return (struct ivy_ast_node *)s;
case PACKAGE_DYNAMIC: case PACKAGE_DYNAMIC:
d = (struct ivy_ast_pkg_dynamic_node *)ast_node_create( d = (struct ivy_ast_pkg_dynamic_node *)ast_node_create(
@@ -374,24 +374,24 @@ static void pkg_static_collect_children(
struct ivy_ast_pkg_static_node *pkg struct ivy_ast_pkg_static_node *pkg
= (struct ivy_ast_pkg_static_node *)node; = (struct ivy_ast_pkg_static_node *)node;
b_queue_entry *entry = b_queue_first(&pkg->n_items); fx_queue_entry *entry = fx_queue_first(&pkg->n_items);
while (entry) { while (entry) {
struct ivy_ast_node *item struct ivy_ast_node *item
= b_unbox(struct ivy_ast_node, entry, n_entry); = fx_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, item); ast_node_iterator_enqueue_node(iterator, node, item);
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
} }
static void pkg_static_item_to_string(struct ivy_ast_node *node, b_string *str) static void pkg_static_item_to_string(struct ivy_ast_node *node, fx_string *str)
{ {
struct ivy_ast_pkg_static_item_node *item struct ivy_ast_pkg_static_item_node *item
= (struct ivy_ast_pkg_static_item_node *)node; = (struct ivy_ast_pkg_static_item_node *)node;
b_string_append_cstr(str, ivy_ast_node_type_to_string(node->n_type)); fx_string_append_cstr(str, ivy_ast_node_type_to_string(node->n_type));
if (!item->n_index) { if (!item->n_index) {
b_string_append_cstrf(str, " (%u)", item->n_implicit_index); fx_string_append_cstrf(str, " (%u)", item->n_implicit_index);
} }
} }

View File

@@ -5,7 +5,7 @@
#include "ivy/status.h" #include "ivy/status.h"
#include "node.h" #include "node.h"
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
#include <stdio.h> #include <stdio.h>
@@ -371,28 +371,28 @@ static void collect_children(
} }
} }
static void to_string(struct ivy_ast_node *node, b_string *str) static void to_string(struct ivy_ast_node *node, fx_string *str)
{ {
struct ivy_ast_property_node *prop = (struct ivy_ast_property_node *)node; struct ivy_ast_property_node *prop = (struct ivy_ast_property_node *)node;
b_string_append_cstrf( fx_string_append_cstrf(
str, "%s (%s) [", ivy_ast_node_type_to_string(node->n_type), str, "%s (%s) [", ivy_ast_node_type_to_string(node->n_type),
prop->n_ident->t_str); prop->n_ident->t_str);
if (prop->n_flags & IVY_AST_PROPERTY_GET) { if (prop->n_flags & IVY_AST_PROPERTY_GET) {
b_string_append_cstr(str, "get"); fx_string_append_cstr(str, "get");
} }
if ((prop->n_flags & IVY_AST_PROPERTY_GET) if ((prop->n_flags & IVY_AST_PROPERTY_GET)
&& prop->n_flags & IVY_AST_PROPERTY_SET) { && prop->n_flags & IVY_AST_PROPERTY_SET) {
b_string_append_cstr(str, ", "); fx_string_append_cstr(str, ", ");
} }
if (prop->n_flags & IVY_AST_PROPERTY_SET) { if (prop->n_flags & IVY_AST_PROPERTY_SET) {
b_string_append_cstr(str, "set"); fx_string_append_cstr(str, "set");
} }
b_string_append_cstr(str, "]"); fx_string_append_cstr(str, "]");
} }
struct ast_node_type property_node_ops = { struct ast_node_type property_node_ops = {

View File

@@ -2,7 +2,7 @@
#include "ivy/status.h" #include "ivy/status.h"
#include "node.h" #include "node.h"
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
#include <stdio.h> #include <stdio.h>
@@ -75,7 +75,7 @@ static struct token_parse_result parse_ident(
if (state->s_prev == IVY_TOK_LABEL) { if (state->s_prev == IVY_TOK_LABEL) {
/* internal parameter name */ /* internal parameter name */
b_queue_push_back(&sel->n_arg_names, &tok->t_entry); fx_queue_push_back(&sel->n_arg_names, &tok->t_entry);
state->s_prev = IVY_TOK_IDENT; state->s_prev = IVY_TOK_IDENT;
state->s_complete = true; state->s_complete = true;
return PARSE_RESULT(IVY_OK, 0); return PARSE_RESULT(IVY_OK, 0);
@@ -101,7 +101,7 @@ static struct token_parse_result parse_label(
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
} }
b_queue_push_back(&sel->n_arg_labels, &tok->t_entry); fx_queue_push_back(&sel->n_arg_labels, &tok->t_entry);
state->s_prev = IVY_TOK_LABEL; state->s_prev = IVY_TOK_LABEL;
state->s_complete = false; state->s_complete = false;
@@ -119,7 +119,7 @@ static struct token_parse_result parse_linefeed(
CHECK_SELECTOR_COMPLETE(); CHECK_SELECTOR_COMPLETE();
if (!b_queue_empty(&sel->n_arg_labels) if (!fx_queue_empty(&sel->n_arg_labels)
&& state->s_prev != IVY_SYM_RIGHT_PAREN) { && state->s_prev != IVY_SYM_RIGHT_PAREN) {
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
} }
@@ -142,7 +142,7 @@ static struct token_parse_result parse_left_paren(
struct ivy_ast_selector_node *sel struct ivy_ast_selector_node *sel
= (struct ivy_ast_selector_node *)state->s_base.s_node; = (struct ivy_ast_selector_node *)state->s_base.s_node;
if (state->s_prev != IVY_TOK_IDENT || !b_queue_empty(&sel->n_arg_labels)) { if (state->s_prev != IVY_TOK_IDENT || !fx_queue_empty(&sel->n_arg_labels)) {
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
} }
@@ -159,7 +159,7 @@ static struct token_parse_result parse_right_paren(
struct ivy_ast_selector_node *sel struct ivy_ast_selector_node *sel
= (struct ivy_ast_selector_node *)state->s_base.s_node; = (struct ivy_ast_selector_node *)state->s_base.s_node;
if (state->s_prev != IVY_TOK_IDENT || b_queue_empty(&sel->n_arg_labels)) { if (state->s_prev != IVY_TOK_IDENT || fx_queue_empty(&sel->n_arg_labels)) {
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
} }
@@ -181,8 +181,8 @@ static struct token_parse_result parse_pipe(
switch (state->s_prev) { switch (state->s_prev) {
case IVY_SYM_RIGHT_PAREN: case IVY_SYM_RIGHT_PAREN:
/* this looks like a complex message selector */ /* this looks like a complex message selector */
if (b_queue_empty(&sel->n_arg_labels) if (fx_queue_empty(&sel->n_arg_labels)
|| b_queue_empty(&sel->n_arg_names)) { || fx_queue_empty(&sel->n_arg_names)) {
/* no message args */ /* no message args */
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
} }
@@ -194,8 +194,8 @@ static struct token_parse_result parse_pipe(
break; break;
case IVY_TOK_IDENT: case IVY_TOK_IDENT:
/* this looks like a unary or keyword message. */ /* this looks like a unary or keyword message. */
if (!b_queue_empty(&sel->n_arg_labels) if (!fx_queue_empty(&sel->n_arg_labels)
&& b_queue_empty(&sel->n_arg_names)) { && fx_queue_empty(&sel->n_arg_names)) {
/* keyword message with no arg names. */ /* keyword message with no arg names. */
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
} }
@@ -223,19 +223,19 @@ static struct token_parse_result parse_other(
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
} }
static void to_string(struct ivy_ast_node *node, b_string *str) static void to_string(struct ivy_ast_node *node, fx_string *str)
{ {
struct ivy_ast_selector_node *sel = (struct ivy_ast_selector_node *)node; struct ivy_ast_selector_node *sel = (struct ivy_ast_selector_node *)node;
b_string_append_cstrf( fx_string_append_cstrf(
str, "%s [", ivy_ast_node_type_to_string(node->n_type)); str, "%s [", ivy_ast_node_type_to_string(node->n_type));
switch (sel->n_recipient) { switch (sel->n_recipient) {
case IVY_SELECTOR_RECIPIENT_CLASS: case IVY_SELECTOR_RECIPIENT_CLASS:
b_string_append_cstr(str, "+"); fx_string_append_cstr(str, "+");
break; break;
case IVY_SELECTOR_RECIPIENT_OBJECT: case IVY_SELECTOR_RECIPIENT_OBJECT:
b_string_append_cstr(str, "-"); fx_string_append_cstr(str, "-");
break; break;
default: default:
/* this will occur if the selector is being used to send a /* this will occur if the selector is being used to send a
@@ -245,50 +245,50 @@ static void to_string(struct ivy_ast_node *node, b_string *str)
} }
if (sel->n_msg_name) { if (sel->n_msg_name) {
b_string_append_cstr(str, sel->n_msg_name->t_str); fx_string_append_cstr(str, sel->n_msg_name->t_str);
} }
if (sel->n_msg_name && !b_queue_empty(&sel->n_arg_labels)) { if (sel->n_msg_name && !fx_queue_empty(&sel->n_arg_labels)) {
b_string_append_cstr(str, "("); fx_string_append_cstr(str, "(");
} }
b_queue_entry *label_entry = b_queue_first(&sel->n_arg_labels); fx_queue_entry *label_entry = fx_queue_first(&sel->n_arg_labels);
b_queue_entry *name_entry = b_queue_first(&sel->n_arg_names); fx_queue_entry *name_entry = fx_queue_first(&sel->n_arg_names);
int i = 0; int i = 0;
while (label_entry) { while (label_entry) {
if (i > 0) { if (i > 0) {
b_string_append_cstr(str, " "); fx_string_append_cstr(str, " ");
} }
struct ivy_token *label, *name; struct ivy_token *label, *name;
label = b_unbox(struct ivy_token, label_entry, t_entry); label = fx_unbox(struct ivy_token, label_entry, t_entry);
name = b_unbox(struct ivy_token, name_entry, t_entry); name = fx_unbox(struct ivy_token, name_entry, t_entry);
if (label && label->t_type == IVY_TOK_LABEL && label->t_str) { if (label && label->t_type == IVY_TOK_LABEL && label->t_str) {
b_string_append_cstrf(str, "%s:", label->t_str); fx_string_append_cstrf(str, "%s:", label->t_str);
} else { } else {
b_string_append_cstrf(str, "_:"); fx_string_append_cstrf(str, "_:");
} }
if (name) { if (name) {
b_string_append_cstrf(str, "%s", name->t_str); fx_string_append_cstrf(str, "%s", name->t_str);
} }
if (name) { if (name) {
i++; i++;
} }
label_entry = b_queue_next(label_entry); label_entry = fx_queue_next(label_entry);
name_entry = b_queue_next(name_entry); name_entry = fx_queue_next(name_entry);
} }
if (sel->n_msg_name && !b_queue_empty(&sel->n_arg_labels)) { if (sel->n_msg_name && !fx_queue_empty(&sel->n_arg_labels)) {
b_string_append_cstr(str, ")"); fx_string_append_cstr(str, ")");
} }
b_string_append_cstr(str, "]"); fx_string_append_cstr(str, "]");
} }
static void init_state(struct ivy_parser *ctx, struct parser_state *sp, uintptr_t arg) static void init_state(struct ivy_parser *ctx, struct parser_state *sp, uintptr_t arg)

View File

@@ -3,12 +3,12 @@
#include "iterate.h" #include "iterate.h"
#include "node.h" #include "node.h"
#include <blue/ds/string.h> #include <fx/ds/string.h>
static void to_string(struct ivy_ast_node *node, b_string *str) static void to_string(struct ivy_ast_node *node, fx_string *str)
{ {
struct ivy_ast_string_node *s = (struct ivy_ast_string_node *)node; struct ivy_ast_string_node *s = (struct ivy_ast_string_node *)node;
b_string_append_cstrf( fx_string_append_cstrf(
str, "%s (\"%s\")", ivy_ast_node_type_to_string(node->n_type), str, "%s (\"%s\")", ivy_ast_node_type_to_string(node->n_type),
s->n_value->t_str); s->n_value->t_str);
} }
@@ -26,7 +26,7 @@ struct token_parse_result parse_string(struct ivy_parser *ctx, struct ivy_token
} }
child->n_value = tok; child->n_value = tok;
b_queue_push_back(&parent->n_value, &child->n_base.n_entry); fx_queue_push_back(&parent->n_value, &child->n_base.n_entry);
return PARSE_RESULT(IVY_OK, 0); return PARSE_RESULT(IVY_OK, 0);
} }
@@ -59,7 +59,7 @@ static enum ivy_status add_child(
struct ivy_ast_fstring_node *str struct ivy_ast_fstring_node *str
= (struct ivy_ast_fstring_node *)parent->s_node; = (struct ivy_ast_fstring_node *)parent->s_node;
b_queue_push_back(&str->n_value, &child->n_entry); fx_queue_push_back(&str->n_value, &child->n_entry);
return IVY_OK; return IVY_OK;
} }
@@ -68,12 +68,12 @@ static void collect_children(
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator) struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
{ {
struct ivy_ast_fstring_node *str = (struct ivy_ast_fstring_node *)node; struct ivy_ast_fstring_node *str = (struct ivy_ast_fstring_node *)node;
b_queue_entry *entry = b_queue_first(&str->n_value); fx_queue_entry *entry = fx_queue_first(&str->n_value);
while (entry) { while (entry) {
struct ivy_ast_node *child struct ivy_ast_node *child
= b_unbox(struct ivy_ast_node, entry, n_entry); = fx_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, child); ast_node_iterator_enqueue_node(iterator, node, child);
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
} }

View File

@@ -10,13 +10,13 @@ struct try_parser_state {
struct ivy_ast_block_node *s_try, *s_finally; struct ivy_ast_block_node *s_try, *s_finally;
b_queue s_catch_branches; fx_queue s_catch_branches;
struct ivy_ast_try_catch_node *s_cur_catch_branch; struct ivy_ast_try_catch_node *s_cur_catch_branch;
}; };
static enum ivy_status flush_catch_branch(struct try_parser_state *state) static enum ivy_status flush_catch_branch(struct try_parser_state *state)
{ {
b_queue_push_back( fx_queue_push_back(
&state->s_catch_branches, &state->s_catch_branches,
&state->s_cur_catch_branch->n_base.n_entry); &state->s_cur_catch_branch->n_base.n_entry);
@@ -41,7 +41,7 @@ static enum ivy_status finalise_try(struct try_parser_state *state)
state->s_try = NULL; state->s_try = NULL;
state->s_finally = NULL; state->s_finally = NULL;
state->s_catch_branches = B_QUEUE_INIT; state->s_catch_branches = FX_QUEUE_INIT;
return IVY_OK; return IVY_OK;
} }
@@ -236,12 +236,12 @@ static void try_collect_children(
ast_node_iterator_enqueue_node(iterator, node, try->n_try); ast_node_iterator_enqueue_node(iterator, node, try->n_try);
b_queue_entry *entry = b_queue_first(&try->n_catch); fx_queue_entry *entry = fx_queue_first(&try->n_catch);
while (entry) { while (entry) {
struct ivy_ast_node *catch struct ivy_ast_node *catch
= b_unbox(struct ivy_ast_node, entry, n_entry); = fx_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, catch); ast_node_iterator_enqueue_node(iterator, node, catch);
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
if (try->n_finally) { if (try->n_finally) {

View File

@@ -4,7 +4,7 @@
#include "ivy/status.h" #include "ivy/status.h"
#include "node.h" #include "node.h"
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
#include <stdio.h> #include <stdio.h>
@@ -14,7 +14,7 @@ struct tuple_parser_state {
struct ivy_ast_node *s_prev_node; struct ivy_ast_node *s_prev_node;
unsigned int s_prev; unsigned int s_prev;
b_queue s_items; fx_queue s_items;
}; };
static void finalise_tuple(struct tuple_parser_state *state) static void finalise_tuple(struct tuple_parser_state *state)
@@ -23,7 +23,7 @@ static void finalise_tuple(struct tuple_parser_state *state)
= (struct ivy_ast_tuple_node *)state->s_base.s_node; = (struct ivy_ast_tuple_node *)state->s_base.s_node;
tuple->n_members = state->s_items; tuple->n_members = state->s_items;
state->s_items = B_QUEUE_INIT; state->s_items = FX_QUEUE_INIT;
} }
struct token_parse_result parse_comma(struct ivy_parser *ctx, struct ivy_token *tok) struct token_parse_result parse_comma(struct ivy_parser *ctx, struct ivy_token *tok)
@@ -40,7 +40,7 @@ struct token_parse_result parse_comma(struct ivy_parser *ctx, struct ivy_token *
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
} }
b_queue_push_back(&state->s_items, &state->s_prev_node->n_entry); fx_queue_push_back(&state->s_items, &state->s_prev_node->n_entry);
state->s_prev_node = NULL; state->s_prev_node = NULL;
state->s_prev = IVY_SYM_COMMA; state->s_prev = IVY_SYM_COMMA;
@@ -69,7 +69,7 @@ struct token_parse_result parse_right_paren(
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
} }
b_queue_push_back(&state->s_items, &state->s_prev_node->n_entry); fx_queue_push_back(&state->s_items, &state->s_prev_node->n_entry);
state->s_prev_node = NULL; state->s_prev_node = NULL;
state->s_prev = IVY_SYM_RIGHT_PAREN; state->s_prev = IVY_SYM_RIGHT_PAREN;
@@ -100,7 +100,7 @@ static void init_state(struct ivy_parser *ctx, struct parser_state *sp, uintptr_
if (arg) { if (arg) {
/* arg is the first node in the tuple */ /* arg is the first node in the tuple */
struct ivy_ast_node *item = (struct ivy_ast_node *)arg; struct ivy_ast_node *item = (struct ivy_ast_node *)arg;
b_queue_push_back(&state->s_items, &item->n_entry); fx_queue_push_back(&state->s_items, &item->n_entry);
state->s_prev = IVY_SYM_COMMA; state->s_prev = IVY_SYM_COMMA;
} }
@@ -117,12 +117,12 @@ static void collect_children(
{ {
struct ivy_ast_tuple_node *tuple = (struct ivy_ast_tuple_node *)node; struct ivy_ast_tuple_node *tuple = (struct ivy_ast_tuple_node *)node;
b_queue_entry *entry = b_queue_first(&tuple->n_members); fx_queue_entry *entry = fx_queue_first(&tuple->n_members);
while (entry) { while (entry) {
struct ivy_ast_node *item struct ivy_ast_node *item
= b_unbox(struct ivy_ast_node, entry, n_entry); = fx_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, item); ast_node_iterator_enqueue_node(iterator, node, item);
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
} }

View File

@@ -1,7 +1,7 @@
#include "ctx.h" #include "ctx.h"
#include "node.h" #include "node.h"
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
#include <stdio.h> #include <stdio.h>
@@ -37,7 +37,7 @@ static struct token_parse_result parse_ident(
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
} }
b_queue_push_back(&node->n_ident, &tok->t_entry); fx_queue_push_back(&node->n_ident, &tok->t_entry);
state->s_prev_token = IVY_TOK_IDENT; state->s_prev_token = IVY_TOK_IDENT;
return PARSE_RESULT(IVY_OK, 0); return PARSE_RESULT(IVY_OK, 0);
@@ -57,31 +57,31 @@ static struct token_parse_result parse_linefeed(
return PARSE_RESULT(IVY_OK, 0); return PARSE_RESULT(IVY_OK, 0);
} }
static void to_string(struct ivy_ast_node *node, b_string *str) static void to_string(struct ivy_ast_node *node, fx_string *str)
{ {
struct ivy_ast_unit_import_node *unit_import struct ivy_ast_unit_import_node *unit_import
= (struct ivy_ast_unit_import_node *)node; = (struct ivy_ast_unit_import_node *)node;
b_string_append_cstr(str, ivy_ast_node_type_to_string(node->n_type)); fx_string_append_cstr(str, ivy_ast_node_type_to_string(node->n_type));
b_string_append_cstr(str, " ("); fx_string_append_cstr(str, " (");
int i = 0; int i = 0;
b_queue_entry *entry = b_queue_first(&unit_import->n_ident); fx_queue_entry *entry = fx_queue_first(&unit_import->n_ident);
while (entry) { 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);
if (i > 0) { if (i > 0) {
b_string_append_cstr(str, "."); fx_string_append_cstr(str, ".");
} }
b_string_append_cstr(str, tok->t_str); fx_string_append_cstr(str, tok->t_str);
i++; i++;
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
b_string_append_cstr(str, ")"); fx_string_append_cstr(str, ")");
} }
static void init_state(struct ivy_parser *ctx, struct parser_state *sp, uintptr_t arg) static void init_state(struct ivy_parser *ctx, struct parser_state *sp, uintptr_t arg)

View File

@@ -1,7 +1,7 @@
#include "ctx.h" #include "ctx.h"
#include "node.h" #include "node.h"
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
#include <stdio.h> #include <stdio.h>
@@ -37,7 +37,7 @@ static struct token_parse_result parse_ident(
return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0);
} }
b_queue_push_back(&node->n_ident, &tok->t_entry); fx_queue_push_back(&node->n_ident, &tok->t_entry);
state->s_prev_token = IVY_TOK_IDENT; state->s_prev_token = IVY_TOK_IDENT;
return PARSE_RESULT(IVY_OK, 0); return PARSE_RESULT(IVY_OK, 0);
@@ -57,30 +57,30 @@ static struct token_parse_result parse_linefeed(
return PARSE_RESULT(IVY_OK, 0); return PARSE_RESULT(IVY_OK, 0);
} }
static void to_string(struct ivy_ast_node *node, b_string *str) static void to_string(struct ivy_ast_node *node, fx_string *str)
{ {
struct ivy_ast_unit_package_node *unit_package struct ivy_ast_unit_package_node *unit_package
= (struct ivy_ast_unit_package_node *)node; = (struct ivy_ast_unit_package_node *)node;
b_string_append_cstr(str, ivy_ast_node_type_to_string(node->n_type)); fx_string_append_cstr(str, ivy_ast_node_type_to_string(node->n_type));
b_string_append_cstr(str, " ("); fx_string_append_cstr(str, " (");
int i = 0; int i = 0;
b_queue_entry *entry = b_queue_first(&unit_package->n_ident); fx_queue_entry *entry = fx_queue_first(&unit_package->n_ident);
while (entry) { 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);
if (i > 0) { if (i > 0) {
b_string_append_cstr(str, "."); fx_string_append_cstr(str, ".");
} }
b_string_append_cstr(str, tok->t_str); fx_string_append_cstr(str, tok->t_str);
i++; i++;
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
b_string_append_cstr(str, ")"); fx_string_append_cstr(str, ")");
} }
static void init_state(struct ivy_parser *ctx, struct parser_state *sp, uintptr_t arg) static void init_state(struct ivy_parser *ctx, struct parser_state *sp, uintptr_t arg)

View File

@@ -50,7 +50,7 @@ static enum ivy_status add_child(
struct parser_state *parent, struct ivy_ast_node *child) struct parser_state *parent, struct ivy_ast_node *child)
{ {
struct ivy_ast_unit_node *unit = (struct ivy_ast_unit_node *)parent->s_node; struct ivy_ast_unit_node *unit = (struct ivy_ast_unit_node *)parent->s_node;
b_queue_push_back(&unit->n_children, &child->n_entry); fx_queue_push_back(&unit->n_children, &child->n_entry);
return IVY_OK; return IVY_OK;
} }
@@ -58,12 +58,12 @@ static void collect_children(
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator) struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
{ {
struct ivy_ast_unit_node *unit = (struct ivy_ast_unit_node *)node; struct ivy_ast_unit_node *unit = (struct ivy_ast_unit_node *)node;
b_queue_entry *entry = b_queue_first(&unit->n_children); fx_queue_entry *entry = fx_queue_first(&unit->n_children);
while (entry) { while (entry) {
struct ivy_ast_node *child struct ivy_ast_node *child
= b_unbox(struct ivy_ast_node, entry, n_entry); = fx_unbox(struct ivy_ast_node, entry, n_entry);
ast_node_iterator_enqueue_node(iterator, node, child); ast_node_iterator_enqueue_node(iterator, node, child);
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
} }

View File

@@ -12,7 +12,7 @@
* - each node type (var, msg, expr) gets its own code generator type * - each node type (var, msg, expr) gets its own code generator type
* - expr code generator is limited to simple operator arithmetic. * - expr code generator is limited to simple operator arithmetic.
* - when a code generator encounters a node of an equal or lower depth than * - 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. * - depth is supplied by the ast iterator.
* - need to devise a way for expression code generator to "return" a * - need to devise a way for expression code generator to "return" a
* mie_value for its parent generator to use. * mie_value for its parent generator to use.
@@ -21,12 +21,12 @@
static struct code_generator_state *get_current_generator_state( static struct code_generator_state *get_current_generator_state(
struct ivy_codegen *gen) 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) { if (!entry) {
return NULL; 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( static void code_generator_state_inherit(
@@ -76,7 +76,7 @@ enum ivy_status codegen_push_generator(
return status; 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; return IVY_OK;
} }
@@ -84,13 +84,13 @@ enum ivy_status codegen_push_generator(
enum ivy_status codegen_pop_generator( enum ivy_status codegen_pop_generator(
struct ivy_codegen *gen, struct code_generator_value *result) 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) { if (!entry) {
return IVY_ERR_BAD_STATE; return IVY_ERR_BAD_STATE;
} }
struct code_generator_state *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; enum ivy_status status = IVY_OK;
@@ -109,7 +109,7 @@ enum ivy_status codegen_pop_generator(
enum ivy_status codegen_define_variable( enum ivy_status codegen_define_variable(
struct ivy_codegen *gen, const char *ident, const struct codegen_var *var) 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) { if (!entry) {
return IVY_ERR_NO_ENTRY; return IVY_ERR_NO_ENTRY;
} }
@@ -118,7 +118,7 @@ enum ivy_status codegen_define_variable(
while (entry) { while (entry) {
struct code_generator_state *state 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; const struct code_generator *generator = state->s_gen;
enum ivy_status status = IVY_ERR_NO_ENTRY; enum ivy_status status = IVY_ERR_NO_ENTRY;
@@ -130,7 +130,7 @@ enum ivy_status codegen_define_variable(
break; break;
} }
entry = b_queue_prev(entry); entry = fx_queue_prev(entry);
} }
return IVY_ERR_NOT_SUPPORTED; return IVY_ERR_NOT_SUPPORTED;
@@ -155,7 +155,7 @@ enum ivy_status resolve_global_variable(
enum ivy_status codegen_resolve_variable( enum ivy_status codegen_resolve_variable(
struct ivy_codegen *gen, const char *ident, struct codegen_var *out) 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) { if (!entry) {
return IVY_ERR_NO_ENTRY; return IVY_ERR_NO_ENTRY;
} }
@@ -164,7 +164,7 @@ enum ivy_status codegen_resolve_variable(
while (entry) { while (entry) {
struct code_generator_state *state 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; const struct code_generator *generator = state->s_gen;
enum ivy_status status = IVY_ERR_NO_ENTRY; enum ivy_status status = IVY_ERR_NO_ENTRY;
@@ -177,7 +177,7 @@ enum ivy_status codegen_resolve_variable(
break; break;
} }
entry = b_queue_prev(entry); entry = fx_queue_prev(entry);
} }
#if 0 #if 0
@@ -187,12 +187,12 @@ enum ivy_status codegen_resolve_variable(
#endif #endif
if (entry) { if (entry) {
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
while (entry) { while (entry) {
struct code_generator_state *state 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; const struct code_generator *generator = state->s_gen;
enum ivy_status status = IVY_OK; enum ivy_status status = IVY_OK;
@@ -204,7 +204,7 @@ enum ivy_status codegen_resolve_variable(
return status; return status;
} }
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
return IVY_OK; return IVY_OK;
@@ -371,7 +371,7 @@ enum ivy_status ivy_codegen_push_node(
return IVY_ERR_BAD_STATE; return IVY_ERR_BAD_STATE;
} }
if (b_queue_empty(&gen->c_state)) { if (fx_queue_empty(&gen->c_state)) {
const struct code_generator *generator const struct code_generator *generator
= get_root_code_generator(node->n_type); = get_root_code_generator(node->n_type);
if (!generator) { if (!generator) {
@@ -441,7 +441,7 @@ enum ivy_status ivy_codegen_push_eof(struct ivy_codegen *gen)
.r_status = IVY_OK, .r_status = IVY_OK,
}; };
while (!b_queue_empty(&gen->c_state)) { while (!fx_queue_empty(&gen->c_state)) {
struct code_generator_value value = {0}; struct code_generator_value value = {0};
status = codegen_pop_generator(gen, &value); status = codegen_pop_generator(gen, &value);
if (status != IVY_OK) { if (status != IVY_OK) {

View File

@@ -3,7 +3,7 @@
#include "var-map.h" #include "var-map.h"
#include <blue/core/queue.h> #include <fx/core/queue.h>
#include <ivy/lang/ast.h> #include <ivy/lang/ast.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
#include <mie/ctx.h> #include <mie/ctx.h>
@@ -124,7 +124,7 @@ struct code_generator {
}; };
struct code_generator_state { struct code_generator_state {
b_queue_entry s_entry; fx_queue_entry s_entry;
uintptr_t s_argv; uintptr_t s_argv;
void *s_argp; void *s_argp;
const struct code_generator *s_gen; const struct code_generator *s_gen;
@@ -135,9 +135,9 @@ struct code_generator_state {
}; };
struct ivy_codegen { struct ivy_codegen {
b_queue c_values; fx_queue c_values;
b_queue c_state; fx_queue c_state;
b_queue c_scope; fx_queue c_scope;
struct mie_builder *c_builder; struct mie_builder *c_builder;
struct mie_ctx *c_ctx; struct mie_ctx *c_ctx;
struct mie_module *c_module; struct mie_module *c_module;

View File

@@ -13,7 +13,7 @@
struct cond_group_codegen_state { struct cond_group_codegen_state {
struct code_generator_state s_base; struct code_generator_state s_base;
struct mie_block *s_end; struct mie_block *s_end;
b_queue s_edges; fx_queue s_edges;
}; };
static struct code_generator_result gen_cond_group( static struct code_generator_result gen_cond_group(
@@ -55,10 +55,10 @@ static enum ivy_status get_eval_type(
{ {
struct mie_type *type = NULL; 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) { while (entry) {
struct mie_phi_edge *edge 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) { if (!edge->e_value) {
goto next; goto next;
} }
@@ -71,7 +71,7 @@ static enum ivy_status get_eval_type(
} }
next: next:
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
*out = type; *out = type;
@@ -82,7 +82,7 @@ static enum ivy_status emit_phi_instr(
struct ivy_codegen *gen, struct cond_group_codegen_state *state, struct ivy_codegen *gen, struct cond_group_codegen_state *state,
struct mie_type *type, struct mie_value **result) 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) { if (!nr_edges) {
return IVY_OK; return IVY_OK;
} }
@@ -94,14 +94,14 @@ static enum ivy_status emit_phi_instr(
size_t i = 0; 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) { while (entry) {
struct mie_phi_edge *edge 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); memcpy(&edges[i], edge, sizeof *edge);
i++; i++;
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
struct mie_value *phi = mie_builder_phi( 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); assert(value->v_type == CODE_GENERATOR_VALUE_PHI_EDGE);
struct mie_phi_edge *edge = code_generator_value_get_phi_edge(value); 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); return CODEGEN_RESULT_OK(0);
} }

View File

@@ -17,7 +17,7 @@ enum expr_operand_type {
}; };
struct expr_item { struct expr_item {
b_queue_entry i_entry; fx_queue_entry i_entry;
enum expr_item_type i_type; enum expr_item_type i_type;
enum expr_operand_type i_operand_type; enum expr_operand_type i_operand_type;
struct ivy_ast_node *i_node; struct ivy_ast_node *i_node;
@@ -29,7 +29,7 @@ struct expr_codegen_state {
struct code_generator_state s_base; struct code_generator_state s_base;
struct ivy_ast_node *s_expr_root; struct ivy_ast_node *s_expr_root;
uintptr_t s_flags; uintptr_t s_flags;
b_queue s_item_queue; fx_queue s_item_queue;
}; };
#if 0 #if 0
@@ -66,7 +66,7 @@ static enum ivy_status push_operand(
item->i_operand_type = EXPR_OPERAND_VAR; 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; return IVY_OK;
} }
@@ -83,7 +83,7 @@ static enum ivy_status push_operator(
item->i_type = EXPR_OPERATOR; item->i_type = EXPR_OPERATOR;
item->i_node = node; 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; return IVY_OK;
} }
@@ -543,24 +543,24 @@ static enum ivy_status state_fini(
struct expr_codegen_state *expr = (struct expr_codegen_state *)state; struct expr_codegen_state *expr = (struct expr_codegen_state *)state;
enum ivy_status status = IVY_OK; enum ivy_status status = IVY_OK;
b_queue stack = B_QUEUE_INIT; fx_queue stack = FX_QUEUE_INIT;
b_queue_entry *cur = NULL; fx_queue_entry *cur = NULL;
while ((cur = b_queue_pop_back(&expr->s_item_queue))) { while ((cur = fx_queue_pop_back(&expr->s_item_queue))) {
struct expr_item *item = b_unbox(struct expr_item, cur, i_entry); struct expr_item *item = fx_unbox(struct expr_item, cur, i_entry);
if (item->i_type == EXPR_OPERAND) { if (item->i_type == EXPR_OPERAND) {
b_queue_push_back(&stack, &item->i_entry); fx_queue_push_back(&stack, &item->i_entry);
continue; continue;
} }
struct ivy_ast_op_node *op = (struct ivy_ast_op_node *)item->i_node; struct ivy_ast_op_node *op = (struct ivy_ast_op_node *)item->i_node;
b_queue_entry *left_entry = b_queue_pop_back(&stack); fx_queue_entry *left_entry = fx_queue_pop_back(&stack);
b_queue_entry *right_entry = b_queue_pop_back(&stack); fx_queue_entry *right_entry = fx_queue_pop_back(&stack);
struct expr_item *left 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 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 *left_value = left->i_value;
struct mie_value *right_value = right->i_value; struct mie_value *right_value = right->i_value;
@@ -670,19 +670,19 @@ static enum ivy_status state_fini(
skip_op: skip_op:
item->i_value = op_value; 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) { if (status != IVY_OK) {
return status; return status;
} }
cur = b_queue_pop_back(&stack); cur = fx_queue_pop_back(&stack);
if (!cur) { if (!cur) {
return IVY_ERR_INTERNAL_FAILURE; 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; struct mie_value *result_value;
if (result_item->i_operand_type == EXPR_OPERAND_VAR) { if (result_item->i_operand_type == EXPR_OPERAND_VAR) {
result_value = load_variable(gen, &result_item->i_var); result_value = load_variable(gen, &result_item->i_var);

View File

@@ -1,7 +1,7 @@
#include "../debug.h" #include "../debug.h"
#include "codegen.h" #include "codegen.h"
#include <blue/core/stringstream.h> #include <fx/core/stringstream.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -98,7 +98,7 @@ static struct code_generator_result gen_selector(
msg->s_prev_part = MSG_SELECTOR; msg->s_prev_part = MSG_SELECTOR;
msg->s_nr_args = 0; 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 *)); msg->s_args = calloc(msg->s_max_args, sizeof(struct mie_value *));
if (!msg->s_args) { if (!msg->s_args) {
@@ -126,38 +126,38 @@ static enum ivy_status state_init(
} }
static void serialise_selector( 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) { if (sel->n_msg_name) {
const char *msg_name = sel->n_msg_name->t_str; 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 { } 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) { 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) { 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; goto next;
} }
const char *label = arg->t_str; const char *label = arg->t_str;
if (label) { 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 { } else {
b_stream_write_char(out, '0'); fx_stream_write_char(out, '0');
} }
next: 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( 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; 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); serialise_selector(msg->s_selector, str);
char *sel = b_stringstream_steal(str); char *sel = fx_stringstream_steal(str);
b_stringstream_unref(str); fx_stringstream_unref(str);
struct mie_value *sel_value = mie_ctx_get_selector(gen->c_ctx, sel); struct mie_value *sel_value = mie_ctx_get_selector(gen->c_ctx, sel);
free(sel); free(sel);

View File

@@ -1,8 +1,8 @@
#include "codegen.h" #include "codegen.h"
#include "var-map.h" #include "var-map.h"
#include <blue/core/stringstream.h> #include <fx/core/stringstream.h>
#include <blue/ds/list.h> #include <fx/ds/list.h>
#include <mie/ir/block.h> #include <mie/ir/block.h>
#include <mie/ir/func.h> #include <mie/ir/func.h>
#include <mie/ir/module.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); 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) { 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); size_t len = strlen(tok->t_str);
b_stream_write_fmt(out, NULL, "%zu%s", len, tok->t_str); fx_stream_write_fmt(out, NULL, "%zu%s", len, tok->t_str);
entry = b_queue_next(entry); 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( 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 *pkg
= (struct ivy_ast_unit_package_node *)node; = (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); serialise_package_name(&pkg->n_ident, str);
char *ident = b_stringstream_steal(str); char *ident = fx_stringstream_steal(str);
b_stringstream_unref(str); fx_stringstream_unref(str);
struct mie_value *ident_val = mie_ctx_get_string(gen->c_ctx, ident); struct mie_value *ident_val = mie_ctx_get_string(gen->c_ctx, ident);
free(ident); free(ident);
@@ -198,14 +198,14 @@ static struct code_generator_result gen_unit_import(
import_list = MIE_ARRAY(rec->r_value); 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); serialise_package_name(&pkg->n_ident, str);
char *ident = b_stringstream_steal(str); char *ident = fx_stringstream_steal(str);
b_stringstream_unref(str); fx_stringstream_unref(str);
struct mie_value *ident_val = mie_ctx_get_string(gen->c_ctx, ident); struct mie_value *ident_val = mie_ctx_get_string(gen->c_ctx, ident);
free(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); return CODEGEN_RESULT_OK(0);
} }

View File

@@ -1,33 +1,33 @@
#include "var-map.h" #include "var-map.h"
#include <blue/ds/hashmap.h> #include <fx/ds/hashmap.h>
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
enum ivy_status codegen_var_map_init(struct codegen_var_map *map) enum ivy_status codegen_var_map_init(struct codegen_var_map *map)
{ {
memset(map, 0x0, sizeof *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; return IVY_OK;
} }
enum ivy_status codegen_var_map_fini(struct codegen_var_map *map) 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; return IVY_OK;
} }
enum ivy_status codegen_var_map_get( enum ivy_status codegen_var_map_get(
struct codegen_var_map *map, const char *ident, struct codegen_var **out) struct codegen_var_map *map, const char *ident, struct codegen_var **out)
{ {
b_hashmap_key key = { fx_hashmap_key key = {
.key_data = ident, .key_data = ident,
.key_size = strlen(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) { if (!value) {
return IVY_ERR_NO_ENTRY; return IVY_ERR_NO_ENTRY;
@@ -42,8 +42,8 @@ enum ivy_status codegen_var_map_put(
struct codegen_var_map *map, const char *ident, struct codegen_var_map *map, const char *ident,
const struct codegen_var *var) const struct codegen_var *var)
{ {
b_hashmap_key key = { fx_hashmap_key key = {
.key_data = b_strdup(ident), .key_data = fx_strdup(ident),
.key_size = strlen(ident), .key_size = strlen(ident),
}; };
@@ -51,7 +51,7 @@ enum ivy_status codegen_var_map_put(
return IVY_ERR_NO_MEMORY; return IVY_ERR_NO_MEMORY;
} }
b_hashmap_value value = { fx_hashmap_value value = {
.value_data = malloc(sizeof *var), .value_data = malloc(sizeof *var),
.value_size = sizeof *var, .value_size = sizeof *var,
}; };
@@ -63,8 +63,8 @@ enum ivy_status codegen_var_map_put(
memcpy(value.value_data, var, sizeof *var); memcpy(value.value_data, var, sizeof *var);
b_status status = b_hashmap_put(map->m_map, &key, &value); fx_status status = fx_hashmap_put(map->m_map, &key, &value);
if (!B_OK(status)) { if (!FX_OK(status)) {
free((void *)key.key_data); free((void *)key.key_data);
free(value.value_data); free(value.value_data);
} }

View File

@@ -1,7 +1,7 @@
#ifndef CODEGEN_VAR_MAP_H_ #ifndef CODEGEN_VAR_MAP_H_
#define CODEGEN_VAR_MAP_H_ #define CODEGEN_VAR_MAP_H_
#include <blue/ds/hashmap.h> #include <fx/ds/hashmap.h>
#include <ivy/status.h> #include <ivy/status.h>
struct mie_value; struct mie_value;
@@ -20,7 +20,7 @@ struct codegen_var {
}; };
struct codegen_var_map { 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); extern enum ivy_status codegen_var_map_init(struct codegen_var_map *map);

View File

@@ -1,8 +1,8 @@
#ifndef IVY_LANG_AST_H_ #ifndef IVY_LANG_AST_H_
#define IVY_LANG_AST_H_ #define IVY_LANG_AST_H_
#include <blue/core/queue.h> #include <fx/core/queue.h>
#include <blue/ds/string.h> #include <fx/ds/string.h>
#include <ivy/lang/operator.h> #include <ivy/lang/operator.h>
#include <ivy/lang/selector.h> #include <ivy/lang/selector.h>
#include <ivy/misc.h> #include <ivy/misc.h>
@@ -11,7 +11,7 @@
struct ivy_diag_ctx; struct ivy_diag_ctx;
struct ivy_token; struct ivy_token;
struct ivy_parser; struct ivy_parser;
struct b_string; struct fx_string;
enum ivy_ast_node_type { enum ivy_ast_node_type {
IVY_AST_NONE = 0x00, IVY_AST_NONE = 0x00,
@@ -69,12 +69,12 @@ enum ivy_ast_iteration_type {
}; };
struct ivy_ast_node_iterator { struct ivy_ast_node_iterator {
b_queue it_queue; fx_queue it_queue;
b_queue_entry *it_insert_after; fx_queue_entry *it_insert_after;
}; };
struct ivy_ast_node_iterator_entry { struct ivy_ast_node_iterator_entry {
b_queue_entry it_entry; fx_queue_entry it_entry;
unsigned int it_depth; unsigned int it_depth;
}; };
@@ -82,13 +82,13 @@ struct ivy_ast_node {
enum ivy_ast_node_type n_type; enum ivy_ast_node_type n_type;
struct ivy_ast_node *n_parent; struct ivy_ast_node *n_parent;
struct ivy_char_cell n_start, n_end; struct ivy_char_cell n_start, n_end;
b_queue_entry n_entry; fx_queue_entry n_entry;
struct ivy_ast_node_iterator_entry n_it; struct ivy_ast_node_iterator_entry n_it;
}; };
struct ivy_ast_unit_node { struct ivy_ast_unit_node {
struct ivy_ast_node n_base; struct ivy_ast_node n_base;
b_queue n_children; fx_queue n_children;
}; };
struct ivy_ast_op_node { struct ivy_ast_op_node {
@@ -116,9 +116,9 @@ struct ivy_ast_selector_node {
/* NULL for keyword messages. */ /* NULL for keyword messages. */
struct ivy_token *n_msg_name; struct ivy_token *n_msg_name;
/* queue of struct ivy_token; empty for unary messages. */ /* queue of struct ivy_token; empty for unary messages. */
b_queue n_arg_labels; fx_queue n_arg_labels;
/* queue of struct ivy_token; empty for unary messages. */ /* queue of struct ivy_token; empty for unary messages. */
b_queue n_arg_names; fx_queue n_arg_names;
}; };
struct ivy_ast_msg_node { struct ivy_ast_msg_node {
@@ -126,7 +126,7 @@ struct ivy_ast_msg_node {
struct ivy_ast_node *n_recipient; struct ivy_ast_node *n_recipient;
struct ivy_ast_selector_node *n_sel; struct ivy_ast_selector_node *n_sel;
/* queue of struct ivy_ast_node; empty for unary messages. */ /* queue of struct ivy_ast_node; empty for unary messages. */
b_queue n_arg; fx_queue n_arg;
}; };
struct ivy_ast_class_node { struct ivy_ast_class_node {
@@ -135,9 +135,9 @@ struct ivy_ast_class_node {
struct ivy_token *n_ident; struct ivy_token *n_ident;
/* queue of struct ivy_ast_property_node */ /* queue of struct ivy_ast_property_node */
b_queue n_properties; fx_queue n_properties;
/* queue of struct ivy_ast_msgh_node */ /* queue of struct ivy_ast_msgh_node */
b_queue n_msg_handlers; fx_queue n_msg_handlers;
}; };
struct ivy_ast_msgh_node { struct ivy_ast_msgh_node {
@@ -176,7 +176,7 @@ struct ivy_ast_lambda_node {
struct ivy_ast_node n_base; struct ivy_ast_node n_base;
/* queue of struct ivy_ast_ident_node; contains the names of the lambda /* queue of struct ivy_ast_ident_node; contains the names of the lambda
* parameters. */ * parameters. */
b_queue n_arg; fx_queue n_arg;
/* expressions to evaluate when lambda is executed. */ /* expressions to evaluate when lambda is executed. */
struct ivy_ast_node *n_body; struct ivy_ast_node *n_body;
}; };
@@ -184,13 +184,13 @@ struct ivy_ast_lambda_node {
struct ivy_ast_unit_package_node { struct ivy_ast_unit_package_node {
struct ivy_ast_node n_base; struct ivy_ast_node n_base;
/* queue of struct ivy_token; list of multi-part identifier parts. */ /* queue of struct ivy_token; list of multi-part identifier parts. */
b_queue n_ident; fx_queue n_ident;
}; };
struct ivy_ast_unit_import_node { struct ivy_ast_unit_import_node {
struct ivy_ast_node n_base; struct ivy_ast_node n_base;
/* queue of struct ivy_token; list of multi-part identifier parts. */ /* queue of struct ivy_token; list of multi-part identifier parts. */
b_queue n_ident; fx_queue n_ident;
}; };
struct ivy_ast_expr_node { struct ivy_ast_expr_node {
@@ -223,7 +223,7 @@ struct ivy_ast_string_node {
struct ivy_ast_fstring_node { struct ivy_ast_fstring_node {
struct ivy_ast_node n_base; struct ivy_ast_node n_base;
/* list of struct ivy_ast_node. nodes are evaluated and combined in-order into a string. */ /* list of struct ivy_ast_node. nodes are evaluated and combined in-order into a string. */
b_queue n_value; fx_queue n_value;
}; };
struct ivy_ast_atom_node { struct ivy_ast_atom_node {
@@ -266,13 +266,13 @@ struct ivy_ast_cascade_node {
struct ivy_ast_node n_base; struct ivy_ast_node n_base;
struct ivy_ast_node *n_recipient; struct ivy_ast_node *n_recipient;
/* queue of struct ivy_ast_msg_node, all with NULL recipients. */ /* queue of struct ivy_ast_msg_node, all with NULL recipients. */
b_queue n_msg; fx_queue n_msg;
}; };
struct ivy_ast_cond_group_node { struct ivy_ast_cond_group_node {
struct ivy_ast_node n_base; struct ivy_ast_node n_base;
/* queue of struct ivy_ast_cond_node. */ /* queue of struct ivy_ast_cond_node. */
b_queue n_branches; fx_queue n_branches;
}; };
struct ivy_ast_try_catch_node { struct ivy_ast_try_catch_node {
@@ -284,7 +284,7 @@ struct ivy_ast_try_catch_node {
struct ivy_ast_try_node { struct ivy_ast_try_node {
struct ivy_ast_node n_base; struct ivy_ast_node n_base;
struct ivy_ast_node *n_try; struct ivy_ast_node *n_try;
b_queue n_catch; fx_queue n_catch;
struct ivy_ast_node *n_finally; struct ivy_ast_node *n_finally;
}; };
@@ -293,7 +293,7 @@ struct ivy_ast_match_node {
/* the match condition. the branch that matches this condition will be evaluated. */ /* the match condition. the branch that matches this condition will be evaluated. */
struct ivy_ast_node *n_cond; struct ivy_ast_node *n_cond;
/* queue of struct ivy_ast_cond_node. */ /* queue of struct ivy_ast_cond_node. */
b_queue n_branches; fx_queue n_branches;
}; };
struct ivy_ast_cond_node { struct ivy_ast_cond_node {
@@ -309,7 +309,7 @@ struct ivy_ast_cond_node {
struct ivy_ast_tuple_node { struct ivy_ast_tuple_node {
struct ivy_ast_node n_base; struct ivy_ast_node n_base;
/* queue of struct ivy_ast_node. each can be either an identifier, a constant, or a tuple. */ /* queue of struct ivy_ast_node. each can be either an identifier, a constant, or a tuple. */
b_queue n_members; fx_queue n_members;
}; };
struct ivy_ast_pkg_static_item_node { struct ivy_ast_pkg_static_item_node {
@@ -325,7 +325,7 @@ struct ivy_ast_pkg_static_item_node {
struct ivy_ast_pkg_static_node { struct ivy_ast_pkg_static_node {
struct ivy_ast_node n_base; struct ivy_ast_node n_base;
/* queue of struct ivy_ast_pkg_static_item_node */ /* queue of struct ivy_ast_pkg_static_item_node */
b_queue n_items; fx_queue n_items;
}; };
struct ivy_ast_pkg_dynamic_node { struct ivy_ast_pkg_dynamic_node {
@@ -339,7 +339,7 @@ struct ivy_ast_pkg_dynamic_node {
struct ivy_ast_block_node { struct ivy_ast_block_node {
struct ivy_ast_node n_base; struct ivy_ast_node n_base;
/* queue of struct ivy_ast_node. expressions to evaluate when the do node itself is evaluated. */ /* queue of struct ivy_ast_node. expressions to evaluate when the do node itself is evaluated. */
b_queue n_expr; fx_queue n_expr;
}; };
typedef enum ivy_status (*ivy_ast_node_iteration_callback)( typedef enum ivy_status (*ivy_ast_node_iteration_callback)(
@@ -365,7 +365,7 @@ IVY_API struct ivy_ast_node *ivy_ast_node_create(enum ivy_ast_node_type type);
IVY_API enum ivy_status ivy_ast_node_iterate( IVY_API enum ivy_status ivy_ast_node_iterate(
struct ivy_ast_node *node, struct ivy_ast_node_iterator *it, struct ivy_ast_node *node, struct ivy_ast_node_iterator *it,
ivy_ast_node_iteration_callback callback, void *arg); ivy_ast_node_iteration_callback callback, void *arg);
IVY_API void ivy_ast_node_to_string(struct ivy_ast_node *node, b_string *out); IVY_API void ivy_ast_node_to_string(struct ivy_ast_node *node, fx_string *out);
IVY_API void ivy_ast_node_set_bounds_from_token( IVY_API void ivy_ast_node_set_bounds_from_token(
struct ivy_ast_node *parent, const struct ivy_token *tok); struct ivy_ast_node *parent, const struct ivy_token *tok);
IVY_API void ivy_ast_node_extend_bounds( IVY_API void ivy_ast_node_extend_bounds(

View File

@@ -1,7 +1,7 @@
#ifndef IVY_LANG_LEX_H_ #ifndef IVY_LANG_LEX_H_
#define IVY_LANG_LEX_H_ #define IVY_LANG_LEX_H_
#include <blue/core/queue.h> #include <fx/core/queue.h>
#include <ivy/line-source.h> #include <ivy/line-source.h>
#include <ivy/misc.h> #include <ivy/misc.h>
#include <ivy/status.h> #include <ivy/status.h>
@@ -123,7 +123,7 @@ struct ivy_token {
struct ivy_char_cell t_start, t_end; struct ivy_char_cell t_start, t_end;
b_queue_entry t_entry; fx_queue_entry t_entry;
union { union {
enum ivy_keyword t_keyword; enum ivy_keyword t_keyword;

View File

@@ -1,7 +1,7 @@
#include "lex.h" #include "lex.h"
#include <blue/ds/number.h> #include <fx/ds/number.h>
#include <blue/term/print.h> #include <fx/term/print.h>
#include <ivy/lang/internal.h> #include <ivy/lang/internal.h>
#include <ivy/lang/lex.h> #include <ivy/lang/lex.h>
#include <stdio.h> #include <stdio.h>
@@ -12,23 +12,23 @@ static void print_symbol_node(struct ivy_lexer_symbol_node *node, int depth)
fputs(" ", stdout); fputs(" ", stdout);
} }
b_printf("[cyan]%c[reset]", node->s_char); fx_printf("[cyan]%c[reset]", node->s_char);
if (node->s_def != NULL) { if (node->s_def != NULL) {
b_printf( fx_printf(
" ([magenta]%s[reset])", " ([magenta]%s[reset])",
ivy_symbol_to_string(node->s_def->id)); ivy_symbol_to_string(node->s_def->id));
} }
b_printf("\n"); fx_printf("\n");
b_queue_entry *entry = b_queue_first(&node->s_children); fx_queue_entry *entry = fx_queue_first(&node->s_children);
while (entry) { while (entry) {
struct ivy_lexer_symbol_node *child struct ivy_lexer_symbol_node *child
= b_unbox(struct ivy_lexer_symbol_node, entry, s_entry); = fx_unbox(struct ivy_lexer_symbol_node, entry, s_entry);
print_symbol_node(child, depth + 1); print_symbol_node(child, depth + 1);
entry = b_queue_next(entry); entry = fx_queue_next(entry);
} }
} }
@@ -39,14 +39,14 @@ void internal_lexer_print_symbol_tree(struct ivy_lexer *lex)
void internal_lexer_print_keyword_dict(struct ivy_lexer *lex) void internal_lexer_print_keyword_dict(struct ivy_lexer *lex)
{ {
b_iterator *it = b_iterator_begin(lex->lex_keywords); fx_iterator *it = fx_iterator_begin(lex->lex_keywords);
b_foreach_ptr(b_dict_item, item, it) fx_foreach_ptr(fx_dict_item, item, it)
{ {
const b_string *kw_name = item->key; const fx_string *kw_name = item->key;
enum ivy_keyword kw_id = b_number_get_int(item->value); enum ivy_keyword kw_id = fx_number_get_int(item->value);
b_printf( fx_printf(
"([magenta]%s[reset]) = [green]%s[reset]\n", "([magenta]%s[reset]) = [green]%s[reset]\n",
ivy_keyword_to_string(kw_id), b_string_ptr(kw_name)); ivy_keyword_to_string(kw_id), fx_string_ptr(kw_name));
} }
} }

Some files were not shown because too many files have changed in this diff Show More