From 89a6ed96878f33eb536b28f349e82002dbbdecf7 Mon Sep 17 00:00:00 2001 From: Bob Nystrom Date: Thu, 15 Jan 2015 16:02:38 -0800 Subject: [PATCH] Get vm compiling as C++. --- src/wren_vm.c | 6 +++--- src/wren_vm.h | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/wren_vm.c b/src/wren_vm.c index c40c0182..9202a17e 100644 --- a/src/wren_vm.c +++ b/src/wren_vm.c @@ -32,7 +32,7 @@ WrenVM* wrenNewVM(WrenConfiguration* configuration) reallocate = configuration->reallocateFn; } - WrenVM* vm = reallocate(NULL, 0, sizeof(WrenVM)); + WrenVM* vm = (WrenVM*)reallocate(NULL, 0, sizeof(WrenVM)); vm->reallocate = reallocate; @@ -520,13 +520,13 @@ static bool runInterpreter(WrenVM* vm) } #else - #define DISPATCH() goto *dispatchTable[instruction = READ_BYTE()]; + #define DISPATCH() goto *dispatchTable[instruction = (Code)READ_BYTE()]; #endif #else - #define INTERPRET_LOOP for (;;) switch (instruction = READ_BYTE()) + #define INTERPRET_LOOP for (;;) switch (instruction = (Code)READ_BYTE()) #define CASE_CODE(name) case CODE_##name #define DISPATCH() break diff --git a/src/wren_vm.h b/src/wren_vm.h index 3850fae5..50a41545 100644 --- a/src/wren_vm.h +++ b/src/wren_vm.h @@ -51,6 +51,9 @@ typedef enum CODE_LOAD_LOCAL_7, CODE_LOAD_LOCAL_8, + // Note: The compiler assumes the following _STORE instructions always + // immediately follow their corresponding _LOAD ones. + // Pushes the value in local slot [arg]. CODE_LOAD_LOCAL,