static OnesComplement()
        {
            OperatorFactory.TryBind(ref Invoke, (byte val) => ~val);
            OperatorFactory.TryBind(ref Invoke, (byte val) => (byte)~val);

            OperatorFactory.TryBind(ref Invoke, (sbyte val) => ~val);
            OperatorFactory.TryBind(ref Invoke, (sbyte val) => (sbyte)~val);

            OperatorFactory.TryBind(ref Invoke, (short val) => ~val);
            OperatorFactory.TryBind(ref Invoke, (short val) => (short)~val);

            OperatorFactory.TryBind(ref Invoke, (ushort val) => ~val);
            OperatorFactory.TryBind(ref Invoke, (ushort val) => (ushort)~val);

            OperatorFactory.TryBind(ref Invoke, (int val) => ~val);

            OperatorFactory.TryBind(ref Invoke, (uint val) => ~val);

            OperatorFactory.TryBind(ref Invoke, (long val) => ~val);

            OperatorFactory.TryBind(ref Invoke, (ulong val) => ~val);

            OperatorFactory.TryBind(ref Invoke, (char val) => ~val);
            OperatorFactory.TryBind(ref Invoke, (char val) => (char)~val);

            OperatorFactory.TryBind(ref Invoke, (bool val) => !val);

            Invoke = Invoke
                     ?? OperatorFactory.CreateDelegate <Func <T, R> >("op_OnesComplement")
                     ?? Throw.Func <T, R>;
        }
Esempio n. 2
0
        static Increment()
        {
            try
            {
                OperatorFactory.TryBind(ref Invoke, (byte val) => ++ val);
                OperatorFactory.TryBind(ref Invoke, (sbyte val) => ++ val);
                OperatorFactory.TryBind(ref Invoke, (short val) => ++ val);
                OperatorFactory.TryBind(ref Invoke, (ushort val) => ++ val);
                OperatorFactory.TryBind(ref Invoke, (int val) => ++ val);
                OperatorFactory.TryBind(ref Invoke, (uint val) => ++ val);
                OperatorFactory.TryBind(ref Invoke, (long val) => ++ val);
                OperatorFactory.TryBind(ref Invoke, (ulong val) => ++ val);
                OperatorFactory.TryBind(ref Invoke, (float val) => ++ val);
                OperatorFactory.TryBind(ref Invoke, (double val) => ++ val);
                OperatorFactory.TryBind(ref Invoke, (bool val) => true);
                OperatorFactory.TryBind(ref Invoke, (char val) => ++ val);

                Invoke = Invoke ?? OperatorFactory.CreateDelegate <Func <T, R> >("op_Increment");
            }
            finally
            {
                Supported = Invoke != null;
                Invoke    = Invoke ?? Throw.Func <T, R>;
            }
        }
Esempio n. 3
0
 static UnaryPlus()
 {
     Invoke = OperatorFactory.CreateDelegate <Func <T, R> >("op_UnaryPlus");
     if (Invoke != null)
     {
         return;
     }
     OperatorFactory.TryBind <T, R, T, T>(ref Invoke, val => val);
     Invoke = Invoke ?? Throw.Func <T, R>;
 }
Esempio n. 4
0
        static LogicalNot()
        {
            OperatorFactory.TryBind(ref Invoke, (byte val) => - val);
            OperatorFactory.TryBind(ref Invoke, (byte val) => (byte)-val);
            OperatorFactory.TryBind(ref Invoke, (byte val) => val == 0);

            OperatorFactory.TryBind(ref Invoke, (sbyte val) => - val);
            OperatorFactory.TryBind(ref Invoke, (sbyte val) => (sbyte)-val);
            OperatorFactory.TryBind(ref Invoke, (sbyte val) => val == 0);

            OperatorFactory.TryBind(ref Invoke, (short val) => - val);
            OperatorFactory.TryBind(ref Invoke, (short val) => (short)-val);
            OperatorFactory.TryBind(ref Invoke, (short val) => val == 0);

            OperatorFactory.TryBind(ref Invoke, (ushort val) => - val);
            OperatorFactory.TryBind(ref Invoke, (ushort val) => (ushort)-val);
            OperatorFactory.TryBind(ref Invoke, (ushort val) => val == 0);

            OperatorFactory.TryBind(ref Invoke, (int val) => - val);
            OperatorFactory.TryBind(ref Invoke, (int val) => val == 0);

            OperatorFactory.TryBind(ref Invoke, (uint val) => - val);
            OperatorFactory.TryBind(ref Invoke, (uint val) => (uint)-val);
            OperatorFactory.TryBind(ref Invoke, (uint val) => val == 0);

            OperatorFactory.TryBind(ref Invoke, (long val) => - val);
            OperatorFactory.TryBind(ref Invoke, (long val) => val == 0);

            OperatorFactory.TryBind(ref Invoke, (ulong val) => - (long)val);
            OperatorFactory.TryBind(ref Invoke, (ulong val) => (ulong)-(long)val);
            OperatorFactory.TryBind(ref Invoke, (ulong val) => val == 0);

            OperatorFactory.TryBind(ref Invoke, (char val) => - val);
            OperatorFactory.TryBind(ref Invoke, (char val) => (char)-val);
            OperatorFactory.TryBind(ref Invoke, (char val) => val == 0);

            OperatorFactory.TryBind(ref Invoke, (float val) => - val);
            // ReSharper disable once CompareOfFloatsByEqualityOperator
            OperatorFactory.TryBind(ref Invoke, (float val) => val == 0);

            OperatorFactory.TryBind(ref Invoke, (double val) => - val);
            // ReSharper disable once CompareOfFloatsByEqualityOperator
            OperatorFactory.TryBind(ref Invoke, (double val) => val == 0);

            OperatorFactory.TryBind(ref Invoke, (bool val) => !val);

            Invoke = Invoke
                     ?? OperatorFactory.CreateDelegate <Func <T, R> >("op_LogicalNot")
                     ?? Throw.Func <T, R>;
        }
