2024-12-15 19:30:14 +00:00
|
|
|
#include "assembler.h"
|
|
|
|
|
|
|
|
|
|
#include <blue/core/hash.h>
|
|
|
|
|
#include <blue/object/dict.h>
|
|
|
|
|
#include <blue/object/number.h>
|
|
|
|
|
#include <blue/object/string.h>
|
|
|
|
|
#include <ivy/asm/bin.h>
|
|
|
|
|
#include <ivy/ident.h>
|
|
|
|
|
#include <ivy/selector.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
struct block_assembler_scope {
|
|
|
|
|
struct assembler_scope s_base;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static enum ivy_status init_scope(
|
|
|
|
|
struct ivy_assembler *as, struct assembler_scope *scope,
|
|
|
|
|
const ivy_assembler_attrib_table attrib)
|
|
|
|
|
{
|
|
|
|
|
struct ivy_bin_block header = {0};
|
|
|
|
|
|
|
|
|
|
header.b_index = b_i32_htob((uint32_t)attrib[IVY_ASM_ATTRIB_INDEX]);
|
|
|
|
|
assembler_write_data(as, &header, sizeof header);
|
|
|
|
|
|
|
|
|
|
struct block_assembler_scope *c
|
|
|
|
|
= (struct block_assembler_scope *)scope;
|
|
|
|
|
|
|
|
|
|
return IVY_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static enum ivy_status put_instr(
|
|
|
|
|
struct ivy_assembler *as, struct assembler_scope *scope,
|
|
|
|
|
const struct ivy_instr *instr)
|
|
|
|
|
{
|
|
|
|
|
uint32_t op = 0xAABBCCDD;
|
|
|
|
|
b_i32 x = b_i32_htob(op);
|
|
|
|
|
assembler_write_data(as, &x, sizeof x);
|
|
|
|
|
return IVY_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const struct assembler_scope_type block_scope_type = {
|
|
|
|
|
.s_scope_size = sizeof(struct block_assembler_scope),
|
|
|
|
|
.s_init_scope = init_scope,
|
|
|
|
|
.s_put_instr = put_instr,
|
|
|
|
|
};
|