Пример #1
0
        ILuaValue ILuaValue.Arithmetic(BinaryOperationType type, ILuaValue other)
        {
            // Attempt to use a meta-method.
            var ret = LuaValueBase._attemptMetamethod(type, this, other);

            if (ret != null)
            {
                return(ret);
            }

            // Do some default operations.
            ret = _defaultArithmetic(type, other);
            if (ret != null)
            {
                return(ret);
            }

            if (other is ILuaValueVisitor visitor)
            {
                return(visitor.Arithmetic(type, this));
            }
            else
            {
                throw new InvalidOperationException(Errors.CannotArithmetic(LuaValueType.Function));
            }
        }
Пример #2
0
        ILuaValue ILuaValueVisitor.Arithmetic(BinaryOperationType type, LuaThread self)
        {
            var ret = LuaValueBase._attemptMetamethod(type, self, this);

            if (ret != null)
            {
                return(ret);
            }

            throw new InvalidOperationException(Errors.CannotArithmetic(LuaValueType.Thread));
        }