示例#1
0
        object _arith(LuaValue a, LuaValue b, Operator op)
        {
            if (op.floatFunc == null)
            {
                Tuple <long, bool> v = LuaValue.convertToInteger(a);
                if (v.Item2)
                {
                    Tuple <long, bool> v2 = LuaValue.convertToInteger(b);
                    if (v2.Item2)
                    {
                        return(op.integerFunc(v.Item1, v2.Item1));
                    }
                }
            }
            else
            {
                if (op.integerFunc != null)
                {
                    if (a.isInteger() && b.isInteger())
                    {
                        var x = a.toInteger();
                        var y = b.toInteger();
                        return(op.integerFunc(x, y));
                    }
                }

                var v = LuaValue.convertToFloat(a);
                if (v.Item2)
                {
                    var v2 = LuaValue.convertToFloat(b);
                    if (v2.Item2)
                    {
                        return(op.floatFunc(v.Item1, v2.Item1));
                    }
                }
            }

            return(null);
        }
示例#2
0
        object _arith(LuaValue a, LuaValue b, Operator op)
        {
            if (op.floatFunc == null)
            {
                Tuple <long, bool> v = LuaValue.convertToInteger(a.value);
                if (v.Item2)
                {
                    Tuple <long, bool> v2 = LuaValue.convertToInteger(b.value);
                    if (v2.Item2)
                    {
                        return(op.integerFunc(v.Item1, v2.Item1));
                    }
                }
            }
            else
            {
                if (op.integerFunc != null)
                {
                    if (a.value.GetType().Name.Equals("Int64") && b.value.GetType().Name.Equals("Int64"))
                    {
                        var x = long.Parse(a.value.ToString());
                        var y = long.Parse(b.value.ToString());
                        return(op.integerFunc(x, y));
                    }
                }

                var v = LuaValue.convertToFloat(a.value);
                if (v.Item2)
                {
                    var v2 = LuaValue.convertToFloat(b.value);
                    if (v2.Item2)
                    {
                        return(op.floatFunc(v.Item1, v2.Item1));
                    }
                }
            }

            return(null);
        }
示例#3
0
        object _arith(object a, object b, Operator op)
        {
            if (op.floatFunc == null)
            {
                var v = LuaValue.convertToInteger(a);
                if (v.Item2)
                {
                    var v2 = LuaValue.convertToInteger(b);
                    if (v2.Item2)
                    {
                        return(op.integerFunc(v.Item1, v2.Item1));
                    }
                }
            }
            else
            {
                if (op.integerFunc != null)
                {
                    if (LuaValue.isInteger(a) && LuaValue.isInteger(b))
                    {
                        var x = LuaValue.toInteger(a);
                        var y = LuaValue.toInteger(b);
                        return(op.integerFunc(x, y));
                    }
                }

                var v = LuaValue.convertToFloat(a);
                if (v.Item2)
                {
                    var v2 = LuaValue.convertToFloat(b);
                    if (v2.Item2)
                    {
                        return(op.floatFunc(v.Item1, v2.Item1));
                    }
                }
            }

            return(null);
        }
示例#4
0
        public (double, bool) ToNumberX(int idx)
        {
            var val = stack.get(idx);

            return(LuaValue.convertToFloat(val));
        }
示例#5
0
        public Tuple <double, bool> ToNumberX(int idx)
        {
            var val = stack.get(idx);

            return(LuaValue.convertToFloat(new LuaValue(val)));
        }