Esempio n. 1
0
 internal static void Move(Instruction i, ref LuaVM vm)
 {
     var(a, b, _) = i.ABC();
     a           += 1;
     b           += 1;
     vm.Copy(b, a);
 }
Esempio n. 2
0
        internal static void move(Instruction i, ref LuaVM vm)
        {
            var ab_ = i.ABC();
            var a   = ab_.Item1 + 1;
            var b   = ab_.Item2 + 1;

            vm.Copy(b, a);
        }
Esempio n. 3
0
        internal static void getUpval(Instruction i, ref LuaVM vm)
        {
            var(a, b, _) = i.ABC();
            a           += 1;
            b           += 1;

            vm.Copy(LuaVM.LuaUpvalueIndex(b), a);
        }
Esempio n. 4
0
        // if R(A+1) ~= nil then {
        //   R(A)=R(A+1); pc += sBx
        // }
        internal static void TForLoop(Instruction i, ref LuaVM vm)
        {
            var(a, sBx) = i.AsBx();
            a          += 1;

            if (!vm.IsNil(a + 1))
            {
                vm.Copy(a + 1, a);
                vm.AddPC(sBx);
            }
        }
Esempio n. 5
0
        // R(A+1) := R(B); R(A) := R(B)[RK(C)]
        internal static void Self(Instruction i, ref LuaVM vm)
        {
            var(a, b, c) = i.ABC();
            a           += 1;
            b           += 1;

            vm.Copy(b, a + 1);
            vm.GetRK(c);
            vm.GetTable(b);
            vm.Replace(a);
        }
Esempio n. 6
0
        // R(A+1) := R(B); R(A) := R(B)[RK(C)]
        internal static void self(Instruction i, ref LuaVM vm)
        {
            var abc = i.ABC();
            var a   = abc.Item1 + 1;
            var b   = abc.Item2 + 1;
            var c   = abc.Item3;

            vm.Copy(b, a + 1);
            vm.GetRK(c);
            vm.GetTable(b);
            vm.Replace(a);
        }
Esempio n. 7
0
        internal static void loadNil(Instruction i, ref LuaVM vm)
        {
            var(a, b) = i.AsBx();
            a        += 1;

            vm.PushNil();
            for (var l = a; l <= a + b; l++)
            {
                vm.Copy(-1, l);
            }

            vm.Pop(1);
        }
Esempio n. 8
0
        internal static void LoadNil(Instruction i, ref LuaVM vm)
        {
            var(a, b, _) = i.ABC();
            a           += 1;

            vm.PushNil();
            for (var j = a; j <= a + b; j++)
            {
                vm.Copy(-1, j);
            }

            vm.Pop(1);
        }
Esempio n. 9
0
        internal static void loadNil(Instruction i, ref LuaVM vm)
        {
            var ab_ = i.AsBx();
            var a   = ab_.Item1 + 1;
            var b   = ab_.Item2;

            vm.PushNil();
            for (var l = a; l <= a + b; l++)
            {
                vm.Copy(-1, l);
            }

            vm.Pop(1);
        }
Esempio n. 10
0
        internal static void testSet(Instruction i, ref LuaVM vm)
        {
            var abc = i.ABC();
            var a   = abc.Item1 + 1;
            var b   = abc.Item2 + 1;
            var c   = abc.Item3 + 1;

            if (vm.ToBoolean(b) == (c != 0))
            {
                vm.Copy(b, a);
            }
            else
            {
                vm.AddPC(1);
            }
        }
Esempio n. 11
0
        internal static void TestSet(Instruction i, ref LuaVM vm)
        {
            var(a, b, c) = i.ABC();
            a           += 1;
            b           += 1;
            c           += 1;

            if (vm.ToBoolean(b) == (c != 0))
            {
                vm.Copy(b, a);
            }
            else
            {
                vm.AddPC(1);
            }
        }
Esempio n. 12
0
        internal static void ForLoop(Instruction i, ref LuaVM vm)
        {
            var(a, sBx) = i.AsBx();
            a          += 1;

            // R(A)+=R(A+2);
            vm.PushValue(a + 2);
            vm.PushValue(a);
            vm.Arith(Constant.LUA_OPADD);
            vm.Replace(a);

            var isPositiveStep = vm.ToNumber(a + 2) >= 0;

            if (
                (isPositiveStep && vm.Compare(a, a + 1, Constant.LUA_OPLE)) ||
                (!isPositiveStep && vm.Compare(a + 1, a, Constant.LUA_OPLE)))
            {
                // pc+=sBx; R(A+3)=R(A)
                vm.AddPC(sBx);
                vm.Copy(a, a + 3);
            }
        }