???
This commit is contained in:
parent
cfbd114fef
commit
962e09843a
@ -135,7 +135,8 @@ function handleHeader(buffer, context) {
|
||||
|
||||
if (buffer.peakKey() == "UNK") {
|
||||
//TODO assert
|
||||
context.header.unkByte = buffer.next()[1].number.value;
|
||||
// DEPRECATED
|
||||
//context.header.unkByte = buffer.next()[1].number.value;
|
||||
return handleHeader(buffer, context);
|
||||
}
|
||||
|
||||
@ -219,10 +220,8 @@ function handleMethodCode(buffer, context, opcodes) {
|
||||
if (Object.keys(insts.instructionTypes).indexOf(nxt[0].raw) != -1)
|
||||
nxt.shift();
|
||||
|
||||
// console.log(nxt[0].raw)
|
||||
var instruction = insts.instructionByName[nxt[0].raw];
|
||||
nxt.shift();
|
||||
//console.log(instruction)
|
||||
|
||||
if (instruction.type == insts.instructionTypes.iABC) {
|
||||
opcodes.push(insts.encodeABC(instruction.opcode, nxt[0].number.value, nxt[1].number.value, nxt[2].number.value));
|
||||
@ -247,6 +246,7 @@ function handleMethod(buffer, context, method) {
|
||||
return false;
|
||||
return handleMethod(buffer, context, method);
|
||||
}
|
||||
|
||||
if (buffer.peakKey() == "START_CONSTANTS") {
|
||||
if (!readBlock(buffer, context, "CONSTANTS", handleMethodConstants, method.constants))
|
||||
return false;
|
||||
@ -265,7 +265,6 @@ function handleMethod(buffer, context, method) {
|
||||
return handleMethod(buffer, context, method);
|
||||
}
|
||||
|
||||
|
||||
if (buffer.peakKey() == "FLAGS") {
|
||||
//TODO assert
|
||||
method.flags = buffer.next()[1].number.value;
|
||||
@ -290,7 +289,6 @@ function handleMethod(buffer, context, method) {
|
||||
return handleMethod(buffer, context, method);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -299,6 +297,7 @@ function handleScript(buffer, context) {
|
||||
readBlock(buffer, context, "HEADER", handleHeader);
|
||||
return handleScript(buffer, context);
|
||||
}
|
||||
|
||||
if (buffer.peakKey() == "START_METHOD") {
|
||||
readBlock(buffer, context, "METHOD", handleMethod, context.mainMethod);
|
||||
return handleScript(buffer, context);
|
||||
|
@ -110,7 +110,6 @@ function dmpHeader(_, level, header) {
|
||||
append(_, level, fmt("SIZE_T %i", header.machineSize));
|
||||
level--;
|
||||
append(_, level, "END_NUMBER_SIZES");
|
||||
append(_, level, fmt("UNK\t\t%i", header.unkByte));
|
||||
append(_, level, fmt("FLAGS\t%i", header.platformFlags));
|
||||
append(_, level, fmt("TYPES\t%i", header.numOfTypes));
|
||||
append(_, level, fmt("SHARE\t%s", header.share ? "true" : "false"));
|
||||
|
5
index.js
5
index.js
@ -17,7 +17,6 @@ function Header(ctx) {
|
||||
this.instructionSize = 4;
|
||||
this.machineSize = 4;
|
||||
this.numberSize = 4;
|
||||
this.unkByte = 0;
|
||||
this.platformFlags = 0;
|
||||
this.numOfTypes = 13;
|
||||
this.sharingMode = 0; // sharing mode (0 - none, 1 - shared, 2 - secure) ? 1 : 0
|
||||
@ -28,7 +27,6 @@ Header.prototype.read = function() {
|
||||
var buffer = this.ctx.reader.readBytes(false, 14);
|
||||
this.magic = buffer.readUInt32LE();
|
||||
this.version = buffer.readUInt8(4);
|
||||
this.unkByte = buffer.readUInt8(8);
|
||||
this.platformFlags = buffer.readUInt8(12); // extensions etc
|
||||
|
||||
this.intSize = buffer.readUInt8(7); // sizeOfInt
|
||||
@ -322,5 +320,6 @@ module.exports = {
|
||||
Constants: Constants,
|
||||
Debug: Debug,
|
||||
Header: Header,
|
||||
constants: consts
|
||||
constants: consts,
|
||||
instructions: insts
|
||||
}
|
@ -51,6 +51,18 @@ module.exports =
|
||||
|
||||
|
||||
{name: "HKS_OPCODE_SELF" , opcode: 0x8 , type: e_iABC }, //
|
||||
/*
|
||||
|
||||
R1 = dest_r1
|
||||
a = R[a] = dest_a
|
||||
a_one = R[a + 1] = dest_a_one
|
||||
b = R[b] = table
|
||||
c = RK[c] = key
|
||||
|
||||
dest_a_one = table
|
||||
dest_a = table[key]
|
||||
dest_r1 = dest_a
|
||||
*/
|
||||
{name: "HKS_OPCODE_RETURN" , opcode: 0x9 , type: e_iABC },
|
||||
|
||||
{name: "HKS_OPCODE_GETTABLE" , opcode: 0xC , type: e_iABC },
|
||||
|
Loading…
Reference in New Issue
Block a user