private static object arith(object a, object b, Operator op) { if (op.FloatFunc == null) { var(v, ok1) = LuaValue.ConvertToInteger(a); if (!ok1) { return(null); } var(v2, ok2) = LuaValue.ConvertToInteger(b); if (ok2) { return(op.IntegerFunc(v, v2)); } } else { if (op.IntegerFunc != null) { if (a is long x && b is long y) { return(op.IntegerFunc(x, y)); } } var(v, ok1) = LuaValue.ConvertToFloat(a); if (!ok1) { return(null); } var(v2, ok2) = LuaValue.ConvertToFloat(b); if (ok2) { return(op.FloatFunc(v, v2)); } } return(null); }
public (double, bool) ToNumberX(int idx) { var val = _stack.Get(idx); return(LuaValue.ConvertToFloat(val)); }