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); } }
private static void Compare(Instruction i, ref LuaVM vm, CompareOp op) { var(a, b, c) = i.ABC(); vm.GetRK(b); vm.GetRK(c); var br = vm.Compare(-2, -1, op) != (a != 0); if (br) { vm.AddPC(1); } vm.Pop(2); }
internal static void _compare(Instruction i, ref LuaVM vm, CompareOp op) { var abc = i.ABC(); var a = abc.Item1; var b = abc.Item2; var c = abc.Item3; vm.GetRK(b); vm.GetRK(c); if (vm.Compare(-2, -1, op) != (a != 0)) { vm.AddPC(1); } vm.Pop(2); }