From d3516b4fc93c6bfbc26fcd2e4d0bc96947e1b86d Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Sat, 21 Jan 2023 13:10:04 +0000 Subject: [PATCH] Adjusted the interpreter's version guard --- source/interpreter.c | 6 ++++-- test/scripts/lib/runner.toy | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/source/interpreter.c b/source/interpreter.c index bb2bcfc..ace9ab7 100644 --- a/source/interpreter.c +++ b/source/interpreter.c @@ -2370,8 +2370,10 @@ void runInterpreter(Interpreter* interpreter, unsigned char* bytecode, int lengt const unsigned char minor = readByte(interpreter->bytecode, &interpreter->count); const unsigned char patch = readByte(interpreter->bytecode, &interpreter->count); - if (major != TOY_VERSION_MAJOR || minor != TOY_VERSION_MINOR || patch != TOY_VERSION_PATCH) { - interpreter->errorOutput("Interpreter/bytecode version mismatch\n"); + if (major != TOY_VERSION_MAJOR || minor > TOY_VERSION_MINOR) { + char buffer[MAX_STRING_LENGTH]; + snprintf(buffer, MAX_STRING_LENGTH, "Interpreter/bytecode version mismatch (expected %d.%d.%d or earlier, given %d.%d.%d)\n", TOY_VERSION_MAJOR, TOY_VERSION_MINOR, TOY_VERSION_PATCH, major, minor, patch); + interpreter->errorOutput(buffer); return; } diff --git a/test/scripts/lib/runner.toy b/test/scripts/lib/runner.toy index ef1aabc..8f2e804 100644 --- a/test/scripts/lib/runner.toy +++ b/test/scripts/lib/runner.toy @@ -23,6 +23,15 @@ import runner; s.freeScript(); } +//test running an external binary file +{ + var s = loadScriptBytecode("scripts:/lib/runner/sample_bytecode.tb"); + + s.runScript(); + + s.freeScript(); +} + //test resetting an external script { var s = loadScript("scripts:/runner_sample_code.toy");