From e5546f97c297a00fea46f276c283557ca5e6f213 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Mon, 16 Mar 2026 14:07:33 +0000 Subject: [PATCH] meta: replace bluelib with fx --- CMakeLists.txt | 6 +- asm/CMakeLists.txt | 2 +- asm/assembler/assembler.c | 42 ++++---- asm/assembler/block.c | 46 ++++---- asm/assembler/class.c | 22 ++-- asm/assembler/constpool.c | 68 ++++++------ asm/include/ivy/asm/bin.h | 66 ++++++------ asm/include/ivy/asm/instr.h | 4 +- asm/include/ivy/asm/lex.h | 4 +- asm/instr.c | 4 +- asm/lex.c | 128 +++++++++++------------ asm/lex.h | 20 ++-- asm/mie/select.c | 12 +-- asm/parse/block.c | 60 +++++------ asm/parse/class.c | 4 +- asm/parse/ident.c | 12 +-- asm/parse/parse.c | 10 +- asm/parse/parse.h | 6 +- asm/parse/unit.c | 4 +- asm/reader.c | 40 +++---- cmake/FindBluelib.cmake | 189 --------------------------------- cmake/FindFX.cmake | 189 +++++++++++++++++++++++++++++++++ common/CMakeLists.txt | 2 +- common/file.c | 26 ++--- common/ident.c | 28 ++--- common/include/ivy/file.h | 4 +- common/include/ivy/ident.h | 6 +- common/include/ivy/selector.h | 6 +- common/include/ivy/status.h | 8 +- common/selector.c | 50 ++++----- common/status.c | 44 ++++---- diag/CMakeLists.txt | 2 +- diag/ctx.c | 8 +- diag/ctx.h | 4 +- diag/diag.c | 8 +- diag/diag.h | 8 +- diag/include/ivy/diag.h | 6 +- diag/stream.c | 8 +- diag/write/pretty.c | 38 +++---- frontend/CMakeLists.txt | 6 +- frontend/cmd/assemble.c | 122 +++++++++++----------- frontend/cmd/compile.c | 184 ++++++++++++++++---------------- frontend/cmd/disassemble.c | 124 +++++++++++----------- frontend/cmd/exec.c | 38 +++---- frontend/cmd/internal.c | 38 +++---- frontend/cmd/repl.c | 76 +++++++------- frontend/debug.c | 156 ++++++++++++++-------------- frontend/line-ed/history.c | 38 +++---- frontend/line-ed/hl-range.c | 64 ++++++------ frontend/line-ed/hl-range.h | 12 +-- frontend/line-ed/hook.c | 18 ++-- frontend/line-ed/hook.h | 4 +- frontend/line-ed/input.c | 28 ++--- frontend/line-ed/line-ed.c | 36 +++---- frontend/line-ed/line-ed.h | 22 ++-- frontend/line-ed/refresh.c | 30 +++--- frontend/main.c | 4 +- lang/CMakeLists.txt | 2 +- lang/ast/atom.c | 6 +- lang/ast/block.c | 10 +- lang/ast/cascade.c | 6 +- lang/ast/class.c | 22 ++-- lang/ast/cond.c | 14 +-- lang/ast/ctx.c | 50 ++++----- lang/ast/ctx.h | 10 +- lang/ast/double.c | 6 +- lang/ast/expr/arith.c | 190 +++++++++++++++++----------------- lang/ast/expr/expr.h | 12 +-- lang/ast/expr/stmt.c | 22 ++-- lang/ast/ident.c | 6 +- lang/ast/int.c | 6 +- lang/ast/iterate.c | 48 ++++----- lang/ast/lambda.c | 12 +-- lang/ast/loop-control.c | 6 +- lang/ast/match.c | 10 +- lang/ast/msg.c | 6 +- lang/ast/msgh.c | 2 +- lang/ast/node.c | 28 ++--- lang/ast/node.h | 4 +- lang/ast/op.c | 6 +- lang/ast/package.c | 20 ++-- lang/ast/property.c | 14 +-- lang/ast/selector.c | 60 +++++------ lang/ast/string.c | 16 +-- lang/ast/try.c | 12 +-- lang/ast/tuple.c | 18 ++-- lang/ast/unit-import.c | 22 ++-- lang/ast/unit-package.c | 22 ++-- lang/ast/unit.c | 8 +- lang/codegen/codegen.c | 34 +++--- lang/codegen/codegen.h | 10 +- lang/codegen/cond-group.c | 18 ++-- lang/codegen/expr.c | 32 +++--- lang/codegen/msg.c | 32 +++--- lang/codegen/unit.c | 32 +++--- lang/codegen/var-map.c | 22 ++-- lang/codegen/var-map.h | 4 +- lang/include/ivy/lang/ast.h | 50 ++++----- lang/include/ivy/lang/lex.h | 4 +- lang/internal.c | 28 ++--- lang/lex.c | 124 +++++++++++----------- lang/lex.h | 20 ++-- mie | 2 +- test/diag.c | 50 ++++----- test/mie-ir.c | 4 +- 105 files changed, 1668 insertions(+), 1668 deletions(-) delete mode 100644 cmake/FindBluelib.cmake create mode 100644 cmake/FindFX.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 9260a4c..04c0776 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.14) project(ivy C) if (WIN32) @@ -24,10 +24,10 @@ if (NOT IVY_STATIC) endif () if (IVY_STATIC) - set(Bluelib_STATIC TRUE) + set(FX_STATIC TRUE) endif () -find_package(Bluelib REQUIRED) +find_package(FX REQUIRED) add_subdirectory(common) add_subdirectory(diag) diff --git a/asm/CMakeLists.txt b/asm/CMakeLists.txt index c0f32b9..48e2471 100644 --- a/asm/CMakeLists.txt +++ b/asm/CMakeLists.txt @@ -11,5 +11,5 @@ else () endif () target_include_directories(ivy-asm PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/) -target_link_libraries(ivy-asm ivy-common mie Bluelib::Core Bluelib::Ds) +target_link_libraries(ivy-asm ivy-common mie FX::Core FX::Ds) target_compile_definitions(ivy-asm PRIVATE IVY_EXPORT=1 IVY_STATIC=${IVY_STATIC}) diff --git a/asm/assembler/assembler.c b/asm/assembler/assembler.c index 02b0a61..9049589 100644 --- a/asm/assembler/assembler.c +++ b/asm/assembler/assembler.c @@ -1,6 +1,6 @@ #include "assembler.h" -#include +#include #include #include #include @@ -19,13 +19,13 @@ static const struct assembler_scope_type *scope_types[] = { static const size_t nr_scope_types = sizeof scope_types / sizeof scope_types[0]; struct asm_table_entry { - b_queue_entry e_entry; + fx_queue_entry e_entry; struct ivy_bin_table_entry e_data; }; struct ivy_assembler { struct assembler_scope *as_scope; - b_queue as_table; + fx_queue as_table; FILE *as_data; size_t as_data_offset; @@ -48,7 +48,7 @@ enum ivy_status ivy_assembler_create(FILE *fp, struct ivy_assembler **as) out->as_xdat = tmpfile(); struct ivy_bin_header header = {0}; - header.h_magic = b_i32_htob(0xAABBCCDD); + header.h_magic = fx_i32_htob(0xAABBCCDD); fseek(fp, 0, SEEK_SET); fwrite(&header, sizeof header, 1, fp); @@ -86,9 +86,9 @@ enum ivy_status ivy_assembler_finish(struct ivy_assembler *as) pad(as, 16); struct ivy_bin_table_entry xdat = {0}; - xdat.e_offset = b_i64_htob(as->as_data_offset); - xdat.e_size = b_i32_htob((uint32_t)xdat_len); - xdat.e_type = b_i32_htob(IVY_TABLE_XDAT); + xdat.e_offset = fx_i64_htob(as->as_data_offset); + xdat.e_size = fx_i32_htob((uint32_t)xdat_len); + xdat.e_type = fx_i32_htob(IVY_TABLE_XDAT); while (1) { size_t r = fread(buf, 1, buf_len, as->as_xdat); @@ -114,14 +114,14 @@ enum ivy_status ivy_assembler_finish(struct ivy_assembler *as) pad(as, 16); struct ivy_bin_header header = {0}; - header.h_table_offset = b_i64_htob(as->as_data_offset); - header.h_table_len = b_i16_htob(0); - header.h_magic = b_i32_htob(IVY_BIN_MAGIC); + header.h_table_offset = fx_i64_htob(as->as_data_offset); + header.h_table_len = fx_i16_htob(0); + header.h_magic = fx_i32_htob(IVY_BIN_MAGIC); - b_queue_entry *entry = b_queue_first(&as->as_table); + fx_queue_entry *entry = fx_queue_first(&as->as_table); while (entry) { struct asm_table_entry *e - = b_unbox(struct asm_table_entry, entry, e_entry); + = fx_unbox(struct asm_table_entry, entry, e_entry); size_t w = fwrite(&e->e_data, 1, sizeof e->e_data, as->as_data); if (w < sizeof e->e_data) { @@ -129,13 +129,13 @@ enum ivy_status ivy_assembler_finish(struct ivy_assembler *as) } nr_table_entries++; - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } fwrite(&xdat, 1, sizeof xdat, as->as_data); nr_table_entries++; - header.h_table_len = b_i16_htob(nr_table_entries); + header.h_table_len = fx_i16_htob(nr_table_entries); fseek(as->as_data, 0, SEEK_SET); fwrite(&header, 1, sizeof header, as->as_data); @@ -257,28 +257,28 @@ enum ivy_status ivy_assembler_end_scope(struct ivy_assembler *as) memset(entry, 0x0, sizeof *entry); entry->e_data.e_offset - = b_i64_htob((uint64_t)as->as_scope->s_start_offset); - entry->e_data.e_size = b_i32_htob( + = fx_i64_htob((uint64_t)as->as_scope->s_start_offset); + entry->e_data.e_size = fx_i32_htob( (uint32_t)(as->as_data_offset - as->as_scope->s_start_offset)); switch (as->as_scope->s_type) { case IVY_ASM_SCOPE_CLASS: - entry->e_data.e_type = b_i32_htob(IVY_TABLE_CLASS); + entry->e_data.e_type = fx_i32_htob(IVY_TABLE_CLASS); break; case IVY_ASM_SCOPE_BLOCK: - entry->e_data.e_type = b_i32_htob(IVY_TABLE_BLOCK); + entry->e_data.e_type = fx_i32_htob(IVY_TABLE_BLOCK); break; case IVY_ASM_SCOPE_CONSTPOOL: - entry->e_data.e_type = b_i32_htob(IVY_TABLE_POOL); + entry->e_data.e_type = fx_i32_htob(IVY_TABLE_POOL); break; case IVY_ASM_SCOPE_IMPORT: - entry->e_data.e_type = b_i32_htob(IVY_TABLE_IMPORT); + entry->e_data.e_type = fx_i32_htob(IVY_TABLE_IMPORT); break; default: break; } - b_queue_push_back(&as->as_table, &entry->e_entry); + fx_queue_push_back(&as->as_table, &entry->e_entry); free(as->as_scope); as->as_scope = NULL; diff --git a/asm/assembler/block.c b/asm/assembler/block.c index 8210d20..4c85aaa 100644 --- a/asm/assembler/block.c +++ b/asm/assembler/block.c @@ -1,9 +1,9 @@ #include "assembler.h" -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include @@ -19,15 +19,15 @@ enum label_state { struct label { enum label_state l_state; - b_queue_entry l_entry; + fx_queue_entry l_entry; const struct ivy_asm_token *l_name; size_t l_offset; }; struct block_assembler_scope { struct assembler_scope s_base; - b_hashmap *s_labels; - b_queue s_label_refs; + fx_hashmap *s_labels; + fx_queue s_label_refs; size_t s_text_start; }; @@ -57,10 +57,10 @@ static enum ivy_status init_scope( struct ivy_bin_block header = {0}; struct block_assembler_scope *c = (struct block_assembler_scope *)scope; - c->s_labels = b_hashmap_create(NULL, NULL); + c->s_labels = fx_hashmap_create(NULL, NULL); c->s_text_start = ivy_assembler_get_ptr(as); - header.b_index = b_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_INDEX]); + header.b_index = fx_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_INDEX]); assembler_write_data(as, &header, sizeof header); return IVY_OK; @@ -68,12 +68,12 @@ static enum ivy_status init_scope( static struct label *get_label(struct block_assembler_scope *scope, const char *name) { - b_hashmap_key key = { + fx_hashmap_key key = { .key_data = name, .key_size = strlen(name), }; - const b_hashmap_value *v = b_hashmap_get(scope->s_labels, &key); + const fx_hashmap_value *v = fx_hashmap_get(scope->s_labels, &key); if (!v) { return NULL; } @@ -88,9 +88,9 @@ static enum ivy_status resolve_label_refs( enum ivy_status status = IVY_OK; size_t nr_read = 0; - b_queue_entry *entry = b_queue_first(&c->s_label_refs); + fx_queue_entry *entry = fx_queue_first(&c->s_label_refs); while (entry) { - struct label *label_ref = b_unbox(struct label, entry, l_entry); + struct label *label_ref = fx_unbox(struct label, entry, l_entry); struct label *label_dest = get_label(c, label_ref->l_name->t_str); if (!label_dest) { @@ -99,7 +99,7 @@ static enum ivy_status resolve_label_refs( return IVY_ERR_NO_ENTRY; } - b_i32 x; + fx_i32 x; status = assembler_read_data_at( as, &x, label_ref->l_offset, sizeof x, &nr_read); @@ -109,12 +109,12 @@ static enum ivy_status resolve_label_refs( return IVY_ERR_IO_FAILURE; } - uint32_t instr = b_i32_btoh(x); + uint32_t instr = fx_i32_btoh(x); instr = R_SET_D3(instr, label_dest->l_offset); - x = b_i32_htob(instr); + x = fx_i32_htob(instr); assembler_write_data_at(as, &x, label_ref->l_offset, sizeof x); - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } return status; @@ -164,7 +164,7 @@ static enum ivy_status put_instr( return IVY_ERR_INTERNAL_FAILURE; } - b_i32 x = b_i32_htob(v); + fx_i32 x = fx_i32_htob(v); assembler_write_data(as, &x, sizeof x); return IVY_OK; } @@ -179,21 +179,21 @@ static enum ivy_status put_label( label->l_name = label_name; label->l_offset = label_offset - c->s_text_start; - b_hashmap_key key = { + fx_hashmap_key key = { .key_data = label_name->t_str, .key_size = strlen(label_name->t_str), }; - b_hashmap_value value = { + fx_hashmap_value value = { .value_data = label, .value_size = sizeof *label, }; - if (b_hashmap_get(c->s_labels, &key)) { + if (fx_hashmap_get(c->s_labels, &key)) { return IVY_ERR_NAME_EXISTS; } - b_status status = b_hashmap_put(c->s_labels, &key, &value); + fx_status status = fx_hashmap_put(c->s_labels, &key, &value); return ivy_status_from_b_status(status); } @@ -208,7 +208,7 @@ static enum ivy_status put_label_ref( label->l_name = label_name; label->l_offset = ref_offset; - b_queue_push_back(&c->s_label_refs, &label->l_entry); + fx_queue_push_back(&c->s_label_refs, &label->l_entry); return IVY_OK; } diff --git a/asm/assembler/class.c b/asm/assembler/class.c index 9d3d028..a59a524 100644 --- a/asm/assembler/class.c +++ b/asm/assembler/class.c @@ -8,7 +8,7 @@ static enum ivy_status init_scope( { struct ivy_bin_class header = {0}; - header.c_ident = b_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_IDENT]); + header.c_ident = fx_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_IDENT]); assembler_write_data(as, &header, sizeof header); @@ -22,27 +22,27 @@ static enum ivy_status put_xval( struct ivy_bin_class_table_entry entry = {0}; switch (type) { case IVY_ASM_XVAL_PROPERTY: - entry.e_type = b_i32_htob(IVY_CLASS_TABLE_PROP); + entry.e_type = fx_i32_htob(IVY_CLASS_TABLE_PROP); entry.e_property.p_ident - = b_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_IDENT]); + = fx_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_IDENT]); entry.e_property.p_get - = b_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_GET]); + = fx_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_GET]); entry.e_property.p_set - = b_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_SET]); + = fx_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_SET]); break; case IVY_ASM_XVAL_MEMBER_VAR: - entry.e_type = b_i32_htob(IVY_CLASS_TABLE_MVAR); + entry.e_type = fx_i32_htob(IVY_CLASS_TABLE_MVAR); entry.e_mvar.m_ident - = b_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_IDENT]); + = fx_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_IDENT]); entry.e_mvar.m_index - = b_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_INDEX]); + = fx_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_INDEX]); break; case IVY_ASM_XVAL_MESSAGE_HANDLER: - entry.e_type = b_i32_htob(IVY_CLASS_TABLE_MSGH); + entry.e_type = fx_i32_htob(IVY_CLASS_TABLE_MSGH); entry.e_msgh.msg_selector - = b_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_SELECTOR]); + = fx_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_SELECTOR]); entry.e_msgh.msg_block - = b_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_BLOCK]); + = fx_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_BLOCK]); break; default: return IVY_ERR_NOT_SUPPORTED; diff --git a/asm/assembler/constpool.c b/asm/assembler/constpool.c index a5d41b3..5cc5b38 100644 --- a/asm/assembler/constpool.c +++ b/asm/assembler/constpool.c @@ -1,9 +1,9 @@ #include "assembler.h" -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include @@ -12,7 +12,7 @@ struct constpool_assembler_scope { struct assembler_scope s_base; - b_dict *s_strings; + fx_dict *s_strings; size_t s_next_slot; }; @@ -26,7 +26,7 @@ static enum ivy_status init_scope( struct constpool_assembler_scope *c = (struct constpool_assembler_scope *)scope; - c->s_strings = b_dict_create(); + c->s_strings = fx_dict_create(); c->s_next_slot = 0; return IVY_OK; @@ -35,19 +35,19 @@ static enum ivy_status init_scope( static ivy_extended_data_key get_cached_string( struct constpool_assembler_scope *scope, const char *s) { - b_number *key = b_dict_at(scope->s_strings, s); + fx_number *key = fx_dict_at(scope->s_strings, s); if (!key) { return IVY_EX_DATA_KEY_NULL; } - return (ivy_extended_data_key)b_number_get_int32(key); + return (ivy_extended_data_key)fx_number_get_int32(key); } static void put_cached_string( struct constpool_assembler_scope *scope, const char *s, ivy_extended_data_key key) { - b_dict_put(scope->s_strings, s, B_RV_INT32(key)); + fx_dict_put(scope->s_strings, s, FX_RV_INT32(key)); } static ivy_extended_data_key write_string(struct ivy_assembler *as, const char *s) @@ -63,8 +63,8 @@ static ivy_extended_data_key write_string(struct ivy_assembler *as, const char * size_t len = strlen(s); struct ivy_bin_string str = {0}; - str.s_hash = b_i32_htob((uint32_t)b_hash_cstr(s)); - str.s_len = b_i32_htob((uint32_t)len); + str.s_hash = fx_i32_htob((uint32_t)fx_hash_cstr(s)); + str.s_len = fx_i32_htob((uint32_t)len); key = assembler_write_extended_data(as, &str, sizeof str); @@ -90,29 +90,29 @@ static ivy_extended_data_key write_selector( } if (sel->sel_name) { - dat.sel_name = b_i32_htob(write_string(as, sel->sel_name)); + dat.sel_name = fx_i32_htob(write_string(as, sel->sel_name)); } size_t i = 0; - size_t nr_args = b_queue_length(&sel->sel_args); + size_t nr_args = fx_queue_length(&sel->sel_args); dat.sel_nr_args = (uint8_t)nr_args; /* TODO hash. */ ivy_extended_data_key *arg_handles = calloc(nr_args, sizeof(ivy_extended_data_key)); - b_queue_entry *entry = b_queue_first(&sel->sel_args); + fx_queue_entry *entry = fx_queue_first(&sel->sel_args); while (entry) { struct ivy_selector_arg *arg - = b_unbox(struct ivy_selector_arg, entry, arg_entry); + = fx_unbox(struct ivy_selector_arg, entry, arg_entry); arg_handles[i++] = write_string(as, arg->arg_label); - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } ivy_extended_data_key selector_handle = assembler_write_extended_data(as, &dat, sizeof dat); for (i = 0; i < nr_args; i++) { - b_i32 arg_handle = b_i32_htob(arg_handles[i]); + fx_i32 arg_handle = fx_i32_htob(arg_handles[i]); assembler_write_extended_data(as, &arg_handle, sizeof arg_handle); } @@ -126,17 +126,17 @@ static ivy_extended_data_key write_ident( struct ivy_bin_ident dat = {0}; /* TODO hash. */ - size_t nr_parts = b_queue_length(&id->id_parts); + size_t nr_parts = fx_queue_length(&id->id_parts); size_t i = 0; ivy_extended_data_key *part_handles = calloc(nr_parts, sizeof(ivy_extended_data_key)); - b_queue_entry *entry = b_queue_first(&id->id_parts); + fx_queue_entry *entry = fx_queue_first(&id->id_parts); while (entry) { struct ivy_ident_part *arg - = b_unbox(struct ivy_ident_part, entry, p_entry); + = fx_unbox(struct ivy_ident_part, entry, p_entry); part_handles[i++] = write_string(as, arg->p_str); - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } dat.id_nr_parts = (uint8_t)nr_parts; @@ -145,7 +145,7 @@ static ivy_extended_data_key write_ident( = assembler_write_extended_data(as, &dat, sizeof dat); for (i = 0; i < nr_parts; i++) { - b_i32 part_handle = b_i32_htob(part_handles[i]); + fx_i32 part_handle = fx_i32_htob(part_handles[i]); assembler_write_extended_data(as, &part_handle, sizeof part_handle); } @@ -170,32 +170,32 @@ static enum ivy_status put_pval( switch (type) { case IVY_ASM_PVAL_STRING: - entry.e_type = b_i32_htob(IVY_CONSTPOOL_TABLE_STRING); + entry.e_type = fx_i32_htob(IVY_CONSTPOOL_TABLE_STRING); k = write_string(as, val); - entry.e_ex_handle = b_i32_htob(k); + entry.e_ex_handle = fx_i32_htob(k); break; case IVY_ASM_PVAL_IDENT: - entry.e_type = b_i32_htob(IVY_CONSTPOOL_TABLE_IDENT); + entry.e_type = fx_i32_htob(IVY_CONSTPOOL_TABLE_IDENT); k = write_ident(as, val); - entry.e_ex_handle = b_i32_htob(k); + entry.e_ex_handle = fx_i32_htob(k); break; case IVY_ASM_PVAL_ATOM: - entry.e_type = b_i32_htob(IVY_CONSTPOOL_TABLE_ATOM); + entry.e_type = fx_i32_htob(IVY_CONSTPOOL_TABLE_ATOM); k = write_string(as, val); - entry.e_ex_handle = b_i32_htob(k); + entry.e_ex_handle = fx_i32_htob(k); break; case IVY_ASM_PVAL_SINT: - entry.e_type = b_i32_htob(IVY_CONSTPOOL_TABLE_INT); - entry.e_int = b_i32_htob((uint32_t)i); + entry.e_type = fx_i32_htob(IVY_CONSTPOOL_TABLE_INT); + entry.e_int = fx_i32_htob((uint32_t)i); break; case IVY_ASM_PVAL_UINT: - entry.e_type = b_i32_htob(IVY_CONSTPOOL_TABLE_UINT); - entry.e_int = b_i32_htob((uint32_t)i); + entry.e_type = fx_i32_htob(IVY_CONSTPOOL_TABLE_UINT); + entry.e_int = fx_i32_htob((uint32_t)i); break; case IVY_ASM_PVAL_SELECTOR: - entry.e_type = b_i32_htob(IVY_CONSTPOOL_TABLE_SELECTOR); + entry.e_type = fx_i32_htob(IVY_CONSTPOOL_TABLE_SELECTOR); k = write_selector(as, val); - entry.e_ex_handle = b_i32_htob(k); + entry.e_ex_handle = fx_i32_htob(k); break; default: return IVY_ERR_NOT_SUPPORTED; diff --git a/asm/include/ivy/asm/bin.h b/asm/include/ivy/asm/bin.h index 136916b..600576d 100644 --- a/asm/include/ivy/asm/bin.h +++ b/asm/include/ivy/asm/bin.h @@ -1,7 +1,7 @@ #ifndef IVY_ASM_BIN_H_ #define IVY_ASM_BIN_H_ -#include +#include #include #define IVY_BIN_MAGIC 0x2E495659u @@ -30,61 +30,61 @@ #define IVY_BIN_NULL_HANDLE ((ivy_bin_data_handle)0) struct ivy_bin_header { - b_i32 h_magic; - b_i16 h_table_len; + fx_i32 h_magic; + fx_i16 h_table_len; uint8_t h_reserved[2]; - b_i64 h_table_offset; + fx_i64 h_table_offset; }; struct ivy_bin_table_entry { - b_i32 e_type; - b_i32 e_size; - b_i64 e_offset; + fx_i32 e_type; + fx_i32 e_size; + fx_i64 e_offset; }; struct ivy_bin_class_table_entry { - b_i32 e_type; + fx_i32 e_type; union { struct { - b_i32 p_ident; - b_i32 p_get; - b_i32 p_set; + fx_i32 p_ident; + fx_i32 p_get; + fx_i32 p_set; } e_property; struct { - b_i32 m_index; - b_i32 m_ident; + fx_i32 m_index; + fx_i32 m_ident; uint8_t m_reserved[4]; } e_mvar; struct { - b_i32 msg_selector; - b_i32 msg_block; + fx_i32 msg_selector; + fx_i32 msg_block; uint8_t m_reserved[4]; } e_msgh; }; }; struct ivy_bin_class { - b_i32 c_ident; + fx_i32 c_ident; uint8_t c_reserved[12]; struct ivy_bin_class_table_entry c_table[]; }; struct ivy_bin_lambda { - b_i32 l_ident; - b_i32 l_instr[]; + fx_i32 l_ident; + fx_i32 l_instr[]; }; struct ivy_bin_msgh { - b_i32 msg_recipient; - b_i32 msg_selector; - b_i32 msg_instr[]; + fx_i32 msg_recipient; + fx_i32 msg_selector; + fx_i32 msg_instr[]; }; struct ivy_bin_string { - b_i32 s_hash; - b_i32 s_len; + fx_i32 s_hash; + fx_i32 s_len; char s_chars[]; }; @@ -92,24 +92,24 @@ struct ivy_bin_selector { uint8_t sel_flags; uint8_t sel_nr_args; uint8_t sel_reserved[2]; - b_i32 sel_hash; - b_i32 sel_name; - b_i32 sel_args[]; + fx_i32 sel_hash; + fx_i32 sel_name; + fx_i32 sel_args[]; }; struct ivy_bin_ident { - b_i32 id_hash; + fx_i32 id_hash; uint8_t id_nr_parts; uint8_t id_reserved[3]; - b_i32 id_parts[]; + fx_i32 id_parts[]; }; struct ivy_bin_constpool_table_entry { - b_i32 e_type; + fx_i32 e_type; union { - b_i32 e_ex_handle; - b_i32 e_int; + fx_i32 e_ex_handle; + fx_i32 e_int; }; }; @@ -119,11 +119,11 @@ struct ivy_bin_constpool { }; struct ivy_bin_block { - b_i32 b_index; + fx_i32 fx_index; }; struct ivy_bin_import_table_entry { - b_i32 e_ident; + fx_i32 e_ident; }; #endif diff --git a/asm/include/ivy/asm/instr.h b/asm/include/ivy/asm/instr.h index 3fbe4f2..6b54bed 100644 --- a/asm/include/ivy/asm/instr.h +++ b/asm/include/ivy/asm/instr.h @@ -1,7 +1,7 @@ #ifndef IVY_ASM_INSTR_H_ #define IVY_ASM_INSTR_H_ -#include +#include #include #include #include @@ -85,6 +85,6 @@ struct ivy_instr { IVY_API const struct ivy_instr_definition *ivy_instr_find( enum ivy_instr_id id, const enum ivy_instr_operand_type operands[4]); -IVY_API enum ivy_status ivy_instr_decode(b_i32 instr, struct ivy_instr *out); +IVY_API enum ivy_status ivy_instr_decode(fx_i32 instr, struct ivy_instr *out); #endif diff --git a/asm/include/ivy/asm/lex.h b/asm/include/ivy/asm/lex.h index 5e55891..3184f0a 100644 --- a/asm/include/ivy/asm/lex.h +++ b/asm/include/ivy/asm/lex.h @@ -1,7 +1,7 @@ #ifndef IVY_ASM_LEX_H_ #define IVY_ASM_LEX_H_ -#include +#include #include #include #include @@ -64,7 +64,7 @@ enum ivy_asm_symbol { struct ivy_asm_token { enum ivy_asm_token_type t_type; - b_queue_entry t_entry; + fx_queue_entry t_entry; union { enum ivy_asm_keyword t_keyword; diff --git a/asm/instr.c b/asm/instr.c index 48128e3..975b8b1 100644 --- a/asm/instr.c +++ b/asm/instr.c @@ -139,9 +139,9 @@ const struct ivy_instr_definition *ivy_instr_find( return NULL; } -enum ivy_status ivy_instr_decode(b_i32 x, struct ivy_instr *out) +enum ivy_status ivy_instr_decode(fx_i32 x, struct ivy_instr *out) { - uint32_t instr = b_i32_btoh(x); + uint32_t instr = fx_i32_btoh(x); unsigned int opcode = R_GET_OPCODE(instr); if (opcode >= nr_instructions) { return IVY_ERR_INVALID_VALUE; diff --git a/asm/lex.c b/asm/lex.c index 01288fb..c6a8cf8 100644 --- a/asm/lex.c +++ b/asm/lex.c @@ -1,10 +1,10 @@ #include "lex.h" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include @@ -63,40 +63,40 @@ static struct lexer_state *push_lexer_state( memset(state, 0x0, sizeof *state); state->s_type = state_type; - b_queue_push_back(&lex->lex_state, &state->s_entry); + fx_queue_push_back(&lex->lex_state, &state->s_entry); return state; } static void pop_lexer_state(struct ivy_asm_lexer *lex) { - b_queue_entry *entry = b_queue_pop_back(&lex->lex_state); + fx_queue_entry *entry = fx_queue_pop_back(&lex->lex_state); if (!entry) { return; } - struct lexer_state *state = b_unbox(struct lexer_state, entry, s_entry); + struct lexer_state *state = fx_unbox(struct lexer_state, entry, s_entry); free(state); } static struct lexer_state *get_lexer_state(struct ivy_asm_lexer *lex) { - b_queue_entry *entry = b_queue_last(&lex->lex_state); + fx_queue_entry *entry = fx_queue_last(&lex->lex_state); if (!entry) { return NULL; } - return b_unbox(struct lexer_state, entry, s_entry); + return fx_unbox(struct lexer_state, entry, s_entry); } -static void destroy_state_stack(b_queue *state) +static void destroy_state_stack(fx_queue *state) { - b_queue_entry *entry = b_queue_first(state); + fx_queue_entry *entry = fx_queue_first(state); while (entry) { struct lexer_state *node - = b_unbox(struct lexer_state, entry, s_entry); - b_queue_entry *next = b_queue_next(entry); - b_queue_delete(state, entry); + = fx_unbox(struct lexer_state, entry, s_entry); + fx_queue_entry *next = fx_queue_next(entry); + fx_queue_delete(state, entry); free(node); @@ -107,27 +107,27 @@ static void destroy_state_stack(b_queue *state) static struct ivy_asm_lexer_symbol_node *get_symbol_node( struct ivy_asm_lexer_symbol_node *node, char c) { - b_queue_entry *entry = b_queue_first(&node->s_children); + fx_queue_entry *entry = fx_queue_first(&node->s_children); while (entry) { - struct ivy_asm_lexer_symbol_node *child = b_unbox( + struct ivy_asm_lexer_symbol_node *child = fx_unbox( struct ivy_asm_lexer_symbol_node, entry, s_entry); if (child->s_char == c) { return child; } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } return NULL; } -static b_string *get_temp_string(struct ivy_asm_lexer *lex) +static fx_string *get_temp_string(struct ivy_asm_lexer *lex) { if (!lex->lex_temp) { - lex->lex_temp = b_string_create(); + lex->lex_temp = fx_string_create(); } - b_string_clear(lex->lex_temp); + fx_string_clear(lex->lex_temp); return lex->lex_temp; } @@ -152,7 +152,7 @@ static enum ivy_status put_symbol( child->s_id = IVY_ASM_SYM_NONE; child->s_char = c; - b_queue_push_back(&tree->s_children, &child->s_entry); + fx_queue_push_back(&tree->s_children, &child->s_entry); tree = child; } @@ -162,12 +162,12 @@ static enum ivy_status put_symbol( static void destroy_symbol_tree(struct ivy_asm_lexer_symbol_node *tree) { - b_queue_entry *entry = b_queue_first(&tree->s_children); + fx_queue_entry *entry = fx_queue_first(&tree->s_children); while (entry) { - struct ivy_asm_lexer_symbol_node *node = b_unbox( + struct ivy_asm_lexer_symbol_node *node = fx_unbox( struct ivy_asm_lexer_symbol_node, entry, s_entry); - b_queue_entry *next = b_queue_next(entry); - b_queue_delete(&tree->s_children, entry); + fx_queue_entry *next = fx_queue_next(entry); + fx_queue_delete(&tree->s_children, entry); destroy_symbol_tree(node); @@ -200,23 +200,23 @@ static struct ivy_asm_lexer_symbol_node *build_symbol_tree(void) return root; } -static void init_keywords(b_dict *keyword_dict) +static void init_keywords(fx_dict *keyword_dict) { for (size_t i = 0; i < nr_keywords; i++) { struct lex_token_def *keyword = &keywords[i]; - b_dict_put(keyword_dict, keyword->name, B_RV_INT(keyword->id)); + fx_dict_put(keyword_dict, keyword->name, FX_RV_INT(keyword->id)); } } static enum ivy_asm_keyword find_keyword_by_name( struct ivy_asm_lexer *lex, const char *s) { - b_number *id = b_dict_at(lex->lex_keywords, s); + fx_number *id = fx_dict_at(lex->lex_keywords, s); if (!id) { return IVY_ASM_KW_NONE; } - return b_number_get_int(id); + return fx_number_get_int(id); } enum ivy_status ivy_asm_lexer_create(struct ivy_asm_lexer **lexp) @@ -245,7 +245,7 @@ enum ivy_status ivy_asm_lexer_create(struct ivy_asm_lexer **lexp) return IVY_ERR_NO_MEMORY; } - lex->lex_keywords = b_dict_create(); + lex->lex_keywords = fx_dict_create(); init_keywords(lex->lex_keywords); *lexp = lex; @@ -254,13 +254,13 @@ enum ivy_status ivy_asm_lexer_create(struct ivy_asm_lexer **lexp) void ivy_asm_lexer_destroy(struct ivy_asm_lexer *lex) { - b_queue_entry *entry = b_queue_first(&lex->lex_queue); + fx_queue_entry *entry = fx_queue_first(&lex->lex_queue); while (entry) { struct ivy_asm_token *tok - = b_unbox(struct ivy_asm_token, entry, t_entry); - b_queue_entry *next = b_queue_next(entry); - b_queue_delete(&lex->lex_queue, entry); + = fx_unbox(struct ivy_asm_token, entry, t_entry); + fx_queue_entry *next = fx_queue_next(entry); + fx_queue_delete(&lex->lex_queue, entry); ivy_asm_token_destroy(tok); @@ -276,11 +276,11 @@ void ivy_asm_lexer_destroy(struct ivy_asm_lexer *lex) } if (lex->lex_temp) { - b_string_unref(lex->lex_temp); + fx_string_unref(lex->lex_temp); } if (lex->lex_keywords) { - b_dict_unref(lex->lex_keywords); + fx_dict_unref(lex->lex_keywords); } destroy_state_stack(&lex->lex_state); @@ -411,7 +411,7 @@ static struct ivy_asm_token *create_token(enum ivy_asm_token_type type) static enum ivy_status push_token( struct ivy_asm_lexer *lex, struct ivy_asm_token *tok) { - b_queue_push_back(&lex->lex_queue, &tok->t_entry); + fx_queue_push_back(&lex->lex_queue, &tok->t_entry); lex->lex_prev_token = tok->t_type; return IVY_OK; } @@ -610,7 +610,7 @@ static enum ivy_status read_dquote_marker(struct ivy_asm_lexer *lex) static enum ivy_status read_string_content(struct ivy_asm_lexer *lex) { int c; - b_string *str = get_temp_string(lex); + fx_string *str = get_temp_string(lex); struct lexer_state *state = get_lexer_state(lex); if (!str) { @@ -629,15 +629,15 @@ static enum ivy_status read_string_content(struct ivy_asm_lexer *lex) } char s[2] = {c, 0}; - b_string_append_cstr(str, s); + fx_string_append_cstr(str, s); advance(lex); } - if (b_string_get_size(str, B_STRLEN_NORMAL) == 0) { + if (fx_string_get_size(str, FX_STRLEN_NORMAL) == 0) { return IVY_OK; } - char *s = b_string_steal(str); + char *s = fx_string_steal(str); enum ivy_status status = push_string_content(lex, s); if (status != IVY_OK) { @@ -692,7 +692,7 @@ static enum ivy_status read_number(struct ivy_asm_lexer *lex) int base = 10; int dots = 0; bool neg = false; - b_string *str = get_temp_string(lex); + fx_string *str = get_temp_string(lex); while (true) { int c = peek(lex); @@ -733,7 +733,7 @@ static enum ivy_status read_number(struct ivy_asm_lexer *lex) token_len++; dots++; char s[] = {c, 0}; - b_string_append_cstr(str, s); + fx_string_append_cstr(str, s); advance(lex); continue; } @@ -776,7 +776,7 @@ static enum ivy_status read_number(struct ivy_asm_lexer *lex) } char s[] = {c, 0}; - b_string_append_cstr(str, s); + fx_string_append_cstr(str, s); token_len++; advance(lex); } @@ -785,7 +785,7 @@ static enum ivy_status read_number(struct ivy_asm_lexer *lex) return push_uint(lex, 0); } - const char *s = b_string_ptr(str); + const char *s = fx_string_ptr(str); char *ep = NULL; if (dots > 0) { @@ -826,8 +826,8 @@ static enum ivy_status read_keyword(struct ivy_asm_lexer *lex) { advance(lex); - b_string *str = get_temp_string(lex); - b_string_append_cstr(str, "@"); + fx_string *str = get_temp_string(lex); + fx_string_append_cstr(str, "@"); bool label = false; @@ -843,11 +843,11 @@ static enum ivy_status read_keyword(struct ivy_asm_lexer *lex) } char s[2] = {c, 0}; - b_string_append_cstr(str, s); + fx_string_append_cstr(str, s); advance(lex); } - const char *s = b_string_ptr(str); + const char *s = fx_string_ptr(str); enum ivy_asm_keyword keyword = find_keyword_by_name(lex, s); @@ -862,7 +862,7 @@ static enum ivy_status read_label_ref(struct ivy_asm_lexer *lex) { advance(lex); - b_string *str = get_temp_string(lex); + fx_string *str = get_temp_string(lex); bool label = false; while (true) { @@ -883,21 +883,21 @@ static enum ivy_status read_label_ref(struct ivy_asm_lexer *lex) } char s[2] = {c, 0}; - b_string_append_cstr(str, s); + fx_string_append_cstr(str, s); advance(lex); } - const char *s = b_string_ptr(str); + const char *s = fx_string_ptr(str); struct ivy_asm_token *tok = create_token(IVY_ASM_TOK_LABEL_REF); - tok->t_str = b_string_steal(str); + tok->t_str = fx_string_steal(str); return push_token(lex, tok); } static enum ivy_status read_ident(struct ivy_asm_lexer *lex) { - b_string *str = get_temp_string(lex); + fx_string *str = get_temp_string(lex); bool label = false; while (true) { @@ -918,15 +918,15 @@ static enum ivy_status read_ident(struct ivy_asm_lexer *lex) } char s[2] = {c, 0}; - b_string_append_cstr(str, s); + fx_string_append_cstr(str, s); advance(lex); } - const char *s = b_string_ptr(str); + const char *s = fx_string_ptr(str); struct ivy_asm_token *tok = create_token(label ? IVY_ASM_TOK_LABEL : IVY_ASM_TOK_IDENT); - tok->t_str = b_string_steal(str); + tok->t_str = fx_string_steal(str); return push_token(lex, tok); } @@ -1003,7 +1003,7 @@ struct ivy_asm_token *ivy_asm_lexer_peek(struct ivy_asm_lexer *lex) { enum ivy_status status = IVY_OK; - while (b_queue_empty(&lex->lex_queue)) { + while (fx_queue_empty(&lex->lex_queue)) { status = pump_tokens(lex); if (status != IVY_OK) { @@ -1013,8 +1013,8 @@ struct ivy_asm_token *ivy_asm_lexer_peek(struct ivy_asm_lexer *lex) } lex->lex_status = status; - b_queue_entry *entry = b_queue_first(&lex->lex_queue); - struct ivy_asm_token *tok = b_unbox(struct ivy_asm_token, entry, t_entry); + fx_queue_entry *entry = fx_queue_first(&lex->lex_queue); + struct ivy_asm_token *tok = fx_unbox(struct ivy_asm_token, entry, t_entry); return tok; } @@ -1022,7 +1022,7 @@ struct ivy_asm_token *ivy_asm_lexer_read(struct ivy_asm_lexer *lex) { enum ivy_status status = IVY_OK; - while (b_queue_empty(&lex->lex_queue)) { + while (fx_queue_empty(&lex->lex_queue)) { status = pump_tokens(lex); if (status != IVY_OK) { @@ -1031,8 +1031,8 @@ struct ivy_asm_token *ivy_asm_lexer_read(struct ivy_asm_lexer *lex) } } - b_queue_entry *entry = b_queue_pop_front(&lex->lex_queue); - struct ivy_asm_token *tok = b_unbox(struct ivy_asm_token, entry, t_entry); + fx_queue_entry *entry = fx_queue_pop_front(&lex->lex_queue); + struct ivy_asm_token *tok = fx_unbox(struct ivy_asm_token, entry, t_entry); return tok; } diff --git a/asm/lex.h b/asm/lex.h index 8ce4e7c..e9167b0 100644 --- a/asm/lex.h +++ b/asm/lex.h @@ -1,9 +1,9 @@ #ifndef _LEX_H_ #define _LEX_H_ -#include -#include -#include +#include +#include +#include #include #include @@ -15,15 +15,15 @@ enum lexer_state_type { struct lexer_state { enum lexer_state_type s_type; - b_queue_entry s_entry; + fx_queue_entry s_entry; }; struct ivy_asm_lexer_symbol_node { char s_char; enum ivy_asm_symbol s_id; - b_queue_entry s_entry; - b_queue s_children; + fx_queue_entry s_entry; + fx_queue s_children; }; struct lex_token_def { @@ -35,14 +35,14 @@ struct lex_token_def { struct ivy_asm_lexer { struct ivy_asm_lexer_symbol_node *lex_sym_tree; struct ivy_line_source *lex_source; - b_dict *lex_keywords; + fx_dict *lex_keywords; enum ivy_status lex_status; - b_queue lex_queue; + fx_queue lex_queue; enum ivy_asm_token_type lex_prev_token; - b_string *lex_temp; - b_queue lex_state; + fx_string *lex_temp; + fx_queue lex_state; unsigned int lex_brace_depth; char *lex_linebuf; diff --git a/asm/mie/select.c b/asm/mie/select.c index 37103dd..b95af5c 100644 --- a/asm/mie/select.c +++ b/asm/mie/select.c @@ -98,11 +98,11 @@ static enum mie_status get_selector( struct mie_type *ptr_type = mie_ctx_get_type(ctx, MIE_TYPE_PTR); struct mie_select_graph *graph = mie_select_builder_get_graph(builder); - b_queue *nodes = &graph->g_nodes; - b_queue_entry *entry = b_queue_first(nodes); + fx_queue *nodes = &graph->g_nodes; + fx_queue_entry *entry = fx_queue_first(nodes); while (entry) { struct mie_select_node *node - = b_unbox(struct mie_select_node, entry, n_entry); + = fx_unbox(struct mie_select_node, entry, n_entry); if (node->n_target != target) { goto skip; @@ -124,7 +124,7 @@ static enum mie_status get_selector( mie_select_node_get_value(node, ptr_type, 0, out); return MIE_SUCCESS; skip: - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } struct mie_select_node *sel_node; @@ -311,7 +311,7 @@ static enum mie_status lower_msg( struct mie_ctx *ctx = mie_select_builder_get_ctx(builder); struct mie_select_value **param_chains = calloc( - b_max(size_t, 2, msg->msg_nr_args + 1), + fx_max(size_t, 2, msg->msg_nr_args + 1), sizeof(struct mie_select_value *)); size_t nr_param_chains = 0; struct mie_select_value *chain, *recipient, nr_args; @@ -354,7 +354,7 @@ static enum mie_status lower_msg( } struct mie_select_value *stack_chains = calloc( - b_max(size_t, 1, msg->msg_nr_args), + fx_max(size_t, 1, msg->msg_nr_args), sizeof(struct mie_select_value)); size_t nr_stack_chains = 0; nr_param_chains = 0; diff --git a/asm/parse/block.c b/asm/parse/block.c index 8d9bb54..fe0e190 100644 --- a/asm/parse/block.c +++ b/asm/parse/block.c @@ -1,7 +1,7 @@ #include "parse.h" -#include -#include +#include +#include #include #include #include @@ -48,14 +48,14 @@ enum arg_type { }; struct label { - b_queue_entry l_entry; + fx_queue_entry l_entry; struct ivy_asm_token *l_name; unsigned long long l_offset; }; struct arg { enum arg_type arg_type; - b_queue_entry arg_entry; + fx_queue_entry arg_entry; union { struct ivy_asm_token *arg_const; @@ -86,11 +86,11 @@ struct block_parser_state { unsigned int s_prev_token; enum instr_component s_prev_component; - b_queue s_labels; + fx_queue s_labels; - b_queue s_mnemonic; + fx_queue s_mnemonic; - b_queue s_args; + fx_queue s_args; struct arg *s_current_arg; }; @@ -163,7 +163,7 @@ static enum index_base get_index_base(struct ivy_asm_token *tok) } const char *s = tok->t_str; - uint64_t hash = b_hash_cstr(s); + uint64_t hash = fx_hash_cstr(s); switch (hash) { case HASH_SELF: @@ -195,28 +195,28 @@ static enum index_base get_index_base(struct ivy_asm_token *tok) } } -static enum ivy_instr_id get_instruction_id(b_queue *mnemonic_tokens) +static enum ivy_instr_id get_instruction_id(fx_queue *mnemonic_tokens) { char mnemonic[64]; mnemonic[0] = 0; - b_stringstream *s - = b_stringstream_create_with_buffer(mnemonic, sizeof mnemonic); + fx_stringstream *s + = fx_stringstream_create_with_buffer(mnemonic, sizeof mnemonic); unsigned int i = 0; - b_queue_entry *entry = b_queue_first(mnemonic_tokens); + fx_queue_entry *entry = fx_queue_first(mnemonic_tokens); while (entry) { struct ivy_asm_token *tok - = b_unbox(struct ivy_asm_token, entry, t_entry); - b_queue_entry *next = b_queue_next(entry); - b_queue_delete(mnemonic_tokens, entry); + = fx_unbox(struct ivy_asm_token, entry, t_entry); + fx_queue_entry *next = fx_queue_next(entry); + fx_queue_delete(mnemonic_tokens, entry); if (i > 0) { - b_stream_write_char(s, '.'); + fx_stream_write_char(s, '.'); } - b_stream_write_string(s, tok->t_str, NULL); + fx_stream_write_string(s, tok->t_str, NULL); i++; ivy_asm_token_destroy(tok); @@ -224,7 +224,7 @@ static enum ivy_instr_id get_instruction_id(b_queue *mnemonic_tokens) entry = next; } - uint64_t hash = b_hash_cstr(mnemonic); + uint64_t hash = fx_hash_cstr(mnemonic); for (i = 0; i < nr_mnemonics; i++) { if (hash == mnemonics[i].m_hash && !strcmp(mnemonic, mnemonics[i].m_name)) { @@ -251,9 +251,9 @@ static enum ivy_status write_instruction( enum ivy_instr_operand_type operand_types[MAX_ARGS] = {0}; - b_queue_entry *entry = b_queue_first(&state->s_args); + fx_queue_entry *entry = fx_queue_first(&state->s_args); while (entry) { - struct arg *arg = b_unbox(struct arg, entry, arg_entry); + struct arg *arg = fx_unbox(struct arg, entry, arg_entry); if (i >= MAX_ARGS) { return IVY_ERR_BAD_SYNTAX; @@ -310,7 +310,7 @@ static enum ivy_status write_instruction( return IVY_ERR_BAD_SYNTAX; } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } const struct ivy_instr_definition *instr_info @@ -323,11 +323,11 @@ static enum ivy_status write_instruction( instr.i_op = instr_info; i = 0; - entry = b_queue_first(&state->s_args); + entry = fx_queue_first(&state->s_args); while (entry) { - struct arg *arg = b_unbox(struct arg, entry, arg_entry); - b_queue_entry *next = b_queue_next(entry); - b_queue_delete(&state->s_args, entry); + struct arg *arg = fx_unbox(struct arg, entry, arg_entry); + fx_queue_entry *next = fx_queue_next(entry); + fx_queue_delete(&state->s_args, entry); switch (arg->arg_type) { case ARG_REG: @@ -381,7 +381,7 @@ static enum ivy_status push_const_arg( arg->arg_type = ARG_CONST; arg->arg_const = tok; - b_queue_push_back(&state->s_args, &arg->arg_entry); + fx_queue_push_back(&state->s_args, &arg->arg_entry); return IVY_OK; } @@ -407,7 +407,7 @@ static enum ivy_status push_label_arg( arg->arg_type = ARG_LABEL; arg->arg_label = tok; - b_queue_push_back(&state->s_args, &arg->arg_entry); + fx_queue_push_back(&state->s_args, &arg->arg_entry); return IVY_OK; } @@ -426,7 +426,7 @@ static enum ivy_status push_reg_arg( arg->arg_reg.reg_token = tok; arg->arg_reg.reg_index = reg_index; - b_queue_push_back(&state->s_args, &arg->arg_entry); + fx_queue_push_back(&state->s_args, &arg->arg_entry); return IVY_OK; } @@ -482,7 +482,7 @@ static enum ivy_status parse_ident( switch (state->s_prev_component) { case INSTR_NONE: case INSTR_OPCODE_DOT: - b_queue_push_back(&state->s_mnemonic, &tok->t_entry); + fx_queue_push_back(&state->s_mnemonic, &tok->t_entry); state->s_prev_component = INSTR_OPCODE; return IVY_OK; case INSTR_OPCODE: @@ -619,7 +619,7 @@ static enum ivy_status parse_right_bracket( return IVY_ERR_BAD_SYNTAX; } - b_queue_push_back(&state->s_args, &state->s_current_arg->arg_entry); + fx_queue_push_back(&state->s_args, &state->s_current_arg->arg_entry); state->s_current_arg = NULL; state->s_prev_component = INSTR_OPERAND; diff --git a/asm/parse/class.c b/asm/parse/class.c index d0b09c4..e0a28de 100644 --- a/asm/parse/class.c +++ b/asm/parse/class.c @@ -1,6 +1,6 @@ #include "parse.h" -#include +#include #include enum item_type { @@ -23,7 +23,7 @@ struct class_parser_state { static enum ivy_status push_attrib(struct class_parser_state *state) { - uint64_t hash = b_hash_cstr(state->s_attrib_name->t_str); + uint64_t hash = fx_hash_cstr(state->s_attrib_name->t_str); const char *s = state->s_attrib_name->t_str; unsigned long long v = state->s_attrib_value->t_int.uv; diff --git a/asm/parse/ident.c b/asm/parse/ident.c index 4213f00..756041c 100644 --- a/asm/parse/ident.c +++ b/asm/parse/ident.c @@ -9,7 +9,7 @@ struct ident_parser_state { struct parser_state s_base; unsigned int s_prev_token; - b_queue s_parts; + fx_queue s_parts; }; static void init_state(struct ivy_asm_parser *ctx, struct parser_state *s) @@ -28,7 +28,7 @@ static enum ivy_status parse_ident( return IVY_ERR_BAD_SYNTAX; } - b_queue_push_back(&state->s_parts, &tok->t_entry); + fx_queue_push_back(&state->s_parts, &tok->t_entry); state->s_prev_token = IVY_ASM_TOK_IDENT; return IVY_OK; @@ -61,12 +61,12 @@ static enum ivy_status parse_right_paren( struct ivy_ident *ident = ivy_ident_create(); - b_queue_entry *entry = b_queue_first(&state->s_parts); + fx_queue_entry *entry = fx_queue_first(&state->s_parts); while (entry) { struct ivy_asm_token *tok - = b_unbox(struct ivy_asm_token, entry, t_entry); - b_queue_entry *next = b_queue_next(entry); - b_queue_delete(&state->s_parts, entry); + = fx_unbox(struct ivy_asm_token, entry, t_entry); + fx_queue_entry *next = fx_queue_next(entry); + fx_queue_delete(&state->s_parts, entry); ivy_ident_add_part(ident, tok->t_str); ivy_asm_token_destroy(tok); diff --git a/asm/parse/parse.c b/asm/parse/parse.c index 9700467..b0ec04a 100644 --- a/asm/parse/parse.c +++ b/asm/parse/parse.c @@ -155,19 +155,19 @@ struct parser_state *asm_parser_push_state( type_info->n_init_state(parser, state); } - b_queue_push_back(&parser->p_state, &state->s_entry); + fx_queue_push_back(&parser->p_state, &state->s_entry); return state; } void asm_parser_pop_state(struct ivy_asm_parser *parser, void *ret) { - b_queue_entry *last = b_queue_pop_back(&parser->p_state); + fx_queue_entry *last = fx_queue_pop_back(&parser->p_state); if (!last) { return; } - struct parser_state *state = b_unbox(struct parser_state, last, s_entry); + struct parser_state *state = fx_unbox(struct parser_state, last, s_entry); if (state->s_type->n_finish_state) { state->s_type->n_finish_state(parser, state); @@ -183,11 +183,11 @@ void asm_parser_pop_state(struct ivy_asm_parser *parser, void *ret) struct parser_state *asm_parser_get_state(struct ivy_asm_parser *parser) { - b_queue_entry *last = b_queue_last(&parser->p_state); + fx_queue_entry *last = fx_queue_last(&parser->p_state); if (!last) { return NULL; } - return b_unbox(struct parser_state, last, s_entry); + return fx_unbox(struct parser_state, last, s_entry); } diff --git a/asm/parse/parse.h b/asm/parse/parse.h index 37bbe9d..4e86a7e 100644 --- a/asm/parse/parse.h +++ b/asm/parse/parse.h @@ -1,7 +1,7 @@ #ifndef _PARSE_PARSE_H_ #define _PARSE_PARSE_H_ -#include +#include #include #include @@ -60,7 +60,7 @@ struct parser_state_type { }; struct parser_state { - b_queue_entry s_entry; + fx_queue_entry s_entry; const struct parser_state_type* s_type; ivy_assembler_attrib_table s_attrib; void* s_previous_value; @@ -68,7 +68,7 @@ struct parser_state { struct ivy_asm_parser { struct ivy_assembler* p_assembler; - b_queue p_state; + fx_queue p_state; }; extern struct parser_state* asm_parser_push_state(struct ivy_asm_parser* parser, enum parser_state_type_id type, const ivy_assembler_attrib_table attrib); diff --git a/asm/parse/unit.c b/asm/parse/unit.c index dd7e1c6..41fb1dd 100644 --- a/asm/parse/unit.c +++ b/asm/parse/unit.c @@ -1,6 +1,6 @@ #include "parse.h" -#include +#include #include struct unit_parser_state { @@ -16,7 +16,7 @@ struct unit_parser_state { static enum ivy_status push_attrib(struct unit_parser_state *state) { - uint64_t hash = b_hash_cstr(state->s_attrib_name->t_str); + uint64_t hash = fx_hash_cstr(state->s_attrib_name->t_str); const char *s = state->s_attrib_name->t_str; unsigned long long v = state->s_attrib_value->t_int.uv; diff --git a/asm/reader.c b/asm/reader.c index 6327c42..844a505 100644 --- a/asm/reader.c +++ b/asm/reader.c @@ -12,9 +12,9 @@ static enum ivy_status decode_header( const struct ivy_bin_header *hdr, struct ivy_asm_object_info *out) { - out->obj_magic = b_i32_btoh(hdr->h_magic); - out->obj_nr_sections = b_i16_btoh(hdr->h_table_len); - out->obj_table_offset = b_i64_btoh(hdr->h_table_offset); + out->obj_magic = fx_i32_btoh(hdr->h_magic); + out->obj_nr_sections = fx_i16_btoh(hdr->h_table_len); + out->obj_table_offset = fx_i64_btoh(hdr->h_table_offset); return IVY_OK; } @@ -22,9 +22,9 @@ static enum ivy_status decode_header( static enum ivy_status decode_table_entry( const struct ivy_bin_table_entry *entry, struct ivy_asm_section_info *out) { - out->s_type = b_i32_btoh(entry->e_type); - out->s_offset = b_i64_btoh(entry->e_offset); - out->s_length = b_i32_btoh(entry->e_size); + out->s_type = fx_i32_btoh(entry->e_type); + out->s_offset = fx_i64_btoh(entry->e_offset); + out->s_length = fx_i32_btoh(entry->e_size); return IVY_OK; } @@ -258,7 +258,7 @@ static enum ivy_status read_string_xdata( return IVY_ERR_BAD_FORMAT; } - size_t str_len = b_i32_btoh(str.s_len); + size_t str_len = fx_i32_btoh(str.s_len); if (str_len == 0) { *out = NULL; return IVY_OK; @@ -306,7 +306,7 @@ enum ivy_status ivy_asm_constpool_reader_read_value( return IVY_ERR_BAD_FORMAT; } - unsigned long type = b_i32_btoh(entry.e_type); + unsigned long type = fx_i32_btoh(entry.e_type); struct ivy_asm_constpool_value *value = malloc(sizeof *value); if (!value) { @@ -319,26 +319,26 @@ enum ivy_status ivy_asm_constpool_reader_read_value( switch (type) { case IVY_CONSTPOOL_TABLE_STRING: { value->v_type = IVY_ASM_CONSTPOOL_TYPE_STRING; - handle = b_i32_btoh(entry.e_ex_handle); + handle = fx_i32_btoh(entry.e_ex_handle); status = read_string_xdata(reader, handle, &value->v_str); break; } case IVY_CONSTPOOL_TABLE_INT: value->v_type = IVY_ASM_CONSTPOOL_TYPE_INT; - value->v_int = b_i32_btoh(entry.e_int); + value->v_int = fx_i32_btoh(entry.e_int); break; case IVY_CONSTPOOL_TABLE_UINT: value->v_type = IVY_ASM_CONSTPOOL_TYPE_UINT; - value->v_uint = b_i32_btoh(entry.e_int); + value->v_uint = fx_i32_btoh(entry.e_int); break; case IVY_CONSTPOOL_TABLE_ATOM: value->v_type = IVY_ASM_CONSTPOOL_TYPE_ATOM; - handle = b_i32_btoh(entry.e_ex_handle); + handle = fx_i32_btoh(entry.e_ex_handle); status = read_string_xdata(reader, handle, &value->v_str); break; case IVY_CONSTPOOL_TABLE_SELECTOR: { value->v_type = IVY_ASM_CONSTPOOL_TYPE_SELECTOR; - handle = b_i32_btoh(entry.e_ex_handle); + handle = fx_i32_btoh(entry.e_ex_handle); struct ivy_bin_selector sel_entry; status = ivy_asm_section_reader_read( @@ -365,7 +365,7 @@ enum ivy_status ivy_asm_constpool_reader_read_value( ivy_selector_set_recipient(sel, IVY_SEL_CLASS); } - size_t name_key = b_i32_btoh(sel_entry.sel_name); + size_t name_key = fx_i32_btoh(sel_entry.sel_name); status = read_string_xdata(reader, name_key, &sel->sel_name); if (status != IVY_OK) { ivy_selector_destroy(sel); @@ -375,7 +375,7 @@ enum ivy_status ivy_asm_constpool_reader_read_value( handle += sizeof sel_entry; size_t nr_args = sel_entry.sel_nr_args; for (size_t i = 0; i < nr_args; i++) { - b_i32 arg; + fx_i32 arg; status = ivy_asm_section_reader_read( reader->r_xdat, handle, sizeof arg, &arg, &r); @@ -388,7 +388,7 @@ enum ivy_status ivy_asm_constpool_reader_read_value( break; } - size_t arg_key = b_i32_btoh(arg); + size_t arg_key = fx_i32_btoh(arg); char *arg_name = NULL; status = read_string_xdata(reader, arg_key, &arg_name); if (status != IVY_OK) { @@ -411,7 +411,7 @@ enum ivy_status ivy_asm_constpool_reader_read_value( } case IVY_CONSTPOOL_TABLE_IDENT: { value->v_type = IVY_ASM_CONSTPOOL_TYPE_IDENT; - handle = b_i32_btoh(entry.e_ex_handle); + handle = fx_i32_btoh(entry.e_ex_handle); struct ivy_bin_ident id_entry; status = ivy_asm_section_reader_read( @@ -436,7 +436,7 @@ enum ivy_status ivy_asm_constpool_reader_read_value( handle += sizeof id_entry; size_t nr_parts = id_entry.id_nr_parts; for (size_t i = 0; i < nr_parts; i++) { - b_i32 part; + fx_i32 part; status = ivy_asm_section_reader_read( reader->r_xdat, handle, sizeof part, &part, &r); @@ -449,7 +449,7 @@ enum ivy_status ivy_asm_constpool_reader_read_value( break; } - size_t part_key = b_i32_btoh(part); + size_t part_key = fx_i32_btoh(part); char *part_name = NULL; status = read_string_xdata(reader, part_key, &part_name); if (status != IVY_OK) { @@ -517,7 +517,7 @@ enum ivy_status ivy_asm_constpool_value_destroy(struct ivy_asm_constpool_value * bool ivy_asm_section_type_to_string(uint32_t in, char out[5]) { - b_i32 v = b_i32_htob(in); + fx_i32 v = fx_i32_htob(in); for (size_t i = 0; i < sizeof in; i++) { char c = v.i_bytes[i]; diff --git a/cmake/FindBluelib.cmake b/cmake/FindBluelib.cmake deleted file mode 100644 index 648ceaa..0000000 --- a/cmake/FindBluelib.cmake +++ /dev/null @@ -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() diff --git a/cmake/FindFX.cmake b/cmake/FindFX.cmake new file mode 100644 index 0000000..735ae13 --- /dev/null +++ b/cmake/FindFX.cmake @@ -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() diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 946f1b6..6c63448 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -12,4 +12,4 @@ endif () 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_link_libraries(ivy-common Bluelib::Core Bluelib::Ds) +target_link_libraries(ivy-common FX::Core FX::Ds) diff --git a/common/file.c b/common/file.c index 5c1528b..c55053f 100644 --- a/common/file.c +++ b/common/file.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include #include #include @@ -18,17 +18,17 @@ static enum ivy_status get_row( size_t *nr_read) { 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) { 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); - size_t line_len = b_string_get_size(line, B_STRLEN_NORMAL); - size_t copy_len = b_min(ulong, count, line_len); + const char *line_str = fx_string_ptr(line); + size_t line_len = fx_string_get_size(line, FX_STRLEN_NORMAL); + size_t copy_len = fx_min(ulong, count, line_len); memcpy(buf, line_str, copy_len); 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; } - b_string *line_str = b_string_create_from_cstr(buf); - b_array_append(f->f_lines, B_OBJECT(line_str)); - b_string_unref(line_str); + fx_string *line_str = fx_string_create_from_cstr(buf); + fx_array_append(f->f_lines, FX_OBJECT(line_str)); + fx_string_unref(line_str); *nr_read = strlen(buf); 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_readline = readline; file->f_fp = fp; - file->f_path = b_strdup(path); - file->f_lines = b_array_create(); + file->f_path = fx_strdup(path); + file->f_lines = fx_array_create(); *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) { - b_array_unref(file->f_lines); + fx_array_unref(file->f_lines); free(file->f_path); fclose(file->f_fp); free(file); diff --git a/common/ident.c b/common/ident.c index a98776e..0c4fb30 100644 --- a/common/ident.c +++ b/common/ident.c @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include #include #include #include @@ -20,12 +20,12 @@ struct ivy_ident *ivy_ident_create(void) 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) { struct ivy_ident_part *part - = b_unbox(struct ivy_ident_part, entry, p_entry); - b_queue_entry *next = b_queue_next(entry); - b_queue_delete(&ident->id_parts, entry); + = fx_unbox(struct ivy_ident_part, entry, p_entry); + fx_queue_entry *next = fx_queue_next(entry); + fx_queue_delete(&ident->id_parts, entry); free(part->p_str); free(part); @@ -45,25 +45,25 @@ void ivy_ident_add_part(struct ivy_ident *ident, const char *s) 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) { - b_stringstream *strv = b_stringstream_create_with_buffer(out, max); + fx_stringstream *strv = fx_stringstream_create_with_buffer(out, max); 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) { if (i > 0) { - b_stream_write_char(strv, '.'); + fx_stream_write_char(strv, '.'); } struct ivy_ident_part *part - = b_unbox(struct ivy_ident_part, entry, p_entry); - b_stream_write_string(strv, part->p_str, NULL); + = fx_unbox(struct ivy_ident_part, entry, p_entry); + fx_stream_write_string(strv, part->p_str, NULL); i++; } diff --git a/common/include/ivy/file.h b/common/include/ivy/file.h index 237b32f..900b87d 100644 --- a/common/include/ivy/file.h +++ b/common/include/ivy/file.h @@ -1,14 +1,14 @@ #ifndef IVY_COMMON_FILE_H_ #define IVY_COMMON_FILE_H_ -#include +#include #include #include #include struct ivy_file { struct ivy_line_source f_base; - b_array *f_lines; + fx_array *f_lines; char *f_path; FILE *f_fp; }; diff --git a/common/include/ivy/ident.h b/common/include/ivy/ident.h index c06190c..ed24fed 100644 --- a/common/include/ivy/ident.h +++ b/common/include/ivy/ident.h @@ -1,17 +1,17 @@ #ifndef IVY_IDENT_H_ #define IVY_IDENT_H_ -#include +#include #include #include struct ivy_ident_part { char *p_str; - b_queue_entry p_entry; + fx_queue_entry p_entry; }; struct ivy_ident { - b_queue id_parts; + fx_queue id_parts; }; IVY_API struct ivy_ident *ivy_ident_create(void); diff --git a/common/include/ivy/selector.h b/common/include/ivy/selector.h index f3fecae..080afac 100644 --- a/common/include/ivy/selector.h +++ b/common/include/ivy/selector.h @@ -1,7 +1,7 @@ #ifndef IVY_SELECTOR_H_ #define IVY_SELECTOR_H_ -#include +#include #include enum ivy_selector_recipient { @@ -13,13 +13,13 @@ enum ivy_selector_recipient { struct ivy_selector { enum ivy_selector_recipient sel_recipient; char *sel_name; - b_queue sel_args; + fx_queue sel_args; }; struct ivy_selector_arg { char *arg_label; 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); diff --git a/common/include/ivy/status.h b/common/include/ivy/status.h index acc4c9a..1f973ab 100644 --- a/common/include/ivy/status.h +++ b/common/include/ivy/status.h @@ -5,9 +5,9 @@ #define IVY_ERROR_VENDOR (ivy_error_vendor()) -enum b_status; +enum fx_status; -struct b_error_vendor; +struct fx_error_vendor; enum ivy_status { 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 struct b_error_vendor *ivy_error_vendor(void); -IVY_API enum ivy_status ivy_status_from_b_status(enum b_status status); +IVY_API const struct fx_error_vendor *ivy_error_vendor(void); +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); #endif diff --git a/common/selector.c b/common/selector.c index 215a415..7fbc26d 100644 --- a/common/selector.c +++ b/common/selector.c @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include #include #include #include @@ -25,12 +25,12 @@ void ivy_selector_destroy(struct ivy_selector *sel) 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) { struct ivy_selector_arg *arg - = b_unbox(struct ivy_selector_arg, entry, arg_entry); - b_queue_entry *next = b_queue_next(entry); - b_queue_delete(&sel->sel_args, entry); + = fx_unbox(struct ivy_selector_arg, entry, arg_entry); + fx_queue_entry *next = fx_queue_next(entry); + fx_queue_delete(&sel->sel_args, entry); if (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) { - sel->sel_name = b_strdup(name); + sel->sel_name = fx_strdup(name); 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); if (label) { - arg->arg_label = b_strdup(label); + arg->arg_label = fx_strdup(label); if (!arg->arg_label) { free(arg); @@ -80,7 +80,7 @@ enum ivy_status ivy_selector_add_arg( } if (name) { - arg->arg_name = b_strdup(name); + arg->arg_name = fx_strdup(name); if (!arg->arg_name) { 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; } 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) { case IVY_SEL_OBJECT: - b_stream_write_char(str, '-'); + fx_stream_write_char(str, '-'); break; case IVY_SEL_CLASS: - b_stream_write_char(str, '+'); + fx_stream_write_char(str, '+'); break; default: break; } 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)) { - b_stream_write_char(str, '('); + if (sel->sel_name && !fx_queue_empty(&sel->sel_args)) { + 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) { struct ivy_selector_arg *arg - = b_unbox(struct ivy_selector_arg, entry, arg_entry); - b_stream_write_fmt( + = fx_unbox(struct ivy_selector_arg, entry, arg_entry); + fx_stream_write_fmt( 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)) { - b_stream_write_char(str, ')'); + if (sel->sel_name && !fx_queue_empty(&sel->sel_args)) { + fx_stream_write_char(str, ')'); } - size_t len = b_stringstream_get_length(str); - b_stringstream_unref(str); + size_t len = fx_stringstream_get_length(str); + fx_stringstream_unref(str); return len; } diff --git a/common/status.c b/common/status.c index d7e0386..22e0a74 100644 --- a/common/status.c +++ b/common/status.c @@ -1,34 +1,34 @@ -#include +#include #include #include -static const b_error_definition error_defs[] = { - B_ERROR_DEFINITION(IVY_OK, "OK", "Success"), - B_ERROR_DEFINITION(IVY_ERR_EOF, "EOF", "Unexpected end of file"), - B_ERROR_DEFINITION(IVY_ERR_IO_FAILURE, "IO_FAILURE", "I/O failure"), - B_ERROR_DEFINITION(IVY_ERR_BAD_SYNTAX, "BAD_SYNTAX", "Invalid syntax"), - B_ERROR_DEFINITION(IVY_ERR_NO_MEMORY, "NO_MEMORY", "Out of memory"), - B_ERROR_DEFINITION( +static const fx_error_definition error_defs[] = { + FX_ERROR_DEFINITION(IVY_OK, "OK", "Success"), + FX_ERROR_DEFINITION(IVY_ERR_EOF, "EOF", "Unexpected end of file"), + FX_ERROR_DEFINITION(IVY_ERR_IO_FAILURE, "IO_FAILURE", "I/O failure"), + FX_ERROR_DEFINITION(IVY_ERR_BAD_SYNTAX, "BAD_SYNTAX", "Invalid syntax"), + FX_ERROR_DEFINITION(IVY_ERR_NO_MEMORY, "NO_MEMORY", "Out of memory"), + FX_ERROR_DEFINITION( IVY_ERR_NOT_SUPPORTED, "NOT_SUPPORTED", "Operation not supported"), - B_ERROR_DEFINITION( + FX_ERROR_DEFINITION( IVY_ERR_INTERNAL_FAILURE, "INTERNAL_FAILURE", "Internal failure"), - B_ERROR_DEFINITION(IVY_ERR_BAD_STATE, "BAD_STATE", "Bad state"), - B_ERROR_DEFINITION( + FX_ERROR_DEFINITION(IVY_ERR_BAD_STATE, "BAD_STATE", "Bad state"), + FX_ERROR_DEFINITION( IVY_ERR_INVALID_VALUE, "INVALID_VALUE", "Invalid value"), - B_ERROR_DEFINITION(IVY_ERR_NO_ENTRY, "NO_ENTRY", "Name does not exist"), - B_ERROR_DEFINITION( + FX_ERROR_DEFINITION(IVY_ERR_NO_ENTRY, "NO_ENTRY", "Name does not exist"), + FX_ERROR_DEFINITION( IVY_ERR_NAME_EXISTS, "NAME_EXISTS", "Name already exists"), - B_ERROR_DEFINITION(IVY_ERR_BAD_FORMAT, "BAD_FORMAT", "Bad format"), - B_ERROR_DEFINITION( + FX_ERROR_DEFINITION(IVY_ERR_BAD_FORMAT, "BAD_FORMAT", "Bad format"), + FX_ERROR_DEFINITION( IVY_ERR_PARSE_FAILURE, "PARSE_FAILURE", "Parse failure"), - B_ERROR_DEFINITION( + FX_ERROR_DEFINITION( IVY_ERR_CODEGEN_FAILURE, "CODEGEN_FAILURE", "Code generation failure"), }; -static const b_error_vendor error_vendor = { +static const fx_error_vendor error_vendor = { .v_name = "Ivy", .v_error_definitions = 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; } -const struct b_error_vendor *ivy_error_vendor(void) +const struct fx_error_vendor *ivy_error_vendor(void) { return &error_vendor; } @@ -48,12 +48,12 @@ const struct b_error_vendor *ivy_error_vendor(void) case (from): \ 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) { - ENUM_CONVERT(B_SUCCESS, IVY_OK); - ENUM_CONVERT(B_ERR_NAME_EXISTS, IVY_ERR_NAME_EXISTS); - ENUM_CONVERT(B_ERR_NO_MEMORY, IVY_ERR_NO_MEMORY); + ENUM_CONVERT(FX_SUCCESS, IVY_OK); + ENUM_CONVERT(FX_ERR_NAME_EXISTS, IVY_ERR_NAME_EXISTS); + ENUM_CONVERT(FX_ERR_NO_MEMORY, IVY_ERR_NO_MEMORY); default: return IVY_ERR_INTERNAL_FAILURE; } diff --git a/diag/CMakeLists.txt b/diag/CMakeLists.txt index f5a9a32..a12173a 100644 --- a/diag/CMakeLists.txt +++ b/diag/CMakeLists.txt @@ -12,4 +12,4 @@ endif () 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_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) diff --git a/diag/ctx.c b/diag/ctx.c index 44ad399..ca18cf2 100644 --- a/diag/ctx.c +++ b/diag/ctx.c @@ -52,12 +52,12 @@ void ivy_diag_ctx_write( struct ivy_diag_ctx *ctx, enum ivy_diag_format format, 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) { 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); - 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_parent = ctx; - b_queue_push_back(&ctx->ctx_diags, &out->diag_entry); + fx_queue_push_back(&ctx->ctx_diags, &out->diag_entry); return out; } diff --git a/diag/ctx.h b/diag/ctx.h index 499ca39..b0738ad 100644 --- a/diag/ctx.h +++ b/diag/ctx.h @@ -1,7 +1,7 @@ #ifndef _DIAG_CTX_H_ #define _DIAG_CTX_H_ -#include +#include #include struct ivy_line_source; @@ -15,7 +15,7 @@ struct ivy_diag_ctx { const struct ivy_diag_msg *ctx_msg; size_t ctx_nr_msg; - b_queue ctx_diags; + fx_queue ctx_diags; }; extern const struct ivy_diag_class *diag_ctx_get_class( diff --git a/diag/diag.c b/diag/diag.c index eee938b..37c9e90 100644 --- a/diag/diag.c +++ b/diag/diag.c @@ -3,7 +3,7 @@ #include "ctx.h" #include -#include +#include #include #include #include @@ -18,7 +18,7 @@ struct diag_c_msg *diag_msg_create(const struct ivy_diag_msg *content) memset(out, 0x0, sizeof *out); 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; } @@ -77,7 +77,7 @@ void ivy_diag_push_msg(struct ivy_diag *diag, unsigned long msg, ...) 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( @@ -92,5 +92,5 @@ void ivy_diag_push_snippet( 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); } diff --git a/diag/diag.h b/diag/diag.h index 02d87b9..859de7f 100644 --- a/diag/diag.h +++ b/diag/diag.h @@ -1,7 +1,7 @@ #ifndef _DIAG_DIAG_H_ #define _DIAG_DIAG_H_ -#include +#include #include struct ivy_diag_msg; @@ -14,7 +14,7 @@ enum diag_component_type { struct diag_component { enum diag_component_type c_type; - b_queue_entry c_entry; + fx_queue_entry c_entry; }; struct diag_c_msg { @@ -38,8 +38,8 @@ struct ivy_diag { unsigned long diag_class; unsigned long diag_row, diag_col; - b_queue_entry diag_entry; - b_queue diag_components; + fx_queue_entry diag_entry; + fx_queue diag_components; }; extern struct diag_c_msg *diag_msg_create(const struct ivy_diag_msg *content); diff --git a/diag/include/ivy/diag.h b/diag/include/ivy/diag.h index 5429c59..b38d6dd 100644 --- a/diag/include/ivy/diag.h +++ b/diag/include/ivy/diag.h @@ -44,7 +44,7 @@ struct ivy_line_source; struct ivy_diag_ctx; struct ivy_diag; -struct b_tty; +struct fx_tty; enum ivy_diag_stream_flags { IVY_DIAG_STREAM_F_NONE = 0x00u, @@ -64,7 +64,7 @@ struct ivy_diag_stream { int s_esc; union { - struct b_tty *s_tty; + struct fx_tty *s_tty; 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_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 void ivy_diag_ctx_destroy(struct ivy_diag_ctx *ctx); diff --git a/diag/stream.c b/diag/stream.c index 186aa33..069e928 100644 --- a/diag/stream.c +++ b/diag/stream.c @@ -1,6 +1,6 @@ #include "stream.h" -#include +#include #include 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; } -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); @@ -41,7 +41,7 @@ enum ivy_status diag_stream_get_dimensions( break; case IVY_DIAG_STREAM_TTY: { 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) { *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; break; case IVY_DIAG_STREAM_TTY: - b_tty_putc(stream->s_tty, 0, c); + fx_tty_putc(stream->s_tty, 0, c); status = IVY_OK; break; default: diff --git a/diag/write/pretty.c b/diag/write/pretty.c index cce1fe7..b0bad39 100644 --- a/diag/write/pretty.c +++ b/diag/write/pretty.c @@ -4,9 +4,9 @@ #include "../write.h" #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -25,7 +25,7 @@ struct snippet_print_ctx { size_t ctx_line_buf_ptr; bool ctx_has_underline; - b_stringstream *ctx_underline; + fx_stringstream *ctx_underline; struct diag_c_snippet *ctx_snippet; @@ -67,23 +67,23 @@ struct snippet_print_ctx { #define STREAM_COLOUR_ERROR_B(stream, str) \ 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) \ 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) \ 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) \ 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) \ 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( @@ -143,12 +143,12 @@ static void print_msg( struct ivy_diag_stream *stream) { if (stream->s_type == IVY_DIAG_STREAM_TTY) { - b_paragraph_format format = { + fx_paragraph_format format = { .p_left_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 { diag_stream_puts(stream, " "); diag_stream_puts(stream, msg->msg_content); @@ -218,7 +218,7 @@ static bool amendment_contains_cell( } 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) { 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_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); 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) { if (!ctx->ctx_hl) { - b_stream_write_char(ctx->ctx_underline, ' '); + fx_stream_write_char(ctx->ctx_underline, ' '); return; } @@ -388,10 +388,10 @@ static void update_underline(struct snippet_print_ctx *ctx) case IVY_DIAG_HIGHLIGHT_ERROR: case IVY_DIAG_HIGHLIGHT_WARNING: case IVY_DIAG_HIGHLIGHT_HINT: - b_stream_write_char(ctx->ctx_underline, '^'); + fx_stream_write_char(ctx->ctx_underline, '^'); break; default: - b_stream_write_char(ctx->ctx_underline, ' '); + fx_stream_write_char(ctx->ctx_underline, ' '); break; } } @@ -481,15 +481,15 @@ static enum ivy_status write( print_header(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) { 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'); print_component(ctx, diag, c, stream); - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } return IVY_OK; diff --git a/frontend/CMakeLists.txt b/frontend/CMakeLists.txt index b9ba531..fffeda6 100644 --- a/frontend/CMakeLists.txt +++ b/frontend/CMakeLists.txt @@ -20,8 +20,8 @@ target_link_libraries( ivy-asm ivy-lang ivy-common - Bluelib::Core - Bluelib::Ds - Bluelib::Cmd) + FX::Core + FX::Ds + FX::Cmd) target_compile_definitions(ivy PRIVATE IVY_STATIC=${IVY_STATIC}) diff --git a/frontend/cmd/assemble.c b/frontend/cmd/assemble.c index 3b6112a..272c35a 100644 --- a/frontend/cmd/assemble.c +++ b/frontend/cmd/assemble.c @@ -1,9 +1,9 @@ #include "../debug.h" #include "cmd.h" -#include -#include -#include +#include +#include +#include #include #include #include @@ -24,15 +24,15 @@ static int assemble_file(const char *in_path, const char *out_path) struct ivy_file *src = NULL; status = ivy_file_open(in_path, &src); if (!src) { - b_err("cannot open source file '%s'", in_path); - b_i("reason: %s", ivy_status_to_string(status)); + fx_err("cannot open source file '%s'", in_path); + fx_i("reason: %s", ivy_status_to_string(status)); return -1; } FILE *out = fopen(out_path, "w+b"); if (!out) { - b_err("cannot open output file '%s'", out_path); - b_i("reason: %s", strerror(errno)); + fx_err("cannot open output file '%s'", out_path); + fx_i("reason: %s", strerror(errno)); return -1; } @@ -40,8 +40,8 @@ static int assemble_file(const char *in_path, const char *out_path) status = ivy_assembler_create(out, &as); if (status != IVY_OK) { - b_err("failed to initialise Ivy assembler"); - b_i("reason: %s", ivy_status_to_string(status)); + fx_err("failed to initialise Ivy assembler"); + fx_i("reason: %s", ivy_status_to_string(status)); ivy_file_close(src); fclose(out); @@ -51,8 +51,8 @@ static int assemble_file(const char *in_path, const char *out_path) struct ivy_asm_lexer *lex; status = ivy_asm_lexer_create(&lex); if (status != IVY_OK) { - b_err("failed to initialise Ivy assembly lexer"); - b_i("reason: %s", ivy_status_to_string(status)); + fx_err("failed to initialise Ivy assembly lexer"); + fx_i("reason: %s", ivy_status_to_string(status)); ivy_file_close(src); fclose(out); @@ -63,8 +63,8 @@ static int assemble_file(const char *in_path, const char *out_path) struct ivy_asm_parser *parser; status = ivy_asm_parser_create(&parser); if (status != IVY_OK) { - b_err("failed to initialise Ivy assembly parser"); - b_i("reason: %s", ivy_status_to_string(status)); + fx_err("failed to initialise Ivy assembly parser"); + fx_i("reason: %s", ivy_status_to_string(status)); ivy_asm_lexer_destroy(lex); ivy_file_close(src); @@ -85,8 +85,8 @@ static int assemble_file(const char *in_path, const char *out_path) } if (status != IVY_OK) { - b_err("failed to parse '%s'", in_path); - b_i("reason: lex error (%s)", + fx_err("failed to parse '%s'", in_path); + fx_i("reason: lex error (%s)", ivy_status_to_string(ivy_asm_lexer_get_status(lex))); 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); if (status != IVY_OK) { - b_err("failed to parse '%s'", in_path); - b_i("reason: parse error (%s)", + fx_err("failed to parse '%s'", in_path); + fx_i("reason: parse error (%s)", ivy_status_to_string(status)); break; } @@ -112,31 +112,31 @@ static int assemble_file(const char *in_path, const char *out_path) 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++) { if (src_path[i] == '/' || src_path[i] == '\\') { - b_string_clear(name); + fx_string_clear(name); continue; } 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) { - b_string_unref(name); + if (fx_string_get_size(name, FX_STRLEN_NORMAL) == 0) { + fx_string_unref(name); name = NULL; } 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++) { if (src_filename[i] == '.') { @@ -144,53 +144,53 @@ static b_string *generate_object_filename(const char *src_filename) } 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) { - b_string_append_cstr(name, "out"); + if (fx_string_get_size(name, FX_STRLEN_NORMAL) == 0) { + fx_string_append_cstr(name, "out"); } - b_string_append_cstr(name, ".io"); + fx_string_append_cstr(name, ".io"); 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 *out_path = NULL; - b_string *in_name = NULL; - b_string *out_name = NULL; + fx_string *in_name = NULL; + fx_string *out_name = NULL; - b_arglist_get_string( - args, B_COMMAND_INVALID_ID, ARG_SOURCE_FILE, 0, &in_path); + fx_arglist_get_string( + args, FX_COMMAND_INVALID_ID, ARG_SOURCE_FILE, 0, &in_path); if (!in_path) { - b_err("no source file specified."); + fx_err("no source file specified."); return -1; } in_name = get_source_filename(in_path); if (!in_path) { - b_err("source filepath is not a file."); + fx_err("source filepath is not a file."); 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) { - out_name = generate_object_filename(b_string_ptr(in_name)); - out_path = b_string_ptr(out_name); + out_name = generate_object_filename(fx_string_ptr(in_name)); + out_path = fx_string_ptr(out_name); } int r = assemble_file(in_path, out_path); - b_string_unref(in_name); - b_string_unref(out_name); + fx_string_unref(in_name); + fx_string_unref(out_name); return r; #if 0 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) { 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); if (status != IVY_OK) { - b_err("failed to initialise assembler"); - b_i("reason: ", ivy_status_to_string(status)); + fx_err("failed to initialise assembler"); + fx_i("reason: ", ivy_status_to_string(status)); fclose(out); 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_NAME("assemble"); - B_COMMAND_SHORT_NAME('A'); - B_COMMAND_DESC( + FX_COMMAND_NAME("assemble"); + FX_COMMAND_SHORT_NAME('A'); + FX_COMMAND_DESC( "assemble one or more Ivy assembly source files into Ivy " "object files."); - B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT); - B_COMMAND_FUNCTION(assemble); + FX_COMMAND_FLAGS(FX_COMMAND_SHOW_HELP_BY_DEFAULT); + FX_COMMAND_FUNCTION(assemble); - B_COMMAND_ARG(ARG_SOURCE_FILE) + FX_COMMAND_ARG(ARG_SOURCE_FILE) { - B_ARG_NAME("source file"); - B_ARG_DESC("the .iasm assembly file to compile."); - B_ARG_NR_VALUES(1); + FX_ARG_NAME("source file"); + FX_ARG_DESC("the .iasm assembly file to compile."); + FX_ARG_NR_VALUES(1); } - B_COMMAND_OPTION(OPT_OUT_FILE) + FX_COMMAND_OPTION(OPT_OUT_FILE) { - B_OPTION_SHORT_NAME('o'); - B_OPTION_LONG_NAME("out"); - B_OPTION_DESC("the path to write the output binary file to."); - B_OPTION_ARG(ARG_OUT_FILE) + FX_OPTION_SHORT_NAME('o'); + FX_OPTION_LONG_NAME("out"); + FX_OPTION_DESC("the path to write the output binary file to."); + FX_OPTION_ARG(ARG_OUT_FILE) { - B_ARG_NAME("path"); - B_ARG_NR_VALUES(1); + FX_ARG_NAME("path"); + FX_ARG_NR_VALUES(1); } } - B_COMMAND_HELP_OPTION(); + FX_COMMAND_HELP_OPTION(); } diff --git a/frontend/cmd/compile.c b/frontend/cmd/compile.c index e0abca8..3107397 100644 --- a/frontend/cmd/compile.c +++ b/frontend/cmd/compile.c @@ -2,9 +2,9 @@ #include "cmd.h" #include "mie/select/builder.h" -#include -#include -#include +#include +#include +#include #include #include #include @@ -68,19 +68,19 @@ static enum ivy_status node_codegen( 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); - 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); - 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); - 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); - 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); - 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); 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()); 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_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) { 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); } - 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); @@ -151,10 +151,10 @@ static b_result open_file(struct compile_ctx *ctx, const char *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; @@ -166,7 +166,7 @@ static b_result parse_file_tokens(struct compile_ctx *ctx) ivy_diag_ctx_write( ctx->diag, IVY_DIAG_FORMAT_PRETTY, &ctx->diag_stream); - return b_error_with_code( + return fx_error_with_code( 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_stream); ivy_token_destroy(tok); - return b_error_with_code( + return fx_error_with_code( IVY_ERROR_VENDOR, IVY_ERR_BAD_SYNTAX); } 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, 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); @@ -209,45 +209,45 @@ static b_result generate_mie_ir(struct compile_ctx *ctx) enum ivy_status status = ivy_ast_node_iterate(node, &it, node_codegen, ctx); 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, status); } status = ivy_codegen_push_eof(ctx->codegen); 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, status); } 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) { printf("selecting %s.%s...\n", func->f_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) { 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( 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) { 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( ctx->select, (struct mie_instr *)instr_v); - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } if (block->b_terminator) { @@ -267,48 +267,48 @@ static b_result build_block_isel_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) { 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; - b_result result = build_block_isel_graph(ctx, func, block); - if (b_result_is_error(result)) { - return b_result_propagate(result); + fx_result result = build_block_isel_graph(ctx, func, block); + if (fx_result_is_error(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) { 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; - b_result result = build_func_isel_graph(ctx, func); - if (b_result_is_error(result)) { - return b_result_propagate(result); + fx_result result = build_func_isel_graph(ctx, func); + if (fx_result_is_error(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_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); - 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 = 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); - 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) \ 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; \ } \ - if (b_result_is_error(result)) { \ - b_throw(result); \ + if (fx_result_is_error(result)) { \ + fx_throw(result); \ return error_code; \ } \ } while (0) 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); int progress = 0; @@ -397,13 +397,13 @@ end: 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; - b_arglist_foreach_filtered(&it, args, B_COMMAND_INVALID_ID, ARG_SOURCE_FILE) + fx_arglist_iterator it; + fx_arglist_foreach_filtered(&it, args, FX_COMMAND_INVALID_ID, ARG_SOURCE_FILE) { - b_arglist_value *path = it.value; - if (path->val_type != B_COMMAND_ARG_STRING) { + fx_arglist_value *path = it.value; + if (path->val_type != FX_COMMAND_ARG_STRING) { 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_NAME("compile"); - B_COMMAND_SHORT_NAME('C'); - B_COMMAND_DESC( + FX_COMMAND_NAME("compile"); + FX_COMMAND_SHORT_NAME('C'); + FX_COMMAND_DESC( "compile one or more Ivy source files into Ivy object files."); - B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT); - B_COMMAND_FUNCTION(compile); + FX_COMMAND_FLAGS(FX_COMMAND_SHOW_HELP_BY_DEFAULT); + FX_COMMAND_FUNCTION(compile); - B_COMMAND_OPTION(OPT_SHOW_LEX_TOKENS) + FX_COMMAND_OPTION(OPT_SHOW_LEX_TOKENS) { - B_OPTION_LONG_NAME("show-lex"); - B_OPTION_SHORT_NAME('l'); - B_OPTION_DESC( + FX_OPTION_LONG_NAME("show-lex"); + FX_OPTION_SHORT_NAME('l'); + FX_OPTION_DESC( "print the lexical tokens generated from the input " "files."); } - B_COMMAND_OPTION(OPT_SHOW_AST_NODES) + FX_COMMAND_OPTION(OPT_SHOW_AST_NODES) { - B_OPTION_LONG_NAME("show-ast"); - B_OPTION_SHORT_NAME('a'); - B_OPTION_DESC( + FX_OPTION_LONG_NAME("show-ast"); + FX_OPTION_SHORT_NAME('a'); + FX_OPTION_DESC( "print the abstract syntax tree generated from the " "input files."); } - B_COMMAND_OPTION(OPT_SHOW_IR) + FX_COMMAND_OPTION(OPT_SHOW_IR) { - B_OPTION_LONG_NAME("show-ir"); - B_OPTION_SHORT_NAME('i'); - B_OPTION_DESC( + FX_OPTION_LONG_NAME("show-ir"); + FX_OPTION_SHORT_NAME('i'); + FX_OPTION_DESC( "print the Mie IR generated from the " "input files."); } - B_COMMAND_OPTION(OPT_SHOW_ISEL_PRE) + FX_COMMAND_OPTION(OPT_SHOW_ISEL_PRE) { - B_OPTION_LONG_NAME("show-isel-pre"); - B_OPTION_SHORT_NAME('s'); - B_OPTION_DESC( + FX_OPTION_LONG_NAME("show-isel-pre"); + FX_OPTION_SHORT_NAME('s'); + FX_OPTION_DESC( "print the instruction selection graph before " "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"); - B_OPTION_SHORT_NAME('m'); - B_OPTION_DESC( + FX_OPTION_LONG_NAME("show-isel-post"); + FX_OPTION_SHORT_NAME('m'); + FX_OPTION_DESC( "print the instruction selection graph after " "selection has taken place."); } - B_COMMAND_ARG(ARG_SOURCE_FILE) + FX_COMMAND_ARG(ARG_SOURCE_FILE) { - B_ARG_NAME("source file"); - B_ARG_DESC("the .im source files to compile."); - B_ARG_NR_VALUES(B_ARG_1_OR_MORE_VALUES); + FX_ARG_NAME("source file"); + FX_ARG_DESC("the .im source files to compile."); + FX_ARG_NR_VALUES(FX_ARG_1_OR_MORE_VALUES); } - B_COMMAND_HELP_OPTION(); + FX_COMMAND_HELP_OPTION(); } diff --git a/frontend/cmd/disassemble.c b/frontend/cmd/disassemble.c index dc1ad2a..04ced65 100644 --- a/frontend/cmd/disassemble.c +++ b/frontend/cmd/disassemble.c @@ -1,8 +1,8 @@ #include "cmd.h" -#include -#include -#include +#include +#include +#include #include #include #include @@ -30,7 +30,7 @@ enum { OPT_CONSTPOOL, }; -static void dump_instruction(b_i32 x) +static void dump_instruction(fx_i32 x) { struct ivy_instr 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( - pool, b_i32_btoh(class_header.c_ident), &class_ident); + pool, fx_i32_btoh(class_header.c_ident), &class_ident); if (status != IVY_OK) { goto cleanup; } @@ -262,13 +262,13 @@ static enum ivy_status dump_class( printf(" [%03zu] ", i); char s[256]; - uint32_t type = b_i32_btoh(entry.e_type); + uint32_t type = fx_i32_btoh(entry.e_type); switch (type) { case IVY_CLASS_TABLE_PROP: { printf("type:property\n"); struct ivy_asm_constpool_value *prop_ident = NULL; 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); if (status != IVY_OK) { break; @@ -279,8 +279,8 @@ static enum ivy_status dump_class( break; } - uint32_t get = b_i32_btoh(entry.e_property.p_get); - uint32_t set = b_i32_btoh(entry.e_property.p_set); + uint32_t get = fx_i32_btoh(entry.e_property.p_get); + uint32_t set = fx_i32_btoh(entry.e_property.p_set); ivy_ident_to_string(prop_ident->v_ident, s, sizeof s); ivy_asm_constpool_value_destroy(prop_ident); @@ -305,7 +305,7 @@ static enum ivy_status dump_class( printf("type:variable\n"); struct ivy_asm_constpool_value *var_ident = NULL; 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) { break; } @@ -315,7 +315,7 @@ static enum ivy_status dump_class( 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_asm_constpool_value_destroy(var_ident); printf(" ident:%s, index:0x%" PRIx32 @@ -328,7 +328,7 @@ static enum ivy_status dump_class( printf("type:method\n"); struct ivy_asm_constpool_value *sel = NULL; 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) { break; } @@ -338,7 +338,7 @@ static enum ivy_status dump_class( 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_asm_constpool_value_destroy(sel); @@ -399,7 +399,7 @@ static enum ivy_status dump_constpool(struct ivy_asm_reader *object) enum ivy_status status = ivy_asm_reader_open_constpool(object, 0, 0, &pool); if (status == IVY_ERR_NO_ENTRY) { - b_err("object file has no constpool.\n"); + fx_err("object file has no constpool.\n"); return status; } @@ -409,8 +409,8 @@ static enum ivy_status dump_constpool(struct ivy_asm_reader *object) struct ivy_asm_constpool_value *v; status = ivy_asm_constpool_reader_read_value(pool, i, &v); if (status != IVY_OK) { - b_err("cannot read constpool value"); - b_i("reason: %s", ivy_status_to_string(status)); + fx_err("cannot read constpool value"); + fx_i("reason: %s", ivy_status_to_string(status)); break; } @@ -455,7 +455,7 @@ static enum ivy_status dump_constpool(struct ivy_asm_reader *object) 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; @@ -503,7 +503,7 @@ static enum ivy_status dump_header( 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; break; } @@ -520,7 +520,7 @@ static enum ivy_status dump_header( 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); *dump_offset = sizeof text; break; @@ -584,7 +584,7 @@ static enum ivy_status dump_section( printf(" | "); if (flags & DUMP_INSTRUCTIONS) { - dump_instructions((b_i32 *)x, buffer_size); + dump_instructions((fx_i32 *)x, buffer_size); } else { 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( - 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; bool sections - = b_arglist_get_count(args, OPT_SECTIONS, B_COMMAND_INVALID_ID) > 0; - bool dump = b_arglist_get_count(args, OPT_DUMP, B_COMMAND_INVALID_ID) > 0; + = fx_arglist_get_count(args, OPT_SECTIONS, FX_COMMAND_INVALID_ID) > 0; + bool dump = fx_arglist_get_count(args, OPT_DUMP, FX_COMMAND_INVALID_ID) > 0; 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; 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; - 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) { - b_err("no input file specified."); + fx_err("no input file specified."); return -1; } FILE *in = fopen(in_path, "rb"); if (!in) { - b_err("cannot open object file"); - b_i("reason: %s", strerror(errno)); + fx_err("cannot open object file"); + fx_i("reason: %s", strerror(errno)); return -1; } @@ -682,8 +682,8 @@ static int disassemble( enum ivy_status status = ivy_asm_reader_open(in, &reader); if (status != IVY_OK) { - b_err("cannot open object file"); - b_i("reason: %s", ivy_status_to_string(status)); + fx_err("cannot open object file"); + fx_i("reason: %s", ivy_status_to_string(status)); fclose(in); return -1; @@ -719,59 +719,59 @@ static int disassemble( B_COMMAND(CMD_DISASSEMBLE, CMD_ROOT) { - B_COMMAND_NAME("disassemble"); - B_COMMAND_SHORT_NAME('D'); - B_COMMAND_DESC("disassemble an Ivy object file."); - B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT); - B_COMMAND_FUNCTION(disassemble); + FX_COMMAND_NAME("disassemble"); + FX_COMMAND_SHORT_NAME('D'); + FX_COMMAND_DESC("disassemble an Ivy object file."); + FX_COMMAND_FLAGS(FX_COMMAND_SHOW_HELP_BY_DEFAULT); + FX_COMMAND_FUNCTION(disassemble); - B_COMMAND_ARG(ARG_BIN_FILE) + FX_COMMAND_ARG(ARG_BIN_FILE) { - B_ARG_NAME("input file"); - B_ARG_DESC("the Ivy object file to disassemble."); - B_ARG_NR_VALUES(1); + FX_ARG_NAME("input file"); + FX_ARG_DESC("the Ivy object file to disassemble."); + FX_ARG_NR_VALUES(1); } - B_COMMAND_OPTION(OPT_HEADER) + FX_COMMAND_OPTION(OPT_HEADER) { - B_OPTION_SHORT_NAME('h'); - B_OPTION_LONG_NAME("header"); - B_OPTION_DESC("print the object file header."); + FX_OPTION_SHORT_NAME('h'); + FX_OPTION_LONG_NAME("header"); + FX_OPTION_DESC("print the object file header."); } - B_COMMAND_OPTION(OPT_SECTIONS) + FX_COMMAND_OPTION(OPT_SECTIONS) { - B_OPTION_SHORT_NAME('s'); - B_OPTION_LONG_NAME("section-table"); - B_OPTION_DESC("print the object file section table."); + FX_OPTION_SHORT_NAME('s'); + FX_OPTION_LONG_NAME("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'); - B_OPTION_LONG_NAME("dump"); - B_OPTION_DESC( + FX_OPTION_SHORT_NAME('d'); + FX_OPTION_LONG_NAME("dump"); + FX_OPTION_DESC( "decode and print the contents of each object " "section."); } - B_COMMAND_OPTION(OPT_CLASSES) + FX_COMMAND_OPTION(OPT_CLASSES) { - B_OPTION_SHORT_NAME('c'); - B_OPTION_LONG_NAME("classes"); - B_OPTION_DESC( + FX_OPTION_SHORT_NAME('c'); + FX_OPTION_LONG_NAME("classes"); + FX_OPTION_DESC( "print the classes contained in the object " "file."); } - B_COMMAND_OPTION(OPT_CONSTPOOL) + FX_COMMAND_OPTION(OPT_CONSTPOOL) { - B_OPTION_SHORT_NAME('p'); - B_OPTION_LONG_NAME("pool-data"); - B_OPTION_DESC( + FX_OPTION_SHORT_NAME('p'); + FX_OPTION_LONG_NAME("pool-data"); + FX_OPTION_DESC( "print the constant pool data in the object " "file."); } - B_COMMAND_HELP_OPTION(); + FX_COMMAND_HELP_OPTION(); } diff --git a/frontend/cmd/exec.c b/frontend/cmd/exec.c index 5718ed8..32847bb 100644 --- a/frontend/cmd/exec.c +++ b/frontend/cmd/exec.c @@ -1,41 +1,41 @@ #include "cmd.h" -#include +#include enum { 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; } -B_COMMAND(CMD_ROOT, B_COMMAND_INVALID_ID) +B_COMMAND(CMD_ROOT, FX_COMMAND_INVALID_ID) { - B_COMMAND_NAME("ivy"); - B_COMMAND_DESC("evaluate an Ivy source file or Ivy object file."); - B_COMMAND_HELP_OPTION(); - B_COMMAND_FLAGS(B_COMMAND_SHOW_HELP_BY_DEFAULT); - B_COMMAND_FUNCTION(exec); + FX_COMMAND_NAME("ivy"); + FX_COMMAND_DESC("evaluate an Ivy source file or Ivy object file."); + FX_COMMAND_HELP_OPTION(); + FX_COMMAND_FLAGS(FX_COMMAND_SHOW_HELP_BY_DEFAULT); + FX_COMMAND_FUNCTION(exec); - B_COMMAND_ARG(ARG_FILE) + FX_COMMAND_ARG(ARG_FILE) { - B_ARG_NAME("file"); - B_ARG_DESC("The file to execute."); - B_ARG_NR_VALUES(1); + FX_ARG_NAME("file"); + FX_ARG_DESC("The file to execute."); + FX_ARG_NR_VALUES(1); } - B_COMMAND_USAGE() + FX_COMMAND_USAGE() { - B_COMMAND_USAGE_OPT_PLACEHOLDER(); - B_COMMAND_USAGE_ARG(ARG_FILE); + FX_COMMAND_USAGE_OPT_PLACEHOLDER(); + FX_COMMAND_USAGE_ARG(ARG_FILE); } - B_COMMAND_USAGE() + FX_COMMAND_USAGE() { - B_COMMAND_USAGE_COMMAND_PLACEHOLDER(); - B_COMMAND_USAGE_OPT_PLACEHOLDER(); - B_COMMAND_USAGE_ARG_PLACEHOLDER(); + FX_COMMAND_USAGE_COMMAND_PLACEHOLDER(); + FX_COMMAND_USAGE_OPT_PLACEHOLDER(); + FX_COMMAND_USAGE_ARG_PLACEHOLDER(); } } diff --git a/frontend/cmd/internal.c b/frontend/cmd/internal.c index e1797ea..120329d 100644 --- a/frontend/cmd/internal.c +++ b/frontend/cmd/internal.c @@ -1,30 +1,30 @@ -#include +#include #include "cmd.h" #include #include -#include +#include enum { OPT_PRINT_SYMBOLS = 0x1000, 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; enum ivy_status status = ivy_lexer_create(&lex); 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)); 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); } - 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); } @@ -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_NAME("internal"); - B_COMMAND_SHORT_NAME('X'); - B_COMMAND_DESC("internal frontend debugging tools."); - B_COMMAND_FUNCTION(internal); + FX_COMMAND_NAME("internal"); + FX_COMMAND_SHORT_NAME('X'); + FX_COMMAND_DESC("internal frontend debugging tools."); + FX_COMMAND_FUNCTION(internal); - B_COMMAND_OPTION(OPT_PRINT_SYMBOLS) + FX_COMMAND_OPTION(OPT_PRINT_SYMBOLS) { - B_OPTION_LONG_NAME("print-symbols"); - B_OPTION_SHORT_NAME('s'); - B_OPTION_DESC( + FX_OPTION_LONG_NAME("print-symbols"); + FX_OPTION_SHORT_NAME('s'); + FX_OPTION_DESC( "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"); - B_OPTION_SHORT_NAME('k'); - B_OPTION_DESC( + FX_OPTION_LONG_NAME("print-keywords"); + FX_OPTION_SHORT_NAME('k'); + FX_OPTION_DESC( "print the keyword dictionary used by the language lexer."); } - B_COMMAND_HELP_OPTION(); + FX_COMMAND_HELP_OPTION(); } diff --git a/frontend/cmd/repl.c b/frontend/cmd/repl.c index 3ab0ea0..e74b0cf 100644 --- a/frontend/cmd/repl.c +++ b/frontend/cmd/repl.c @@ -2,8 +2,8 @@ #include "../line-ed/line-ed.h" #include "cmd.h" -#include -#include +#include +#include #include #include #include @@ -180,26 +180,26 @@ static enum ivy_status repl_create(struct repl **out) 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 - b_printf( + fx_printf( "[bold,bright_red]error[[E0384][reset,bold,white]: cannot " "assign twice to immutable variable `i`[reset]\n"); - b_printf("[bold,bright_blue] -->[reset] src/main.rs:7:3\n"); - b_printf("[bold,bright_blue] |[reset]\n"); - b_printf("[bold,bright_blue]4 |[reset] let i = 0;\n"); - b_printf("[bold,bright_blue] | -[reset]\n"); - b_printf("[bold,bright_blue] | |[reset]\n"); - b_printf( + fx_printf("[bold,bright_blue] -->[reset] src/main.rs:7:3\n"); + fx_printf("[bold,bright_blue] |[reset]\n"); + fx_printf("[bold,bright_blue]4 |[reset] let i = 0;\n"); + fx_printf("[bold,bright_blue] | -[reset]\n"); + fx_printf("[bold,bright_blue] | |[reset]\n"); + fx_printf( "[bold,bright_blue] | first assignment to " "`i`[reset]\n"); - b_printf( + fx_printf( "[bold,bright_blue] | help: make this binding " "mutable: `mut i`[reset]\n"); - b_printf("[bold,bright_blue]...[reset]\n"); - b_printf("[bold,bright_blue]7 |[reset] i += 1;\n"); - b_printf( + fx_printf("[bold,bright_blue]...[reset]\n"); + fx_printf("[bold,bright_blue]7 |[reset] i += 1;\n"); + fx_printf( "[bold,bright_blue] |[bold,bright_red] ^^^^^^ cannot " "assign twice to immutable variable[reset]\n"); #endif @@ -210,14 +210,14 @@ int repl(const b_command *cmd, const b_arglist *args, const b_array *_) return -1; } - repl->r_show_lex = b_arglist_get_count( - args, OPT_SHOW_LEX_TOKENS, B_COMMAND_INVALID_ID) + repl->r_show_lex = fx_arglist_get_count( + args, OPT_SHOW_LEX_TOKENS, FX_COMMAND_INVALID_ID) > 0; - repl->r_show_ast = b_arglist_get_count( - args, OPT_SHOW_AST_NODES, B_COMMAND_INVALID_ID) + repl->r_show_ast = fx_arglist_get_count( + args, OPT_SHOW_AST_NODES, FX_COMMAND_INVALID_ID) > 0; 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) { 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) { - b_err("lex error (%s)", + fx_err("lex error (%s)", ivy_status_to_string( ivy_lexer_get_status(repl->r_lex))); 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); 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); skip_line(repl->r_lex); 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_NAME("shell"); - B_COMMAND_SHORT_NAME('S'); - B_COMMAND_DESC("start an interactive Ivy shell."); - B_COMMAND_HELP_OPTION(); - B_COMMAND_FUNCTION(repl); + FX_COMMAND_NAME("shell"); + FX_COMMAND_SHORT_NAME('S'); + FX_COMMAND_DESC("start an interactive Ivy shell."); + FX_COMMAND_HELP_OPTION(); + FX_COMMAND_FUNCTION(repl); - B_COMMAND_OPTION(OPT_SHOW_LEX_TOKENS) + FX_COMMAND_OPTION(OPT_SHOW_LEX_TOKENS) { - B_OPTION_LONG_NAME("show-lex"); - B_OPTION_SHORT_NAME('l'); - B_OPTION_DESC( + FX_OPTION_LONG_NAME("show-lex"); + FX_OPTION_SHORT_NAME('l'); + FX_OPTION_DESC( "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"); - B_OPTION_SHORT_NAME('a'); - B_OPTION_DESC( + FX_OPTION_LONG_NAME("show-ast"); + FX_OPTION_SHORT_NAME('a'); + FX_OPTION_DESC( "print the abstract syntax tree generated from the " "input."); } - B_COMMAND_OPTION(OPT_SHOW_IR) + FX_COMMAND_OPTION(OPT_SHOW_IR) { - B_OPTION_LONG_NAME("show-ir"); - B_OPTION_SHORT_NAME('i'); - B_OPTION_DESC("print the Mie IR generated from the input."); + FX_OPTION_LONG_NAME("show-ir"); + FX_OPTION_SHORT_NAME('i'); + FX_OPTION_DESC("print the Mie IR generated from the input."); } } diff --git a/frontend/debug.c b/frontend/debug.c index ee62f28..c272ee4 100644 --- a/frontend/debug.c +++ b/frontend/debug.c @@ -1,7 +1,7 @@ #include "debug.h" -#include -#include +#include +#include #include #include #include @@ -14,41 +14,41 @@ extern void print_lex_token(struct ivy_token *tok) switch (tok->t_type) { case IVY_TOK_KEYWORD: - b_puts("[magenta]"); + fx_puts("[magenta]"); break; case IVY_TOK_SYMBOL: - b_puts("[blue]"); + fx_puts("[blue]"); break; case IVY_TOK_ATOM: - b_puts("[yellow]"); + fx_puts("[yellow]"); break; case IVY_TOK_INT: case IVY_TOK_DOUBLE: - b_puts("[yellow]"); + fx_puts("[yellow]"); break; case IVY_TOK_LABEL: - b_puts("[red]"); + fx_puts("[red]"); break; case IVY_TOK_IDENT: - b_puts("[cyan]"); + fx_puts("[cyan]"); break; case IVY_TOK_STRING: - b_puts("[green]"); + fx_puts("[green]"); break; case IVY_TOK_STR_START: - b_puts("[green]"); + fx_puts("[green]"); break; case IVY_TOK_STR_END: - b_puts("[green]"); + fx_puts("[green]"); break; case IVY_TOK_LINEFEED: - b_puts("[dark_grey]"); + fx_puts("[dark_grey]"); break; default: 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) { case IVY_TOK_IDENT: @@ -73,40 +73,40 @@ extern void print_lex_token(struct ivy_token *tok) break; } - b_puts("[reset]\n"); + fx_puts("[reset]\n"); } extern void print_asm_lex_token(struct ivy_asm_token *tok) { switch (tok->t_type) { case IVY_ASM_TOK_KEYWORD: - b_puts("[magenta]"); + fx_puts("[magenta]"); break; case IVY_ASM_TOK_SYMBOL: - b_puts("[blue]"); + fx_puts("[blue]"); break; case IVY_ASM_TOK_INT: case IVY_ASM_TOK_DOUBLE: case IVY_ASM_TOK_LABEL_REF: - b_puts("[yellow]"); + fx_puts("[yellow]"); break; case IVY_ASM_TOK_LABEL: - b_puts("[red]"); + fx_puts("[red]"); break; case IVY_ASM_TOK_IDENT: - b_puts("[cyan]"); + fx_puts("[cyan]"); break; case IVY_ASM_TOK_STRING: - b_puts("[green]"); + fx_puts("[green]"); break; case IVY_ASM_TOK_LINEFEED: - b_puts("[dark_grey]"); + fx_puts("[dark_grey]"); break; default: 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) { case IVY_ASM_TOK_IDENT: @@ -135,7 +135,7 @@ extern void print_asm_lex_token(struct ivy_asm_token *tok) break; } - b_puts("[reset]\n"); + fx_puts("[reset]\n"); } extern enum ivy_status print_ast_node( @@ -154,7 +154,7 @@ extern enum ivy_status print_ast_node( if (!args || (args && args->indent)) { 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_RETURN: case IVY_AST_GLOBAL: - b_puts("[magenta]"); + fx_puts("[magenta]"); break; case IVY_AST_OP: - b_puts("[blue]"); + fx_puts("[blue]"); break; case IVY_AST_MSG: - b_puts("[red]"); + fx_puts("[red]"); break; case IVY_AST_INT: case IVY_AST_DOUBLE: @@ -187,73 +187,73 @@ extern enum ivy_status print_ast_node( case IVY_AST_C_TRUE: case IVY_AST_C_FALSE: case IVY_AST_C_NULL: - b_puts("[yellow]"); + fx_puts("[yellow]"); break; case IVY_AST_COND: case IVY_AST_BLOCK: case IVY_AST_TRY_CATCH: - b_puts("[red]"); + fx_puts("[red]"); break; case IVY_AST_IDENT: case IVY_AST_SELECTOR: - b_puts("[cyan]"); + fx_puts("[cyan]"); break; case IVY_AST_STRING: case IVY_AST_FSTRING: - b_puts("[green]"); + fx_puts("[green]"); break; case IVY_AST_DISCARD: - b_puts("[dark_grey]"); + fx_puts("[dark_grey]"); break; default: break; } - b_string *str = b_string_create(); + fx_string *str = fx_string_create(); ivy_ast_node_to_string(node, str); - b_printf("%s", b_string_ptr(str)); - b_string_unref(str); + fx_printf("%s", fx_string_ptr(str)); + fx_string_unref(str); #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) { case IVY_AST_INT: { 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; } case IVY_AST_DOUBLE: { 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; } case IVY_AST_IDENT: { 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; } case IVY_AST_STRING: { 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; } case IVY_AST_ATOM: { 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; } case IVY_AST_SELECTOR: { struct ivy_ast_selector_node *v = (struct ivy_ast_selector_node *)node; - b_printf(" [["); + fx_printf(" [["); switch (v->n_recipient) { case IVY_SELECTOR_RECIPIENT_CLASS: - b_putc('+'); + fx_putc('+'); break; case IVY_SELECTOR_RECIPIENT_OBJECT: - b_putc('-'); + fx_putc('-'); break; default: /* 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) { - 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)) { - b_putc('('); + if (v->n_msg_name && !fx_queue_empty(&v->n_arg_labels)) { + fx_putc('('); } - b_queue_iterator label_it = {0}; - b_queue_iterator name_it = {0}; + fx_queue_iterator label_it = {0}; + fx_queue_iterator name_it = {0}; - b_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_labels, &label_it); + fx_queue_iterator_begin(&v->n_arg_names, &name_it); bool name_present = false; int i = 0; - while (b_queue_iterator_is_valid(&label_it)) { + while (fx_queue_iterator_is_valid(&label_it)) { if (i > 0 && name_present) { 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 *name = b_unbox( + struct ivy_token *name = fx_unbox( struct ivy_token, name_it.entry, t_entry); if (label) { - b_printf("%s:", label->t_str); + fx_printf("%s:", label->t_str); } if (name) { - b_printf("%s", name->t_str); + fx_printf("%s", name->t_str); } name_present = (name != NULL); i++; - b_queue_iterator_next(&label_it); - b_queue_iterator_next(&name_it); + fx_queue_iterator_next(&label_it); + fx_queue_iterator_next(&name_it); } - if (v->n_msg_name && !b_queue_empty(&v->n_arg_labels)) { - b_putc(')'); + if (v->n_msg_name && !fx_queue_empty(&v->n_arg_labels)) { + fx_putc(')'); } - b_puts("]"); + fx_puts("]"); break; } case IVY_AST_OP: { 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; } case IVY_AST_CLASS: { 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; } case IVY_AST_UNIT_PACKAGE: { struct ivy_ast_unit_package_node *v = (struct ivy_ast_unit_package_node *)node; - b_printf(" ("); - b_queue_iterator it = {0}; + fx_printf(" ("); + fx_queue_iterator it = {0}; int i = 0; - b_queue_foreach (&it, &v->n_ident) { + fx_queue_foreach (&it, &v->n_ident) { 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) { - b_printf("."); + fx_printf("."); } - b_printf("%s", tok->t_str); + fx_printf("%s", tok->t_str); i++; } - b_printf(")"); + fx_printf(")"); break; } case IVY_AST_UNIT_IMPORT: { struct ivy_ast_unit_import_node *v = (struct ivy_ast_unit_import_node *)node; - b_printf(" ("); - b_queue_iterator it = {0}; + fx_printf(" ("); + fx_queue_iterator it = {0}; int i = 0; - b_queue_foreach (&it, &v->n_ident) { + fx_queue_foreach (&it, &v->n_ident) { 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) { - b_printf("."); + fx_printf("."); } - b_printf("%s", tok->t_str); + fx_printf("%s", tok->t_str); i++; } - b_printf(")"); + fx_printf(")"); break; } default: @@ -389,6 +389,6 @@ extern enum ivy_status print_ast_node( } #endif - b_puts("[reset]\n"); + fx_puts("[reset]\n"); return IVY_OK; } diff --git a/frontend/line-ed/history.c b/frontend/line-ed/history.c index e84933a..8ad0c11 100644 --- a/frontend/line-ed/history.c +++ b/frontend/line-ed/history.c @@ -1,42 +1,42 @@ #include "line-ed.h" -#include -#include +#include +#include void alloc_empty_history_entry(struct line_ed *ed) { - b_string *str = (b_string *)b_array_at( - ed->l_history, b_array_size(ed->l_history) - 1); - if (!str || b_string_get_size(str, B_STRLEN_NORMAL) > 0) { - str = b_string_create(); - b_array_append(ed->l_history, (b_object *)str); + fx_string *str = (fx_string *)fx_array_at( + ed->l_history, fx_array_size(ed->l_history) - 1); + if (!str || fx_string_get_size(str, FX_STRLEN_NORMAL) > 0) { + str = fx_string_create(); + 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) { - b_string *cur = (b_string *)b_array_get(ed->l_history, ed->l_history_pos); - b_string_replace_all(cur, ed->l_buf); + fx_string *cur = (fx_string *)fx_array_get(ed->l_history, ed->l_history_pos); + fx_string_replace_all(cur, ed->l_buf); } 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}; - b_string_append_cstr(cur, s); - b_string_append_cstr(cur, ed->l_buf); + fx_string_append_cstr(cur, s); + fx_string_append_cstr(cur, ed->l_buf); } 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 = 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'; 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) { - size_t nlines = b_array_size(ed->l_history); + size_t nlines = fx_array_size(ed->l_history); if (nlines < 2) { return NULL; } - b_string *last = (b_string *)b_array_at(ed->l_history, nlines - 2); - return b_string_ptr(last); + fx_string *last = (fx_string *)fx_array_at(ed->l_history, nlines - 2); + return fx_string_ptr(last); } diff --git a/frontend/line-ed/hl-range.c b/frontend/line-ed/hl-range.c index 6e51ed4..8f46943 100644 --- a/frontend/line-ed/hl-range.c +++ b/frontend/line-ed/hl-range.c @@ -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) { - if (b_queue_empty(&ed->l_hl_ranges)) { + if (fx_queue_empty(&ed->l_hl_ranges)) { return 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) { - 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); if (cmp_end != 1) { return cur; } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } 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) { - b_queue_entry *entry = &range->h_entry; - entry = b_queue_next(entry); + fx_queue_entry *entry = &range->h_entry; + entry = fx_queue_next(entry); if (!entry) { return NULL; } - range = b_unbox(struct hl_range, entry, h_entry); + range = fx_unbox(struct hl_range, entry, h_entry); 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) { - b_tty_reset_vmode(tty); + fx_tty_reset_vmode(tty); 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); if (cmp_start < 0) { - b_tty_reset_vmode(tty); + fx_tty_reset_vmode(tty); } 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) { @@ -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( 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); if (!out) { @@ -179,7 +179,7 @@ static void move_start_to_meet_end( void line_ed_put_highlight( 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 = 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; - b_queue_entry *entry = NULL; - entry = b_queue_first(&ed->l_hl_ranges); + fx_queue_entry *entry = NULL; + entry = fx_queue_first(&ed->l_hl_ranges); 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; } struct hl_range *cur = NULL; enum hl_range_comparison prev_cmp = -1; - b_queue_entry *insert_before = NULL; - b_queue_entry *insert_after = NULL; + fx_queue_entry *insert_before = NULL; + fx_queue_entry *insert_after = NULL; bool end = false; while (entry) { - b_queue_entry *next = b_queue_next(entry); - cur = b_unbox(struct hl_range, entry, h_entry); + fx_queue_entry *next = fx_queue_next(entry); + cur = fx_unbox(struct hl_range, entry, h_entry); enum hl_range_comparison cmp = compare_hl_ranges(cur, highlight); switch (cmp) { case HL_RANGE_A_IN_B: - b_queue_delete(&ed->l_hl_ranges, entry); + fx_queue_delete(&ed->l_hl_ranges, entry); free(cur); break; case HL_RANGE_B_IN_A: @@ -220,10 +220,10 @@ void line_ed_put_highlight( h2 = create_highlight( 0, 0, cur->h_end_x, cur->h_end_y, &cur->h_vmode); move_start_to_meet_end(h2, highlight); - b_queue_insert_after( + fx_queue_insert_after( &ed->l_hl_ranges, &highlight->h_entry, &cur->h_entry); - b_queue_insert_after( + fx_queue_insert_after( &ed->l_hl_ranges, &h2->h_entry, &highlight->h_entry); insert_before = insert_after = NULL; @@ -239,7 +239,7 @@ void line_ed_put_highlight( insert_before = entry; break; case HL_RANGE_GREATER: - b_queue_insert_before( + fx_queue_insert_before( &ed->l_hl_ranges, &highlight->h_entry, entry); insert_before = insert_after = NULL; end = true; @@ -255,32 +255,32 @@ void line_ed_put_highlight( } if (insert_before) { - b_queue_insert_before( + fx_queue_insert_before( &ed->l_hl_ranges, &highlight->h_entry, insert_before); } else if (insert_after) { - b_queue_insert_after( + fx_queue_insert_after( &ed->l_hl_ranges, &highlight->h_entry, insert_after); } } 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) { - 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); - 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) { - b_queue_entry *entry = b_queue_first(&ed->l_hl_ranges); + fx_queue_entry *entry = fx_queue_first(&ed->l_hl_ranges); 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, h->h_end_x, h->h_end_y); - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } } diff --git a/frontend/line-ed/hl-range.h b/frontend/line-ed/hl-range.h index 835c2a7..d35738f 100644 --- a/frontend/line-ed/hl-range.h +++ b/frontend/line-ed/hl-range.h @@ -1,9 +1,9 @@ #ifndef LINE_ED_HL_RANGE_H_ #define LINE_ED_HL_RANGE_H_ -#include +#include -#include +#include struct line_ed; @@ -20,18 +20,18 @@ enum hl_range_comparison { struct hl_range { size_t h_start_x, h_start_y; size_t h_end_x, h_end_y; - b_tty_vmode h_vmode; - b_queue_entry h_entry; + fx_tty_vmode h_vmode; + fx_queue_entry h_entry; }; 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_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( 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( const struct hl_range *a, const struct hl_range *b); diff --git a/frontend/line-ed/hook.c b/frontend/line-ed/hook.c index f0aeca3..cb8e8f4 100644 --- a/frontend/line-ed/hook.c +++ b/frontend/line-ed/hook.c @@ -4,38 +4,38 @@ 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) { - 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) { 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) { hook->hook_keypress(ed, hook, key); } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } } 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) { 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) { hook->hook_buffer_modified(ed, hook); } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } } diff --git a/frontend/line-ed/hook.h b/frontend/line-ed/hook.h index db933e7..613344a 100644 --- a/frontend/line-ed/hook.h +++ b/frontend/line-ed/hook.h @@ -1,7 +1,7 @@ #ifndef LINE_ED_HOOK_H_ #define LINE_ED_HOOK_H_ -#include +#include enum hook_id { HOOK_KEYPRESS, @@ -10,7 +10,7 @@ enum hook_id { 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); #endif diff --git a/frontend/line-ed/input.c b/frontend/line-ed/input.c index c6f117c..5dbae94 100644 --- a/frontend/line-ed/input.c +++ b/frontend/line-ed/input.c @@ -113,7 +113,7 @@ void cursor_left(struct line_ed *ed) { if (ed->l_cursor_x != 0) { //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); ed->l_cursor_x--; ed->l_buf_ptr--; @@ -135,8 +135,8 @@ void cursor_left(struct line_ed *ed) ed->l_cursor_x = len - 1; //printf("\033[A\033[%dG", len + prompt_len); - b_tty_move_cursor_y(ed->l_tty, B_TTY_POS_CURSOR, -1); - b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_START, (int)(len + prompt_len)); + fx_tty_move_cursor_y(ed->l_tty, FX_TTY_POS_CURSOR, -1); + fx_tty_move_cursor_x(ed->l_tty, FX_TTY_POS_START, (int)(len + prompt_len)); fflush(stdout); } @@ -151,7 +151,7 @@ void cursor_right(struct line_ed *ed) ed->l_cursor_x++; ed->l_buf_ptr++; //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); return; } @@ -165,8 +165,8 @@ void cursor_right(struct line_ed *ed) ed->l_buf_ptr++; //printf("\033[B\033[G"); - b_tty_move_cursor_y(ed->l_tty, B_TTY_POS_CURSOR, 1); - b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_START, 0); + fx_tty_move_cursor_y(ed->l_tty, FX_TTY_POS_CURSOR, 1); + fx_tty_move_cursor_x(ed->l_tty, FX_TTY_POS_START, 0); fflush(stdout); } @@ -178,13 +178,13 @@ void arrow_up(struct line_ed *ed) if (ed->l_cursor_y > 0) { //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); - b_tty_move_cursor_x( - ed->l_tty, B_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_move_cursor_x( + ed->l_tty, FX_TTY_POS_START, (long long)prompt_length(ed, PROMPT_MAIN)); + fx_tty_clear(ed->l_tty, FX_TTY_CLEAR_SCREEN | FX_TTY_CLEAR_FROM_CURSOR); save_buf_to_history(ed); ed->l_history_pos--; @@ -196,18 +196,18 @@ void arrow_up(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; } if (ed->l_cursor_y > 0) { //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); - b_tty_move_cursor_x( - ed->l_tty, B_TTY_POS_START, prompt_length(ed, PROMPT_MAIN) + 1); + fx_tty_move_cursor_x( + ed->l_tty, FX_TTY_POS_START, prompt_length(ed, PROMPT_MAIN) + 1); save_buf_to_history(ed); ed->l_history_pos++; diff --git a/frontend/line-ed/line-ed.c b/frontend/line-ed/line-ed.c index 8fa8504..860e4dc 100644 --- a/frontend/line-ed/line-ed.c +++ b/frontend/line-ed/line-ed.c @@ -5,7 +5,7 @@ #include "input.h" #include "prompt.h" -#include +#include #include #include #include @@ -49,14 +49,14 @@ struct line_ed *line_ed_create(void) return NULL; } - out->l_history = b_array_create(); + out->l_history = fx_array_create(); if (!out->l_history) { free(out->l_buf); free(out); return NULL; } - out->l_tty = b_stdtty; + out->l_tty = fx_stdtty; out->l_buf_end = out->l_buf + LINE_MAX; out->l_buf_ptr = 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) { - b_array_unref(ed->l_history); + fx_array_unref(ed->l_history); line_ed_clear_highlights(ed); free(ed->l_buf); 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; } - b_tty *tty = ed->l_tty; - b_tty_set_mode(tty, B_TTY_RAW); + fx_tty *tty = ed->l_tty; + fx_tty_set_mode(tty, FX_TTY_RAW); show_prompt(ed); 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; while (!end) { - b_keycode key = b_tty_read_key(tty); + fx_keycode key = fx_tty_read_key(tty); hook_keypress(ed, key); - if (key == B_TTY_CTRL_KEY('d')) { + if (key == FX_TTY_CTRL_KEY('d')) { if (!input_is_empty(ed)) { continue; } @@ -210,13 +210,13 @@ size_t line_ed_readline(struct line_ed *ed, char *out, size_t max) break; } - if (key & B_MOD_CTRL) { + if (key & FX_MOD_CTRL) { continue; } switch (key) { - case B_KEY_RETURN: - b_tty_reset_vmode(tty); + case FX_KEY_RETURN: + fx_tty_reset_vmode(tty); if (ed->l_line_end > ed->l_buf && *(ed->l_line_end - 1) != '\\') { 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); show_prompt(ed); break; - case B_KEY_BACKSPACE: + case FX_KEY_BACKSPACE: backspace(ed); break; - case B_KEY_ARROW_LEFT: + case FX_KEY_ARROW_LEFT: cursor_left(ed); break; - case B_KEY_ARROW_RIGHT: + case FX_KEY_ARROW_RIGHT: cursor_right(ed); break; - case B_KEY_ARROW_UP: + case FX_KEY_ARROW_UP: arrow_up(ed); break; - case B_KEY_ARROW_DOWN: + case FX_KEY_ARROW_DOWN: arrow_down(ed); break; 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); 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; append_buf_to_history(ed); } 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); if (!last || strcmp(last, ed->l_buf) != 0) { diff --git a/frontend/line-ed/line-ed.h b/frontend/line-ed/line-ed.h index daf804c..4870e98 100644 --- a/frontend/line-ed/line-ed.h +++ b/frontend/line-ed/line-ed.h @@ -3,21 +3,21 @@ #define LINE_MAX 4096 -#include -#include -#include +#include +#include +#include #include #include struct s_tty; -struct b_tty_vmode; +struct fx_tty_vmode; struct line_ed; 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 *); - b_queue_entry hook_entry; + fx_queue_entry hook_entry; }; enum line_ed_flags { @@ -57,7 +57,7 @@ struct line_ed { struct ivy_line_source l_line_source; /* pointer to tty interface */ - b_tty *l_tty; + fx_tty *l_tty; /* the lexical scope that we are currently in. * this is provided by components further up the input pipeline, @@ -65,14 +65,14 @@ struct line_ed { const char *l_scope_type; /* array of previously entered commands */ - b_array *l_history; + fx_array *l_history; /* index of the currently selected history entry */ size_t l_history_pos; /* list of defined highlight ranges */ - b_queue l_hl_ranges; + fx_queue l_hl_ranges; /* list of installed hooks */ - b_queue l_hooks; + fx_queue l_hooks; }; 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( 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_print_highlights(struct line_ed *ed); diff --git a/frontend/line-ed/refresh.c b/frontend/line-ed/refresh.c index 6917056..0050aa3 100644 --- a/frontend/line-ed/refresh.c +++ b/frontend/line-ed/refresh.c @@ -5,7 +5,7 @@ #include "buffer.h" #include "cursor.h" #include "hl-range.h" -#include +#include /* 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 @@ -16,12 +16,12 @@ */ 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); for (size_t i = 0; s[i] != '\n' && s[i] != '\0'; i++) { if (!cur_range) { - b_tty_reset_vmode(tty); + fx_tty_reset_vmode(tty); fputc(s[i], stdout); 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 (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; @@ -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 * was just inserted. */ 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 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 * from the screen. */ //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) { /* next, move the physical cursor up and to the beginning of the previous line */ size_t tmp_x; 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); - b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_START, tmp_x); + fx_tty_move_cursor_y(ed->l_tty, FX_TTY_POS_CURSOR, -1); + fx_tty_move_cursor_x(ed->l_tty, FX_TTY_POS_START, tmp_x); //fprintf(stdout, "\033[A\033[%uG", tmp_x + 1); start_x = 0; } else { /* next, move the physical cursor up and to the end of the previous line */ //fprintf(stdout, "\033[A\033[%uG", new_x); - b_tty_move_cursor_y(ed->l_tty, B_TTY_POS_CURSOR, -1); - b_tty_move_cursor_x(ed->l_tty, B_TTY_POS_START, new_x); + fx_tty_move_cursor_y(ed->l_tty, FX_TTY_POS_CURSOR, -1); + 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 @@ -202,11 +202,11 @@ void backspace_nl_refresh(struct line_ed *ed, struct refresh_state *state) * were concatenated. */ if (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); - 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); } @@ -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 (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; } //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); 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) */ 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 for (unsigned int i = 0; i < cursor_rdelta; i++) { diff --git a/frontend/main.c b/frontend/main.c index f0bbbb7..4a7aad9 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -1,8 +1,8 @@ #include "cmd/cmd.h" -#include +#include int main(int argc, const char **argv) { - return b_command_dispatch(CMD_ROOT, argc, argv); + return fx_command_dispatch(CMD_ROOT, argc, argv); } diff --git a/lang/CMakeLists.txt b/lang/CMakeLists.txt index eba1caf..23a4e53 100644 --- a/lang/CMakeLists.txt +++ b/lang/CMakeLists.txt @@ -11,5 +11,5 @@ else () endif () 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}) diff --git a/lang/ast/atom.c b/lang/ast/atom.c index 6ccf9e6..f558c1c 100644 --- a/lang/ast/atom.c +++ b/lang/ast/atom.c @@ -1,13 +1,13 @@ #include "ctx.h" #include "node.h" -#include +#include -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; - b_string_append_cstrf( + fx_string_append_cstrf( str, "%s (%s)", ivy_ast_node_type_to_string(node->n_type), v->n_content->t_str); } diff --git a/lang/ast/block.c b/lang/ast/block.c index 1ac741e..5c0d935 100644 --- a/lang/ast/block.c +++ b/lang/ast/block.c @@ -5,7 +5,7 @@ #include "iterate.h" #include "node.h" -#include +#include #include 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 *)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; } @@ -143,12 +143,12 @@ static void collect_children( struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator) { 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) { 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); - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } } diff --git a/lang/ast/cascade.c b/lang/ast/cascade.c index 323f746..4bfd963 100644 --- a/lang/ast/cascade.c +++ b/lang/ast/cascade.c @@ -11,12 +11,12 @@ static void collect_children( 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) { 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); - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } } diff --git a/lang/ast/class.c b/lang/ast/class.c index 457142a..9de9cc8 100644 --- a/lang/ast/class.c +++ b/lang/ast/class.c @@ -2,7 +2,7 @@ #include "iterate.h" #include "node.h" -#include +#include #include #include @@ -130,10 +130,10 @@ static enum ivy_status add_child( switch (child->n_type) { 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; 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; default: return IVY_ERR_NOT_SUPPORTED; @@ -142,11 +142,11 @@ static enum ivy_status add_child( 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; - b_string_append_cstrf( + fx_string_append_cstrf( str, "%s (%s)", ivy_ast_node_type_to_string(node->n_type), 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_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) { 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); - 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) { 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); - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } } diff --git a/lang/ast/cond.c b/lang/ast/cond.c index 58e303d..f500d3a 100644 --- a/lang/ast/cond.c +++ b/lang/ast/cond.c @@ -8,7 +8,7 @@ struct cond_group_parser_state { unsigned int s_prev_token; struct ivy_ast_cond_node *s_cur_branch; - b_queue s_branches; + fx_queue s_branches; 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; } - 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 = (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); group->n_branches = state->s_branches; - state->s_branches = B_QUEUE_INIT; + state->s_branches = FX_QUEUE_INIT; return IVY_OK; } else { /* 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); group->n_branches = state->s_branches; - state->s_branches = B_QUEUE_INIT; + state->s_branches = FX_QUEUE_INIT; 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 *)node; - b_queue_entry *entry = b_queue_first(&group->n_branches); + fx_queue_entry *entry = fx_queue_first(&group->n_branches); while (entry) { 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); - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } } diff --git a/lang/ast/ctx.c b/lang/ast/ctx.c index 68beade..8df5dd2 100644 --- a/lang/ast/ctx.c +++ b/lang/ast/ctx.c @@ -3,7 +3,7 @@ #include "../debug.h" #include "node.h" -#include +#include #include #include #include @@ -14,10 +14,10 @@ #ifdef IVY_LANG_DEBUG static void print_state_stack(struct ivy_parser *parser) { - b_queue_iterator it = {0}; - b_queue_foreach (&it, &parser->p_state) { + fx_queue_iterator it = {0}; + fx_queue_foreach (&it, &parser->p_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( " %s\n", 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; - b_queue_entry *entry = b_queue_first(&parser->p_state); + fx_queue_entry *entry = fx_queue_first(&parser->p_state); ; while (entry) { struct parser_state *state - = b_unbox(struct parser_state, entry, s_entry); - b_queue_entry *next = b_queue_next(entry); - b_queue_delete(&parser->p_state, entry); + = fx_unbox(struct parser_state, entry, s_entry); + fx_queue_entry *next = fx_queue_next(entry); + fx_queue_delete(&parser->p_state, entry); if (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) { - b_queue_entry *entry = b_queue_last(&parser->p_state); + fx_queue_entry *entry = fx_queue_last(&parser->p_state); if (!entry) { 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; } struct parser_state *parser_get_parent_state_generic( 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) { return NULL; } - entry = b_queue_prev(entry); + entry = fx_queue_prev(entry); if (!entry) { 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) { return NULL; @@ -219,15 +219,15 @@ struct parser_state *parser_push_state( 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) { - struct parser_state *current_state = b_unbox( + struct parser_state *current_state = fx_unbox( struct parser_state, current_state_entry, s_entry); state->s_parent = current_state->s_node; } 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) { 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; } - b_queue_entry *entry = b_queue_last(&parser->p_state); - struct parser_state *state = b_unbox(struct parser_state, entry, s_entry); - b_queue_pop_back(&parser->p_state); + fx_queue_entry *entry = fx_queue_last(&parser->p_state); + struct parser_state *state = fx_unbox(struct parser_state, entry, s_entry); + fx_queue_pop_back(&parser->p_state); if (state && state->s_node && (flags & STATE_ADD_NODE_TO_PARENT)) { 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) { - b_queue_entry *entry = b_queue_first(&parser->p_state); - struct parser_state *state = b_unbox(struct parser_state, entry, s_entry); + fx_queue_entry *entry = fx_queue_first(&parser->p_state); + struct parser_state *state = fx_unbox(struct parser_state, entry, s_entry); return state ? state->s_node : NULL; } struct ivy_ast_node *ivy_parser_dequeue_node(struct ivy_parser *parser) { - b_queue_entry *entry = b_queue_first(&parser->p_state); - struct parser_state *state = b_unbox(struct parser_state, entry, s_entry); + fx_queue_entry *entry = fx_queue_first(&parser->p_state); + struct parser_state *state = fx_unbox(struct parser_state, entry, s_entry); if (!state) { 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; - entry = b_queue_pop_front(&unit->n_children); + entry = fx_queue_pop_front(&unit->n_children); if (!entry) { 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( diff --git a/lang/ast/ctx.h b/lang/ast/ctx.h index 475563d..f81bf40 100644 --- a/lang/ast/ctx.h +++ b/lang/ast/ctx.h @@ -1,7 +1,7 @@ #ifndef _AST_CTX_H_ #define _AST_CTX_H_ -#include +#include #include #include #include @@ -14,7 +14,7 @@ ((state_type *)parser_get_parent_state_generic(parser, type_id)) struct parser_state { - b_queue_entry s_entry; + fx_queue_entry s_entry; struct ivy_ast_node *s_parent; struct ivy_ast_node *s_node; }; @@ -22,9 +22,9 @@ struct parser_state { struct ivy_parser { enum ivy_status p_status; struct ivy_diag_ctx *p_diag_ctx; - b_queue p_state; - b_queue p_token_queue; - b_queue p_node_queue; + fx_queue p_state; + fx_queue p_token_queue; + fx_queue p_node_queue; }; enum pop_state_flags { diff --git a/lang/ast/double.c b/lang/ast/double.c index c9664d5..e663aa9 100644 --- a/lang/ast/double.c +++ b/lang/ast/double.c @@ -1,13 +1,13 @@ #include "ctx.h" #include "node.h" -#include +#include -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; - b_string_append_cstrf( + fx_string_append_cstrf( str, "%s (%.2lf)", ivy_ast_node_type_to_string(node->n_type), v->n_value->t_double); } diff --git a/lang/ast/expr/arith.c b/lang/ast/expr/arith.c index 0e86906..fa347ea 100644 --- a/lang/ast/expr/arith.c +++ b/lang/ast/expr/arith.c @@ -3,7 +3,7 @@ #include "../node.h" #include "expr.h" -#include +#include #include #include #include @@ -63,7 +63,7 @@ enum ivy_status arith_push_operand( IVY_AST_IDENT); v->n_content = 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; } 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); v->n_value = 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; } case IVY_TOK_DOUBLE: { @@ -80,7 +80,7 @@ enum ivy_status arith_push_operand( IVY_AST_DOUBLE); v->n_value = 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; } 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); v->n_content = 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; } case IVY_TOK_STRING: { @@ -97,7 +97,7 @@ enum ivy_status arith_push_operand( IVY_AST_STRING); v->n_value = 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; } 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); 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; } 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); - b_queue_push_back(&state->s_output_queue, &v->n_entry); + fx_queue_push_back(&state->s_output_queue, &v->n_entry); break; } default: @@ -204,20 +204,20 @@ static struct ivy_ast_node *create_operator_node_from_token(struct ivy_token *to #ifdef IVY_LANG_DEBUG static void print_expr_queues(struct expr_parser_state *state) { - b_queue_iterator it = {0}; + fx_queue_iterator it = {0}; debug_printf("operators:"); - b_queue_foreach (&it, &state->s_operator_stack) { + fx_queue_foreach (&it, &state->s_operator_stack) { 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(" "); print_operand(n); } debug_printf("\noperands:"); - b_queue_foreach (&it, &state->s_output_queue) { + fx_queue_foreach (&it, &state->s_output_queue) { 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(" "); print_operand(n); } @@ -234,13 +234,13 @@ void arith_push_operator(struct expr_parser_state *state, struct ivy_ast_node *n } 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) { break; } 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; switch (top_node->n_type) { @@ -266,11 +266,11 @@ void arith_push_operator(struct expr_parser_state *state, struct ivy_ast_node *n break; } - b_queue_delete(&state->s_operator_stack, top); - b_queue_push_back(&state->s_output_queue, top); + fx_queue_delete(&state->s_operator_stack, 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 print_expr_queues(state); #endif @@ -296,7 +296,7 @@ enum ivy_status expr_finalise_arith( struct expr_parser_state *state, struct ivy_ast_node **expr_tree, 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 * 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, * we don't have to handle parentheses here */ while (true) { - entry = b_queue_pop_back(&state->s_operator_stack); + entry = fx_queue_pop_back(&state->s_operator_stack); if (!entry) { break; } 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) { /* this should never happen */ 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 * then leave them on the stack and stop here. */ 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; } - b_queue_push_back(&state->s_output_queue, entry); + fx_queue_push_back(&state->s_output_queue, entry); } #if 0 @@ -353,22 +353,22 @@ enum ivy_status expr_finalise_arith( * always follow their operands, so a queue of operands is needed * for the conversion. */ - b_queue q = B_QUEUE_INIT; - b_queue_entry *tmp = NULL; - entry = b_queue_first(&state->s_output_queue); + fx_queue q = FX_QUEUE_INIT; + fx_queue_entry *tmp = NULL; + entry = fx_queue_first(&state->s_output_queue); int i = 0; while (entry) { struct ivy_ast_node *item - = b_unbox(struct ivy_ast_node, entry, n_entry); - b_queue_entry *next = b_queue_next(entry); - b_queue_delete(&state->s_output_queue, entry); + = fx_unbox(struct ivy_ast_node, entry, n_entry); + fx_queue_entry *next = fx_queue_next(entry); + fx_queue_delete(&state->s_output_queue, entry); /* if the node is an operand, just push it to a temporary queue * and come back to it later. */ if (item->n_type != IVY_AST_OP && item->n_type != IVY_AST_MSG) { /* operand */ - b_queue_push_back(&q, &item->n_entry); + fx_queue_push_back(&q, &item->n_entry); goto next; } @@ -384,11 +384,11 @@ enum ivy_status expr_finalise_arith( * self-contained keyword message, and can be pushed to * the operand queue as-is. */ if (!msg->n_recipient) { - tmp = b_queue_pop_back(&q); - msg->n_recipient = b_unbox( + tmp = fx_queue_pop_back(&q); + msg->n_recipient = fx_unbox( 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; } @@ -397,15 +397,15 @@ enum ivy_status expr_finalise_arith( * all the operands it needs, it can be pushed to the operand * queue as-is */ 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; } /* otherwise, pop the relevant operands from the operand * queue... */ op = op_node->n_op; - tmp = b_queue_pop_back(&q); - op_node->n_right = b_unbox(struct ivy_ast_node, tmp, n_entry); + tmp = fx_queue_pop_back(&q); + op_node->n_right = fx_unbox(struct ivy_ast_node, tmp, n_entry); if (op_node->n_right) { 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) { - tmp = b_queue_pop_back(&q); + tmp = fx_queue_pop_back(&q); 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) { 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 * queue */ - b_queue_push_back(&q, &op_node->n_base.n_entry); + fx_queue_push_back(&q, &op_node->n_base.n_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 * used above. move them back to the parser state's output queue here * so they can be used later. */ - entry = b_queue_first(&state->s_operator_stack); + entry = fx_queue_first(&state->s_operator_stack); while (entry) { - b_queue_entry *entry2 = b_queue_pop_front(&q); + fx_queue_entry *entry2 = fx_queue_pop_front(&q); if (!entry2) { return IVY_ERR_INTERNAL_FAILURE; } - b_queue_push_back(&state->s_output_queue, entry2); - entry = b_queue_next(entry); + fx_queue_push_back(&state->s_output_queue, entry2); + entry = fx_queue_next(entry); } #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 * of the new expression tree */ - tmp = b_queue_pop_back(&q); - *expr_tree = b_unbox(struct ivy_ast_node, tmp, n_entry); + tmp = fx_queue_pop_back(&q); + *expr_tree = fx_unbox(struct ivy_ast_node, tmp, n_entry); return IVY_OK; } @@ -521,7 +521,7 @@ struct token_parse_result arith_parse_operand( memset(empty_label, 0x0, sizeof *empty_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 *)parser_push_state( @@ -695,9 +695,9 @@ struct token_parse_result arith_parse_left_paren( if (state->s_prev_token == IVY_TOK_IDENT) { /* 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 - = 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) { /* 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; } - 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 *)parser_push_state( @@ -761,7 +761,7 @@ not_complex_msg: memset(empty_label, 0x0, sizeof *empty_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 *)parser_push_state( @@ -908,21 +908,21 @@ struct token_parse_result arith_parse_right_bracket( 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 *)ast_node_create(IVY_AST_SELECTOR); - b_queue_entry *entry = b_queue_first(labels); - b_queue_entry *next = NULL; + fx_queue_entry *entry = fx_queue_first(labels); + fx_queue_entry *next = NULL; while (entry) { struct ivy_token *label - = b_unbox(struct ivy_token, entry, t_entry); - next = b_queue_next(entry); - b_queue_delete(labels, entry); + = fx_unbox(struct ivy_token, entry, t_entry); + next = fx_queue_next(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; } @@ -937,16 +937,16 @@ static struct ivy_ast_cascade_node *expr_finalise_cascade( cascade->n_recipient = state->s_recipient; - b_queue_entry *entry = b_queue_first(&state->s_cascade_msg); - b_queue_entry *next = NULL; + fx_queue_entry *entry = fx_queue_first(&state->s_cascade_msg); + fx_queue_entry *next = NULL; while (entry) { struct ivy_ast_node *msg - = b_unbox(struct ivy_ast_node, entry, n_entry); - next = b_queue_next(entry); - b_queue_delete(&state->s_cascade_msg, entry); + = fx_unbox(struct ivy_ast_node, entry, n_entry); + next = fx_queue_next(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; } @@ -962,16 +962,16 @@ static struct ivy_ast_msg_node *expr_finalise_keyword_msg( msg->n_recipient = state->s_recipient; msg->n_sel = keyword_selector_from_label_list(&state->s_labels); - b_queue_entry *entry = b_queue_first(&state->s_args); - b_queue_entry *next = NULL; + fx_queue_entry *entry = fx_queue_first(&state->s_args); + fx_queue_entry *next = NULL; while (entry) { struct ivy_ast_node *arg - = b_unbox(struct ivy_ast_node, entry, n_entry); - next = b_queue_next(entry); - b_queue_delete(&state->s_args, entry); + = fx_unbox(struct ivy_ast_node, entry, n_entry); + next = fx_queue_next(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; } @@ -988,26 +988,26 @@ static struct ivy_ast_msg_node *expr_finalise_complex_msg( state->s_msg = NULL; - b_queue_entry *entry = b_queue_first(&state->s_labels); - b_queue_entry *next = NULL; + fx_queue_entry *entry = fx_queue_first(&state->s_labels); + fx_queue_entry *next = NULL; while (entry) { struct ivy_token *label - = b_unbox(struct ivy_token, entry, t_entry); - next = b_queue_next(entry); - b_queue_delete(&state->s_labels, entry); - b_queue_push_back(&msg->n_sel->n_arg_labels, &label->t_entry); + = fx_unbox(struct ivy_token, entry, t_entry); + next = fx_queue_next(entry); + fx_queue_delete(&state->s_labels, entry); + fx_queue_push_back(&msg->n_sel->n_arg_labels, &label->t_entry); entry = next; } - entry = b_queue_first(&state->s_args); + entry = fx_queue_first(&state->s_args); while (entry) { struct ivy_ast_node *arg - = b_unbox(struct ivy_ast_node, entry, n_entry); - next = b_queue_next(entry); - b_queue_delete(&state->s_args, entry); + = fx_unbox(struct ivy_ast_node, entry, n_entry); + next = fx_queue_next(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; } @@ -1032,9 +1032,9 @@ static enum ivy_status begin_cascade_operation(struct ivy_parser *ctx) enum ivy_operator_precedence min_precedence = IVY_PRECEDENCE_CASCADE; - struct ivy_ast_node *prev = b_unbox( + struct ivy_ast_node *prev = fx_unbox( 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) { /* unary complex messages (which will be found on the * 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_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 *)parser_push_state( @@ -1338,8 +1338,8 @@ struct token_parse_result arith_parse_caret( return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); } - if (!b_queue_empty(&state->s_operator_stack) - || !b_queue_empty(&state->s_output_queue)) { + if (!fx_queue_empty(&state->s_operator_stack) + || !fx_queue_empty(&state->s_output_queue)) { 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 - && b_queue_empty(&state->s_output_queue) - && b_queue_empty(&state->s_operator_stack)) { + && fx_queue_empty(&state->s_output_queue) + && fx_queue_empty(&state->s_operator_stack)) { parser_pop_state(ctx, 0); } else { /* 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; bool new_parser = true; - if (b_queue_empty(&state->s_operator_stack) - && b_queue_empty(&state->s_output_queue)) { + if (fx_queue_empty(&state->s_operator_stack) + && fx_queue_empty(&state->s_output_queue)) { new_parser = false; } @@ -1498,7 +1498,7 @@ struct token_parse_result arith_parse_label( 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 *)parser_push_state( @@ -1511,7 +1511,7 @@ struct token_parse_result arith_parse_label( /* we may have just finished parsing a keyword-message argument, * and this label marks the start of a new one. store the label * 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 *)parser_push_state( @@ -1532,16 +1532,16 @@ enum ivy_status arith_add_child( if (state->s_sub_type == EXPR_SUBTYPE_CASCADE) { /* 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 ( state->s_sub_type == EXPR_SUBTYPE_KEYWORD_MSG || state->s_sub_type == EXPR_SUBTYPE_COMPLEX_MSG) { /* 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) { /* treat the child node as a sub-expression enclosed in * 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; } else if (child->n_type == IVY_AST_MSG) { arith_push_operator(state, child); @@ -1549,7 +1549,7 @@ enum ivy_status arith_add_child( } else { /* treat the child node as a sub-expression enclosed in * 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; } diff --git a/lang/ast/expr/expr.h b/lang/ast/expr/expr.h index 99160d2..c86bed9 100644 --- a/lang/ast/expr/expr.h +++ b/lang/ast/expr/expr.h @@ -4,7 +4,7 @@ #include "../ctx.h" #include "../node.h" -#include +#include #define EXPR_TERMINATOR_MAX 8 @@ -76,19 +76,19 @@ struct expr_parser_state { unsigned short s_terminators[EXPR_TERMINATOR_MAX]; unsigned short s_nr_terminators; - b_queue s_output_queue; - b_queue s_operator_stack; + fx_queue s_output_queue; + fx_queue s_operator_stack; /* these variables are for keyword-message expressions */ struct ivy_ast_node *s_recipient; struct ivy_ast_msg_node *s_msg; - b_queue s_labels; + fx_queue s_labels; union { /* 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. */ - b_queue s_cascade_msg; + fx_queue s_cascade_msg; }; }; diff --git a/lang/ast/expr/stmt.c b/lang/ast/expr/stmt.c index 290f463..4b4926c 100644 --- a/lang/ast/expr/stmt.c +++ b/lang/ast/expr/stmt.c @@ -1,7 +1,7 @@ #include "../node.h" #include "expr.h" -#include +#include #include #include #include @@ -27,8 +27,8 @@ struct token_parse_result stmt_parse_try( state->s_prev_token = IVY_KW_TRY; - if (b_queue_empty(&state->s_operator_stack) - && b_queue_empty(&state->s_output_queue)) { + if (fx_queue_empty(&state->s_operator_stack) + && fx_queue_empty(&state->s_output_queue)) { parser_pop_state(ctx, 0); } @@ -71,8 +71,8 @@ struct token_parse_result stmt_parse_for( state->s_prev_token = IVY_KW_FOR; - if (b_queue_empty(&state->s_operator_stack) - && b_queue_empty(&state->s_output_queue)) { + if (fx_queue_empty(&state->s_operator_stack) + && fx_queue_empty(&state->s_output_queue)) { parser_pop_state(ctx, 0); } @@ -107,8 +107,8 @@ struct token_parse_result stmt_parse_while( state->s_prev_token = IVY_KW_WHILE; - if (b_queue_empty(&state->s_operator_stack) - && b_queue_empty(&state->s_output_queue)) { + if (fx_queue_empty(&state->s_operator_stack) + && fx_queue_empty(&state->s_output_queue)) { parser_pop_state(ctx, 0); } @@ -140,8 +140,8 @@ struct token_parse_result stmt_parse_match( state->s_prev_token = IVY_KW_MATCH; - if (b_queue_empty(&state->s_operator_stack) - && b_queue_empty(&state->s_output_queue)) { + if (fx_queue_empty(&state->s_operator_stack) + && fx_queue_empty(&state->s_output_queue)) { parser_pop_state(ctx, 0); } @@ -186,8 +186,8 @@ struct token_parse_result stmt_parse_if( state->s_prev_token = IVY_KW_IF; - if (b_queue_empty(&state->s_operator_stack) - && b_queue_empty(&state->s_output_queue)) { + if (fx_queue_empty(&state->s_operator_stack) + && fx_queue_empty(&state->s_output_queue)) { parser_pop_state(ctx, 0); } diff --git a/lang/ast/ident.c b/lang/ast/ident.c index 1922975..9efb3c2 100644 --- a/lang/ast/ident.c +++ b/lang/ast/ident.c @@ -1,13 +1,13 @@ #include "ctx.h" #include "node.h" -#include +#include -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; - b_string_append_cstrf( + fx_string_append_cstrf( str, "%s (%s)", ivy_ast_node_type_to_string(node->n_type), ident->n_content->t_str); } diff --git a/lang/ast/int.c b/lang/ast/int.c index 1ac1626..203a44d 100644 --- a/lang/ast/int.c +++ b/lang/ast/int.c @@ -1,13 +1,13 @@ #include "ctx.h" #include "node.h" -#include +#include -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; - b_string_append_cstrf( + fx_string_append_cstrf( str, "%s (%llu)", ivy_ast_node_type_to_string(node->n_type), v->n_value->t_int); } diff --git a/lang/ast/iterate.c b/lang/ast/iterate.c index 05a8d36..81e8986 100644 --- a/lang/ast/iterate.c +++ b/lang/ast/iterate.c @@ -7,14 +7,14 @@ enum ivy_status iterate_regular( ivy_ast_node_iteration_callback callback) { #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; - while (!b_queue_empty(&it->it_queue)) { - b_queue_entry *entry = b_queue_first(&it->it_queue); - struct ivy_ast_node_iterator_entry *it_entry = b_unbox( + while (!fx_queue_empty(&it->it_queue)) { + fx_queue_entry *entry = fx_queue_first(&it->it_queue); + struct ivy_ast_node_iterator_entry *it_entry = fx_unbox( 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) { /* this should never happen. */ @@ -32,7 +32,7 @@ enum ivy_status iterate_regular( type->n_collect_children(node, it); } - b_queue_delete(&it->it_queue, entry); + fx_queue_delete(&it->it_queue, entry); } #endif @@ -60,15 +60,15 @@ enum ivy_status iterate_postorder( * - should probably use this just for the executable parts of the AST, * 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; - b_queue_entry *entry = b_queue_first(&it->it_queue); + fx_queue_entry *entry = fx_queue_first(&it->it_queue); 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); - node = b_unbox(struct ivy_ast_node, it_entry, n_it); + node = fx_unbox(struct ivy_ast_node, it_entry, n_it); if (!node) { /* this should never happen. */ @@ -81,16 +81,16 @@ enum ivy_status iterate_postorder( type->n_collect_children(node, it); } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } - while (!b_queue_empty(&it->it_queue)) { - b_queue_entry *entry = b_queue_pop_back(&it->it_queue); + while (!fx_queue_empty(&it->it_queue)) { + fx_queue_entry *entry = fx_queue_pop_back(&it->it_queue); if (!entry) { break; } - node = b_unbox(struct ivy_ast_node, entry, n_it); + node = fx_unbox(struct ivy_ast_node, entry, n_it); if (!node) { /* 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, 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; - b_queue_entry *entry = b_queue_first(&it->it_queue); + fx_queue_entry *entry = fx_queue_first(&it->it_queue); 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); - node = b_unbox(struct ivy_ast_node, it_entry, n_it); + node = fx_unbox(struct ivy_ast_node, it_entry, n_it); if (!node) { /* this should never happen. */ @@ -134,16 +134,16 @@ enum ivy_status ivy_ast_node_iterate( type->n_collect_children(node, it); } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } - while (!b_queue_empty(&it->it_queue)) { - b_queue_entry *entry = b_queue_pop_back(&it->it_queue); + while (!fx_queue_empty(&it->it_queue)) { + fx_queue_entry *entry = fx_queue_pop_back(&it->it_queue); if (!entry) { break; } - node = b_unbox(struct ivy_ast_node, entry, n_it); + node = fx_unbox(struct ivy_ast_node, entry, n_it); if (!node) { /* this should never happen. */ @@ -165,10 +165,10 @@ void ast_node_iterator_enqueue_node( struct ivy_ast_node *node) { 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); } 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; diff --git a/lang/ast/lambda.c b/lang/ast/lambda.c index a509657..b5ed476 100644 --- a/lang/ast/lambda.c +++ b/lang/ast/lambda.c @@ -11,7 +11,7 @@ struct lambda_parser_state { struct ivy_ast_node *s_prev_node; unsigned int s_prev; - b_queue s_args; + fx_queue s_args; struct ivy_ast_node *s_body; }; @@ -56,7 +56,7 @@ static struct token_parse_result parse_ident( } 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; 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_body = state->s_body; - state->s_args = B_QUEUE_INIT; + state->s_args = FX_QUEUE_INIT; 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_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) { 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); - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } if (lambda->n_body) { diff --git a/lang/ast/loop-control.c b/lang/ast/loop-control.c index ea2f795..99c55e2 100644 --- a/lang/ast/loop-control.c +++ b/lang/ast/loop-control.c @@ -1,11 +1,11 @@ #include "ctx.h" #include "node.h" -#include +#include -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 = { diff --git a/lang/ast/match.c b/lang/ast/match.c index 0295e7e..65e6356 100644 --- a/lang/ast/match.c +++ b/lang/ast/match.c @@ -9,7 +9,7 @@ struct match_parser_state { struct ivy_ast_node *s_cond; struct ivy_ast_cond_node *s_cur_branch; - b_queue s_branches; + fx_queue s_branches; 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; } - 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 = (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_branches = state->s_branches; - state->s_branches = B_QUEUE_INIT; + state->s_branches = FX_QUEUE_INIT; return IVY_OK; } @@ -262,10 +262,10 @@ static void match_collect_children( 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) { 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); } } diff --git a/lang/ast/msg.c b/lang/ast/msg.c index 343d635..81c28cf 100644 --- a/lang/ast/msg.c +++ b/lang/ast/msg.c @@ -16,12 +16,12 @@ static void collect_children( 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) { 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); - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } } diff --git a/lang/ast/msgh.c b/lang/ast/msgh.c index 5c1bc14..3152a09 100644 --- a/lang/ast/msgh.c +++ b/lang/ast/msgh.c @@ -4,7 +4,7 @@ #include "ivy/status.h" #include "node.h" -#include +#include #include struct msgh_parser_state { diff --git a/lang/ast/node.c b/lang/ast/node.c index 2cd7408..10f1206 100644 --- a/lang/ast/node.c +++ b/lang/ast/node.c @@ -1,6 +1,6 @@ #include "node.h" -#include +#include #include #include #include @@ -250,7 +250,7 @@ struct ivy_ast_node *ast_node_create(enum ivy_ast_node_type type) 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); 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) { type_info->n_to_string(node, out); } else { - b_string_append_cstr( + fx_string_append_cstr( 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) { 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; - b_queue_entry *entry = b_queue_first(&it.it_queue); + fx_queue_entry *entry = fx_queue_first(&it.it_queue); 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); - node = b_unbox(struct ivy_ast_node, it_entry, n_it); + node = fx_unbox(struct ivy_ast_node, it_entry, n_it); if (!node) { /* this should never happen. */ @@ -322,16 +322,16 @@ void ivy_ast_node_destroy(struct ivy_ast_node *node) type->n_collect_children(node, &it); } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } - while (!b_queue_empty(&it.it_queue)) { - b_queue_entry *entry = b_queue_pop_back(&it.it_queue); + while (!fx_queue_empty(&it.it_queue)) { + fx_queue_entry *entry = fx_queue_pop_back(&it.it_queue); if (!entry) { 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); 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) { - 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) { - b_queue_entry *entry = b_queue_pop_front(&unit->n_children); + fx_queue_entry *entry = fx_queue_pop_front(&unit->n_children); if (!entry) { return NULL; } - return b_unbox(struct ivy_ast_node, entry, n_entry); + return fx_unbox(struct ivy_ast_node, entry, n_entry); } diff --git a/lang/ast/node.h b/lang/ast/node.h index 2b4b1b3..a089967 100644 --- a/lang/ast/node.h +++ b/lang/ast/node.h @@ -1,7 +1,7 @@ #ifndef _AST_NODE_H_ #define _AST_NODE_H_ -#include +#include #include #include @@ -47,7 +47,7 @@ typedef struct token_parse_result (*token_parse_function)( struct ast_node_type { enum ivy_status (*n_add_child)( 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_collect_children)( struct ivy_ast_node *, struct ivy_ast_node_iterator *); diff --git a/lang/ast/op.c b/lang/ast/op.c index 96bfb9f..9b7505e 100644 --- a/lang/ast/op.c +++ b/lang/ast/op.c @@ -2,13 +2,13 @@ #include "iterate.h" #include "node.h" -#include +#include -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; - b_string_append_cstrf( + fx_string_append_cstrf( str, "%s (%s)", ivy_ast_node_type_to_string(node->n_type), ivy_operator_id_to_string(op->n_op->op_id)); } diff --git a/lang/ast/package.c b/lang/ast/package.c index b680ca1..4021e77 100644 --- a/lang/ast/package.c +++ b/lang/ast/package.c @@ -4,7 +4,7 @@ #include "iterate.h" #include "node.h" -#include +#include #include enum package_type { @@ -23,7 +23,7 @@ struct package_parser_state { unsigned int s_prev; /* only used for PACKAGE_STATIC */ - b_queue s_items; + fx_queue s_items; struct ivy_ast_node *s_next_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++; } - 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_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; - state->s_items = B_QUEUE_INIT; + state->s_items = FX_QUEUE_INIT; return (struct ivy_ast_node *)s; case PACKAGE_DYNAMIC: 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 *)node; - b_queue_entry *entry = b_queue_first(&pkg->n_items); + fx_queue_entry *entry = fx_queue_first(&pkg->n_items); while (entry) { 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); - 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 *)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) { - b_string_append_cstrf(str, " (%u)", item->n_implicit_index); + fx_string_append_cstrf(str, " (%u)", item->n_implicit_index); } } diff --git a/lang/ast/property.c b/lang/ast/property.c index 3762d51..ce5094c 100644 --- a/lang/ast/property.c +++ b/lang/ast/property.c @@ -5,7 +5,7 @@ #include "ivy/status.h" #include "node.h" -#include +#include #include #include @@ -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; - b_string_append_cstrf( + fx_string_append_cstrf( str, "%s (%s) [", ivy_ast_node_type_to_string(node->n_type), prop->n_ident->t_str); 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) && 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) { - 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 = { diff --git a/lang/ast/selector.c b/lang/ast/selector.c index 77cd70b..e71fdc8 100644 --- a/lang/ast/selector.c +++ b/lang/ast/selector.c @@ -2,7 +2,7 @@ #include "ivy/status.h" #include "node.h" -#include +#include #include #include @@ -75,7 +75,7 @@ static struct token_parse_result parse_ident( if (state->s_prev == IVY_TOK_LABEL) { /* 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_complete = true; 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); } - 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_complete = false; @@ -119,7 +119,7 @@ static struct token_parse_result parse_linefeed( 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) { 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 *)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); } @@ -159,7 +159,7 @@ static struct token_parse_result parse_right_paren( struct ivy_ast_selector_node *sel = (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); } @@ -181,8 +181,8 @@ static struct token_parse_result parse_pipe( switch (state->s_prev) { case IVY_SYM_RIGHT_PAREN: /* this looks like a complex message selector */ - if (b_queue_empty(&sel->n_arg_labels) - || b_queue_empty(&sel->n_arg_names)) { + if (fx_queue_empty(&sel->n_arg_labels) + || fx_queue_empty(&sel->n_arg_names)) { /* no message args */ return PARSE_RESULT(IVY_ERR_BAD_SYNTAX, 0); } @@ -194,8 +194,8 @@ static struct token_parse_result parse_pipe( break; case IVY_TOK_IDENT: /* this looks like a unary or keyword message. */ - if (!b_queue_empty(&sel->n_arg_labels) - && b_queue_empty(&sel->n_arg_names)) { + if (!fx_queue_empty(&sel->n_arg_labels) + && fx_queue_empty(&sel->n_arg_names)) { /* keyword message with no arg names. */ 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); } -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; - b_string_append_cstrf( + fx_string_append_cstrf( str, "%s [", ivy_ast_node_type_to_string(node->n_type)); switch (sel->n_recipient) { case IVY_SELECTOR_RECIPIENT_CLASS: - b_string_append_cstr(str, "+"); + fx_string_append_cstr(str, "+"); break; case IVY_SELECTOR_RECIPIENT_OBJECT: - b_string_append_cstr(str, "-"); + fx_string_append_cstr(str, "-"); break; default: /* 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) { - 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)) { - b_string_append_cstr(str, "("); + if (sel->n_msg_name && !fx_queue_empty(&sel->n_arg_labels)) { + fx_string_append_cstr(str, "("); } - b_queue_entry *label_entry = b_queue_first(&sel->n_arg_labels); - b_queue_entry *name_entry = b_queue_first(&sel->n_arg_names); + fx_queue_entry *label_entry = fx_queue_first(&sel->n_arg_labels); + fx_queue_entry *name_entry = fx_queue_first(&sel->n_arg_names); int i = 0; while (label_entry) { if (i > 0) { - b_string_append_cstr(str, " "); + fx_string_append_cstr(str, " "); } struct ivy_token *label, *name; - label = b_unbox(struct ivy_token, label_entry, t_entry); - name = b_unbox(struct ivy_token, name_entry, t_entry); + label = fx_unbox(struct ivy_token, label_entry, t_entry); + name = fx_unbox(struct ivy_token, name_entry, t_entry); 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 { - b_string_append_cstrf(str, "_:"); + fx_string_append_cstrf(str, "_:"); } if (name) { - b_string_append_cstrf(str, "%s", name->t_str); + fx_string_append_cstrf(str, "%s", name->t_str); } if (name) { i++; } - label_entry = b_queue_next(label_entry); - name_entry = b_queue_next(name_entry); + label_entry = fx_queue_next(label_entry); + name_entry = fx_queue_next(name_entry); } - if (sel->n_msg_name && !b_queue_empty(&sel->n_arg_labels)) { - b_string_append_cstr(str, ")"); + if (sel->n_msg_name && !fx_queue_empty(&sel->n_arg_labels)) { + 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) diff --git a/lang/ast/string.c b/lang/ast/string.c index f5342fa..b990758 100644 --- a/lang/ast/string.c +++ b/lang/ast/string.c @@ -3,12 +3,12 @@ #include "iterate.h" #include "node.h" -#include +#include -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; - b_string_append_cstrf( + fx_string_append_cstrf( str, "%s (\"%s\")", ivy_ast_node_type_to_string(node->n_type), 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; - 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); } @@ -59,7 +59,7 @@ static enum ivy_status add_child( struct ivy_ast_fstring_node *str = (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; } @@ -68,12 +68,12 @@ static void collect_children( struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator) { 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) { 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); - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } } diff --git a/lang/ast/try.c b/lang/ast/try.c index 28491fb..d4ada82 100644 --- a/lang/ast/try.c +++ b/lang/ast/try.c @@ -10,13 +10,13 @@ struct try_parser_state { 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; }; 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_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_finally = NULL; - state->s_catch_branches = B_QUEUE_INIT; + state->s_catch_branches = FX_QUEUE_INIT; return IVY_OK; } @@ -236,12 +236,12 @@ static void try_collect_children( 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) { 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); - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } if (try->n_finally) { diff --git a/lang/ast/tuple.c b/lang/ast/tuple.c index 0166f11..c59facb 100644 --- a/lang/ast/tuple.c +++ b/lang/ast/tuple.c @@ -4,7 +4,7 @@ #include "ivy/status.h" #include "node.h" -#include +#include #include #include @@ -14,7 +14,7 @@ struct tuple_parser_state { struct ivy_ast_node *s_prev_node; unsigned int s_prev; - b_queue s_items; + fx_queue s_items; }; 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; 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) @@ -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); } - 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 = IVY_SYM_COMMA; @@ -69,7 +69,7 @@ struct token_parse_result parse_right_paren( 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 = IVY_SYM_RIGHT_PAREN; @@ -100,7 +100,7 @@ static void init_state(struct ivy_parser *ctx, struct parser_state *sp, uintptr_ if (arg) { /* arg is the first node in the tuple */ 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; } @@ -117,12 +117,12 @@ static void collect_children( { 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) { 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); - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } } diff --git a/lang/ast/unit-import.c b/lang/ast/unit-import.c index 5a6f2b0..f9d45df 100644 --- a/lang/ast/unit-import.c +++ b/lang/ast/unit-import.c @@ -1,7 +1,7 @@ #include "ctx.h" #include "node.h" -#include +#include #include #include @@ -37,7 +37,7 @@ static struct token_parse_result parse_ident( 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; return PARSE_RESULT(IVY_OK, 0); @@ -57,31 +57,31 @@ static struct token_parse_result parse_linefeed( 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 *)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; - b_queue_entry *entry = b_queue_first(&unit_import->n_ident); + fx_queue_entry *entry = fx_queue_first(&unit_import->n_ident); 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) { - 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++; - 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) diff --git a/lang/ast/unit-package.c b/lang/ast/unit-package.c index bb0a956..8561666 100644 --- a/lang/ast/unit-package.c +++ b/lang/ast/unit-package.c @@ -1,7 +1,7 @@ #include "ctx.h" #include "node.h" -#include +#include #include #include @@ -37,7 +37,7 @@ static struct token_parse_result parse_ident( 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; return PARSE_RESULT(IVY_OK, 0); @@ -57,30 +57,30 @@ static struct token_parse_result parse_linefeed( 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 *)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; - b_queue_entry *entry = b_queue_first(&unit_package->n_ident); + fx_queue_entry *entry = fx_queue_first(&unit_package->n_ident); 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) { - 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++; - 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) diff --git a/lang/ast/unit.c b/lang/ast/unit.c index 9f54838..02b5892 100644 --- a/lang/ast/unit.c +++ b/lang/ast/unit.c @@ -50,7 +50,7 @@ static enum ivy_status add_child( struct parser_state *parent, struct ivy_ast_node *child) { 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; } @@ -58,12 +58,12 @@ static void collect_children( struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator) { 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) { 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); - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } } diff --git a/lang/codegen/codegen.c b/lang/codegen/codegen.c index 38e60ac..49b1c2d 100644 --- a/lang/codegen/codegen.c +++ b/lang/codegen/codegen.c @@ -12,7 +12,7 @@ * - each node type (var, msg, expr) gets its own code generator type * - expr code generator is limited to simple operator arithmetic. * - when a code generator encounters a node of an equal or lower depth than - * the node that started it, it has reached the end of its subtree. + * the node that started it, it has reached the end of its subst. * - depth is supplied by the ast iterator. * - need to devise a way for expression code generator to "return" a * mie_value for its parent generator to use. @@ -21,12 +21,12 @@ static struct code_generator_state *get_current_generator_state( struct ivy_codegen *gen) { - b_queue_entry *entry = b_queue_last(&gen->c_state); + fx_queue_entry *entry = fx_queue_last(&gen->c_state); if (!entry) { return NULL; } - return b_unbox(struct code_generator_state, entry, s_entry); + return fx_unbox(struct code_generator_state, entry, s_entry); } static void code_generator_state_inherit( @@ -76,7 +76,7 @@ enum ivy_status codegen_push_generator( return status; } - b_queue_push_back(&gen->c_state, &state->s_entry); + fx_queue_push_back(&gen->c_state, &state->s_entry); return IVY_OK; } @@ -84,13 +84,13 @@ enum ivy_status codegen_push_generator( enum ivy_status codegen_pop_generator( struct ivy_codegen *gen, struct code_generator_value *result) { - b_queue_entry *entry = b_queue_pop_back(&gen->c_state); + fx_queue_entry *entry = fx_queue_pop_back(&gen->c_state); if (!entry) { return IVY_ERR_BAD_STATE; } struct code_generator_state *state - = b_unbox(struct code_generator_state, entry, s_entry); + = fx_unbox(struct code_generator_state, entry, s_entry); enum ivy_status status = IVY_OK; @@ -109,7 +109,7 @@ enum ivy_status codegen_pop_generator( enum ivy_status codegen_define_variable( struct ivy_codegen *gen, const char *ident, const struct codegen_var *var) { - b_queue_entry *entry = b_queue_last(&gen->c_state); + fx_queue_entry *entry = fx_queue_last(&gen->c_state); if (!entry) { return IVY_ERR_NO_ENTRY; } @@ -118,7 +118,7 @@ enum ivy_status codegen_define_variable( while (entry) { struct code_generator_state *state - = b_unbox(struct code_generator_state, entry, s_entry); + = fx_unbox(struct code_generator_state, entry, s_entry); const struct code_generator *generator = state->s_gen; enum ivy_status status = IVY_ERR_NO_ENTRY; @@ -130,7 +130,7 @@ enum ivy_status codegen_define_variable( break; } - entry = b_queue_prev(entry); + entry = fx_queue_prev(entry); } return IVY_ERR_NOT_SUPPORTED; @@ -155,7 +155,7 @@ enum ivy_status resolve_global_variable( enum ivy_status codegen_resolve_variable( struct ivy_codegen *gen, const char *ident, struct codegen_var *out) { - b_queue_entry *entry = b_queue_last(&gen->c_state); + fx_queue_entry *entry = fx_queue_last(&gen->c_state); if (!entry) { return IVY_ERR_NO_ENTRY; } @@ -164,7 +164,7 @@ enum ivy_status codegen_resolve_variable( while (entry) { struct code_generator_state *state - = b_unbox(struct code_generator_state, entry, s_entry); + = fx_unbox(struct code_generator_state, entry, s_entry); const struct code_generator *generator = state->s_gen; enum ivy_status status = IVY_ERR_NO_ENTRY; @@ -177,7 +177,7 @@ enum ivy_status codegen_resolve_variable( break; } - entry = b_queue_prev(entry); + entry = fx_queue_prev(entry); } #if 0 @@ -187,12 +187,12 @@ enum ivy_status codegen_resolve_variable( #endif if (entry) { - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } while (entry) { struct code_generator_state *state - = b_unbox(struct code_generator_state, entry, s_entry); + = fx_unbox(struct code_generator_state, entry, s_entry); const struct code_generator *generator = state->s_gen; enum ivy_status status = IVY_OK; @@ -204,7 +204,7 @@ enum ivy_status codegen_resolve_variable( return status; } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } return IVY_OK; @@ -371,7 +371,7 @@ enum ivy_status ivy_codegen_push_node( return IVY_ERR_BAD_STATE; } - if (b_queue_empty(&gen->c_state)) { + if (fx_queue_empty(&gen->c_state)) { const struct code_generator *generator = get_root_code_generator(node->n_type); if (!generator) { @@ -441,7 +441,7 @@ enum ivy_status ivy_codegen_push_eof(struct ivy_codegen *gen) .r_status = IVY_OK, }; - while (!b_queue_empty(&gen->c_state)) { + while (!fx_queue_empty(&gen->c_state)) { struct code_generator_value value = {0}; status = codegen_pop_generator(gen, &value); if (status != IVY_OK) { diff --git a/lang/codegen/codegen.h b/lang/codegen/codegen.h index 0450e16..1a8991f 100644 --- a/lang/codegen/codegen.h +++ b/lang/codegen/codegen.h @@ -3,7 +3,7 @@ #include "var-map.h" -#include +#include #include #include #include @@ -124,7 +124,7 @@ struct code_generator { }; struct code_generator_state { - b_queue_entry s_entry; + fx_queue_entry s_entry; uintptr_t s_argv; void *s_argp; const struct code_generator *s_gen; @@ -135,9 +135,9 @@ struct code_generator_state { }; struct ivy_codegen { - b_queue c_values; - b_queue c_state; - b_queue c_scope; + fx_queue c_values; + fx_queue c_state; + fx_queue c_scope; struct mie_builder *c_builder; struct mie_ctx *c_ctx; struct mie_module *c_module; diff --git a/lang/codegen/cond-group.c b/lang/codegen/cond-group.c index c5435a3..4a16281 100644 --- a/lang/codegen/cond-group.c +++ b/lang/codegen/cond-group.c @@ -13,7 +13,7 @@ struct cond_group_codegen_state { struct code_generator_state s_base; struct mie_block *s_end; - b_queue s_edges; + fx_queue s_edges; }; static struct code_generator_result gen_cond_group( @@ -55,10 +55,10 @@ static enum ivy_status get_eval_type( { struct mie_type *type = NULL; - b_queue_entry *entry = b_queue_first(&state->s_edges); + fx_queue_entry *entry = fx_queue_first(&state->s_edges); while (entry) { struct mie_phi_edge *edge - = b_unbox(struct mie_phi_edge, entry, e_entry); + = fx_unbox(struct mie_phi_edge, entry, e_entry); if (!edge->e_value) { goto next; } @@ -71,7 +71,7 @@ static enum ivy_status get_eval_type( } next: - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } *out = type; @@ -82,7 +82,7 @@ static enum ivy_status emit_phi_instr( struct ivy_codegen *gen, struct cond_group_codegen_state *state, struct mie_type *type, struct mie_value **result) { - size_t nr_edges = b_queue_length(&state->s_edges); + size_t nr_edges = fx_queue_length(&state->s_edges); if (!nr_edges) { return IVY_OK; } @@ -94,14 +94,14 @@ static enum ivy_status emit_phi_instr( size_t i = 0; - b_queue_entry *entry = b_queue_first(&state->s_edges); + fx_queue_entry *entry = fx_queue_first(&state->s_edges); while (entry) { struct mie_phi_edge *edge - = b_unbox(struct mie_phi_edge, entry, e_entry); + = fx_unbox(struct mie_phi_edge, entry, e_entry); memcpy(&edges[i], edge, sizeof *edge); i++; - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } struct mie_value *phi = mie_builder_phi( @@ -159,7 +159,7 @@ static struct code_generator_result value_received( assert(value->v_type == CODE_GENERATOR_VALUE_PHI_EDGE); struct mie_phi_edge *edge = code_generator_value_get_phi_edge(value); - b_queue_push_back(&cond->s_edges, &edge->e_entry); + fx_queue_push_back(&cond->s_edges, &edge->e_entry); return CODEGEN_RESULT_OK(0); } diff --git a/lang/codegen/expr.c b/lang/codegen/expr.c index d441998..39b394b 100644 --- a/lang/codegen/expr.c +++ b/lang/codegen/expr.c @@ -17,7 +17,7 @@ enum expr_operand_type { }; struct expr_item { - b_queue_entry i_entry; + fx_queue_entry i_entry; enum expr_item_type i_type; enum expr_operand_type i_operand_type; struct ivy_ast_node *i_node; @@ -29,7 +29,7 @@ struct expr_codegen_state { struct code_generator_state s_base; struct ivy_ast_node *s_expr_root; uintptr_t s_flags; - b_queue s_item_queue; + fx_queue s_item_queue; }; #if 0 @@ -66,7 +66,7 @@ static enum ivy_status push_operand( item->i_operand_type = EXPR_OPERAND_VAR; } - b_queue_push_back(&expr->s_item_queue, &item->i_entry); + fx_queue_push_back(&expr->s_item_queue, &item->i_entry); return IVY_OK; } @@ -83,7 +83,7 @@ static enum ivy_status push_operator( item->i_type = EXPR_OPERATOR; item->i_node = node; - b_queue_push_back(&expr->s_item_queue, &item->i_entry); + fx_queue_push_back(&expr->s_item_queue, &item->i_entry); return IVY_OK; } @@ -543,24 +543,24 @@ static enum ivy_status state_fini( struct expr_codegen_state *expr = (struct expr_codegen_state *)state; enum ivy_status status = IVY_OK; - b_queue stack = B_QUEUE_INIT; + fx_queue stack = FX_QUEUE_INIT; - b_queue_entry *cur = NULL; - while ((cur = b_queue_pop_back(&expr->s_item_queue))) { - struct expr_item *item = b_unbox(struct expr_item, cur, i_entry); + fx_queue_entry *cur = NULL; + while ((cur = fx_queue_pop_back(&expr->s_item_queue))) { + struct expr_item *item = fx_unbox(struct expr_item, cur, i_entry); if (item->i_type == EXPR_OPERAND) { - b_queue_push_back(&stack, &item->i_entry); + fx_queue_push_back(&stack, &item->i_entry); continue; } struct ivy_ast_op_node *op = (struct ivy_ast_op_node *)item->i_node; - b_queue_entry *left_entry = b_queue_pop_back(&stack); - b_queue_entry *right_entry = b_queue_pop_back(&stack); + fx_queue_entry *left_entry = fx_queue_pop_back(&stack); + fx_queue_entry *right_entry = fx_queue_pop_back(&stack); struct expr_item *left - = b_unbox(struct expr_item, left_entry, i_entry); + = fx_unbox(struct expr_item, left_entry, i_entry); struct expr_item *right - = b_unbox(struct expr_item, right_entry, i_entry); + = fx_unbox(struct expr_item, right_entry, i_entry); struct mie_value *left_value = left->i_value; struct mie_value *right_value = right->i_value; @@ -670,19 +670,19 @@ static enum ivy_status state_fini( skip_op: item->i_value = op_value; - b_queue_push_back(&stack, &item->i_entry); + fx_queue_push_back(&stack, &item->i_entry); } if (status != IVY_OK) { return status; } - cur = b_queue_pop_back(&stack); + cur = fx_queue_pop_back(&stack); if (!cur) { return IVY_ERR_INTERNAL_FAILURE; } - struct expr_item *result_item = b_unbox(struct expr_item, cur, i_entry); + struct expr_item *result_item = fx_unbox(struct expr_item, cur, i_entry); struct mie_value *result_value; if (result_item->i_operand_type == EXPR_OPERAND_VAR) { result_value = load_variable(gen, &result_item->i_var); diff --git a/lang/codegen/msg.c b/lang/codegen/msg.c index 051bc41..8250926 100644 --- a/lang/codegen/msg.c +++ b/lang/codegen/msg.c @@ -1,7 +1,7 @@ #include "../debug.h" #include "codegen.h" -#include +#include #include #include #include @@ -98,7 +98,7 @@ static struct code_generator_result gen_selector( msg->s_prev_part = MSG_SELECTOR; msg->s_nr_args = 0; - msg->s_max_args = b_queue_length(&msg->s_selector->n_arg_labels); + msg->s_max_args = fx_queue_length(&msg->s_selector->n_arg_labels); msg->s_args = calloc(msg->s_max_args, sizeof(struct mie_value *)); if (!msg->s_args) { @@ -126,38 +126,38 @@ static enum ivy_status state_init( } static void serialise_selector( - struct ivy_ast_selector_node *sel, b_stringstream *out) + struct ivy_ast_selector_node *sel, fx_stringstream *out) { - b_stream_write_string(out, "_M", NULL); + fx_stream_write_string(out, "_M", NULL); if (sel->n_msg_name) { const char *msg_name = sel->n_msg_name->t_str; - b_stream_write_fmt(out, NULL, "%zu%s", strlen(msg_name), msg_name); + fx_stream_write_fmt(out, NULL, "%zu%s", strlen(msg_name), msg_name); } else { - b_stream_write_char(out, '0'); + fx_stream_write_char(out, '0'); } - b_queue_entry *entry = b_queue_first(&sel->n_arg_labels); + fx_queue_entry *entry = fx_queue_first(&sel->n_arg_labels); while (entry) { - struct ivy_token *arg = b_unbox(struct ivy_token, entry, t_entry); + struct ivy_token *arg = fx_unbox(struct ivy_token, entry, t_entry); if (arg->t_type != IVY_TOK_IDENT && arg->t_type != IVY_TOK_LABEL) { - b_stream_write_char(out, '0'); + fx_stream_write_char(out, '0'); goto next; } const char *label = arg->t_str; if (label) { - b_stream_write_fmt(out, NULL, "%zu%s", strlen(label), label); + fx_stream_write_fmt(out, NULL, "%zu%s", strlen(label), label); } else { - b_stream_write_char(out, '0'); + fx_stream_write_char(out, '0'); } next: - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } - b_stream_write_char(out, 'E'); + fx_stream_write_char(out, 'E'); } static enum ivy_status state_fini( @@ -168,10 +168,10 @@ static enum ivy_status state_fini( struct msg_codegen_state *msg = (struct msg_codegen_state *)state; - b_stringstream *str = b_stringstream_create(); + fx_stringstream *str = fx_stringstream_create(); serialise_selector(msg->s_selector, str); - char *sel = b_stringstream_steal(str); - b_stringstream_unref(str); + char *sel = fx_stringstream_steal(str); + fx_stringstream_unref(str); struct mie_value *sel_value = mie_ctx_get_selector(gen->c_ctx, sel); free(sel); diff --git a/lang/codegen/unit.c b/lang/codegen/unit.c index c18b64a..7b650b0 100644 --- a/lang/codegen/unit.c +++ b/lang/codegen/unit.c @@ -1,8 +1,8 @@ #include "codegen.h" #include "var-map.h" -#include -#include +#include +#include #include #include #include @@ -142,19 +142,19 @@ static struct code_generator_result gen_while_loop( return CODEGEN_RESULT_OK(CODEGEN_R_REPEAT_NODE); } -static void serialise_package_name(b_queue *parts, b_stringstream *out) +static void serialise_package_name(fx_queue *parts, fx_stringstream *out) { - b_stream_write_string(out, "_ZN", NULL); + fx_stream_write_string(out, "_ZN", NULL); - b_queue_entry *entry = b_queue_first(parts); + fx_queue_entry *entry = fx_queue_first(parts); while (entry) { - struct ivy_token *tok = b_unbox(struct ivy_token, entry, t_entry); + struct ivy_token *tok = fx_unbox(struct ivy_token, entry, t_entry); size_t len = strlen(tok->t_str); - b_stream_write_fmt(out, NULL, "%zu%s", len, tok->t_str); - entry = b_queue_next(entry); + fx_stream_write_fmt(out, NULL, "%zu%s", len, tok->t_str); + entry = fx_queue_next(entry); } - b_stream_write_char(out, 'E'); + fx_stream_write_char(out, 'E'); } static struct code_generator_result gen_unit_package( @@ -165,10 +165,10 @@ static struct code_generator_result gen_unit_package( struct ivy_ast_unit_package_node *pkg = (struct ivy_ast_unit_package_node *)node; - b_stringstream *str = b_stringstream_create(); + fx_stringstream *str = fx_stringstream_create(); serialise_package_name(&pkg->n_ident, str); - char *ident = b_stringstream_steal(str); - b_stringstream_unref(str); + char *ident = fx_stringstream_steal(str); + fx_stringstream_unref(str); struct mie_value *ident_val = mie_ctx_get_string(gen->c_ctx, ident); free(ident); @@ -198,14 +198,14 @@ static struct code_generator_result gen_unit_import( import_list = MIE_ARRAY(rec->r_value); } - b_stringstream *str = b_stringstream_create(); + fx_stringstream *str = fx_stringstream_create(); serialise_package_name(&pkg->n_ident, str); - char *ident = b_stringstream_steal(str); - b_stringstream_unref(str); + char *ident = fx_stringstream_steal(str); + fx_stringstream_unref(str); struct mie_value *ident_val = mie_ctx_get_string(gen->c_ctx, ident); free(ident); - b_list_push_back(import_list->a_values, ident_val); + fx_list_push_back(import_list->a_values, ident_val); return CODEGEN_RESULT_OK(0); } diff --git a/lang/codegen/var-map.c b/lang/codegen/var-map.c index d9075a7..b6d5720 100644 --- a/lang/codegen/var-map.c +++ b/lang/codegen/var-map.c @@ -1,33 +1,33 @@ #include "var-map.h" -#include -#include +#include +#include #include #include enum ivy_status codegen_var_map_init(struct codegen_var_map *map) { memset(map, 0x0, sizeof *map); - map->m_map = b_hashmap_create(free, free); + map->m_map = fx_hashmap_create(free, free); return IVY_OK; } enum ivy_status codegen_var_map_fini(struct codegen_var_map *map) { - b_hashmap_unref(map->m_map); + fx_hashmap_unref(map->m_map); return IVY_OK; } enum ivy_status codegen_var_map_get( struct codegen_var_map *map, const char *ident, struct codegen_var **out) { - b_hashmap_key key = { + fx_hashmap_key key = { .key_data = ident, .key_size = strlen(ident), }; - const b_hashmap_value *value = b_hashmap_get(map->m_map, &key); + const fx_hashmap_value *value = fx_hashmap_get(map->m_map, &key); if (!value) { return IVY_ERR_NO_ENTRY; @@ -42,8 +42,8 @@ enum ivy_status codegen_var_map_put( struct codegen_var_map *map, const char *ident, const struct codegen_var *var) { - b_hashmap_key key = { - .key_data = b_strdup(ident), + fx_hashmap_key key = { + .key_data = fx_strdup(ident), .key_size = strlen(ident), }; @@ -51,7 +51,7 @@ enum ivy_status codegen_var_map_put( return IVY_ERR_NO_MEMORY; } - b_hashmap_value value = { + fx_hashmap_value value = { .value_data = malloc(sizeof *var), .value_size = sizeof *var, }; @@ -63,8 +63,8 @@ enum ivy_status codegen_var_map_put( memcpy(value.value_data, var, sizeof *var); - b_status status = b_hashmap_put(map->m_map, &key, &value); - if (!B_OK(status)) { + fx_status status = fx_hashmap_put(map->m_map, &key, &value); + if (!FX_OK(status)) { free((void *)key.key_data); free(value.value_data); } diff --git a/lang/codegen/var-map.h b/lang/codegen/var-map.h index ce8cd74..82c165b 100644 --- a/lang/codegen/var-map.h +++ b/lang/codegen/var-map.h @@ -1,7 +1,7 @@ #ifndef CODEGEN_VAR_MAP_H_ #define CODEGEN_VAR_MAP_H_ -#include +#include #include struct mie_value; @@ -20,7 +20,7 @@ struct codegen_var { }; struct codegen_var_map { - b_hashmap *m_map; + fx_hashmap *m_map; }; extern enum ivy_status codegen_var_map_init(struct codegen_var_map *map); diff --git a/lang/include/ivy/lang/ast.h b/lang/include/ivy/lang/ast.h index 76015da..ec6466c 100644 --- a/lang/include/ivy/lang/ast.h +++ b/lang/include/ivy/lang/ast.h @@ -1,8 +1,8 @@ #ifndef IVY_LANG_AST_H_ #define IVY_LANG_AST_H_ -#include -#include +#include +#include #include #include #include @@ -11,7 +11,7 @@ struct ivy_diag_ctx; struct ivy_token; struct ivy_parser; -struct b_string; +struct fx_string; enum ivy_ast_node_type { IVY_AST_NONE = 0x00, @@ -69,12 +69,12 @@ enum ivy_ast_iteration_type { }; struct ivy_ast_node_iterator { - b_queue it_queue; - b_queue_entry *it_insert_after; + fx_queue it_queue; + fx_queue_entry *it_insert_after; }; struct ivy_ast_node_iterator_entry { - b_queue_entry it_entry; + fx_queue_entry it_entry; unsigned int it_depth; }; @@ -82,13 +82,13 @@ struct ivy_ast_node { enum ivy_ast_node_type n_type; struct ivy_ast_node *n_parent; 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_unit_node { struct ivy_ast_node n_base; - b_queue n_children; + fx_queue n_children; }; struct ivy_ast_op_node { @@ -116,9 +116,9 @@ struct ivy_ast_selector_node { /* NULL for keyword messages. */ struct ivy_token *n_msg_name; /* 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. */ - b_queue n_arg_names; + fx_queue n_arg_names; }; struct ivy_ast_msg_node { @@ -126,7 +126,7 @@ struct ivy_ast_msg_node { struct ivy_ast_node *n_recipient; struct ivy_ast_selector_node *n_sel; /* queue of struct ivy_ast_node; empty for unary messages. */ - b_queue n_arg; + fx_queue n_arg; }; struct ivy_ast_class_node { @@ -135,9 +135,9 @@ struct ivy_ast_class_node { struct ivy_token *n_ident; /* queue of struct ivy_ast_property_node */ - b_queue n_properties; + fx_queue n_properties; /* queue of struct ivy_ast_msgh_node */ - b_queue n_msg_handlers; + fx_queue n_msg_handlers; }; struct ivy_ast_msgh_node { @@ -176,7 +176,7 @@ struct ivy_ast_lambda_node { struct ivy_ast_node n_base; /* queue of struct ivy_ast_ident_node; contains the names of the lambda * parameters. */ - b_queue n_arg; + fx_queue n_arg; /* expressions to evaluate when lambda is executed. */ struct ivy_ast_node *n_body; }; @@ -184,13 +184,13 @@ struct ivy_ast_lambda_node { struct ivy_ast_unit_package_node { struct ivy_ast_node n_base; /* 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_node n_base; /* queue of struct ivy_token; list of multi-part identifier parts. */ - b_queue n_ident; + fx_queue n_ident; }; struct ivy_ast_expr_node { @@ -223,7 +223,7 @@ struct ivy_ast_string_node { struct ivy_ast_fstring_node { struct ivy_ast_node n_base; /* 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 { @@ -266,13 +266,13 @@ struct ivy_ast_cascade_node { struct ivy_ast_node n_base; struct ivy_ast_node *n_recipient; /* 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_node n_base; /* queue of struct ivy_ast_cond_node. */ - b_queue n_branches; + fx_queue n_branches; }; struct ivy_ast_try_catch_node { @@ -284,7 +284,7 @@ struct ivy_ast_try_catch_node { struct ivy_ast_try_node { struct ivy_ast_node n_base; struct ivy_ast_node *n_try; - b_queue n_catch; + fx_queue n_catch; 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. */ struct ivy_ast_node *n_cond; /* queue of struct ivy_ast_cond_node. */ - b_queue n_branches; + fx_queue n_branches; }; struct ivy_ast_cond_node { @@ -309,7 +309,7 @@ struct ivy_ast_cond_node { struct ivy_ast_tuple_node { struct ivy_ast_node n_base; /* 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 { @@ -325,7 +325,7 @@ struct ivy_ast_pkg_static_item_node { struct ivy_ast_pkg_static_node { struct ivy_ast_node n_base; /* queue of struct ivy_ast_pkg_static_item_node */ - b_queue n_items; + fx_queue n_items; }; struct ivy_ast_pkg_dynamic_node { @@ -339,7 +339,7 @@ struct ivy_ast_pkg_dynamic_node { struct ivy_ast_block_node { struct ivy_ast_node n_base; /* 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)( @@ -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( struct ivy_ast_node *node, struct ivy_ast_node_iterator *it, 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( struct ivy_ast_node *parent, const struct ivy_token *tok); IVY_API void ivy_ast_node_extend_bounds( diff --git a/lang/include/ivy/lang/lex.h b/lang/include/ivy/lang/lex.h index fd80160..2305c56 100644 --- a/lang/include/ivy/lang/lex.h +++ b/lang/include/ivy/lang/lex.h @@ -1,7 +1,7 @@ #ifndef IVY_LANG_LEX_H_ #define IVY_LANG_LEX_H_ -#include +#include #include #include #include @@ -123,7 +123,7 @@ struct ivy_token { struct ivy_char_cell t_start, t_end; - b_queue_entry t_entry; + fx_queue_entry t_entry; union { enum ivy_keyword t_keyword; diff --git a/lang/internal.c b/lang/internal.c index 82bcac0..a678616 100644 --- a/lang/internal.c +++ b/lang/internal.c @@ -1,7 +1,7 @@ #include "lex.h" -#include -#include +#include +#include #include #include #include @@ -12,23 +12,23 @@ static void print_symbol_node(struct ivy_lexer_symbol_node *node, int depth) fputs(" ", stdout); } - b_printf("[cyan]%c[reset]", node->s_char); + fx_printf("[cyan]%c[reset]", node->s_char); if (node->s_def != NULL) { - b_printf( + fx_printf( " ([magenta]%s[reset])", 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) { 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); - 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) { - b_iterator *it = b_iterator_begin(lex->lex_keywords); - b_foreach_ptr(b_dict_item, item, it) + fx_iterator *it = fx_iterator_begin(lex->lex_keywords); + fx_foreach_ptr(fx_dict_item, item, it) { - const b_string *kw_name = item->key; - enum ivy_keyword kw_id = b_number_get_int(item->value); + const fx_string *kw_name = item->key; + enum ivy_keyword kw_id = fx_number_get_int(item->value); - b_printf( + fx_printf( "([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)); } } diff --git a/lang/lex.c b/lang/lex.c index 522b177..f8a5493 100644 --- a/lang/lex.c +++ b/lang/lex.c @@ -1,10 +1,10 @@ #include "lex.h" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include @@ -163,40 +163,40 @@ static struct lexer_state *push_lexer_state( state->s_type = state_type; state->s_brace_depth = lex->lex_brace_depth; - b_queue_push_back(&lex->lex_state, &state->s_entry); + fx_queue_push_back(&lex->lex_state, &state->s_entry); return state; } static void pop_lexer_state(struct ivy_lexer *lex) { - b_queue_entry *entry = b_queue_pop_back(&lex->lex_state); + fx_queue_entry *entry = fx_queue_pop_back(&lex->lex_state); if (!entry) { return; } - struct lexer_state *state = b_unbox(struct lexer_state, entry, s_entry); + struct lexer_state *state = fx_unbox(struct lexer_state, entry, s_entry); free(state); } static struct lexer_state *get_lexer_state(struct ivy_lexer *lex) { - b_queue_entry *entry = b_queue_last(&lex->lex_state); + fx_queue_entry *entry = fx_queue_last(&lex->lex_state); if (!entry) { return NULL; } - return b_unbox(struct lexer_state, entry, s_entry); + return fx_unbox(struct lexer_state, entry, s_entry); } -static void destroy_state_stack(b_queue *state) +static void destroy_state_stack(fx_queue *state) { - b_queue_entry *entry = b_queue_first(state); + fx_queue_entry *entry = fx_queue_first(state); while (entry) { struct lexer_state *node - = b_unbox(struct lexer_state, entry, s_entry); - b_queue_entry *next = b_queue_next(entry); - b_queue_delete(state, entry); + = fx_unbox(struct lexer_state, entry, s_entry); + fx_queue_entry *next = fx_queue_next(entry); + fx_queue_delete(state, entry); free(node); @@ -207,27 +207,27 @@ static void destroy_state_stack(b_queue *state) static struct ivy_lexer_symbol_node *get_symbol_node( struct ivy_lexer_symbol_node *node, char c) { - b_queue_entry *entry = b_queue_first(&node->s_children); + fx_queue_entry *entry = fx_queue_first(&node->s_children); while (entry) { struct ivy_lexer_symbol_node *child - = b_unbox(struct ivy_lexer_symbol_node, entry, s_entry); + = fx_unbox(struct ivy_lexer_symbol_node, entry, s_entry); if (child->s_char == c) { return child; } - entry = b_queue_next(entry); + entry = fx_queue_next(entry); } return NULL; } -static b_string *get_temp_string(struct ivy_lexer *lex) +static fx_string *get_temp_string(struct ivy_lexer *lex) { if (!lex->lex_temp) { - lex->lex_temp = b_string_create(); + lex->lex_temp = fx_string_create(); } - b_string_clear(lex->lex_temp); + fx_string_clear(lex->lex_temp); return lex->lex_temp; } @@ -252,7 +252,7 @@ static enum ivy_status put_symbol( child->s_def = NULL; 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; } @@ -262,12 +262,12 @@ static enum ivy_status put_symbol( static void destroy_symbol_tree(struct ivy_lexer_symbol_node *tree) { - b_queue_entry *entry = b_queue_first(&tree->s_children); + fx_queue_entry *entry = fx_queue_first(&tree->s_children); while (entry) { struct ivy_lexer_symbol_node *node - = b_unbox(struct ivy_lexer_symbol_node, entry, s_entry); - b_queue_entry *next = b_queue_next(entry); - b_queue_delete(&tree->s_children, entry); + = fx_unbox(struct ivy_lexer_symbol_node, entry, s_entry); + fx_queue_entry *next = fx_queue_next(entry); + fx_queue_delete(&tree->s_children, entry); destroy_symbol_tree(node); @@ -300,22 +300,22 @@ static struct ivy_lexer_symbol_node *build_symbol_tree(void) return root; } -static void init_keywords(b_dict *keyword_dict) +static void init_keywords(fx_dict *keyword_dict) { for (size_t i = 0; i < nr_keywords; i++) { struct lex_token_def *keyword = &keywords[i]; - b_dict_put(keyword_dict, keyword->name, B_RV_INT(keyword->id)); + fx_dict_put(keyword_dict, keyword->name, FX_RV_INT(keyword->id)); } } static enum ivy_keyword find_keyword_by_name(struct ivy_lexer *lex, const char *s) { - b_number *id = b_dict_at(lex->lex_keywords, s); + fx_number *id = fx_dict_at(lex->lex_keywords, s); if (!id) { return IVY_KW_NONE; } - return b_number_get_int(id); + return fx_number_get_int(id); } enum ivy_status ivy_lexer_create(struct ivy_lexer **lexp) @@ -346,7 +346,7 @@ enum ivy_status ivy_lexer_create(struct ivy_lexer **lexp) return IVY_ERR_NO_MEMORY; } - lex->lex_keywords = b_dict_create(); + lex->lex_keywords = fx_dict_create(); init_keywords(lex->lex_keywords); *lexp = lex; @@ -355,12 +355,12 @@ enum ivy_status ivy_lexer_create(struct ivy_lexer **lexp) void ivy_lexer_destroy(struct ivy_lexer *lex) { - b_queue_entry *entry = b_queue_first(&lex->lex_queue); + fx_queue_entry *entry = fx_queue_first(&lex->lex_queue); while (entry) { - struct ivy_token *tok = b_unbox(struct ivy_token, entry, t_entry); - b_queue_entry *next = b_queue_next(entry); - b_queue_delete(&lex->lex_queue, entry); + struct ivy_token *tok = fx_unbox(struct ivy_token, entry, t_entry); + fx_queue_entry *next = fx_queue_next(entry); + fx_queue_delete(&lex->lex_queue, entry); ivy_token_destroy(tok); @@ -376,11 +376,11 @@ void ivy_lexer_destroy(struct ivy_lexer *lex) } if (lex->lex_temp) { - b_string_unref(lex->lex_temp); + fx_string_unref(lex->lex_temp); } if (lex->lex_keywords) { - b_dict_unref(lex->lex_keywords); + fx_dict_unref(lex->lex_keywords); } destroy_state_stack(&lex->lex_state); @@ -546,7 +546,7 @@ static enum ivy_status push_token(struct ivy_lexer *lex, struct ivy_token *tok) tok->t_end.c_row = lex->lex_token_end_row; tok->t_end.c_col = lex->lex_token_end_col; - b_queue_push_back(&lex->lex_queue, &tok->t_entry); + fx_queue_push_back(&lex->lex_queue, &tok->t_entry); lex->lex_prev_token = tok->t_type; return IVY_OK; } @@ -772,7 +772,7 @@ static enum ivy_status read_dquote_marker(struct ivy_lexer *lex) static enum ivy_status read_atom(struct ivy_lexer *lex) { - b_string *str = get_temp_string(lex); + fx_string *str = get_temp_string(lex); while (true) { int c = peek(lex); @@ -790,24 +790,24 @@ static enum ivy_status read_atom(struct ivy_lexer *lex) } char s[] = {c, 0}; - b_string_append_cstr(str, s); + fx_string_append_cstr(str, s); set_token_end(lex); advance(lex); } - if (b_string_get_size(str, B_STRLEN_NORMAL) == 0) { + if (fx_string_get_size(str, FX_STRLEN_NORMAL) == 0) { /* TODO report empty atom error */ return IVY_ERR_BAD_SYNTAX; } - char *s = b_string_steal(str); + char *s = fx_string_steal(str); return push_atom(lex, s); } static enum ivy_status read_string_content(struct ivy_lexer *lex) { int c; - b_string *str = get_temp_string(lex); + fx_string *str = get_temp_string(lex); struct lexer_state *state = get_lexer_state(lex); if (!str) { @@ -830,16 +830,16 @@ static enum ivy_status read_string_content(struct ivy_lexer *lex) } char s[2] = {c, 0}; - b_string_append_cstr(str, s); + fx_string_append_cstr(str, s); set_token_end(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; } - char *s = b_string_steal(str); + char *s = fx_string_steal(str); enum ivy_status status = push_string_content(lex, s); if (status != IVY_OK) { @@ -854,7 +854,7 @@ static enum ivy_status read_number(struct ivy_lexer *lex, bool negate) int token_len = 0; int base = 10; int dots = 0; - b_string *str = get_temp_string(lex); + fx_string *str = get_temp_string(lex); if (!negate) { set_token_start(lex); @@ -889,7 +889,7 @@ static enum ivy_status read_number(struct ivy_lexer *lex, bool negate) token_len++; dots++; char s[] = {c, 0}; - b_string_append_cstr(str, s); + fx_string_append_cstr(str, s); set_token_end(lex); advance(lex); continue; @@ -936,7 +936,7 @@ static enum ivy_status read_number(struct ivy_lexer *lex, bool negate) } char s[] = {c, 0}; - b_string_append_cstr(str, s); + fx_string_append_cstr(str, s); set_token_end(lex); advance(lex); token_len++; @@ -946,7 +946,7 @@ static enum ivy_status read_number(struct ivy_lexer *lex, bool negate) return push_int(lex, 0); } - const char *s = b_string_ptr(str); + const char *s = fx_string_ptr(str); char *ep = NULL; /* negative numbers will be lexed as a hyphen followed by a positive @@ -1057,7 +1057,7 @@ static enum ivy_status read_symbol(struct ivy_lexer *lex) static enum ivy_status read_ident(struct ivy_lexer *lex) { - b_string *str = get_temp_string(lex); + fx_string *str = get_temp_string(lex); bool label = false; set_token_start(lex); char prev = 0; @@ -1085,13 +1085,13 @@ static enum ivy_status read_ident(struct ivy_lexer *lex) } char s[2] = {c, 0}; - b_string_append_cstr(str, s); + fx_string_append_cstr(str, s); set_token_end(lex); advance(lex); prev = c; } - const char *s = b_string_ptr(str); + const char *s = fx_string_ptr(str); if (!label && !strcmp(s, "_")) { return push_symbol(lex, IVY_SYM_UNDERSCORE); } @@ -1103,7 +1103,7 @@ static enum ivy_status read_ident(struct ivy_lexer *lex) struct ivy_token *tok = create_token(label ? IVY_TOK_LABEL : IVY_TOK_IDENT); - tok->t_str = b_string_steal(str); + tok->t_str = fx_string_steal(str); return push_token(lex, tok); } @@ -1177,7 +1177,7 @@ struct ivy_token *ivy_lexer_peek(struct ivy_lexer *lex) { enum ivy_status status = IVY_OK; - while (b_queue_empty(&lex->lex_queue)) { + while (fx_queue_empty(&lex->lex_queue)) { status = pump_tokens(lex); if (status != IVY_OK) { @@ -1188,8 +1188,8 @@ struct ivy_token *ivy_lexer_peek(struct ivy_lexer *lex) lex->lex_status = status; - b_queue_entry *entry = b_queue_first(&lex->lex_queue); - struct ivy_token *tok = b_unbox(struct ivy_token, entry, t_entry); + fx_queue_entry *entry = fx_queue_first(&lex->lex_queue); + struct ivy_token *tok = fx_unbox(struct ivy_token, entry, t_entry); return tok; } @@ -1197,7 +1197,7 @@ struct ivy_token *ivy_lexer_read(struct ivy_lexer *lex) { enum ivy_status status = IVY_OK; - while (b_queue_empty(&lex->lex_queue)) { + while (fx_queue_empty(&lex->lex_queue)) { status = pump_tokens(lex); if (status != IVY_OK) { @@ -1206,14 +1206,14 @@ struct ivy_token *ivy_lexer_read(struct ivy_lexer *lex) } } - b_queue_entry *entry = b_queue_pop_front(&lex->lex_queue); - struct ivy_token *tok = b_unbox(struct ivy_token, entry, t_entry); + fx_queue_entry *entry = fx_queue_pop_front(&lex->lex_queue); + struct ivy_token *tok = fx_unbox(struct ivy_token, entry, t_entry); return tok; } bool ivy_lexer_tokens_available(struct ivy_lexer *lex) { - if (!b_queue_empty(&lex->lex_queue)) { + if (!fx_queue_empty(&lex->lex_queue)) { return true; } @@ -1235,7 +1235,7 @@ struct ivy_token *ivy_token_create_ident(const char *s) memset(tok, 0x0, sizeof *tok); tok->t_type = IVY_TOK_IDENT; - tok->t_str = b_strdup(s); + tok->t_str = fx_strdup(s); if (!tok->t_str) { free(tok); diff --git a/lang/lex.h b/lang/lex.h index d3bca2a..204f44d 100644 --- a/lang/lex.h +++ b/lang/lex.h @@ -1,9 +1,9 @@ #ifndef _LEX_H_ #define _LEX_H_ -#include -#include -#include +#include +#include +#include #include #include #include @@ -16,15 +16,15 @@ struct ivy_lexer { struct ivy_lexer_symbol_node *lex_sym_tree; struct ivy_diag_ctx *lex_diag_ctx; struct ivy_line_source *lex_source; - b_dict *lex_keywords; + fx_dict *lex_keywords; enum ivy_status lex_status; int lex_prev_char, lex_cur_char; - b_queue lex_queue; + fx_queue lex_queue; enum ivy_token_type lex_prev_token; - b_string *lex_temp; - b_queue lex_state; + fx_string *lex_temp; + fx_queue lex_state; unsigned int lex_brace_depth; unsigned long lex_token_start_row, lex_token_start_col; @@ -47,15 +47,15 @@ enum lexer_state_type { struct lexer_state { enum lexer_state_type s_type; unsigned int s_brace_depth; - b_queue_entry s_entry; + fx_queue_entry s_entry; }; struct ivy_lexer_symbol_node { char s_char; struct lex_token_def *s_def; - b_queue_entry s_entry; - b_queue s_children; + fx_queue_entry s_entry; + fx_queue s_children; }; struct lex_token_def { diff --git a/mie b/mie index 937dc57..ef858dd 160000 --- a/mie +++ b/mie @@ -1 +1 @@ -Subproject commit 937dc57c4e287755f83fa38e773d29e50a20a6d7 +Subproject commit ef858dd06150d759833d4cc30e470c74e0a049cd diff --git a/test/diag.c b/test/diag.c index 5653662..bc81cd7 100644 --- a/test/diag.c +++ b/test/diag.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -114,49 +114,49 @@ int main(void) ivy_diag_push_msg(diag, MSG_EXAMPLE_2); struct ivy_diag_stream stream; - ivy_diag_stream_init_tty(&stream, b_stdtty); + ivy_diag_stream_init_tty(&stream, fx_stdtty); ivy_diag_ctx_write(ctx, IVY_DIAG_FORMAT_PRETTY, &stream); #if 0 - b_printf( + fx_printf( "[cyan]--- UNRECOGNISED SYMBOL " "-------------------------" "--------------------------[reset]\n"); - b_printf(" [cyan]> src/std/io/StreamReader.im[reset]:8:11\n\n"); + fx_printf(" [cyan]> src/std/io/StreamReader.im[reset]:8:11\n\n"); - b_printf( + fx_printf( " encountered a symbol that is not part of the Ivy " "syntax.\n\n"); - b_printf(" [cyan]6 |[reset] var x = 32.\n"); - b_printf(" [cyan]7 |[reset] var y = 64.\n"); - b_printf(" [cyan]8 |[reset] var z = x [red]$[reset] y.\n"); - b_printf(" [red]^[reset]\n\n"); + fx_printf(" [cyan]6 |[reset] var x = 32.\n"); + fx_printf(" [cyan]7 |[reset] var y = 64.\n"); + fx_printf(" [cyan]8 |[reset] var z = x [red]$[reset] y.\n"); + fx_printf(" [red]^[reset]\n\n"); - b_printf("\n\n"); + fx_printf("\n\n"); - b_printf( + fx_printf( "[red,bold]error[[E0102][reset]: [bold]encountered an " "unrecognised symbol[reset]\n"); - b_printf(" [blue,bold]-->[reset] src/std/io/StreamReader.im\n"); - b_printf(" [blue,bold] |[reset]\n"); - b_printf(" [blue,bold]6 |[reset] var x = 32.\n"); - b_printf(" [blue,bold]7 |[reset] var y = 64.\n"); - b_printf(" [blue,bold]8 |[reset] var z = x [red,bold]$[reset] y.\n"); - b_printf(" [blue,bold] |[reset] [red,bold]^[reset]\n"); + fx_printf(" [blue,bold]-->[reset] src/std/io/StreamReader.im\n"); + fx_printf(" [blue,bold] |[reset]\n"); + fx_printf(" [blue,bold]6 |[reset] var x = 32.\n"); + fx_printf(" [blue,bold]7 |[reset] var y = 64.\n"); + fx_printf(" [blue,bold]8 |[reset] var z = x [red,bold]$[reset] y.\n"); + fx_printf(" [blue,bold] |[reset] [red,bold]^[reset]\n"); - b_printf("\n\n"); + fx_printf("\n\n"); - b_printf(" [red,bold]\u2A2F[reset] unrecognised symbol\n"); - b_printf(" [cyan,bold]>[reset] src/std/io/StreamReader.im\n"); - b_printf(" \u256D\u2500\u2500\u2500\n"); - b_printf(" [dark_grey]0[reset] \u2502 var x = 2 $ 3.\n"); - b_printf(" \u00B7 [green]\u252C[reset]\n"); - b_printf( + fx_printf(" [red,bold]\u2A2F[reset] unrecognised symbol\n"); + fx_printf(" [cyan,bold]>[reset] src/std/io/StreamReader.im\n"); + fx_printf(" \u256D\u2500\u2500\u2500\n"); + fx_printf(" [dark_grey]0[reset] \u2502 var x = 2 $ 3.\n"); + fx_printf(" \u00B7 [green]\u252C[reset]\n"); + fx_printf( " \u00B7 [green]\u2570\u2500\u2500 this symbol is " "not " "used in Ivy syntax.[reset]\n"); - b_printf(" \u2570\u2500\u2500\u2500\n"); + fx_printf(" \u2570\u2500\u2500\u2500\n"); #endif return 0; diff --git a/test/mie-ir.c b/test/mie-ir.c index c15bfb0..4600412 100644 --- a/test/mie-ir.c +++ b/test/mie-ir.c @@ -29,10 +29,10 @@ int main(void) mie_builder_set_insert_point(builder, entry); mie_builder_store(builder, mie_ctx_get_int(ctx, 1, 32), a_ptr); - mie_builder_store(builder, mie_ctx_get_int(ctx, 2, 32), b_ptr); + mie_builder_store(builder, mie_ctx_get_int(ctx, 2, 32), fx_ptr); struct mie_value *a = mie_builder_load(builder, i32, a_ptr, NULL); - struct mie_value *b = mie_builder_load(builder, i32, b_ptr, NULL); + struct mie_value *b = mie_builder_load(builder, i32, fx_ptr, NULL); struct mie_value *c = mie_builder_add(builder, a, b, NULL);