Esempio n. 1
0
        /// <summary>
        /// R(A) -= R(A + 2)
        /// pc += sBx
        /// </summary>
        public static void ForPrep(Instruction ins, ILuaVM vm)
        {
            ins.AsBx(out var a, out var sbx);
            a += 1;

            if (vm.Type(a) == ELuaType.String)
            {
                vm.PushNumber(vm.ToNumber(a));
                vm.Replace(a);
            }

            if (vm.Type(a + 1) == ELuaType.String)
            {
                vm.PushNumber(vm.ToNumber(a + 1));
                vm.Replace(a + 1);
            }

            if (vm.Type(a + 2) == ELuaType.String)
            {
                vm.PushNumber(vm.ToNumber(a + 2));
                vm.Replace(a + 2);
            }

            // R(A) -= R(A + 2)
            vm.PushValue(a);
            vm.PushValue(a + 2);
            vm.Arith(EArithOp.Sub);
            vm.Replace(a);

            // pc += sBx
            vm.AddPC(sbx);
        }
Esempio n. 2
0
 /// <summary>
 /// UpValue[B] = R(A)
 /// </summary>
 public static void SetUpval(Instruction ins, ILuaVM vm)
 {
     ins.ABC(out var a, out var b, out _);
     a += 1;
     b += 1;
     vm.Copy(a, vm.LuaUpvalueIndex(b));
 }
Esempio n. 3
0
 internal static void LoadK(Instruction i, ILuaVM vm)
 {
     var(a, bx) = i.ABx();
     a         += 1;
     vm.GetConst(bx);
     vm.Replace(a);
 }
Esempio n. 4
0
 /// <summary>
 /// R(A) = R(B)
 /// </summary>
 public static void Move(Instruction ins, ILuaVM vm)
 {
     ins.ABC(out var a, out var b, out _);
     a += 1;
     b += 1;
     vm.Copy(b, a);
 }
Esempio n. 5
0
        public static void Move(int i, ILuaVM vm)
        {
            int a = Instruction.GetA(i) + 1;
            int b = Instruction.GetB(i) + 1;

            vm.Copy(b, a);
        }
Esempio n. 6
0
        //R(A) := {} (size = B,C)
        public static void NewTable(int i, ILuaVM vm)
        {
            int a = Instruction.GetA(i) + 1;
            int b = Instruction.GetB(i) + 1;
            int c = Instruction.GetC(i);

            vm.GetRK(c);
        }
Esempio n. 7
0
        public static void LoadKx(int i, ILuaVM vm)
        {
            int a  = Instruction.GetA(i) + 1;
            int ax = Instruction.GetAx(vm.Fetch());

            vm.GetConst(ax);
            vm.Replace(a);
        }
Esempio n. 8
0
        public static void LoadK(int i, ILuaVM vm)
        {
            int a  = Instruction.GetA(i) + 1;
            int bx = Instruction.GetBx(i);

            vm.GetConst(bx);
            vm.Replace(a);
        }
Esempio n. 9
0
 /// <summary>
 /// R(A) = Kst(extra arg)
 /// </summary>
 public static void LoadKx(Instruction ins, ILuaVM vm)
 {
     ins.ABx(out var a, out _);
     a += 1;
     new Instruction(vm.Fetch()).Ax(out var ax);
     vm.GetConst(ax);
     vm.Replace(a);
 }
Esempio n. 10
0
        /// <summary>
        /// R(A) = {} (size = B, C)
        /// </summary>
        public static void NewTable(Instruction ins, ILuaVM vm)
        {
            ins.ABC(out var a, out var b, out var c);
            a += 1;

            vm.CreateTable(Fpb.Fb2Int(b), Fpb.Fb2Int(c));
            vm.Replace(a);
        }
Esempio n. 11
0
    internal static void GetUpval(Instruction i, ILuaVM vm)
    {
        var(a, b, _) = i.ABC();
        a           += 1;
        b           += 1;

        vm.Copy(LuaState.LuaUpvalueIndex(b), a);
    }
Esempio n. 12
0
 /// <summary>
 /// UpValue[A][RK(B)] = RK(C)
 /// </summary>
 public static void SetTabUp(Instruction ins, ILuaVM vm)
 {
     ins.ABC(out var a, out var b, out var c);
     a += 1;
     vm.GetRK(b);
     vm.GetRK(c);
     vm.SetTable(vm.LuaUpvalueIndex(a));
 }
