Adjusted the interpreter's version guard

This commit is contained in:
2023-01-21 13:10:04 +00:00
parent df85d30553
commit d3516b4fc9
2 changed files with 13 additions and 2 deletions

View File

@@ -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;
}

View File

@@ -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");