Esempio n. 5
0
        static Addition()
        {
            try
            {
                OperatorFactory.TryBind(ref Invoke, (string a, string b) => a + b);
                OperatorFactory.TryBind(ref Invoke, (bool a, bool b) => a || b);

                Invoke = Invoke ?? AdditionTable.Factory.CreateDelegate <T1, T2, R>();
            }
            finally
            {
                Supported = Invoke != null;
                Invoke    = Invoke ?? Throw.Func <T1, T2, R>;
            }
        }
Esempio n. 6
0
        static Multiply()
        {
            try
            {
                OperatorFactory.TryBind(ref Invoke, (bool a, bool b) => a && b);
                OperatorFactory.TryBind <T1, T2, R, string, int, string>(ref Invoke, Do_string_int);

                Invoke = Invoke ?? MultiplyTable.Factory.CreateDelegate <T1, T2, R>();
            }
            finally
            {
                Supported = Invoke != null;
                Invoke    = Invoke ?? Throw.Func <T1, T2, R>;
            }
        }
Esempio n. 7
0
        static Zero()
        {
            OperatorFactory.TryBind(ref Invoke, () => (byte)0);
            OperatorFactory.TryBind(ref Invoke, () => (sbyte)0);
            OperatorFactory.TryBind(ref Invoke, () => (short)0);
            OperatorFactory.TryBind(ref Invoke, () => (ushort)0);
            OperatorFactory.TryBind(ref Invoke, () => 0);
            OperatorFactory.TryBind(ref Invoke, () => 0U);
            OperatorFactory.TryBind(ref Invoke, () => 0L);
            OperatorFactory.TryBind(ref Invoke, () => 0UL);
            OperatorFactory.TryBind(ref Invoke, () => 0F);
            OperatorFactory.TryBind(ref Invoke, () => 0D);
            OperatorFactory.TryBind(ref Invoke, () => false);
            OperatorFactory.TryBind(ref Invoke, () => (char)0);
            OperatorFactory.TryBind(ref Invoke, () => "");

            Invoke = Invoke ?? (() => default(T));
        }
Esempio n. 8
0
        static Subtraction()
        {
            try
            {
                OperatorFactory.TryBind(ref Invoke, (bool a, bool b) => a && !b);

                if (Invoke != null)
                {
                    return;
                }

                Invoke = SubtractionTable.Factory.CreateDelegate <T1, T2, R>();
            }
            finally
            {
                Supported = Invoke != null;
                Invoke    = Invoke ?? Throw.Func <T1, T2, R>;
            }
        }
