private static void _binaryArith(Instruction i, LuaVM vm, ArithOp op)
        {
            var(a, b, c) = i.ABC();
            a           += 1;

            vm.GetRK(b);
            vm.GetRK(c);
            vm.Arith(op);
            vm.Replace(a);
        }
        private static void _unaryArith(Instruction i, LuaVM vm, ArithOp op)
        {
            var(a, b, _) = i.ABC();
            a           += 1;
            b           += 1;

            vm.PushValue(b);
            vm.Arith(op);
            vm.Replace(a);
        }
        private static void _unaryArith(Instruction i, LuaVM vm, ArithOp op)
        {
            var ab_ = i.ABC();
            var a   = ab_.Item1 + 1;
            var b   = ab_.Item2 + 1;

            vm.PushValue(b);
            vm.Arith(op);
            vm.Replace(a);
        }
Exemple #4
0
        internal static void forPrep(Instruction i, ref LuaVM vm)
        {
            var(a, sBx) = i.AsBx();
            a          += 1;

            vm.PushValue(a);
            vm.PushValue(a + 2);
            vm.Arith(Consts.LUA_OPSUB);
            vm.Replace(a);
            vm.AddPC(sBx);
        }
Exemple #5
0
        internal static void forPrep(Instruction i, ref LuaVM vm)
        {
            var asBx = i.AsBx();
            var a    = asBx.Item1 + 1;
            var sBx  = asBx.Item2;

            vm.PushValue(a);
            vm.PushValue(a + 2);
            vm.Arith(Consts.LUA_OPSUB);
            vm.Replace(a);
            vm.AddPC(sBx);
        }
        private static void _binaryArith(Instruction i, LuaVM vm, ArithOp op)
        {
            var abc = i.ABC();
            var a   = abc.Item1 + 1;
            var b   = abc.Item2;
            var c   = abc.Item3;

            vm.GetRK(b);
            vm.GetRK(c);
            vm.Arith(op);
            vm.Replace(a);
        }
Exemple #7
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);
            }
        }