Compare commits

..

No commits in common. "a22aa808e01d34de9a5ade59b00d9cd4d3351e2b" and "c37e9a21d8c204ddc05fa0534f261923b6350d0c" have entirely different histories.

2 changed files with 8 additions and 18 deletions

View File

@ -231,8 +231,7 @@ class LuaDecomp:
def __emitOperand(self, a: int, b: str, c: str, op: str) -> None:
self.__setReg(a, "(" + b + op + c + ")")
# handles conditional jumps
def __condJmp(self, op: str, rkBC: bool = True):
def __compJmp(self, op: str):
instr = self.__getCurrInstr()
jmpType = "if"
scopeStart = "then"
@ -255,13 +254,7 @@ class LuaDecomp:
self.__addExpr("%s not " % jmpType)
else:
self.__addExpr("%s " % jmpType)
# write actual comparison
if rkBC:
self.__addExpr(self.__readRK(instr.B) + op + self.__readRK(instr.C) + " ")
else: # just testing rkB
self.__addExpr(op + self.__readRK(instr.B))
self.__addExpr(self.__readRK(instr.B) + op + self.__readRK(instr.C) + " ")
self.pc += 1 # skip next instr
if scopeStart:
self.__startScope("%s " % scopeStart, self.pc - 1, jmp)
@ -375,16 +368,11 @@ class LuaDecomp:
elif instr.opcode == Opcodes.JMP:
pass
elif instr.opcode == Opcodes.EQ:
self.__condJmp(" == ")
self.__compJmp(" == ")
elif instr.opcode == Opcodes.LT:
self.__condJmp(" < ")
self.__compJmp(" < ")
elif instr.opcode == Opcodes.LE:
self.__condJmp(" <= ")
elif instr.opcode == Opcodes.TEST:
if instr.C == 0:
self.__condJmp("", False)
else:
self.__condJmp("not ", False)
self.__compJmp(" <= ")
elif instr.opcode == Opcodes.CALL:
preStr = ""
callStr = ""

View File

@ -1,7 +1,7 @@
'''
l(un)dump.py
A Lua5.1 cross-platform bytecode deserializer && serializer. This module pulls int and size_t sizes from the
A Lua5.1 cross-platform bytecode deserializer. This module pulls int and size_t sizes from the
chunk header, meaning it should be able to deserialize lua bytecode dumps from most platforms,
regardless of the host machine.
@ -9,9 +9,11 @@
as well as read the lundump.c source file from the Lua5.1 source.
'''
from multiprocessing.spawn import get_executable
import struct
import array
from enum import IntEnum, Enum, auto
from typing_extensions import Self
class InstructionType(Enum):
ABC = auto(),