/// <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); }
private static void Compare(Instruction i, ILuaVM vm, CompareOp op) { var(a, b, c) = i.ABC(); vm.GetRK(b); vm.GetRK(c); if (vm.Compare(-2, -1, op) != (a != 0)) { vm.AddPC(1); } vm.Pop(2); }
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); }
private static void FixStack(int a, ILuaVM vm) { var x = (int)vm.ToInteger(-1); vm.Pop(1); vm.CheckStack(x - a); for (var i = a; i < x; i++) { vm.PushValue(i); } vm.Rotate(vm.RegisterCount() + 1, x - a); }
/// <summary> /// if ((RK(B) op RK(C)) != A) /// pc++ /// </summary> private static void Compare(Instruction ins, ILuaVM vm, ECompOp op) { ins.ABC(out var a, out var b, out var c); vm.GetRK(b); vm.GetRK(c); if (vm.Compare(-2, -1, op) != (a != 0)) { vm.AddPC(1); } vm.Pop(2); }
public static void SetList(Instruction i, ILuaVM vm) { const int FIELDS_PER_FLUSH = 50; var(a, b, c) = i.ABC(); a += 1; bool bIsZero = b == 0; if (bIsZero) { b = (int)vm.ToInteger(-1) - a - 1; vm.Pop(1); } if (c > 0) { c -= 1; } else { c = ((Instruction)vm.Fetch()).Ax(); } Int64 idx = (Int64)(c * FIELDS_PER_FLUSH); for (int j = 1; j <= b; j++) { idx++; vm.PushValue(a + j); vm.SetI(a, idx); } if (bIsZero) { for (int j = vm.RegisterCount() + 1; j <= vm.GetTop(); j++) { idx++; vm.PushValue(j); vm.SetI(a, idx); } vm.SetTop(vm.RegisterCount()); } }
/// <summary> /// R(A)[(C - 1) * FPF + i] := R(A + i), 1 <= i <= B /// </summary> public static void SetList(Instruction ins, ILuaVM vm) { ins.ABC(out var a, out var b, out var c); a += 1; if (c > 0) { c--; } else { new Instruction(vm.Fetch()).Ax(out c); } var bIsZero = b == 0; if (bIsZero) { b = (int)vm.ToInteger(-1) - a - 1; vm.Pop(1); } vm.CheckStack(1); var idx = (LuaInt)(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); } vm.SetTop(vm.RegisterCount()); } }