Exemple #1
0
 def gettable(self, vm: LuaVM):
     a, b, c = self.getAbc()
     a += 1
     b += 1
     vm.GetRk(c)
     vm.GetTable(b)
     vm.Replace(a)
Exemple #2
0
 def gettabup(self, vm: LuaVM):
     a, b, c = self.getAbc()
     a += 1
     b += 1
     vm.GetRk(c)
     vm.GetTable(vm.LuaUpvalueIndex(b))
     vm.Replace(a)
Exemple #3
0
 def self(self, vm: LuaVM):
     a, b, c = self.getAbc()
     a += 1
     b += 1
     vm.Copy(b, a + 1)
     vm.GetRk(c)
     vm.GetTable(b)
     vm.Replace(a)
Exemple #4
0
 def _popResults(self, a: int, c: int, vm: LuaVM):
     if c is 1:
         pass
     elif c > 1:
         for i in range(a + c - 2, a - 1, -1):
             vm.Replace(i)
     else:
         vm.CheckStack(1)
         vm.PushInteger(a)
Exemple #5
0
 def _pushFuncAndArgs(self, a: int, b: int, vm: LuaVM) -> int:
     if b >= 1:
         vm.CheckStack(b)
         for i in range(a, a + b):
             vm.PushValue(i)
         return b - 1
     else:
         self._fixStack(a, vm)
         return vm.GetTop() - vm.RegisterCount() - 1
Exemple #6
0
    def _return(self, vm: LuaVM):
        a, b, _ = self.getAbc()
        a += 1

        if b is 1:
            pass
        elif b > 1:
            vm.CheckStack(b - 1)
            for i in range(a, a + b - 1):
                vm.PushValue(i)
        else:
            self._fixStack(a, vm)
Exemple #7
0
    def tailCall(self, vm: LuaVM):
        a, b, _ = self.getAbc()
        a += 1
        c = 0

        nArgs = self._pushFuncAndArgs(a, b, vm)
        vm.Call(nArgs, c - 1)
        self._popResults(a, c, vm)
Exemple #8
0
 def _fixStack(a: int, vm: LuaVM):
     x = vm.ToInteger(-1)
     vm.Pop(1)
     vm.CheckStack(x - a)
     for i in range(a, x):
         vm.PushValue(i)
     vm.Rotate(vm.RegisterCount() + 1, x - a)
Exemple #9
0
 def setupval(self, vm: LuaVM):
     a, b, _ = self.getAbc()
     a += 1
     b += 1
     vm.Copy(a, vm.LuaUpvalueIndex(b))
Exemple #10
0
 def settabup(self, vm: LuaVM):
     a, b, c = self.getAbc()
     a += 1
     vm.GetRk(b)
     vm.GetRk(c)
     vm.SetTable(vm.LuaUpvalueIndex(a))
Exemple #11
0
 def vararg(self, vm: LuaVM):
     a, b, _ = self.getAbc()
     a += 1
     if b is not 1:
         vm.LoadVararg(b - 1)
         self._popResults(a, b, vm)
Exemple #12
0
 def closure(self, vm: LuaVM):
     a, bx = self.getAbx()
     a += 1
     vm.LoadProto(bx)
     vm.Replace(a)
Exemple #13
0
    def setlist(self, vm: LuaVM):
        a, b, c = self.getAbc()
        a += 1
        if c > 0:
            c -= 1
        else:
            c = Instruction(vm.Fetch()).getAx()

        bisZero = b is 0
        if bisZero:
            b = (vm.ToInteger(-1)) - a - 1
            vm.Pop(1)

        vm.CheckStack(1)
        index = c * LuaTable.LFIELDS_PER_FLUSH

        for i in range(1, b + 1):
            index += 1
            vm.PushValue(a + i)
            vm.SetI(a, index)

        if bisZero:
            for i in range(vm.RegisterCount() + 1, vm.GetTop() + 1):
                index += 1
                vm.PushValue(i)
                vm.SetI(a, index)
            vm.SetTop(vm.RegisterCount())
Exemple #14
0
 def settable(self, vm: LuaVM):
     a, b, c = self.getAbc()
     a += 1
     vm.GetRk(b)
     vm.GetRk(c)
     vm.SetTable(a)
Exemple #15
0
 def newtable(self, vm: LuaVM):
     a, b, c = self.getAbc()
     a += 1
     vm.CreateTable(FbToInt(b), FbToInt(c))
     vm.Replace(a)