asm: define on-disk data structures for assembly files

This commit is contained in:
2024-12-09 20:38:01 +00:00
parent 51fe7a0a71
commit 26ed9fee04

111
asm/include/ivy/asm/bin.h Normal file
View File

@@ -0,0 +1,111 @@
#ifndef IVY_ASM_BIN_H_
#define IVY_ASM_BIN_H_
#include <stdint.h>
#define IVY_BIN_MAGIC 0x2E495659u
#define IVY_TABLE_IMPORT 0x58494D50u
#define IVY_TABLE_CLASS 0x58434C53u
#define IVY_TABLE_LAMBDA 0x4C424441u
#define IVY_TABLE_MSGH 0x4D534748u
#define IVY_TABLE_POOL 0x504F4F4Cu
#define IVY_TABLE_XDAT 0x53544142u
#define IVY_CLASS_TABLE_MVAR 0x4D564152u
#define IVY_CLASS_TABLE_PROP 0x50524F50u
#define IVY_CONSTPOOL_TABLE_NULL 0x00000000u
#define IVY_CONSTPOOL_TABLE_STRING 0x58535452u
#define IVY_CONSTPOOL_TABLE_INT 0x53494E54u
#define IVY_CONSTPOOL_TABLE_UINT 0x55494E54u
#define IVY_CONSTPOOL_TABLE_ATOM 0x41544F4Du
#define IVY_CONSTPOOL_TABLE_SELECTOR 0x5853454Cu
#define IVY_CONSTPOOL_TABLE_IDENT 0x49444E54u
#define IVY_BIN_SELECTOR_OBJECT 0x00000001u
#define IVY_BIN_SELECTOR_CLASS 0x00000002u
struct ivy_bin_header {
uint32_t h_magic;
uint16_t h_table_len;
uint64_t h_table_offset;
};
struct ivy_bin_table_entry {
uint32_t e_type;
uint64_t e_offset;
uint32_t e_size;
};
struct ivy_bin_class_table_entry {
uint32_t e_type;
union {
struct {
uint32_t p_ident;
uint32_t p_get;
uint32_t p_set;
} e_property;
struct {
uint32_t m_index;
uint32_t m_ident;
} e_mvar;
};
};
struct ivy_bin_class {
uint32_t c_ident;
struct ivy_bin_class_table_entry c_table[];
};
struct ivy_bin_lambda {
uint32_t l_ident;
uint32_t l_instr[];
};
struct ivy_bin_msgh {
uint32_t msg_recipient;
uint32_t msg_selector;
uint32_t msg_instr[];
};
struct ivy_bin_constpool_header {
uint32_t c_nr_table_entries;
uint64_t c_table_offset;
};
struct ivy_bin_string {
uint32_t s_hash;
uint32_t s_len;
char s_chars[];
};
struct ivy_bin_selector {
uint8_t sel_flags;
uint8_t sel_nr_args;
uint32_t sel_hash;
uint32_t sel_name;
uint32_t sel_args[];
};
struct ivy_bin_ident {
uint32_t id_hash;
uint8_t id_nr_parts;
uint32_t id_parts[];
};
struct ivy_bin_constpool_table_entry {
uint32_t e_type;
union {
uint32_t e_atom;
uint32_t e_string;
uint32_t e_ident;
uint32_t e_sel;
int64_t e_sint;
uint64_t e_uint;
};
};
#endif