From a76ba1b33e397638c4209dd77e6073e423ac07a8 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 22 Apr 2019 02:34:30 +0200 Subject: Start on bytecode. Commit before os switch --- include/bytecode/bytecode.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 include/bytecode/bytecode.h (limited to 'include/bytecode') 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 + +typedef enum { + NOP, /* To allow hot-patching */ + +} BytecodeInstruction; + +typedef u8 BytecodeInstructionType; + +typedef struct { + Buffer/**/ 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 -- cgit v1.2.3