internal static void length(Instruction i, LuaVm vm) { var abc = i.ABC(); var a = abc.Item1 + 1; var b = abc.Item2 + 1; vm.Len(b); vm.Replace(a); }
internal static void _unaryArith(Instruction i, LuaVm vm, ArithOp op) { var ab_ = i.ABC(); var a = ab_.Item1 + 1; var b = ab_.Item2 + 1; vm.PushValue(b); vm.Arith(op); vm.Replace(a); }
internal static void not(Instruction i, LuaVm vm) { var abc = i.ABC(); var a = abc.Item1 + 1; var b = abc.Item2 + 1; var c = abc.Item3 + 1; vm.PushBoolean(!vm.ToBoolean(b)); vm.Replace(a); }
internal static void forPrep(Instruction i, LuaVm vm) { var asBx = i.AsBx(); var a = asBx.Item1 + 1; var sBx = asBx.Item2; vm.PushValue(a); vm.PushValue(a + 2); vm.Arith(Consts.LUA_OPSUB); vm.Replace(a); vm.AddPC(sBx); }
internal static void _binaryArith(Instruction i, LuaVm vm, ArithOp op) { var abc = i.ABC(); var a = abc.Item1 + 1; var b = abc.Item2; var c = abc.Item3; vm.GetRK(b); vm.GetRK(c); vm.Arith(op); vm.Replace(a); }
internal static void concat(Instruction i, LuaVm vm) { var abc = i.ABC(); var a = abc.Item1 + 1; var b = abc.Item2 + 1; var c = abc.Item3 + 1; var n = c - b + 1; vm.CheckStack(n); for (var l = b; l <= c; l++) { vm.PushValue(l); } vm.Concat(n); vm.Replace(a); }
internal static void forLoop(Instruction i, LuaVm vm) { var asBx = i.AsBx(); var a = asBx.Item1 + 1; var sBx = asBx.Item2; // R(A)+=R(A+2); vm.PushValue(a + 2); vm.PushValue(a); vm.Arith(Consts.LUA_OPADD); vm.Replace(a); var isPositiveStep = vm.ToNumber(a + 2) >= 0; if ( (isPositiveStep && vm.Compare(a, a + 1, Consts.LUA_OPLE)) || (!isPositiveStep && vm.Compare(a + 1, a, Consts.LUA_OPLE))) { // pc+=sBx; R(A+3)=R(A) vm.AddPC(sBx); vm.Copy(a, a + 3); } }