asm: reader: implement constpool reader interface
This commit is contained in:
@@ -6,6 +6,20 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define IVY_ASM_SECTION_ANY_TYPE ((uint32_t) - 1)
|
||||
|
||||
struct ivy_ident;
|
||||
|
||||
enum ivy_asm_constpool_value_type {
|
||||
IVY_ASM_CONSTPOOL_TYPE_NONE = 0,
|
||||
IVY_ASM_CONSTPOOL_TYPE_INT,
|
||||
IVY_ASM_CONSTPOOL_TYPE_UINT,
|
||||
IVY_ASM_CONSTPOOL_TYPE_STRING,
|
||||
IVY_ASM_CONSTPOOL_TYPE_ATOM,
|
||||
IVY_ASM_CONSTPOOL_TYPE_IDENT,
|
||||
IVY_ASM_CONSTPOOL_TYPE_SELECTOR,
|
||||
};
|
||||
|
||||
struct ivy_asm_object_info {
|
||||
uint32_t obj_magic;
|
||||
size_t obj_table_offset;
|
||||
@@ -18,8 +32,21 @@ struct ivy_asm_section_info {
|
||||
size_t s_length;
|
||||
};
|
||||
|
||||
struct ivy_asm_constpool_value {
|
||||
enum ivy_asm_constpool_value_type v_type;
|
||||
|
||||
union {
|
||||
long long v_int;
|
||||
unsigned long long v_uint;
|
||||
struct ivy_ident *v_ident;
|
||||
struct ivy_selector *v_sel;
|
||||
char *v_str;
|
||||
};
|
||||
};
|
||||
|
||||
struct ivy_asm_reader;
|
||||
struct ivy_asm_section_reader;
|
||||
struct ivy_asm_constpool_reader;
|
||||
|
||||
IVY_API enum ivy_status ivy_asm_reader_open(FILE *in, struct ivy_asm_reader **out);
|
||||
IVY_API enum ivy_status ivy_asm_reader_close(struct ivy_asm_reader *reader);
|
||||
@@ -30,8 +57,11 @@ IVY_API const struct ivy_asm_section_info *ivy_asm_reader_get_sections(
|
||||
struct ivy_asm_reader *reader);
|
||||
|
||||
IVY_API enum ivy_status ivy_asm_reader_open_section(
|
||||
struct ivy_asm_reader *reader, size_t index,
|
||||
struct ivy_asm_reader *reader, uint32_t type, size_t index,
|
||||
struct ivy_asm_section_reader **out);
|
||||
IVY_API enum ivy_status ivy_asm_reader_open_constpool(
|
||||
struct ivy_asm_reader *reader, size_t constpool_index,
|
||||
size_t xdat_index, struct ivy_asm_constpool_reader **out);
|
||||
|
||||
IVY_API const struct ivy_asm_section_info *ivy_asm_section_reader_get_info(
|
||||
struct ivy_asm_section_reader *reader);
|
||||
@@ -41,6 +71,17 @@ IVY_API enum ivy_status ivy_asm_section_reader_read(
|
||||
struct ivy_asm_section_reader *reader, size_t offset, size_t count,
|
||||
void *p, size_t *nr_read);
|
||||
|
||||
IVY_API size_t ivy_asm_constpool_reader_get_nr_entries(
|
||||
struct ivy_asm_constpool_reader *reader);
|
||||
IVY_API enum ivy_status ivy_asm_constpool_reader_read_value(
|
||||
struct ivy_asm_constpool_reader *reader, size_t index,
|
||||
struct ivy_asm_constpool_value **out);
|
||||
IVY_API enum ivy_status ivy_asm_constpool_reader_close(
|
||||
struct ivy_asm_constpool_reader *reader);
|
||||
|
||||
IVY_API enum ivy_status ivy_asm_constpool_value_destroy(
|
||||
struct ivy_asm_constpool_value *v);
|
||||
|
||||
IVY_API bool ivy_asm_section_type_to_string(uint32_t in, char out[5]);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user