meta: replace bluelib with fx
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "assembler.h"
|
||||
|
||||
#include <blue/core/queue.h>
|
||||
#include <fx/core/queue.h>
|
||||
#include <ivy/asm/assembler.h>
|
||||
#include <ivy/asm/bin.h>
|
||||
#include <stdio.h>
|
||||
@@ -19,13 +19,13 @@ static const struct assembler_scope_type *scope_types[] = {
|
||||
static const size_t nr_scope_types = sizeof scope_types / sizeof scope_types[0];
|
||||
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user