예제 #1
0
 private bool IsArithmetic(ArithmeticTypes arithmetic)
 {
     return(arithmetic == ArithmeticTypes.Add || arithmetic == ArithmeticTypes.Sub || arithmetic == ArithmeticTypes.Div || arithmetic == ArithmeticTypes.Mul ||
            arithmetic == ArithmeticTypes.Abs || arithmetic == ArithmeticTypes.Log || arithmetic == ArithmeticTypes.Log10 || arithmetic == ArithmeticTypes.Truncate ||
            arithmetic == ArithmeticTypes.Sin || arithmetic == ArithmeticTypes.Cos || arithmetic == ArithmeticTypes.Floor || arithmetic == ArithmeticTypes.Round ||
            arithmetic == ArithmeticTypes.Tan || arithmetic == ArithmeticTypes.Tanh || arithmetic == ArithmeticTypes.Sqrt || arithmetic == ArithmeticTypes.Ceiling);
 }
예제 #2
0
        public static OpCode GetOpCode(ArithmeticTypes arithmetic)
        {
            switch (arithmetic)
            {
            case ArithmeticTypes.Add:
                return(OpCodes.Add);

            case ArithmeticTypes.Sub:
                return(OpCodes.Sub);
            }
            return(null);
        }
예제 #3
0
        public static System.Reflection.MethodInfo GetMethod(ArithmeticTypes mathType)
        {
            switch (mathType)
            {
            case ArithmeticTypes.Abs:
                return((typeof(Math).GetMethod("Abs", new Type[] { typeof(double) })));

            case ArithmeticTypes.Round:
                return((typeof(Math).GetMethod("Round", new Type[] { typeof(double) })));

            case ArithmeticTypes.Sin:
                return((typeof(Math).GetMethod("Sin", new Type[] { typeof(double) })));

            case ArithmeticTypes.Cos:
                return((typeof(Math).GetMethod("Cos", new Type[] { typeof(double) })));

            case ArithmeticTypes.Log:
                return((typeof(Math).GetMethod("Log", new Type[] { typeof(double) })));

            case ArithmeticTypes.Log10:
                return((typeof(Math).GetMethod("Log10", new Type[] { typeof(double) })));

            case ArithmeticTypes.Sqrt:
                return((typeof(Math).GetMethod("Sqrt", new Type[] { typeof(double) })));

            case ArithmeticTypes.Ceiling:
                return((typeof(Math).GetMethod("Ceiling", new Type[] { typeof(double) })));

            case ArithmeticTypes.Floor:
                return((typeof(Math).GetMethod("Floor", new Type[] { typeof(double) })));

            case ArithmeticTypes.Tan:
                return((typeof(Math).GetMethod("Tan", new Type[] { typeof(double) })));

            case ArithmeticTypes.Tanh:
                return((typeof(Math).GetMethod("Tanh", new Type[] { typeof(double) })));

            case ArithmeticTypes.Truncate:
                return((typeof(Math).GetMethod("Truncate", new Type[] { typeof(double) })));
            }
            return(null);
        }
예제 #4
0
 private bool IsXor(ArithmeticTypes arithmetic)
 {
     return(arithmetic == ArithmeticTypes.Xor);
 }
 public ArithmeticVT(Value value, Token token, ArithmeticTypes arithmeticTypes)
 {
     this.value           = value;
     this.token           = token;
     this.arithmeticTypes = arithmeticTypes;
 }
        public double GetValue(List <ArithmeticTypes> arithmetics)
        {
            var generator  = new Generator.Generator();
            var arithmetic = arithmetics[generator.Next(arithmetics.Count)];

            GetType = arithmetic;
            switch (arithmeticTypes)
            {
            case ArithmeticTypes.Abs:
                switch (arithmetic)
                {
                case ArithmeticTypes.Add:
                    return(x + (Math.Abs(y) * -1));

                case ArithmeticTypes.Sub:
                    return(x - (Math.Abs(y) * -1));
                }
                return(-1);

            case ArithmeticTypes.Log:
                switch (arithmetic)
                {
                case ArithmeticTypes.Add:
                    return(x - (Math.Log(y)));

                case ArithmeticTypes.Sub:
                    return(x + (Math.Log(y)));
                }
                return(-1);

            case ArithmeticTypes.Log10:
                switch (arithmetic)
                {
                case ArithmeticTypes.Add:
                    return(x - (Math.Log10(y)));

                case ArithmeticTypes.Sub:
                    return(x + (Math.Log10(y)));
                }
                return(-1);

            case ArithmeticTypes.Sin:
                switch (arithmetic)
                {
                case ArithmeticTypes.Add:
                    return(x - (Math.Sin(y)));

                case ArithmeticTypes.Sub:
                    return(x + (Math.Sin(y)));
                }
                return(-1);

            case ArithmeticTypes.Cos:
                switch (arithmetic)
                {
                case ArithmeticTypes.Add:
                    return(x - (Math.Cos(y)));

                case ArithmeticTypes.Sub:
                    return(x + (Math.Cos(y)));
                }
                return(-1);

            case ArithmeticTypes.Floor:
                switch (arithmetic)
                {
                case ArithmeticTypes.Add:
                    return(x - (Math.Floor(y)));

                case ArithmeticTypes.Sub:
                    return(x + (Math.Floor(y)));
                }
                return(-1);

            case ArithmeticTypes.Round:
                switch (arithmetic)
                {
                case ArithmeticTypes.Add:
                    return(x - (Math.Round(y)));

                case ArithmeticTypes.Sub:
                    return(x + (Math.Round(y)));
                }
                return(-1);

            case ArithmeticTypes.Tan:
                switch (arithmetic)
                {
                case ArithmeticTypes.Add:
                    return(x - (Math.Tan(y)));

                case ArithmeticTypes.Sub:
                    return(x + (Math.Tan(y)));
                }
                return(-1);

            case ArithmeticTypes.Tanh:
                switch (arithmetic)
                {
                case ArithmeticTypes.Add:
                    return(x - (Math.Tanh(y)));

                case ArithmeticTypes.Sub:
                    return(x + (Math.Tanh(y)));
                }
                return(-1);

            case ArithmeticTypes.Sqrt:
                switch (arithmetic)
                {
                case ArithmeticTypes.Add:
                    return(x - (Math.Sqrt(y)));

                case ArithmeticTypes.Sub:
                    return(x + (Math.Sqrt(y)));
                }
                return(-1);

            case ArithmeticTypes.Ceiling:
                switch (arithmetic)
                {
                case ArithmeticTypes.Add:
                    return(x - (Math.Ceiling(y)));

                case ArithmeticTypes.Sub:
                    return(x + (Math.Ceiling(y)));
                }
                return(-1);

            case ArithmeticTypes.Truncate:
                switch (arithmetic)
                {
                case ArithmeticTypes.Add:
                    return(x - (Math.Truncate(y)));

                case ArithmeticTypes.Sub:
                    return(x + (Math.Truncate(y)));
                }
                return(-1);
            }
            return(-1);
        }
 public ArithmeticEmulator(double x, double y, ArithmeticTypes arithmeticTypes)
 {
     this.x = x;
     this.y = y;
     this.arithmeticTypes = arithmeticTypes;
 }