Beispiel #1
0
        internal static void loadKx(Instruction i, ref LuaVM vm)
        {
            var(a, _) = i.ABx();
            a        += 1;
            var ax = new Instruction(vm.Fetch()).Ax();

            vm.GetConst(ax);
            vm.Replace(a);
        }
Beispiel #2
0
        internal static void loadKx(Instruction i, ref LuaVM vm)
        {
            var aBx = i.ABx();
            var a   = aBx.Item1 + 1;
            var ax  = new Instruction(vm.Fetch()).Ax();

            vm.GetConst(ax);
            vm.Replace(a);
        }
Beispiel #3
0
        internal static void setList(Instruction i, ref LuaVM vm)
        {
            var abc = i.ABC();
            var a   = abc.Item1 + 1;
            var b   = abc.Item2;
            var c   = abc.Item3;

            if (c > 0)
            {
                c = c - 1;
            }
            else
            {
                c = new Instruction(vm.Fetch()).Ax();
            }

            var bIsZero = b == 0;

            if (bIsZero)
            {
                b = (int)vm.ToInteger(-1) - a - 1;
                vm.Pop(1);
            }

            vm.CheckStack(1);
            var idx = (long)(c * LFIELDS_PER_FLUSH);

            for (var j = 1; j <= b; j++)
            {
                idx++;
                vm.PushValue(a + j);
                vm.SetI(a, idx);
            }

            if (bIsZero)
            {
                for (var j = vm.RegisterCount() + 1; j <= vm.GetTop(); j++)
                {
                    idx++;
                    vm.PushValue(j);
                    vm.SetI(a, idx);
                }

                // clear stack
                vm.SetTop(vm.RegisterCount());
            }
        }