mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-22 01:29:22 +00:00
Remove unused data about localFunctions
This commit is contained in:
parent
2c62e419a7
commit
aaf490b143
3 changed files with 7 additions and 30 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue