asm: update bluelib api usage
This commit is contained in:
@@ -101,9 +101,7 @@ struct mnemonic {
|
||||
};
|
||||
|
||||
#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[] = {
|
||||
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;
|
||||
uint64_t hash = b_hash_string(s);
|
||||
uint64_t hash = b_hash_cstr(s);
|
||||
|
||||
switch (hash) {
|
||||
case HASH_SELF:
|
||||
@@ -202,29 +200,31 @@ static enum ivy_instr_id get_instruction_id(b_queue *mnemonic_tokens)
|
||||
char mnemonic[64];
|
||||
mnemonic[0] = 0;
|
||||
|
||||
b_stringstream s;
|
||||
b_stringstream_begin(&s, mnemonic, sizeof mnemonic);
|
||||
b_stringstream *s
|
||||
= b_stringstream_create_with_buffer(mnemonic, sizeof mnemonic);
|
||||
|
||||
unsigned int i = 0;
|
||||
|
||||
b_queue_iterator it = {0};
|
||||
b_queue_iterator_begin(mnemonic_tokens, &it);
|
||||
while (b_queue_iterator_is_valid(&it)) {
|
||||
b_queue_entry *entry = b_queue_first(mnemonic_tokens);
|
||||
while (entry) {
|
||||
struct ivy_asm_token *tok
|
||||
= b_unbox(struct ivy_asm_token, it.entry, t_entry);
|
||||
b_queue_iterator_erase(&it);
|
||||
= b_unbox(struct ivy_asm_token, entry, t_entry);
|
||||
b_queue_entry *next = b_queue_next(entry);
|
||||
b_queue_delete(mnemonic_tokens, entry);
|
||||
|
||||
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++;
|
||||
|
||||
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++) {
|
||||
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_iterator it = {0};
|
||||
b_queue_foreach (&it, &state->s_args) {
|
||||
struct arg *arg = b_unbox(struct arg, it.entry, arg_entry);
|
||||
b_queue_entry *entry = b_queue_first(&state->s_args);
|
||||
while (entry) {
|
||||
struct arg *arg = b_unbox(struct arg, entry, arg_entry);
|
||||
|
||||
if (i >= MAX_ARGS) {
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
@@ -309,6 +309,8 @@ static enum ivy_status write_instruction(
|
||||
default:
|
||||
return IVY_ERR_BAD_SYNTAX;
|
||||
}
|
||||
|
||||
entry = b_queue_next(entry);
|
||||
}
|
||||
|
||||
const struct ivy_instr_definition *instr_info
|
||||
@@ -321,10 +323,11 @@ static enum ivy_status write_instruction(
|
||||
instr.i_op = instr_info;
|
||||
i = 0;
|
||||
|
||||
b_queue_iterator_begin(&state->s_args, &it);
|
||||
while (b_queue_iterator_is_valid(&it)) {
|
||||
struct arg *arg = b_unbox(struct arg, it.entry, arg_entry);
|
||||
b_queue_iterator_erase(&it);
|
||||
entry = b_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);
|
||||
|
||||
switch (arg->arg_type) {
|
||||
case ARG_REG:
|
||||
@@ -357,6 +360,8 @@ static enum ivy_status write_instruction(
|
||||
}
|
||||
|
||||
free(arg);
|
||||
|
||||
entry = next;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
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();
|
||||
|
||||
b_queue_iterator it = {0};
|
||||
b_queue_iterator_begin(&state->s_parts, &it);
|
||||
while (b_queue_iterator_is_valid(&it)) {
|
||||
b_queue_entry *entry = b_queue_first(&state->s_parts);
|
||||
while (entry) {
|
||||
struct ivy_asm_token *tok
|
||||
= b_unbox(struct ivy_asm_token, it.entry, t_entry);
|
||||
b_queue_iterator_erase(&it);
|
||||
= b_unbox(struct ivy_asm_token, entry, t_entry);
|
||||
b_queue_entry *next = b_queue_next(entry);
|
||||
b_queue_delete(&state->s_parts, entry);
|
||||
|
||||
ivy_ident_add_part(ident, tok->t_str);
|
||||
ivy_asm_token_destroy(tok);
|
||||
|
||||
entry = next;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
unsigned long long v = state->s_attrib_value->t_int.uv;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user