summaryrefslogtreecommitdiffstats
path: root/bytecode.h
diff options
context:
space:
mode:
Diffstat (limited to 'bytecode.h')
-rw-r--r--bytecode.h46
1 files changed, 44 insertions, 2 deletions
diff --git a/bytecode.h b/bytecode.h
index 70929c91..ba5fec3a 100644
--- a/bytecode.h
+++ b/bytecode.h
@@ -3,10 +3,52 @@
#include <stdint.h>
#include "jv.h"
-#include "opcode.h"
-#include "builtin.h"
+
+typedef enum {
+#define OP(name, imm, in, out) name,
+#include "opcode_list.h"
+#undef OP
+} opcode;
+
+enum {
+ NUM_OPCODES =
+#define OP(name, imm, in, out) +1
+#include "opcode_list.h"
+#undef OP
+};
+
+enum {
+ OP_HAS_CONSTANT = 2,
+ OP_HAS_VARIABLE = 4,
+ OP_HAS_BRANCH = 8,
+ OP_HAS_CFUNC = 32,
+ OP_HAS_UFUNC = 64,
+ OP_IS_CALL_PSEUDO = 128,
+ OP_HAS_BINDING = 1024,
+};
+struct opcode_description {
+ opcode op;
+ const char* name;
+
+ int flags;
+
+ // length in 16-bit units
+ int length;
+
+ int stack_in, stack_out;
+};
+
+const struct opcode_description* opcode_describe(opcode op);
+
#define MAX_CFUNCTION_ARGS 10
+typedef void (*cfunction_ptr)(void);
+struct cfunction {
+ cfunction_ptr fptr;
+ const char* name;
+ int nargs;
+};
+
struct symbol_table {
struct cfunction* cfunctions;
int ncfunctions;