asm: update bluelib api usage
This commit is contained in:
@@ -118,10 +118,10 @@ enum ivy_status ivy_assembler_finish(struct ivy_assembler *as)
|
||||
header.h_table_len = b_i16_htob(0);
|
||||
header.h_magic = b_i32_htob(IVY_BIN_MAGIC);
|
||||
|
||||
b_queue_iterator it = {0};
|
||||
b_queue_foreach (&it, &as->as_table) {
|
||||
b_queue_entry *entry = b_queue_first(&as->as_table);
|
||||
while (entry) {
|
||||
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);
|
||||
|
||||
if (w < sizeof e->e_data) {
|
||||
@@ -129,6 +129,7 @@ enum ivy_status ivy_assembler_finish(struct ivy_assembler *as)
|
||||
}
|
||||
|
||||
nr_table_entries++;
|
||||
entry = b_queue_next(entry);
|
||||
}
|
||||
|
||||
fwrite(&xdat, 1, sizeof xdat, as->as_data);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "assembler.h"
|
||||
|
||||
#include <blue/core/hash.h>
|
||||
#include <blue/object/hashmap.h>
|
||||
#include <blue/object/number.h>
|
||||
#include <blue/object/string.h>
|
||||
#include <blue/ds/hashmap.h>
|
||||
#include <blue/ds/number.h>
|
||||
#include <blue/ds/string.h>
|
||||
#include <ivy/asm/bin.h>
|
||||
#include <ivy/asm/instr.h>
|
||||
#include <ivy/asm/lex.h>
|
||||
@@ -88,9 +88,9 @@ static enum ivy_status resolve_label_refs(
|
||||
enum ivy_status status = IVY_OK;
|
||||
size_t nr_read = 0;
|
||||
|
||||
b_queue_iterator it;
|
||||
b_queue_foreach (&it, &c->s_label_refs) {
|
||||
struct label *label_ref = b_unbox(struct label, it.entry, l_entry);
|
||||
b_queue_entry *entry = b_queue_first(&c->s_label_refs);
|
||||
while (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);
|
||||
|
||||
if (!label_dest) {
|
||||
@@ -114,6 +114,7 @@ static enum ivy_status resolve_label_refs(
|
||||
x = b_i32_htob(instr);
|
||||
|
||||
assembler_write_data_at(as, &x, label_ref->l_offset, sizeof x);
|
||||
entry = b_queue_next(entry);
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "assembler.h"
|
||||
|
||||
#include <blue/core/hash.h>
|
||||
#include <blue/object/dict.h>
|
||||
#include <blue/object/number.h>
|
||||
#include <blue/object/string.h>
|
||||
#include <blue/ds/dict.h>
|
||||
#include <blue/ds/number.h>
|
||||
#include <blue/ds/string.h>
|
||||
#include <ivy/asm/bin.h>
|
||||
#include <ivy/ident.h>
|
||||
#include <ivy/selector.h>
|
||||
@@ -35,7 +35,7 @@ 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_NUMBER(b_dict_at(scope->s_strings, s));
|
||||
b_number *key = b_dict_at(scope->s_strings, s);
|
||||
if (!key) {
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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
|
||||
= calloc(nr_args, sizeof(ivy_extended_data_key));
|
||||
|
||||
b_queue_iterator it = {0};
|
||||
b_queue_foreach (&it, &sel->sel_args) {
|
||||
b_queue_entry *entry = b_queue_first(&sel->sel_args);
|
||||
while (entry) {
|
||||
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);
|
||||
entry = b_queue_next(entry);
|
||||
}
|
||||
|
||||
ivy_extended_data_key selector_handle
|
||||
@@ -130,11 +131,12 @@ static ivy_extended_data_key write_ident(
|
||||
|
||||
ivy_extended_data_key *part_handles
|
||||
= calloc(nr_parts, sizeof(ivy_extended_data_key));
|
||||
b_queue_iterator it = {0};
|
||||
b_queue_foreach (&it, &id->id_parts) {
|
||||
b_queue_entry *entry = b_queue_first(&id->id_parts);
|
||||
while (entry) {
|
||||
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);
|
||||
entry = b_queue_next(entry);
|
||||
}
|
||||
|
||||
dat.id_nr_parts = (uint8_t)nr_parts;
|
||||
|
||||
Reference in New Issue
Block a user