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); }
private static void binaryArith(int i, ILuaVM vm, ArithOpEnum op) { int a = Instruction.GetA(i) + 1; int b = Instruction.GetB(i); int c = Instruction.GetC(i); vm.GetRK(b); vm.GetRK(c); vm.Arith(op); vm.Replace(a); }
public void Arith(ArithOpEnum op) { Object b = stack.Pop(); Object a = op != ArithOpEnum.LUA_OPUNM && op != ArithOpEnum.LUA_OPBNOT ? stack.Pop() : b; Object result = Arithmetic.Arith(a, b, op); if (result != null) { stack.Push(result); } }
public static Object Arith(Object a, Object b, ArithOpEnum op) { LongBinaryOperator integerFunc = integerOps[(int)op]; DoubleBinaryOperator floatFunc = floatOps[(int)op]; if (floatFunc == null) { long?x = LuaValue.ToInteger(a); if (x != null) { long?y = LuaValue.ToInteger(b); if (y != null) { return(integerFunc((long)x, (long)y)); } } } else { if (integerFunc != null) { if (TypeExtension.TypeEqual <long>(a) && TypeExtension.TypeEqual <long>(b)) { return(integerFunc((long)a, (long)b)); } } double?x = LuaValue.ToFloat(a); if (x != null) { double?y = LuaValue.ToFloat(b); if (y != null) { return(floatFunc((double)x, (double)y)); } } } return(null); }