lundump.py: SETGLOBAL uses K[]

This commit is contained in:
CPunch 2022-08-11 16:49:48 -05:00
parent 055af56e27
commit 875e91636b
2 changed files with 4 additions and 4 deletions

View File

@ -28,8 +28,8 @@ example.luac
[ 0] LOADK : R[0] K[1] ; load "pri" into R[0] [ 0] LOADK : R[0] K[1] ; load "pri" into R[0]
[ 1] LOADK : R[1] K[2] ; load "nt" into R[1] [ 1] LOADK : R[1] K[2] ; load "nt" into R[1]
[ 2] CONCAT : R[0] R[0] R[1] ; concat 2 values from R[0] to R[1] [ 2] CONCAT : R[0] R[0] R[1] ; concat 2 values from R[0] to R[1], store into R[0]
[ 3] SETGLOBAL : R[0] R[0] ; [ 3] SETGLOBAL : R[0] K[0] ;
[ 4] EQ : R[0] K[3] K[3] ; [ 4] EQ : R[0] K[3] K[3] ;
[ 5] JMP : R[0] R[5] ; [ 5] JMP : R[0] R[5] ;
[ 6] GETGLOBAL : R[0] K[4] ; [ 6] GETGLOBAL : R[0] K[4] ;

View File

@ -68,7 +68,7 @@ class ConstType(IntEnum):
_RKBCInstr = [Opcodes.SETTABLE, Opcodes.ADD, Opcodes.SUB, Opcodes.MUL, Opcodes.DIV, Opcodes.MOD, Opcodes.POW, Opcodes.EQ, Opcodes.LT] _RKBCInstr = [Opcodes.SETTABLE, Opcodes.ADD, Opcodes.SUB, Opcodes.MUL, Opcodes.DIV, Opcodes.MOD, Opcodes.POW, Opcodes.EQ, Opcodes.LT]
_RKCInstr = [Opcodes.GETTABLE, Opcodes.SELF] _RKCInstr = [Opcodes.GETTABLE, Opcodes.SELF]
_KBx = [Opcodes.LOADK, Opcodes.GETGLOBAL] _KBx = [Opcodes.LOADK, Opcodes.GETGLOBAL, Opcodes.SETGLOBAL]
# is an 'RK' value a K? (result is true for K, false for R) # is an 'RK' value a K? (result is true for K, false for R)
def whichRK(rk: int): def whichRK(rk: int):
@ -130,7 +130,7 @@ class Instruction:
return "load %s into R[%d]" % (chunk.getConstant(self.B).toCode(), self.A) return "load %s into R[%d]" % (chunk.getConstant(self.B).toCode(), self.A)
elif self.opcode == Opcodes.CONCAT: elif self.opcode == Opcodes.CONCAT:
count = self.C - self.B + 1 count = self.C - self.B + 1
return "concat %d values from R[%d] to R[%d]" % (count, self.B, self.C) return "concat %d values from R[%d] to R[%d], store into R[%d]" % (count, self.B, self.C, self.A)
else: else:
return "" return ""