Esempio n. 13
0
        public void Execute(ILuaVM luaVM)
        {
            var action = OpCodes.Codes[(int)Opcode()].Action;

            if (!(action is null))
            {
                action(this, luaVM);
            }
Esempio n. 14
0
 /// <summary>
 /// R(A + 3, ..., R(A + 2 + C) = R(A)(R(A + 1), R(A + 2))
 /// </summary>
 public static void TForCall(Instruction ins, ILuaVM vm)
 {
     ins.ABC(out var a, out _, out var c);
     a += 1;
     PushFuncAndArgs(a, 3, vm);
     vm.Call(2, c);
     PopResults(a + 3, c + 1, vm);
 }
Esempio n. 15
0
        /// <summary>
        /// R(A) = closure(KPROTO[Bx])
        /// </summary>
        public static void Closure(Instruction ins, ILuaVM vm)
        {
            ins.ABx(out var a, out var bx);
            a += 1;

            vm.LoadProto(bx);
            vm.Replace(a);
        }
Esempio n. 16
0
    internal static void NewTable(Instruction i, ILuaVM vm)
    {
        var(a, b, c) = i.ABC();
        a           += 1;

        vm.CreateTable(Fb2int(b), Fb2int(c));
        vm.Replace(a);
    }
Esempio n. 17
0
        //(iBx) R(A) := closure(KPROTO[Bx])
        public static void Closure(int i, ILuaVM vm)
        {
            int a  = Instruction.GetA(i);
            int bx = Instruction.GetBx(i);

            vm.LoadProto(bx);
            vm.Replace(a);
        }
Esempio n. 18
0
    internal static void Closure(Instruction i, ILuaVM vm)
    {
        var(a, bx) = i.ABx();
        a         += 1;

        vm.LoadProto(bx);
        vm.Replace(a);
    }
Esempio n. 19
0
        /// <summary>
        /// R(A) = Kst(Bx)
        /// </summary>
        public static void LoadK(Instruction ins, ILuaVM vm)
        {
            ins.ABx(out var a, out var bx);
            a += 1;

            vm.GetConst(bx);
            vm.Replace(a);
        }
Esempio n. 20
0
    public static void SetTable(Instruction i, ILuaVM vm)
    {
        var(a, b, c) = i.ABC();
        a           += 1;

        vm.GetRK(b);
        vm.GetRK(c);
        vm.SetTable(a);
    }
Esempio n. 21
0
    internal static void Not(Instruction i, ILuaVM vm)
    {
        var(a, b, _) = i.ABC();
        a           += 1;
        b           += 1;

        vm.PushBoolean(!vm.ToBoolean(b));
        vm.Replace(a);
    }
Esempio n. 22
0
    internal static void TForCall(Instruction i, ILuaVM vm)
    {
        var(a, _, c) = i.ABC();
        a           += 1;

        PushFuncAndArgs(a, 3, vm);
        vm.Call(2, c);
        PopResults(a + 3, c + 1, vm);
    }
Esempio n. 23
0
        private static void unaryArith(int i, ILuaVM vm, ArithOpEnum op)
        {
            int a = Instruction.GetA(i) + 1;
            int b = Instruction.GetB(i) + 1;

            vm.PushValue(b);
            vm.Arith(op);
            vm.Replace(a);
        }
Esempio n. 24
0
    internal static void SetTabUp(Instruction i, ILuaVM vm)
    {
        var(a, b, c) = i.ABC();
        a           += 1;

        vm.GetRK(b);
        vm.GetRK(c);
        vm.SetTable(LuaState.LuaUpvalueIndex(a));
    }
Esempio n. 25
0
    internal static void LoadKx(Instruction i, ILuaVM vm)
    {
        var(a, _) = i.ABx();
        a        += 1;
        int ax = ((Instruction)vm.Fetch()).Ax();

        vm.GetConst(ax);
        vm.Replace(a);
    }
Esempio n. 26
0
        /// <summary>
        /// R(A)[RK(B)] = RK(C)
        /// </summary>
        public static void SetTable(Instruction ins, ILuaVM vm)
        {
            ins.ABC(out var a, out var b, out var c);
            a += 1;

            vm.GetRK(b);
            vm.GetRK(c);
            vm.SetTable(a);
        }
Esempio n. 27
0
    internal static void Len(Instruction i, ILuaVM vm)
    {
        var(a, b, _) = i.ABC();
        a           += 1;
        b           += 1;

        vm.Len(b);
        vm.Replace(a);
    }
Esempio n. 28
0
 /// <summary>
 /// if R(A + 1) != null
 ///     R(A) = R(A + 1); pc += sBx
 /// </summary>
 public static void TForLoop(Instruction ins, ILuaVM vm)
 {
     ins.AsBx(out var a, out var sbx);
     a += 1;
     if (!vm.IsNil(a + 1))
     {
         vm.Copy(a + 1, a);
         vm.AddPC(sbx);
     }
 }
Esempio n. 29
0
    internal static void Call(Instruction i, ILuaVM vm)
    {
        var(a, b, c) = i.ABC();
        a           += 1;

        int nArgs = PushFuncAndArgs(a, b, vm);

        vm.Call(nArgs, c - 1);
        PopResults(a, c, vm);
    }
Esempio n. 30
0
        /// <summary>
        /// R(A), ..., R(A + C - 2) = R(A)(R(A + 1), ..., R(A + B - 1))
        /// </summary>
        public static void Call(Instruction ins, ILuaVM vm)
        {
            ins.ABC(out var a, out var b, out var c);
            a += 1;

            var nArgs = PushFuncAndArgs(a, b, vm);

            vm.Call(nArgs, c - 1);
            PopResults(a, c, vm);
        }