mirror of
https://github.com/CPunch/LuaDecompy.git
synced 2025-02-03 05:50:08 +00:00
Compare commits
2 Commits
c37e9a21d8
...
a22aa808e0
Author | SHA1 | Date | |
---|---|---|---|
a22aa808e0 | |||
935844f274 |
20
lparser.py
20
lparser.py
@ -231,7 +231,8 @@ class LuaDecomp:
|
|||||||
def __emitOperand(self, a: int, b: str, c: str, op: str) -> None:
|
def __emitOperand(self, a: int, b: str, c: str, op: str) -> None:
|
||||||
self.__setReg(a, "(" + b + op + c + ")")
|
self.__setReg(a, "(" + b + op + c + ")")
|
||||||
|
|
||||||
def __compJmp(self, op: str):
|
# handles conditional jumps
|
||||||
|
def __condJmp(self, op: str, rkBC: bool = True):
|
||||||
instr = self.__getCurrInstr()
|
instr = self.__getCurrInstr()
|
||||||
jmpType = "if"
|
jmpType = "if"
|
||||||
scopeStart = "then"
|
scopeStart = "then"
|
||||||
@ -254,7 +255,13 @@ class LuaDecomp:
|
|||||||
self.__addExpr("%s not " % jmpType)
|
self.__addExpr("%s not " % jmpType)
|
||||||
else:
|
else:
|
||||||
self.__addExpr("%s " % jmpType)
|
self.__addExpr("%s " % jmpType)
|
||||||
|
|
||||||
|
# write actual comparison
|
||||||
|
if rkBC:
|
||||||
self.__addExpr(self.__readRK(instr.B) + op + self.__readRK(instr.C) + " ")
|
self.__addExpr(self.__readRK(instr.B) + op + self.__readRK(instr.C) + " ")
|
||||||
|
else: # just testing rkB
|
||||||
|
self.__addExpr(op + self.__readRK(instr.B))
|
||||||
|
|
||||||
self.pc += 1 # skip next instr
|
self.pc += 1 # skip next instr
|
||||||
if scopeStart:
|
if scopeStart:
|
||||||
self.__startScope("%s " % scopeStart, self.pc - 1, jmp)
|
self.__startScope("%s " % scopeStart, self.pc - 1, jmp)
|
||||||
@ -368,11 +375,16 @@ class LuaDecomp:
|
|||||||
elif instr.opcode == Opcodes.JMP:
|
elif instr.opcode == Opcodes.JMP:
|
||||||
pass
|
pass
|
||||||
elif instr.opcode == Opcodes.EQ:
|
elif instr.opcode == Opcodes.EQ:
|
||||||
self.__compJmp(" == ")
|
self.__condJmp(" == ")
|
||||||
elif instr.opcode == Opcodes.LT:
|
elif instr.opcode == Opcodes.LT:
|
||||||
self.__compJmp(" < ")
|
self.__condJmp(" < ")
|
||||||
elif instr.opcode == Opcodes.LE:
|
elif instr.opcode == Opcodes.LE:
|
||||||
self.__compJmp(" <= ")
|
self.__condJmp(" <= ")
|
||||||
|
elif instr.opcode == Opcodes.TEST:
|
||||||
|
if instr.C == 0:
|
||||||
|
self.__condJmp("", False)
|
||||||
|
else:
|
||||||
|
self.__condJmp("not ", False)
|
||||||
elif instr.opcode == Opcodes.CALL:
|
elif instr.opcode == Opcodes.CALL:
|
||||||
preStr = ""
|
preStr = ""
|
||||||
callStr = ""
|
callStr = ""
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
'''
|
'''
|
||||||
l(un)dump.py
|
l(un)dump.py
|
||||||
|
|
||||||
A Lua5.1 cross-platform bytecode deserializer. This module pulls int and size_t sizes from the
|
A Lua5.1 cross-platform bytecode deserializer && serializer. 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,
|
chunk header, meaning it should be able to deserialize lua bytecode dumps from most platforms,
|
||||||
regardless of the host machine.
|
regardless of the host machine.
|
||||||
|
|
||||||
@ -9,11 +9,9 @@
|
|||||||
as well as read the lundump.c source file from the Lua5.1 source.
|
as well as read the lundump.c source file from the Lua5.1 source.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from multiprocessing.spawn import get_executable
|
|
||||||
import struct
|
import struct
|
||||||
import array
|
import array
|
||||||
from enum import IntEnum, Enum, auto
|
from enum import IntEnum, Enum, auto
|
||||||
from typing_extensions import Self
|
|
||||||
|
|
||||||
class InstructionType(Enum):
|
class InstructionType(Enum):
|
||||||
ABC = auto(),
|
ABC = auto(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user