예제 #1
0
파일: MadMath.cs 프로젝트: ru-ace/SlowSharp
        public static HybInstance PostfixDec(HybInstance a)
        {
            if (a.IsCompiledType)
            {
                if (a.GetHybType().IsValueType)
                {
                    if (a.Is <Int64>())
                    {
                        return(HybInstance.Int64(a.As <Int64>() - 1));
                    }
                    if (a.Is <Int32>())
                    {
                        return(HybInstance.Int(a.As <Int32>() - 1));
                    }
                    if (a.Is <short>())
                    {
                        return(HybInstance.Short(a.As <short>() - 1));
                    }
                    if (a.Is <byte>())
                    {
                        return(HybInstance.Byte(a.As <byte>() - 1));
                    }
                }
            }

            var decMethod = GetDecMethod(a);

            if (decMethod != null)
            {
                return(decMethod.Target.Invoke(null, new HybInstance[] { a }));
            }

            throw new NotImplementedException();
        }
예제 #2
0
파일: MadMath.cs 프로젝트: ru-ace/SlowSharp
        public static HybInstance PrefixMinus(HybInstance a)
        {
            if (a.IsCompiledType)
            {
                if (a.GetHybType().IsValueType)
                {
                    if (a.Is <Decimal>())
                    {
                        return(HybInstance.Decimal(-a.As <Decimal>()));
                    }
                    if (a.Is <Double>())
                    {
                        return(HybInstance.Double(-a.As <Double>()));
                    }
                    if (a.Is <Single>())
                    {
                        return(HybInstance.Float(-a.As <Single>()));
                    }
                    if (a.Is <Int64>())
                    {
                        return(HybInstance.Int64(-a.As <Int64>()));
                    }
                    if (a.Is <Int32>())
                    {
                        return(HybInstance.Int(-a.As <Int32>()));
                    }
                    if (a.Is <short>())
                    {
                        return(HybInstance.Short(-a.As <short>()));
                    }
                    if (a.Is <sbyte>())
                    {
                        return(HybInstance.Byte(-a.As <sbyte>()));
                    }
                }
            }

            var negationMethod = GetUnaryNegationMethod(a);

            if (negationMethod != null)
            {
                return(negationMethod.Target.Invoke(null, new HybInstance[] { a }));
            }

            throw new NotImplementedException();
        }