aboutsummaryrefslogtreecommitdiff
path: root/include/bytecode
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-04-22 02:34:30 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-25 14:36:46 +0200
commita76ba1b33e397638c4209dd77e6073e423ac07a8 (patch)
tree0ef62209546ba91d53a2fabb54f3b8ac9dcfafdf /include/bytecode
parent6a9466da5377d0bc73c7e5aa48deca3740d3de6f (diff)
Start on bytecode. Commit before os switch
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