asm: update bluelib api usage
This commit is contained in:
@@ -11,5 +11,5 @@ else ()
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
target_include_directories(ivy-asm PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/)
|
target_include_directories(ivy-asm PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/)
|
||||||
target_link_libraries(ivy-asm ivy-common mie Bluelib::Core Bluelib::Object)
|
target_link_libraries(ivy-asm ivy-common mie Bluelib::Core Bluelib::Ds)
|
||||||
target_compile_definitions(ivy-asm PRIVATE IVY_EXPORT=1 IVY_STATIC=${IVY_STATIC})
|
target_compile_definitions(ivy-asm PRIVATE IVY_EXPORT=1 IVY_STATIC=${IVY_STATIC})
|
||||||
|
|||||||
@@ -118,10 +118,10 @@ enum ivy_status ivy_assembler_finish(struct ivy_assembler *as)
|
|||||||
header.h_table_len = b_i16_htob(0);
|
header.h_table_len = b_i16_htob(0);
|
||||||
header.h_magic = b_i32_htob(IVY_BIN_MAGIC);
|
header.h_magic = b_i32_htob(IVY_BIN_MAGIC);
|
||||||
|
|
||||||
b_queue_iterator it = {0};
|
b_queue_entry *entry = b_queue_first(&as->as_table);
|
||||||
b_queue_foreach (&it, &as->as_table) {
|
while (entry) {
|
||||||
struct asm_table_entry *e
|
struct asm_table_entry *e
|
||||||
= b_unbox(struct asm_table_entry, it.entry, e_entry);
|
= b_unbox(struct asm_table_entry, entry, e_entry);
|
||||||
size_t w = fwrite(&e->e_data, 1, sizeof e->e_data, as->as_data);
|
size_t w = fwrite(&e->e_data, 1, sizeof e->e_data, as->as_data);
|
||||||
|
|
||||||
if (w < sizeof e->e_data) {
|
if (w < sizeof e->e_data) {
|
||||||
@@ -129,6 +129,7 @@ enum ivy_status ivy_assembler_finish(struct ivy_assembler *as)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nr_table_entries++;
|
nr_table_entries++;
|
||||||
|
entry = b_queue_next(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
fwrite(&xdat, 1, sizeof xdat, as->as_data);
|
fwrite(&xdat, 1, sizeof xdat, as->as_data);
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#include "assembler.h"
|
#include "assembler.h"
|
||||||
|
|
||||||
#include <blue/core/hash.h>
|
#include <blue/core/hash.h>
|
||||||
#include <blue/object/hashmap.h>
|
#include <blue/ds/hashmap.h>
|
||||||
#include <blue/object/number.h>
|
#include <blue/ds/number.h>
|
||||||
#include <blue/object/string.h>
|
#include <blue/ds/string.h>
|
||||||
#include <ivy/asm/bin.h>
|
#include <ivy/asm/bin.h>
|
||||||
#include <ivy/asm/instr.h>
|
#include <ivy/asm/instr.h>
|
||||||
#include <ivy/asm/lex.h>
|
#include <ivy/asm/lex.h>
|
||||||
@@ -88,9 +88,9 @@ static enum ivy_status resolve_label_refs(
|
|||||||
enum ivy_status status = IVY_OK;
|
enum ivy_status status = IVY_OK;
|
||||||
size_t nr_read = 0;
|
size_t nr_read = 0;
|
||||||
|
|
||||||
b_queue_iterator it;
|
b_queue_entry *entry = b_queue_first(&c->s_label_refs);
|
||||||
b_queue_foreach (&it, &c->s_label_refs) {
|
while (entry) {
|
||||||
struct label *label_ref = b_unbox(struct label, it.entry, l_entry);
|
struct label *label_ref = b_unbox(struct label, entry, l_entry);
|
||||||
struct label *label_dest = get_label(c, label_ref->l_name->t_str);
|
struct label *label_dest = get_label(c, label_ref->l_name->t_str);
|
||||||
|
|
||||||
if (!label_dest) {
|
if (!label_dest) {
|
||||||
@@ -114,6 +114,7 @@ static enum ivy_status resolve_label_refs(
|
|||||||
x = b_i32_htob(instr);
|
x = b_i32_htob(instr);
|
||||||
|
|
||||||
assembler_write_data_at(as, &x, label_ref->l_offset, sizeof x);
|
assembler_write_data_at(as, &x, label_ref->l_offset, sizeof x);
|
||||||
|
entry = b_queue_next(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#include "assembler.h"
|
#include "assembler.h"
|
||||||
|
|
||||||
#include <blue/core/hash.h>
|
#include <blue/core/hash.h>
|
||||||
#include <blue/object/dict.h>
|
#include <blue/ds/dict.h>
|
||||||
#include <blue/object/number.h>
|
#include <blue/ds/number.h>
|
||||||
#include <blue/object/string.h>
|
#include <blue/ds/string.h>
|
||||||
#include <ivy/asm/bin.h>
|
#include <ivy/asm/bin.h>
|
||||||
#include <ivy/ident.h>
|
#include <ivy/ident.h>
|
||||||
#include <ivy/selector.h>
|
#include <ivy/selector.h>
|
||||||
@@ -35,7 +35,7 @@ static enum ivy_status init_scope(
|
|||||||
static ivy_extended_data_key get_cached_string(
|
static ivy_extended_data_key get_cached_string(
|
||||||
struct constpool_assembler_scope *scope, const char *s)
|
struct constpool_assembler_scope *scope, const char *s)
|
||||||
{
|
{
|
||||||
b_number *key = B_NUMBER(b_dict_at(scope->s_strings, s));
|
b_number *key = b_dict_at(scope->s_strings, s);
|
||||||
if (!key) {
|
if (!key) {
|
||||||
return IVY_EX_DATA_KEY_NULL;
|
return IVY_EX_DATA_KEY_NULL;
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ static ivy_extended_data_key write_string(struct ivy_assembler *as, const char *
|
|||||||
size_t len = strlen(s);
|
size_t len = strlen(s);
|
||||||
|
|
||||||
struct ivy_bin_string str = {0};
|
struct ivy_bin_string str = {0};
|
||||||
str.s_hash = b_i32_htob((uint32_t)b_hash_string(s));
|
str.s_hash = b_i32_htob((uint32_t)b_hash_cstr(s));
|
||||||
str.s_len = b_i32_htob((uint32_t)len);
|
str.s_len = b_i32_htob((uint32_t)len);
|
||||||
|
|
||||||
key = assembler_write_extended_data(as, &str, sizeof str);
|
key = assembler_write_extended_data(as, &str, sizeof str);
|
||||||
@@ -101,11 +101,12 @@ static ivy_extended_data_key write_selector(
|
|||||||
ivy_extended_data_key *arg_handles
|
ivy_extended_data_key *arg_handles
|
||||||
= calloc(nr_args, sizeof(ivy_extended_data_key));
|
= calloc(nr_args, sizeof(ivy_extended_data_key));
|
||||||
|
|
||||||
b_queue_iterator it = {0};
|
b_queue_entry *entry = b_queue_first(&sel->sel_args);
|
||||||
b_queue_foreach (&it, &sel->sel_args) {
|
while (entry) {
|
||||||
struct ivy_selector_arg *arg
|
struct ivy_selector_arg *arg
|
||||||
= b_unbox(struct ivy_selector_arg, it.entry, arg_entry);
|
= b_unbox(struct ivy_selector_arg, entry, arg_entry);
|
||||||
arg_handles[i++] = write_string(as, arg->arg_label);
|
arg_handles[i++] = write_string(as, arg->arg_label);
|
||||||
|
entry = b_queue_next(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
ivy_extended_data_key selector_handle
|
ivy_extended_data_key selector_handle
|
||||||
@@ -130,11 +131,12 @@ static ivy_extended_data_key write_ident(
|
|||||||
|
|
||||||
ivy_extended_data_key *part_handles
|
ivy_extended_data_key *part_handles
|
||||||
= calloc(nr_parts, sizeof(ivy_extended_data_key));
|
= calloc(nr_parts, sizeof(ivy_extended_data_key));
|
||||||
b_queue_iterator it = {0};
|
b_queue_entry *entry = b_queue_first(&id->id_parts);
|
||||||
b_queue_foreach (&it, &id->id_parts) {
|
while (entry) {
|
||||||
struct ivy_ident_part *arg
|
struct ivy_ident_part *arg
|
||||||
= b_unbox(struct ivy_ident_part, it.entry, p_entry);
|
= b_unbox(struct ivy_ident_part, entry, p_entry);
|
||||||
part_handles[i++] = write_string(as, arg->p_str);
|
part_handles[i++] = write_string(as, arg->p_str);
|
||||||
|
entry = b_queue_next(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
dat.id_nr_parts = (uint8_t)nr_parts;
|
dat.id_nr_parts = (uint8_t)nr_parts;
|
||||||
|
|||||||
62
asm/lex.c
62
asm/lex.c
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
#include <blue/core/hash.h>
|
#include <blue/core/hash.h>
|
||||||
#include <blue/core/queue.h>
|
#include <blue/core/queue.h>
|
||||||
#include <blue/object/dict.h>
|
#include <blue/ds/dict.h>
|
||||||
#include <blue/object/number.h>
|
#include <blue/ds/number.h>
|
||||||
#include <blue/object/string.h>
|
#include <blue/ds/string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <ivy/asm/lex.h>
|
#include <ivy/asm/lex.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@@ -15,10 +15,7 @@
|
|||||||
|
|
||||||
#define LINEBUF_DEFAULT_CAPACITY 1024
|
#define LINEBUF_DEFAULT_CAPACITY 1024
|
||||||
|
|
||||||
#define LEX_TOKEN_DEF(i, n) \
|
#define LEX_TOKEN_DEF(i, n) {.id = (i), .name = (n)}
|
||||||
{ \
|
|
||||||
.id = (i), .name = (n) \
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct lex_token_def keywords[] = {
|
static struct lex_token_def keywords[] = {
|
||||||
LEX_TOKEN_DEF(IVY_ASM_KW_IMPORT, "@import"),
|
LEX_TOKEN_DEF(IVY_ASM_KW_IMPORT, "@import"),
|
||||||
@@ -94,27 +91,31 @@ static struct lexer_state *get_lexer_state(struct ivy_asm_lexer *lex)
|
|||||||
|
|
||||||
static void destroy_state_stack(b_queue *state)
|
static void destroy_state_stack(b_queue *state)
|
||||||
{
|
{
|
||||||
b_queue_iterator it;
|
b_queue_entry *entry = b_queue_first(state);
|
||||||
b_queue_iterator_begin(state, &it);
|
while (entry) {
|
||||||
while (b_queue_iterator_is_valid(&it)) {
|
|
||||||
struct lexer_state *node
|
struct lexer_state *node
|
||||||
= b_unbox(struct lexer_state, it.entry, s_entry);
|
= b_unbox(struct lexer_state, entry, s_entry);
|
||||||
b_queue_iterator_erase(&it);
|
b_queue_entry *next = b_queue_next(entry);
|
||||||
|
b_queue_delete(state, entry);
|
||||||
|
|
||||||
free(node);
|
free(node);
|
||||||
|
|
||||||
|
entry = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct ivy_asm_lexer_symbol_node *get_symbol_node(
|
static struct ivy_asm_lexer_symbol_node *get_symbol_node(
|
||||||
struct ivy_asm_lexer_symbol_node *node, char c)
|
struct ivy_asm_lexer_symbol_node *node, char c)
|
||||||
{
|
{
|
||||||
b_queue_iterator it;
|
b_queue_entry *entry = b_queue_first(&node->s_children);
|
||||||
b_queue_foreach (&it, &node->s_children) {
|
while (entry) {
|
||||||
struct ivy_asm_lexer_symbol_node *child = b_unbox(
|
struct ivy_asm_lexer_symbol_node *child = b_unbox(
|
||||||
struct ivy_asm_lexer_symbol_node, it.entry, s_entry);
|
struct ivy_asm_lexer_symbol_node, entry, s_entry);
|
||||||
if (child->s_char == c) {
|
if (child->s_char == c) {
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
entry = b_queue_next(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -161,14 +162,16 @@ static enum ivy_status put_symbol(
|
|||||||
|
|
||||||
static void destroy_symbol_tree(struct ivy_asm_lexer_symbol_node *tree)
|
static void destroy_symbol_tree(struct ivy_asm_lexer_symbol_node *tree)
|
||||||
{
|
{
|
||||||
b_queue_iterator it;
|
b_queue_entry *entry = b_queue_first(&tree->s_children);
|
||||||
b_queue_iterator_begin(&tree->s_children, &it);
|
while (entry) {
|
||||||
while (b_queue_iterator_is_valid(&it)) {
|
|
||||||
struct ivy_asm_lexer_symbol_node *node = b_unbox(
|
struct ivy_asm_lexer_symbol_node *node = b_unbox(
|
||||||
struct ivy_asm_lexer_symbol_node, it.entry, s_entry);
|
struct ivy_asm_lexer_symbol_node, entry, s_entry);
|
||||||
b_queue_iterator_erase(&it);
|
b_queue_entry *next = b_queue_next(entry);
|
||||||
|
b_queue_delete(&tree->s_children, entry);
|
||||||
|
|
||||||
destroy_symbol_tree(node);
|
destroy_symbol_tree(node);
|
||||||
|
|
||||||
|
entry = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(tree);
|
free(tree);
|
||||||
@@ -208,7 +211,7 @@ static void init_keywords(b_dict *keyword_dict)
|
|||||||
static enum ivy_asm_keyword find_keyword_by_name(
|
static enum ivy_asm_keyword find_keyword_by_name(
|
||||||
struct ivy_asm_lexer *lex, const char *s)
|
struct ivy_asm_lexer *lex, const char *s)
|
||||||
{
|
{
|
||||||
b_number *id = B_NUMBER(b_dict_at(lex->lex_keywords, s));
|
b_number *id = b_dict_at(lex->lex_keywords, s);
|
||||||
if (!id) {
|
if (!id) {
|
||||||
return IVY_ASM_KW_NONE;
|
return IVY_ASM_KW_NONE;
|
||||||
}
|
}
|
||||||
@@ -251,14 +254,17 @@ enum ivy_status ivy_asm_lexer_create(struct ivy_asm_lexer **lexp)
|
|||||||
|
|
||||||
void ivy_asm_lexer_destroy(struct ivy_asm_lexer *lex)
|
void ivy_asm_lexer_destroy(struct ivy_asm_lexer *lex)
|
||||||
{
|
{
|
||||||
b_queue_iterator it = {0};
|
b_queue_entry *entry = b_queue_first(&lex->lex_queue);
|
||||||
b_queue_iterator_begin(&lex->lex_queue, &it);
|
|
||||||
|
|
||||||
while (b_queue_iterator_is_valid(&it)) {
|
while (entry) {
|
||||||
struct ivy_asm_token *tok
|
struct ivy_asm_token *tok
|
||||||
= b_unbox(struct ivy_asm_token, it.entry, t_entry);
|
= b_unbox(struct ivy_asm_token, entry, t_entry);
|
||||||
b_queue_iterator_erase(&it);
|
b_queue_entry *next = b_queue_next(entry);
|
||||||
|
b_queue_delete(&lex->lex_queue, entry);
|
||||||
|
|
||||||
ivy_asm_token_destroy(tok);
|
ivy_asm_token_destroy(tok);
|
||||||
|
|
||||||
|
entry = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lex->lex_linebuf) {
|
if (lex->lex_linebuf) {
|
||||||
@@ -270,11 +276,11 @@ void ivy_asm_lexer_destroy(struct ivy_asm_lexer *lex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lex->lex_temp) {
|
if (lex->lex_temp) {
|
||||||
b_string_release(lex->lex_temp);
|
b_string_unref(lex->lex_temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lex->lex_keywords) {
|
if (lex->lex_keywords) {
|
||||||
b_dict_release(lex->lex_keywords);
|
b_dict_unref(lex->lex_keywords);
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy_state_stack(&lex->lex_state);
|
destroy_state_stack(&lex->lex_state);
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
#define _LEX_H_
|
#define _LEX_H_
|
||||||
|
|
||||||
#include <blue/core/queue.h>
|
#include <blue/core/queue.h>
|
||||||
#include <blue/object/dict.h>
|
#include <blue/ds/dict.h>
|
||||||
#include <blue/object/string.h>
|
#include <blue/ds/string.h>
|
||||||
#include <ivy/asm/lex.h>
|
#include <ivy/asm/lex.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|||||||
@@ -99,30 +99,32 @@ static enum mie_status get_selector(
|
|||||||
struct mie_select_graph *graph = mie_select_builder_get_graph(builder);
|
struct mie_select_graph *graph = mie_select_builder_get_graph(builder);
|
||||||
|
|
||||||
b_queue *nodes = &graph->g_nodes;
|
b_queue *nodes = &graph->g_nodes;
|
||||||
b_queue_iterator it;
|
b_queue_entry *entry = b_queue_first(nodes);
|
||||||
b_queue_foreach (&it, nodes) {
|
while (entry) {
|
||||||
struct mie_select_node *node
|
struct mie_select_node *node
|
||||||
= b_unbox(struct mie_select_node, it.entry, n_entry);
|
= b_unbox(struct mie_select_node, entry, n_entry);
|
||||||
|
|
||||||
if (node->n_target != target) {
|
if (node->n_target != target) {
|
||||||
continue;
|
goto skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node->n_opcode != IVY_SELECT_OP_SELECTOR) {
|
if (node->n_opcode != IVY_SELECT_OP_SELECTOR) {
|
||||||
continue;
|
goto skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!node->n_value.v || !mie_value_is_selector(node->n_value.v)) {
|
if (!node->n_value.v || !mie_value_is_selector(node->n_value.v)) {
|
||||||
continue;
|
goto skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct mie_selector *sel_node = (struct mie_selector *)node;
|
struct mie_selector *sel_node = (struct mie_selector *)node;
|
||||||
if (strcmp(sel->sel_value, sel_node->sel_value) != 0) {
|
if (strcmp(sel->sel_value, sel_node->sel_value) != 0) {
|
||||||
continue;
|
goto skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
mie_select_node_get_value(node, ptr_type, 0, out);
|
mie_select_node_get_value(node, ptr_type, 0, out);
|
||||||
return MIE_SUCCESS;
|
return MIE_SUCCESS;
|
||||||
|
skip:
|
||||||
|
entry = b_queue_next(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct mie_select_node *sel_node;
|
struct mie_select_node *sel_node;
|
||||||
|
|||||||
@@ -101,9 +101,7 @@ struct mnemonic {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define MNEMONIC(id, name, hash) \
|
#define MNEMONIC(id, name, hash) \
|
||||||
{ \
|
{.m_id = (id), .m_name = (name), .m_hash = (hash)}
|
||||||
.m_id = (id), .m_name = (name), .m_hash = (hash) \
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct mnemonic mnemonics[] = {
|
static const struct mnemonic mnemonics[] = {
|
||||||
MNEMONIC(IVY_INSTR_LDR, "ldr", 0x127688191dd0471d),
|
MNEMONIC(IVY_INSTR_LDR, "ldr", 0x127688191dd0471d),
|
||||||
@@ -165,7 +163,7 @@ static enum index_base get_index_base(struct ivy_asm_token *tok)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char *s = tok->t_str;
|
const char *s = tok->t_str;
|
||||||
uint64_t hash = b_hash_string(s);
|
uint64_t hash = b_hash_cstr(s);
|
||||||
|
|
||||||
switch (hash) {
|
switch (hash) {
|
||||||
case HASH_SELF:
|
case HASH_SELF:
|
||||||
@@ -202,29 +200,31 @@ static enum ivy_instr_id get_instruction_id(b_queue *mnemonic_tokens)
|
|||||||
char mnemonic[64];
|
char mnemonic[64];
|
||||||
mnemonic[0] = 0;
|
mnemonic[0] = 0;
|
||||||
|
|
||||||
b_stringstream s;
|
b_stringstream *s
|
||||||
b_stringstream_begin(&s, mnemonic, sizeof mnemonic);
|
= b_stringstream_create_with_buffer(mnemonic, sizeof mnemonic);
|
||||||
|
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
|
|
||||||
b_queue_iterator it = {0};
|
b_queue_entry *entry = b_queue_first(mnemonic_tokens);
|
||||||
b_queue_iterator_begin(mnemonic_tokens, &it);
|
while (entry) {
|
||||||
while (b_queue_iterator_is_valid(&it)) {
|
|
||||||
struct ivy_asm_token *tok
|
struct ivy_asm_token *tok
|
||||||
= b_unbox(struct ivy_asm_token, it.entry, t_entry);
|
= b_unbox(struct ivy_asm_token, entry, t_entry);
|
||||||
b_queue_iterator_erase(&it);
|
b_queue_entry *next = b_queue_next(entry);
|
||||||
|
b_queue_delete(mnemonic_tokens, entry);
|
||||||
|
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
b_stringstream_add(&s, ".");
|
b_stream_write_char(s, '.');
|
||||||
}
|
}
|
||||||
|
|
||||||
b_stringstream_add(&s, tok->t_str);
|
b_stream_write_string(s, tok->t_str, NULL);
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
ivy_asm_token_destroy(tok);
|
ivy_asm_token_destroy(tok);
|
||||||
|
|
||||||
|
entry = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t hash = b_hash_string(mnemonic);
|
uint64_t hash = b_hash_cstr(mnemonic);
|
||||||
for (i = 0; i < nr_mnemonics; i++) {
|
for (i = 0; i < nr_mnemonics; i++) {
|
||||||
if (hash == mnemonics[i].m_hash
|
if (hash == mnemonics[i].m_hash
|
||||||
&& !strcmp(mnemonic, mnemonics[i].m_name)) {
|
&& !strcmp(mnemonic, mnemonics[i].m_name)) {
|
||||||
@@ -251,9 +251,9 @@ static enum ivy_status write_instruction(
|
|||||||
|
|
||||||
enum ivy_instr_operand_type operand_types[MAX_ARGS] = {0};
|
enum ivy_instr_operand_type operand_types[MAX_ARGS] = {0};
|
||||||
|
|
||||||
b_queue_iterator it = {0};
|
b_queue_entry *entry = b_queue_first(&state->s_args);
|
||||||
b_queue_foreach (&it, &state->s_args) {
|
while (entry) {
|
||||||
struct arg *arg = b_unbox(struct arg, it.entry, arg_entry);
|
struct arg *arg = b_unbox(struct arg, entry, arg_entry);
|
||||||
|
|
||||||
if (i >= MAX_ARGS) {
|
if (i >= MAX_ARGS) {
|
||||||
return IVY_ERR_BAD_SYNTAX;
|
return IVY_ERR_BAD_SYNTAX;
|
||||||
@@ -309,6 +309,8 @@ static enum ivy_status write_instruction(
|
|||||||
default:
|
default:
|
||||||
return IVY_ERR_BAD_SYNTAX;
|
return IVY_ERR_BAD_SYNTAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
entry = b_queue_next(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct ivy_instr_definition *instr_info
|
const struct ivy_instr_definition *instr_info
|
||||||
@@ -321,10 +323,11 @@ static enum ivy_status write_instruction(
|
|||||||
instr.i_op = instr_info;
|
instr.i_op = instr_info;
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
b_queue_iterator_begin(&state->s_args, &it);
|
entry = b_queue_first(&state->s_args);
|
||||||
while (b_queue_iterator_is_valid(&it)) {
|
while (entry) {
|
||||||
struct arg *arg = b_unbox(struct arg, it.entry, arg_entry);
|
struct arg *arg = b_unbox(struct arg, entry, arg_entry);
|
||||||
b_queue_iterator_erase(&it);
|
b_queue_entry *next = b_queue_next(entry);
|
||||||
|
b_queue_delete(&state->s_args, entry);
|
||||||
|
|
||||||
switch (arg->arg_type) {
|
switch (arg->arg_type) {
|
||||||
case ARG_REG:
|
case ARG_REG:
|
||||||
@@ -357,6 +360,8 @@ static enum ivy_status write_instruction(
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(arg);
|
free(arg);
|
||||||
|
|
||||||
|
entry = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
ivy_assembler_put_instr(p->p_assembler, &instr);
|
ivy_assembler_put_instr(p->p_assembler, &instr);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ struct class_parser_state {
|
|||||||
|
|
||||||
static enum ivy_status push_attrib(struct class_parser_state *state)
|
static enum ivy_status push_attrib(struct class_parser_state *state)
|
||||||
{
|
{
|
||||||
uint64_t hash = b_hash_string(state->s_attrib_name->t_str);
|
uint64_t hash = b_hash_cstr(state->s_attrib_name->t_str);
|
||||||
const char *s = state->s_attrib_name->t_str;
|
const char *s = state->s_attrib_name->t_str;
|
||||||
unsigned long long v = state->s_attrib_value->t_int.uv;
|
unsigned long long v = state->s_attrib_value->t_int.uv;
|
||||||
|
|
||||||
|
|||||||
@@ -61,15 +61,17 @@ static enum ivy_status parse_right_paren(
|
|||||||
|
|
||||||
struct ivy_ident *ident = ivy_ident_create();
|
struct ivy_ident *ident = ivy_ident_create();
|
||||||
|
|
||||||
b_queue_iterator it = {0};
|
b_queue_entry *entry = b_queue_first(&state->s_parts);
|
||||||
b_queue_iterator_begin(&state->s_parts, &it);
|
while (entry) {
|
||||||
while (b_queue_iterator_is_valid(&it)) {
|
|
||||||
struct ivy_asm_token *tok
|
struct ivy_asm_token *tok
|
||||||
= b_unbox(struct ivy_asm_token, it.entry, t_entry);
|
= b_unbox(struct ivy_asm_token, entry, t_entry);
|
||||||
b_queue_iterator_erase(&it);
|
b_queue_entry *next = b_queue_next(entry);
|
||||||
|
b_queue_delete(&state->s_parts, entry);
|
||||||
|
|
||||||
ivy_ident_add_part(ident, tok->t_str);
|
ivy_ident_add_part(ident, tok->t_str);
|
||||||
ivy_asm_token_destroy(tok);
|
ivy_asm_token_destroy(tok);
|
||||||
|
|
||||||
|
entry = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
asm_parser_pop_state(ctx, ident);
|
asm_parser_pop_state(ctx, ident);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ struct unit_parser_state {
|
|||||||
|
|
||||||
static enum ivy_status push_attrib(struct unit_parser_state *state)
|
static enum ivy_status push_attrib(struct unit_parser_state *state)
|
||||||
{
|
{
|
||||||
uint64_t hash = b_hash_string(state->s_attrib_name->t_str);
|
uint64_t hash = b_hash_cstr(state->s_attrib_name->t_str);
|
||||||
const char *s = state->s_attrib_name->t_str;
|
const char *s = state->s_attrib_name->t_str;
|
||||||
unsigned long long v = state->s_attrib_value->t_int.uv;
|
unsigned long long v = state->s_attrib_value->t_int.uv;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user