asm: implement an asm parser and emitter
This commit is contained in:
@@ -68,7 +68,7 @@ struct ivy_bin_class {
|
||||
};
|
||||
|
||||
struct ivy_bin_lambda {
|
||||
ivy_bin_data_handle l_ident;
|
||||
b_i32 l_ident;
|
||||
b_i32 l_instr[];
|
||||
};
|
||||
|
||||
@@ -78,12 +78,6 @@ struct ivy_bin_msgh {
|
||||
b_i32 msg_instr[];
|
||||
};
|
||||
|
||||
struct ivy_bin_constpool_header {
|
||||
b_i32 c_nr_table_entries;
|
||||
uint8_t c_reserved[4];
|
||||
b_i64 c_table_offset;
|
||||
};
|
||||
|
||||
struct ivy_bin_string {
|
||||
b_i32 s_hash;
|
||||
b_i32 s_len;
|
||||
@@ -95,25 +89,30 @@ struct ivy_bin_selector {
|
||||
uint8_t sel_nr_args;
|
||||
uint8_t sel_reserved[2];
|
||||
b_i32 sel_hash;
|
||||
ivy_bin_data_handle sel_name;
|
||||
ivy_bin_data_handle sel_args[];
|
||||
b_i32 sel_name;
|
||||
b_i32 sel_args[];
|
||||
};
|
||||
|
||||
struct ivy_bin_ident {
|
||||
b_i32 id_hash;
|
||||
uint8_t id_nr_parts;
|
||||
uint8_t id_reserved[3];
|
||||
ivy_bin_data_handle id_parts[];
|
||||
b_i32 id_parts[];
|
||||
};
|
||||
|
||||
struct ivy_bin_constpool_table_entry {
|
||||
b_i32 e_type;
|
||||
b_i32 e_reserved;
|
||||
|
||||
union {
|
||||
b_i32 e_handle;
|
||||
b_i64 e_int;
|
||||
b_i32 e_ex_handle;
|
||||
b_i32 e_int;
|
||||
};
|
||||
};
|
||||
|
||||
struct ivy_bin_constpool {
|
||||
uint8_t c_reserved[16];
|
||||
struct ivy_bin_constpool_table_entry c_table[];
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef IVY_ASM_LEX_H_
|
||||
#define IVY_ASM_LEX_H_
|
||||
|
||||
#include <blue/core/queue.h>
|
||||
#include <ivy/line-source.h>
|
||||
#include <ivy/misc.h>
|
||||
#include <ivy/status.h>
|
||||
@@ -8,6 +9,7 @@
|
||||
|
||||
enum ivy_asm_token_type {
|
||||
IVY_ASM_TOK_NONE = 0,
|
||||
__IVY_ASM_TOK_INDEX_BASE = 100,
|
||||
IVY_ASM_TOK_KEYWORD,
|
||||
IVY_ASM_TOK_SYMBOL,
|
||||
IVY_ASM_TOK_INT,
|
||||
@@ -16,23 +18,26 @@ enum ivy_asm_token_type {
|
||||
IVY_ASM_TOK_IDENT,
|
||||
IVY_ASM_TOK_STRING,
|
||||
IVY_ASM_TOK_LINEFEED,
|
||||
__IVY_ASM_TOK_INDEX_LIMIT,
|
||||
};
|
||||
|
||||
enum ivy_asm_keyword {
|
||||
IVY_ASM_KW_NONE = 0,
|
||||
IVY_ASM_KW_USE,
|
||||
__IVY_ASM_KW_INDEX_BASE = 200,
|
||||
IVY_ASM_KW_IDENT,
|
||||
IVY_ASM_KW_SELECTOR,
|
||||
IVY_ASM_KW_ATOM,
|
||||
IVY_ASM_KW_LAMBDA,
|
||||
IVY_ASM_KW_SELECTOR,
|
||||
IVY_ASM_KW_IMPORT,
|
||||
IVY_ASM_KW_BLOCK,
|
||||
IVY_ASM_KW_CONSTPOOL,
|
||||
IVY_ASM_KW_CLASS,
|
||||
IVY_ASM_KW_MSGH,
|
||||
IVY_ASM_KW_END,
|
||||
__IVY_ASM_KW_INDEX_LIMIT,
|
||||
};
|
||||
|
||||
enum ivy_asm_symbol {
|
||||
IVY_ASM_SYM_NONE = 0,
|
||||
__IVY_ASM_SYM_INDEX_BASE = 300,
|
||||
IVY_ASM_SYM_DOT,
|
||||
IVY_ASM_SYM_COMMA,
|
||||
IVY_ASM_SYM_LEFT_PAREN,
|
||||
@@ -45,15 +50,17 @@ enum ivy_asm_symbol {
|
||||
IVY_ASM_SYM_SEMICOLON,
|
||||
IVY_ASM_SYM_DOLLAR,
|
||||
IVY_ASM_SYM_HYPHEN,
|
||||
IVY_ASM_SYM_PLUS,
|
||||
IVY_ASM_SYM_SQUOTE,
|
||||
IVY_ASM_SYM_DQUOTE,
|
||||
IVY_ASM_SYM_FORWARD_SLASH_ASTERISK,
|
||||
IVY_ASM_SYM_ASTERISK_FORWARD_SLASH,
|
||||
__IVY_ASM_SYM_INDEX_LIMIT,
|
||||
};
|
||||
|
||||
struct ivy_asm_token {
|
||||
enum ivy_asm_token_type t_type;
|
||||
struct ivy_asm_token *t_next;
|
||||
b_queue_entry t_entry;
|
||||
|
||||
union {
|
||||
enum ivy_asm_keyword t_keyword;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef IVY_ASM_PARSE_H_
|
||||
#define IVY_ASM_PARSE_H_
|
||||
|
||||
#include <ivy/status.h>
|
||||
|
||||
struct ivy_asm_parser;
|
||||
struct ivy_asm_token;
|
||||
struct ivy_assembler;
|
||||
|
||||
IVY_API enum ivy_status ivy_asm_parser_create(struct ivy_asm_parser **out);
|
||||
IVY_API void ivy_asm_parser_destroy(struct ivy_asm_parser *p);
|
||||
|
||||
IVY_API void ivy_asm_parser_set_assembler(
|
||||
struct ivy_asm_parser *p, struct ivy_assembler *as);
|
||||
|
||||
IVY_API enum ivy_status ivy_asm_parser_push_token(
|
||||
struct ivy_asm_parser *p, struct ivy_asm_token *tok);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user