Esempio n. 1
0
        internal static void forLoop(Instruction i, LuaVm vm)
        {
            var asBx = i.AsBx();
            var a    = asBx.Item1 + 1;
            var sBx  = asBx.Item2;

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

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

            if (
                (isPositiveStep && vm.Compare(a, a + 1, Consts.LUA_OPLE)) ||
                (!isPositiveStep && vm.Compare(a + 1, a, Consts.LUA_OPLE)))
            {
                // pc+=sBx; R(A+3)=R(A)
                vm.AddPC(sBx);
                vm.Copy(a, a + 3);
            }
        }
Esempio n. 2
0
        internal static void _compare(Instruction i, LuaVm vm, CompareOp op)
        {
            var abc = i.ABC();
            var a   = abc.Item1 + 1;
            var b   = abc.Item2 + 1;
            var c   = abc.Item3 + 1;

            vm.GetRK(b);
            vm.GetRK(c);
            if (vm.Compare(-2, -1, op) != (a != 0))
            {
                vm.AddPC(1);
            }

            vm.Pop(2);
        }