Esempio n. 9
0
        static PrefixIncrement()
        {
            OperatorFactory.TryBind(ref Invoke, (ref byte val) => ++ val);
            OperatorFactory.TryBind(ref Invoke, (ref sbyte val) => ++ val);
            OperatorFactory.TryBind(ref Invoke, (ref short val) => ++ val);
            OperatorFactory.TryBind(ref Invoke, (ref ushort val) => ++ val);
            OperatorFactory.TryBind(ref Invoke, (ref int val) => ++ val);
            OperatorFactory.TryBind(ref Invoke, (ref uint val) => ++ val);
            OperatorFactory.TryBind(ref Invoke, (ref long val) => ++ val);
            OperatorFactory.TryBind(ref Invoke, (ref ulong val) => ++ val);
            OperatorFactory.TryBind(ref Invoke, (ref float val) => ++ val);
            OperatorFactory.TryBind(ref Invoke, (ref double val) => ++ val);
            OperatorFactory.TryBind(ref Invoke, (ref char val) => ++ val);

            Invoke = Invoke ?? ((ref T value) =>
            {
                value = Increment <T, T> .Invoke(value);
                return(value);
            });
        }
        static PostfixDecrement()
        {
            OperatorFactory.TryBind(ref Invoke, (ref byte val) => val--);
            OperatorFactory.TryBind(ref Invoke, (ref sbyte val) => val--);
            OperatorFactory.TryBind(ref Invoke, (ref short val) => val--);
            OperatorFactory.TryBind(ref Invoke, (ref ushort val) => val--);
            OperatorFactory.TryBind(ref Invoke, (ref int val) => val--);
            OperatorFactory.TryBind(ref Invoke, (ref uint val) => val--);
            OperatorFactory.TryBind(ref Invoke, (ref long val) => val--);
            OperatorFactory.TryBind(ref Invoke, (ref ulong val) => val--);
            OperatorFactory.TryBind(ref Invoke, (ref float val) => val--);
            OperatorFactory.TryBind(ref Invoke, (ref double val) => val--);
            OperatorFactory.TryBind(ref Invoke, (ref char val) => val--);

            Invoke = Invoke ?? ((ref T value) =>
            {
                var old = value;
                value = Decrement <T, T> .Invoke(value);
                return(old);
            });
        }
Esempio n. 11
0
        static Decrement()
        {
            try
            {
                OperatorFactory.TryBind(ref Invoke, (byte val) => -- val);
                OperatorFactory.TryBind(ref Invoke, (sbyte val) => -- val);
                OperatorFactory.TryBind(ref Invoke, (short val) => -- val);
                OperatorFactory.TryBind(ref Invoke, (ushort val) => -- val);
                OperatorFactory.TryBind(ref Invoke, (int val) => -- val);
                OperatorFactory.TryBind(ref Invoke, (uint val) => -- val);
                OperatorFactory.TryBind(ref Invoke, (long val) => -- val);
                OperatorFactory.TryBind(ref Invoke, (ulong val) => -- val);
                OperatorFactory.TryBind(ref Invoke, (float val) => -- val);
                OperatorFactory.TryBind(ref Invoke, (double val) => -- val);
                OperatorFactory.TryBind(ref Invoke, (bool val) => false);
                OperatorFactory.TryBind(ref Invoke, (char val) => -- val);

                if (Invoke != null)
                {
                    return;
                }

                var parameter = Expression.Parameter(typeof(T));
                try
                {
                    Invoke = Expression.Lambda <Func <T, R> >(
                        Expression.Decrement(parameter),
                        parameter
                        ).Compile();
                }
                catch { }
            }
            finally
            {
                Supported = Invoke != null;
                Invoke    = Invoke ?? Throw.Func <T, R>;
            }
        }
Esempio n. 12
0
        static UnaryNegation()
        {
            OperatorFactory.TryBind(ref Invoke, (byte val) => - val);
            OperatorFactory.TryBind(ref Invoke, (byte val) => (byte)-val);

            OperatorFactory.TryBind(ref Invoke, (sbyte val) => - val);
            OperatorFactory.TryBind(ref Invoke, (sbyte val) => (sbyte)-val);

            OperatorFactory.TryBind(ref Invoke, (short val) => - val);
            OperatorFactory.TryBind(ref Invoke, (short val) => (short)-val);

            OperatorFactory.TryBind(ref Invoke, (ushort val) => - val);
            OperatorFactory.TryBind(ref Invoke, (ushort val) => (ushort)-val);

            OperatorFactory.TryBind(ref Invoke, (int val) => - val);

            OperatorFactory.TryBind(ref Invoke, (uint val) => - val);
            OperatorFactory.TryBind(ref Invoke, (uint val) => (uint)-val);

            OperatorFactory.TryBind(ref Invoke, (long val) => - val);

            OperatorFactory.TryBind(ref Invoke, (ulong val) => - (long)val);
            OperatorFactory.TryBind(ref Invoke, (ulong val) => (ulong)-(long)val);

            OperatorFactory.TryBind(ref Invoke, (char val) => - val);
            OperatorFactory.TryBind(ref Invoke, (char val) => (char)-val);

            OperatorFactory.TryBind(ref Invoke, (float val) => - val);

            OperatorFactory.TryBind(ref Invoke, (double val) => - val);

            OperatorFactory.TryBind(ref Invoke, (bool val) => !val);

            Invoke = Invoke
                     ?? OperatorFactory.CreateDelegate <Func <T, R> >("op_UnaryNegation")
                     ?? Throw.Func <T, R>;
        }