/// <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)); }
public static void Move(int i, ILuaVM vm) { int a = Instruction.GetA(i) + 1; int b = Instruction.GetB(i) + 1; vm.Copy(b, a); }
/// <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); }
internal static void GetUpval(Instruction i, ILuaVM vm) { var(a, b, _) = i.ABC(); a += 1; b += 1; vm.Copy(LuaState.LuaUpvalueIndex(b), a); }
/// <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); } }
/// <summary> /// R(A + 1) = R(B) /// R(A) = R(B)[RK(C)] /// </summary> public static void Self(Instruction ins, ILuaVM vm) { ins.ABC(out var a, out var b, out var c); a += 1; b += 1; vm.Copy(b, a + 1); vm.GetRK(c); vm.GetTable(b); vm.Replace(a); }
internal static void TForLoop(Instruction i, ILuaVM vm) { var(a, sBx) = i.AsBx(); a += 1; if (!vm.IsNil(a + 1)) { vm.Copy(a + 1, a); vm.AddPC(sBx); } }
internal static void Self(Instruction i, ILuaVM 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); }
//R(A + 1) := R(B); R(A) := R(B)[RK(C)] public static void Self(int i, ILuaVM vm) { int a = Instruction.GetA(i) + 1; int b = Instruction.GetB(i) + 1; int c = Instruction.GetC(i); vm.Copy(b, a + 1); vm.GetRK(c); vm.GetTable(b); vm.Replace(a); }
/// <summary> /// R(A), R(A + 1), ..., R(A + B) = nil /// </summary> public static void LoadNil(Instruction ins, ILuaVM vm) { ins.ABC(out var a, out var b, out _); a += 1; vm.PushNil(); for (var j = a; j <= a + b; j++) { vm.Copy(-1, j); } vm.Pop(1); }
internal static void LoadNil(Instruction i, ILuaVM vm) { var(a, b, _) = i.ABC(); a += 1; vm.PushNil(); for (int j = a; j <= a + b; j++) { vm.Copy(-1, j); } vm.Pop(1); }
public static void LoadNil(int i, ILuaVM vm) { int a = Instruction.GetA(i) + 1; int b = Instruction.GetB(i); vm.PushNil(); for (int j = a; j <= a + b; j++) { vm.Copy(-1, j); } vm.Pop(1); }
internal static void TestSet(Instruction i, ILuaVM vm) { var(a, b, c) = i.ABC(); a += 1; b += 1; if (vm.ToBoolean(b) == (c != 0)) { vm.Copy(b, a); } else { vm.AddPC(1); } }
internal static void ForLoop(Instruction i, ILuaVM vm) { var(a, sBx) = i.AsBx(); a += 1; // R(A)+=R(A+2) vm.PushValue(a + 2); vm.PushValue(a); vm.Arith(ArithOp.Add); vm.Replace(a); // R(A)<?=R(A+1) bool isPositiveStep = vm.ToNumber(a + 2) >= 0; if ((isPositiveStep && vm.Compare(a, a + 1, CompareOp.Le)) || (!isPositiveStep && vm.Compare(a + 1, a, CompareOp.Le))) { vm.AddPC(sBx); // pc+=sBx vm.Copy(a, a + 3); // R(A+3)=R(A) } }
/// <summary> /// R(A) += R(A + 2) /// if R(A) <?= R(A + 1) { /// pc += sBx /// R(A + 3) = R(A) /// } /// </summary> public static void ForLoop(Instruction ins, ILuaVM vm) { ins.AsBx(out var a, out var sbx); a += 1; // R(A) += R(A + 2) vm.PushValue(a + 2); vm.PushValue(a); vm.Arith(EArithOp.Add); vm.Replace(a); var isPositiveStep = vm.ToNumber(a + 2) >= 0; if (isPositiveStep && vm.Compare(a, a + 1, ECompOp.Le) || !isPositiveStep && vm.Compare(a + 1, a, ECompOp.Le)) { // pc += sBx vm.AddPC(sbx); // R(A + 3) = R(A) vm.Copy(a, a + 3); } }