aboutsummaryrefslogtreecommitdiff
path: root/include/bytecode
diff options
context:
space:
mode:
Diffstat (limited to 'include/bytecode')
-rw-r--r--include/bytecode/bytecode.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/include/bytecode/bytecode.h b/include/bytecode/bytecode.h
new file mode 100644
index 0000000..3a141f0
--- /dev/null
+++ b/include/bytecode/bytecode.h
@@ -0,0 +1,33 @@
+#ifndef AMALGAM_BYTECODE_H
+#define AMALGAM_BYTECODE_H
+
+#include "../std/defs.h"
+#include "../std/misc.h"
+#include "../std/buffer.h"
+#include "../defs.h"
+
+#include <setjmp.h>
+
+typedef enum {
+ NOP, /* To allow hot-patching */
+
+} BytecodeInstruction;
+
+typedef u8 BytecodeInstructionType;
+
+typedef struct {
+ Buffer/*<instruction data>*/ instructions;
+} Bytecode;
+
+typedef struct {
+ jmp_buf env;
+ Bytecode *bytecode;
+ Parser *parser; /* borrowed */
+} BytecodeCompilerContext;
+
+CHECK_RESULT int bytecode_init(Bytecode *self, ScopedAllocator *allocator);
+
+/* longjump to self->env on failure */
+void generate_bytecode_from_ssa(BytecodeCompilerContext *self);
+
+#endif