Pull out opcode definitions into an X-macro file.

This commit is contained in:
Bob Nystrom
2015-03-28 09:56:07 -07:00
parent 6254a2e15e
commit a7fafce265
4 changed files with 200 additions and 257 deletions
+3 -74
View File
@@ -658,80 +658,9 @@ static bool runInterpreter(WrenVM* vm)
// Note that the order of instructions here must exacly match the Code enum
// in wren_vm.h or horrendously bad things happen.
static void* dispatchTable[] = {
&&code_CONSTANT,
&&code_NULL,
&&code_FALSE,
&&code_TRUE,
&&code_LOAD_LOCAL_0,
&&code_LOAD_LOCAL_1,
&&code_LOAD_LOCAL_2,
&&code_LOAD_LOCAL_3,
&&code_LOAD_LOCAL_4,
&&code_LOAD_LOCAL_5,
&&code_LOAD_LOCAL_6,
&&code_LOAD_LOCAL_7,
&&code_LOAD_LOCAL_8,
&&code_LOAD_LOCAL,
&&code_STORE_LOCAL,
&&code_LOAD_UPVALUE,
&&code_STORE_UPVALUE,
&&code_LOAD_MODULE_VAR,
&&code_STORE_MODULE_VAR,
&&code_LOAD_FIELD_THIS,
&&code_STORE_FIELD_THIS,
&&code_LOAD_FIELD,
&&code_STORE_FIELD,
&&code_POP,
&&code_DUP,
&&code_CALL_0,
&&code_CALL_1,
&&code_CALL_2,
&&code_CALL_3,
&&code_CALL_4,
&&code_CALL_5,
&&code_CALL_6,
&&code_CALL_7,
&&code_CALL_8,
&&code_CALL_9,
&&code_CALL_10,
&&code_CALL_11,
&&code_CALL_12,
&&code_CALL_13,
&&code_CALL_14,
&&code_CALL_15,
&&code_CALL_16,
&&code_SUPER_0,
&&code_SUPER_1,
&&code_SUPER_2,
&&code_SUPER_3,
&&code_SUPER_4,
&&code_SUPER_5,
&&code_SUPER_6,
&&code_SUPER_7,
&&code_SUPER_8,
&&code_SUPER_9,
&&code_SUPER_10,
&&code_SUPER_11,
&&code_SUPER_12,
&&code_SUPER_13,
&&code_SUPER_14,
&&code_SUPER_15,
&&code_SUPER_16,
&&code_JUMP,
&&code_LOOP,
&&code_JUMP_IF,
&&code_AND,
&&code_OR,
&&code_IS,
&&code_CLOSE_UPVALUE,
&&code_RETURN,
&&code_CLOSURE,
&&code_CLASS,
&&code_METHOD_INSTANCE,
&&code_METHOD_STATIC,
&&code_LOAD_MODULE,
&&code_IMPORT_VARIABLE,
&&code_END
#define OPCODE(name) &&code_##name,
#include "wren_opcodes.h"
#undef OPCODE
};
#define INTERPRET_LOOP DISPATCH();