mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-22 09:37:17 +00:00
Add runtime version and remove version check hacks (#818)
* add runtime version and remove version check hacks * move jump logic into a shared function
This commit is contained in:
parent
c55babadd6
commit
1ab5a9d0d7
2 changed files with 21 additions and 18 deletions
|
|
@ -32,9 +32,11 @@ async function interpret(start, program, stack = [], { logger = null }) {
|
|||
stack.push(operator(bValue, aValue));
|
||||
}
|
||||
|
||||
// Run all the commands that are safe to run. Increment this number to find
|
||||
// the next bug.
|
||||
const maxOffset = Math.max(...Object.keys(offsetToCommand));
|
||||
function jumpToOffset(offset) {
|
||||
const nextCommandIndex = offsetToCommand[offset];
|
||||
return nextCommandIndex - 1;
|
||||
}
|
||||
|
||||
let i = start;
|
||||
while (i < commands.length) {
|
||||
const command = commands[i];
|
||||
|
|
@ -103,16 +105,22 @@ async function interpret(start, program, stack = [], { logger = null }) {
|
|||
if (value) {
|
||||
break;
|
||||
}
|
||||
const offset = command.arg;
|
||||
const nextCommandIndex = offsetToCommand[offset];
|
||||
i = nextCommandIndex - 1;
|
||||
i = jumpToOffset(command.arg);
|
||||
break;
|
||||
}
|
||||
// jumpIfNot
|
||||
case 17: {
|
||||
const value = stack.pop();
|
||||
// This seems backwards. Same as above
|
||||
if (!value) {
|
||||
break;
|
||||
}
|
||||
i = jumpToOffset(command.arg);
|
||||
break;
|
||||
}
|
||||
// jump
|
||||
case 18: {
|
||||
const offset = command.arg;
|
||||
const nextCommandIndex = offsetToCommand[offset];
|
||||
i = nextCommandIndex - 1;
|
||||
i = jumpToOffset(command.arg);
|
||||
break;
|
||||
}
|
||||
// call
|
||||
|
|
@ -140,15 +148,7 @@ async function interpret(start, program, stack = [], { logger = null }) {
|
|||
}
|
||||
// callGlobal
|
||||
case 25: {
|
||||
let offset = command.arg;
|
||||
// This is where the version checked wa5 scripts start with this offset
|
||||
if (offset === 0) {
|
||||
// skip ahead to where the real program begins
|
||||
// TODO: Why is this magic?
|
||||
i = i + 3;
|
||||
break;
|
||||
}
|
||||
// handle offsets that are over maxOffset that seem to be the wrong sign
|
||||
const offset = command.arg;
|
||||
const nextCommandIndex = offsetToCommand[offset];
|
||||
// Remove this await when we can run the VM synchronously.
|
||||
// See GitHub issue #814
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@ class System extends MakiObject {
|
|||
getScriptGroup() {
|
||||
return new Group();
|
||||
}
|
||||
getRuntimeVersion() {
|
||||
return "5.666";
|
||||
}
|
||||
getToken(str, separator, tokennum) {
|
||||
return "Some Token String";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue