asm: add interfaces for a low-level bytecode assembler
This commit is contained in:
0
asm/assembler.c
Normal file
0
asm/assembler.c
Normal file
0
asm/codegen.c
Normal file
0
asm/codegen.c
Normal file
43
asm/include/ivy/asm/assembler.h
Normal file
43
asm/include/ivy/asm/assembler.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef IVY_ASM_ASSEMBLER_H_
|
||||
#define IVY_ASM_ASSEMBLER_H_
|
||||
|
||||
#include <ivy/misc.h>
|
||||
#include <ivy/status.h>
|
||||
|
||||
#define IVY_ASM_INDEX_AUTO (-1)
|
||||
|
||||
struct ivy_selector;
|
||||
struct ivy_instr;
|
||||
|
||||
struct ivy_assembler;
|
||||
|
||||
enum ivy_assembler_scope_type {
|
||||
IVY_ASM_SCOPE_NONE = 0,
|
||||
IVY_ASM_SCOPE_UNIT,
|
||||
IVY_ASM_SCOPE_CLASS,
|
||||
IVY_ASM_SCOPE_LAMBDA,
|
||||
IVY_ASM_SCOPE_MSGH,
|
||||
IVY_ASM_SCOPE_CONSTPOOL,
|
||||
};
|
||||
|
||||
IVY_API enum ivy_static ivy_assembler_create(struct ivy_assembler **as);
|
||||
IVY_API void ivy_assembler_destroy(struct ivy_assembler *as);
|
||||
|
||||
IVY_API enum ivy_status ivy_assembler_begin_scope(
|
||||
struct ivy_assembler *as, enum ivy_assembler_scope_type type);
|
||||
IVY_API enum ivy_status ivy_assembler_end_scope(struct ivy_assembler *as);
|
||||
|
||||
IVY_API enum ivy_status ivy_assembler_put_string(
|
||||
struct ivy_assembler *as, int index, const char *s);
|
||||
IVY_API enum ivy_status ivy_assembler_put_ident(
|
||||
struct ivy_assembler *as, int index, const char *s);
|
||||
IVY_API enum ivy_status ivy_assembler_put_atom(
|
||||
struct ivy_assembler *as, int index, const char *s);
|
||||
IVY_API enum ivy_status ivy_assembler_put_selector(
|
||||
struct ivy_assembler *as, int index, struct ivy_selector *sel);
|
||||
IVY_API enum ivy_status ivy_assembler_put_mvar(
|
||||
struct ivy_assembler *as, int index, const char *name);
|
||||
IVY_API enum ivy_status ivy_assembler_put_instr(
|
||||
struct ivy_assembler *as, const struct ivy_instr *i);
|
||||
|
||||
#endif
|
||||
0
asm/include/ivy/asm/codegen.h
Normal file
0
asm/include/ivy/asm/codegen.h
Normal file
13
asm/include/ivy/asm/instr.h
Normal file
13
asm/include/ivy/asm/instr.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef IVY_ASM_INSTR_H_
|
||||
#define IVY_ASM_INSTR_H_
|
||||
|
||||
#include <ivy/opcode.h>
|
||||
|
||||
struct ivy_instr {
|
||||
enum ivy_opcode i_op;
|
||||
long i_a0;
|
||||
long i_a1;
|
||||
long i_a2;
|
||||
};
|
||||
|
||||
#endif
|
||||
0
asm/include/ivy/asm/parse.h
Normal file
0
asm/include/ivy/asm/parse.h
Normal file
0
asm/parse.c
Normal file
0
asm/parse.c
Normal file
Reference in New Issue
Block a user