diff --git a/experiments/modern/src/maki-interpreter/index.test.js b/experiments/modern/src/maki-interpreter/index.test.js index ede024f3..7fac7fe2 100644 --- a/experiments/modern/src/maki-interpreter/index.test.js +++ b/experiments/modern/src/maki-interpreter/index.test.js @@ -157,15 +157,6 @@ describe("standardframe.maki", () => { ]); }); - test("can read localFunctions", () => { - expect(maki.localFunctions).toEqual({ - "722": { - function: { code: [], name: "func722", offset: 722 }, - offset: 722, - }, - }); - }); - // [opcode, size] as output by the Perl decompiler // TODO: Get rid of the size values here, they are not used any more // prettier-ignore diff --git a/experiments/modern/src/maki-interpreter/parser.js b/experiments/modern/src/maki-interpreter/parser.js index 5623e0dc..cc425a96 100644 --- a/experiments/modern/src/maki-interpreter/parser.js +++ b/experiments/modern/src/maki-interpreter/parser.js @@ -202,20 +202,17 @@ function decodeCode({ makiFile, classes, variables, methods }) { const length = makiFile.readUInt32LE(); const start = makiFile.getPosition(); - const localFunctions = {}; const commands = []; while (makiFile.getPosition() < start + length) { const pos = makiFile.getPosition() - start; - commands.push( - parseComand({ start, makiFile, length, pos, localFunctions }) - ); + commands.push(parseComand({ start, makiFile, length, pos })); } - return { commands, localFunctions }; + return commands; } // TODO: Refactor this to consume bytes directly off the end of MakiFile -function parseComand({ start, makiFile, length, pos, localFunctions }) { +function parseComand({ start, makiFile, length, pos }) { const opcode = makiFile.readUInt8(); const command = { offset: pos, @@ -254,17 +251,7 @@ function parseComand({ start, makiFile, length, pos, localFunctions }) { // Note in the perl code here: "todo, something strange going on here..." const variable = makiFile.readUInt32LE() + 5; const offset = variable + pos; - arg = { - name: `func${offset}`, - code: [], - offset, - }; - if (localFunctions[offset] == null) { - localFunctions[offset] = { - function: arg, - offset, - }; - } + arg = offset; break; } case "obj": { @@ -310,7 +297,7 @@ function parse(buffer) { const variables = readVariables({ makiFile: makiFile, classes }); readConstants({ makiFile: makiFile, variables }); const bindings = readBindings(makiFile); - const { commands, localFunctions } = decodeCode({ + const commands = decodeCode({ makiFile, classes, variables, @@ -342,7 +329,6 @@ function parse(buffer) { variables, bindings: resolvedBindings, commands, - localFunctions, version, extraVersion, offsetToCommand, diff --git a/experiments/modern/src/maki-interpreter/virtualMachine.js b/experiments/modern/src/maki-interpreter/virtualMachine.js index be7675d0..9551532c 100644 --- a/experiments/modern/src/maki-interpreter/virtualMachine.js +++ b/experiments/modern/src/maki-interpreter/virtualMachine.js @@ -139,12 +139,12 @@ async function interpret(start, program, stack = [], { logger = null }) { // callGlobal case 25: { // This is where the version checked wa5 scripts start with this offset - if (command.arg.offset === 4294967296) { + if (command.arg === 4294967296) { // skip ahead to where the real program begins i = i + 3; break; } - let offset = command.arg.offset; + let offset = command.arg; // handle offsets that are over maxOffset that seem to be the wrong sign if (offset > maxOffset) { offset = offset - 4294967296;