예제 #1
0
        public LogQuery WithLevel(LogLevel?value = null,
                                  ArgumentEvaluationMode mode = ArgumentEvaluationMode.IgnoreNeutral,
                                  EnumOperator @operator      = EnumOperator.Equal)
        {
            switch (mode)
            {
            case ArgumentEvaluationMode.IgnoreNeutral:
                if (Neutrals.Is(value))
                {
                    return(this);
                }
                break;

            case ArgumentEvaluationMode.Explicit:
                break;

            default:
                throw new NotSupportedEnumException(mode);
            }

            switch (@operator)
            {
            case EnumOperator.Equal:
                Entities = Entities.Where(l => l.Level == value);
                return(this);

            case EnumOperator.NotEqual:
                Entities = Entities.Where(l => l.Level != value);
                return(this);

            default:
                throw new NotSupportedEnumException(@operator);
            }
        }
예제 #2
0
 private void btnClear_Click(object sender, EventArgs e)
 {
     currentOperator  = EnumOperator.None;
     lblResult.Text   = "";
     lblEquation.Text = "";
     numSum           = 0;
 }
예제 #3
0
파일: Enums.cs 프로젝트: opalavenger/YMIR
        public static String GetString(this EnumOperator type, string columnNmae, string value, string valueType)
        {
            switch (type)
            {
            case EnumOperator.Equal:
                return(string.Format("{2}.ToLower().Equal({1}{0}){1}", value, (valueType.ToUpper() == "STRING" ? "" : ""), columnNmae));

            case EnumOperator.GreaterThan:
                return(string.Format("{2}.ToLower().CompareTo({1}{0}){1}>0", value, (valueType.ToUpper() == "STRING" ? "" : ""), columnNmae));

            case EnumOperator.LessThan:
                return(string.Format("{2}.ToLower().CompareTo({1}{0}){1}<0", value, (valueType.ToUpper() == "STRING" ? "" : ""), columnNmae));

            case EnumOperator.GreaterThanOrEqual:
                return(string.Format("{2}.ToLower().CompareTo({1}{0}){1}>=0", value, (valueType.ToUpper() == "STRING" ? "" : ""), columnNmae));

            case EnumOperator.LessThanOrEqual:
                return(string.Format("{2}.ToLower().CompareTo({1}{0}){1}<=0", value, (valueType.ToUpper() == "STRING" ? "" : ""), columnNmae));

            case EnumOperator.NotEqual:
                return(string.Format("!{2}.ToLower().Equal({1}{0}){1}", value, (valueType.ToUpper() == "STRING" ? "" : ""), columnNmae));

            case EnumOperator.Like:
                return(string.Format("{2}.ToLower().Contains({1}{0}){1}", value, (valueType.ToUpper() == "STRING" ? "" : ""), columnNmae));

            default:
                return("=");
            }
        }
예제 #4
0
        public TransactionRequestQuery WithStatus(TransactionRequestStatus?value = null,
                                                  ArgumentEvaluationMode mode    = ArgumentEvaluationMode.IgnoreNeutral,
                                                  EnumOperator @operator         = EnumOperator.Equal)
        {
            switch (mode)
            {
            case ArgumentEvaluationMode.IgnoreNeutral:
                if (Neutrals.Is(value))
                {
                    return(this);
                }
                break;

            case ArgumentEvaluationMode.Explicit:
                break;

            default:
                throw new NotSupportedEnumException(mode);
            }

            switch (@operator)
            {
            case EnumOperator.Equal:
                Entities = Entities.Where(tr => tr.Status == value);
                return(this);

            case EnumOperator.NotEqual:
                Entities = Entities.Where(tr => tr.Status != value);
                return(this);

            default:
                throw new NotSupportedEnumException(@operator);
            }
        }
예제 #5
0
        public OrderLineQuery WithType(ItemType?value = null,
                                       ArgumentEvaluationMode mode = ArgumentEvaluationMode.IgnoreNeutral,
                                       EnumOperator @operator      = EnumOperator.Equal)
        {
            switch (mode)
            {
            case ArgumentEvaluationMode.IgnoreNeutral:
                if (Neutrals.Is(value))
                {
                    return(this);
                }
                break;

            case ArgumentEvaluationMode.Explicit:
                break;

            default:
                throw new NotSupportedEnumException(mode);
            }

            switch (@operator)
            {
            case EnumOperator.Equal:
                Entities = Entities.Where(ol => ol.Type == value);
                return(this);

            case EnumOperator.NotEqual:
                Entities = Entities.Where(ol => ol.Type != value);
                return(this);

            default:
                throw new NotSupportedEnumException(@operator);
            }
        }
예제 #6
0
파일: Enums.cs 프로젝트: opalavenger/YMIR
        public static String GetString(this EnumOperator type)
        {
            switch (type)
            {
            case EnumOperator.Equal:
                return("=");

            case EnumOperator.GreaterThan:
                return(">");

            case EnumOperator.LessThan:
                return("<");

            case EnumOperator.GreaterThanOrEqual:
                return(">=");

            case EnumOperator.LessThanOrEqual:
                return("<=");

            case EnumOperator.NotEqual:
                return("<>");

            case EnumOperator.Like:
                return("like");

            default:
                return("=");
            }
        }
예제 #7
0
        /// <summary>
        /// 只需输入运算符,工厂就能实例化出合适的对象,通过多态,返回父类的方式实现了计算器的结果
        /// </summary>
        /// <param name="operate">运算符</param>
        /// <returns></returns>
        public static Operation createOpeate(EnumOperator op)
        {
            Operation oper = null;

            switch (op)
            {
            case EnumOperator.Add:
                oper = new OperationAdd();
                break;

            case EnumOperator.Minus:
                oper = new OperationSub();
                break;

            case EnumOperator.Multiply:
                oper = new OperationMul();
                break;

            case EnumOperator.Divide:
                oper = new OperationDiv();
                break;

            default:
                break;
            }
            return(oper);
        }
예제 #8
0
 /// <summary>
 /// 归零方法
 /// </summary>
 private void gui0()
 {
     currentOperator = EnumOperator.None;
     lblMain.Text    = "";
     lblFu.Text      = "";
     numSum          = 0;
 }
        public QueuedEmailQuery WithSendPriority(Priority?value = null,
                                                 ArgumentEvaluationMode mode = ArgumentEvaluationMode.IgnoreNeutral,
                                                 EnumOperator @operator      = EnumOperator.Equal)
        {
            switch (mode)
            {
            case ArgumentEvaluationMode.IgnoreNeutral:
                if (Neutrals.Is(value))
                {
                    return(this);
                }
                break;

            case ArgumentEvaluationMode.Explicit:
                break;

            default:
                throw new NotSupportedEnumException(mode);
            }

            switch (@operator)
            {
            case EnumOperator.Equal:
                Entities = Entities.Where(qe => qe.SendPriority == value);
                return(this);

            case EnumOperator.NotEqual:
                Entities = Entities.Where(qe => qe.SendPriority != value);
                return(this);

            default:
                throw new NotSupportedEnumException(@operator);
            }
        }
예제 #10
0
        public static string ToCommand(this EnumOperator pOperator)
        {
            switch (pOperator)
            {
            case EnumOperator.Equal: return("=");

            case EnumOperator.Different: return("<>");

            case EnumOperator.LessThan: return("<");

            case EnumOperator.GreaterThan: return(">");

            case EnumOperator.LessEqualThan: return("<=");

            case EnumOperator.GreaterEqualThan: return(">=");

            case EnumOperator.In: return("IN");

            case EnumOperator.NotIn: return("NOT IN");

            case EnumOperator.Like: return("LIKE");

            default: return(string.Empty);
            }
        }
예제 #11
0
파일: EnumParam.cs 프로젝트: bQvle/Sqline
 public EnumParam(TEnum value, EnumOperator valueOperator)
 {
     if (valueOperator == EnumOperator.EqualsNull)
     {
         throw new NotNullableException("EnumParam cannot be null");
     }
     FOperator = valueOperator;
     FValue    = value;
 }
예제 #12
0
        public static bool IsListOperator(this EnumOperator pOperator)
        {
            switch (pOperator)
            {
            case EnumOperator.In:
            case EnumOperator.NotIn: return(true);

            default: return(false);
            }
        }
예제 #13
0
        /// <summary>
        /// 根据运算符和两个数字计算结果
        /// 调用简单工厂模式生成的类
        /// </summary>
        private void Evaluate()
        {
            Operation oper;

            //根据不同的对象生成不同的类,多态!
            switch (currentOperator)
            {
            case EnumOperator.None:
                break;

            //加
            case EnumOperator.Add:
                oper          = OperationFactory.createOpeate(EnumOperator.Add);
                oper.NumberA  = numSum;
                oper.NumnberB = currentValue;
                numSum        = oper.GetResult();
                break;

            //减
            case EnumOperator.Minus:
                oper          = OperationFactory.createOpeate(EnumOperator.Minus);
                oper.NumberA  = numSum;
                oper.NumnberB = currentValue;
                numSum        = oper.GetResult();
                break;

            //乘
            case EnumOperator.Multiply:
                oper          = OperationFactory.createOpeate(EnumOperator.Multiply);
                oper.NumberA  = numSum;
                oper.NumnberB = currentValue;
                numSum        = oper.GetResult();
                break;

            //除
            case EnumOperator.Divide:
                //判断结果
                if (currentValue != 0)
                {
                    oper          = OperationFactory.createOpeate(EnumOperator.Divide);
                    oper.NumberA  = numSum;
                    oper.NumnberB = currentValue;
                    numSum        = oper.GetResult();
                }
                else
                {
                    MessageBox.Show("除数不能为0哦,亲~", "出错了~");
                }
                break;
            }
            currentValue    = 0;
            currentOperator = EnumOperator.None;
        }
예제 #14
0
 public NullableEnumParam(TEnum value, EnumOperator enumOperator)
 {
     if (typeof(TEnum).IsClass && value == null)
     {
         FOperator = EnumOperator.EqualsNull;
         IsNull    = false;
         return;
     }
     FOperator = enumOperator;
     FValue    = value;
     if (enumOperator == EnumOperator.EqualsNull)
     {
         IsNull = false;
     }
 }
예제 #15
0
        public int ApplyOperation(int number1, int number2, EnumOperator enumOperator)
        {
            switch (enumOperator)
            {
            case EnumOperator.Plus:
                return(number1 + number2);

            case EnumOperator.Minus:
                return(number1 - number2);

            case EnumOperator.Times:
                return(number1 * number2);

            default:
                throw new FaultException("Unknown operator");
            }
        }
예제 #16
0
        /// <summary>
        /// 定义一个枚举运算符参数的函数
        /// 里面调用DisplayOperator方法
        /// </summary>
        /// <param name="op"></param>
        private void OperatorClick(EnumOperator op)
        {
            if (currentOperator != EnumOperator.None)
            {
                //计算
                Evaluate();
            }
            else
            {
                //numSum = double.Parse(lblResult.Text);
                double.TryParse(lblMain.Text, out numSum);
            }

            DisplayOperator(op);

            lblMain.Text    = "";
            currentOperator = op;
        }
예제 #17
0
        /// <summary>
        /// 根据运算符号来执行四则运算显示的内容
        /// </summary>
        /// <param name="op"></param>
        private void DisplayOperator(EnumOperator op)
        {
            //选择判断
            switch (op)
            {
            case EnumOperator.None:
                lblFu.Text  = lblMain.Text;
                lblFu.Text += "";
                break;

            case EnumOperator.Add:
                if (lblMain.Text != "")
                {
                    lblFu.Text = lblMain.Text;
                }
                lblFu.Text += "+";
                break;

            case EnumOperator.Minus:
                if (lblMain.Text != "")
                {
                    lblFu.Text = lblMain.Text;
                }
                lblFu.Text += "-";
                break;

            case EnumOperator.Multiply:
                lblFu.Text  = lblMain.Text;
                lblFu.Text += "x";
                break;

            case EnumOperator.Divide:
                lblFu.Text  = lblMain.Text;
                lblFu.Text += "➗";
                break;

            default:
                break;
            }
        }
예제 #18
0
파일: Form1.cs 프로젝트: clark8022/ClarkApp
        private void DisplayOperator(EnumOperator op)
        {
            switch (op)
            {
            case EnumOperator.None:
                label2.Text  = label1.Text;
                label2.Text += "";
                break;

            case EnumOperator.Add:
                if (label1.Text != "")
                {
                    label2.Text = label1.Text;
                }
                label2.Text += "+";
                break;

            case EnumOperator.Minus:
                if (label1.Text != "")
                {
                    label2.Text = label1.Text;
                }
                label2.Text += "-";
                break;

            case EnumOperator.Multiply:
                label2.Text  = label1.Text;
                label2.Text += "x";
                break;

            case EnumOperator.Divide:
                label2.Text  = label1.Text;
                label2.Text += "➗";
                break;

            default:
                break;
            }
        }
예제 #19
0
        private void DisplayOperator(EnumOperator op)
        {
            switch (op)
            {
            case EnumOperator.None:
                lblEquation.Text  = lblResult.Text;
                lblEquation.Text += "";
                break;

            case EnumOperator.Add:
                if (lblResult.Text != "")
                {
                    lblEquation.Text = lblResult.Text;
                }
                lblEquation.Text += "+";
                break;

            case EnumOperator.Minus:
                if (lblResult.Text != "")
                {
                    lblEquation.Text = lblResult.Text;
                }
                lblEquation.Text += "-";
                break;

            case EnumOperator.Multiply:
                lblEquation.Text  = lblResult.Text;
                lblEquation.Text += "x";
                break;

            case EnumOperator.Divide:
                lblEquation.Text  = lblResult.Text;
                lblEquation.Text += "÷";
                break;

            default:
                break;
            }
        }
예제 #20
0
        void OnEnable()
        {
            blending     = GetComponent <Blending>();
            targetCamera = GetComponent <Camera>();

            blending.enabled = true;
            mouseTracker.Clear();

            mouseCurr            = new MousePosition(targetCamera, blending.BlendingData);
            fsmTrackerTargetMode = new FSM <TargetModeEnum>(this);
            fsmGUIMode           = new FSM <GUIModeEnum>(this);

            cornerControl = new CornerControl(this, blending, mouseTracker, mouseCurr);
            edgeControl   = new EdgeControl(this, blending, mouseTracker, mouseCurr);
            blendControl  = new BlendControl(this, blending, mouseTracker, mouseCurr);

            #region FSM Setup
            fsmTrackerTargetMode.State(TargetModeEnum.None);
            fsmTrackerTargetMode.State(TargetModeEnum.Corner)
            .Enter(fsm => cornerControl.Activity = true)
            .Update(fsm => cornerControl.Update())
            .Exit(fsm => cornerControl.Activity = false);
            fsmTrackerTargetMode.State(TargetModeEnum.Edge)
            .Enter(fsm => edgeControl.Activity = true)
            .Update(fsm => edgeControl.Update())
            .Exit(fsm => edgeControl.Activity = false);
            fsmTrackerTargetMode.State(TargetModeEnum.Blend)
            .Enter(fsm => blendControl.Activity = true)
            .Update(fsm => blendControl.Update())
            .Exit(fsm => blendControl.Activity = false);
            fsmTrackerTargetMode.Init();

            fsmGUIMode.State(GUIModeEnum.Hidden).Update(fsm => {
                if (Input.GetKeyDown(config.guiModeToggleKey))
                {
                    fsm.Goto(GUIModeEnum.Show);
                }
            });
            fsmGUIMode.State(GUIModeEnum.Show).Update(fsm => {
                if (Input.GetKeyDown(config.guiModeToggleKey))
                {
                    fsm.Goto(GUIModeEnum.Hidden);
                }
            });
            fsmGUIMode.Init();
            #endregion

            #region Reactive setup
            trackerMode.Changed += (r => {
                fsmTrackerTargetMode.Goto(r.Value);
                trackerIndex.Value = EnumOperator <TargetModeEnum> .FindIndex(r.Value);
            });
            trackerIndex.Changed += (r => {
                trackerMode.Value = EnumOperator <TargetModeEnum> .ValueAt(r.Value);
            });

            screenColumnCount.Changed += (r => {
                UpdateScreenSetup(r.Value, screenRowCount.Value);
                screenColumnCountText.Value = r.Value.ToString();
            });
            screenRowCount.Changed += (r => {
                UpdateScreenSetup(screenColumnCount.Value, r.Value);
                screenRowCountText.Value = r.Value.ToString();
            });
            screenColumnCountText.Changed += (r => {
                int nextValue;
                if (int.TryParse(r.Value, out nextValue))
                {
                    screenColumnCount.Value = Mathf.Max(1, nextValue);
                }
            });
            screenRowCountText.Changed += (r => {
                int nextValue;
                if (int.TryParse(r.Value, out nextValue))
                {
                    screenRowCount.Value = Mathf.Max(1, nextValue);
                }
            });

            outputMode.Changed += (r => {
                blending.BlendingData.OutputKeyword = r.Value;
                outputIndex.Value = EnumOperator <KwOutput> .FindIndex(r.Value);
            });
            outputIndex.Changed += (r => {
                outputMode.Value = EnumOperator <KwOutput> .ValueAt(r.Value);
            });

            wireframeMode.Changed += (r => {
                blending.BlendingData.WireframeKeyword = r.Value;
                wireframeIndex.Value = EnumOperator <KwWireframe> .FindIndex(r.Value);
            });
            wireframeIndex.Changed += (r => {
                wireframeMode.Value = EnumOperator <KwWireframe> .ValueAt(r.Value);
            });

            textureBlendMode.Changed += (r => {
                blending.BlendingData.TextureBlendkeyword = r.Value;
                textureBlendIndex.Value = EnumOperator <KwTextureBlend> .FindIndex(r.Value);
            });
            textureBlendIndex.Changed += (r =>
                                          textureBlendMode.Value = EnumOperator <KwTextureBlend> .ValueAt(r.Value));

            maskTextureIndex.Changed += (r => {
                blending.BlendingData.MaskTextureIndex = r.Value;
                maskTextureIndexText.Value = r.Value.ToString();
            });
            maskTextureIndexText.Changed += (r => {
                int nextValue;
                if (int.TryParse(r.Value, out nextValue))
                {
                    maskTextureIndex.Value = nextValue;
                }
            });
            #endregion

            Load();
            UpdateScreenSetup(screenColumnCount.Value, screenRowCount.Value);
        }
예제 #21
0
 public static bool Evaluate(EnumOperator operatorType, object first, object second)
 {
예제 #22
0
        private void CreateNumericalInstruction(EnumTypes Type, EnumOperator operation, string name, dynamic val)
        {
            List<string> ops = new List<string>(0);
            DefineVariable(Type, name, null);

            switch (operation)
            {

                case EnumOperator.UNARY_PLUS:
                    {
                        for (int i = 0; i < branches.Count; i++)
                        {
                            if (Regex.IsMatch((string)branches.ElementAt(i).Value, "([0-9])"))
                            {
                                ops.Add((string)branches.ElementAt(i).Value);
                                //if(Regex.IsMatch((string)this.tree.getroot(tree).Value,"([0-9])"))
                                //{
                                //    ops.Add((string)this.tree.getroot(tree).Value);
                                //}
                                for (int j = 0; j < this.thetree.ASTbranches.Count; j++)
                                {
                                    if (Regex.IsMatch((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value, "([0-9])"))
                                    {
                                        ops.Add((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value);
                                    }
                                    else
                                    {
                                        continue;
                                    }
                                }
                            }
                            else
                            {
                                continue;
                            }
                            if (ops.Count < 1)
                            {
                                try
                                {
                                    throw new InvalidOperationException("Cannot Create Specified instruction type with no operands");
                                }
                                catch (InvalidOperationException ex)
                                {
                                    Console.ForegroundColor = ConsoleColor.DarkRed;
                                    Console.WriteLine(ex.GetType());
                                    Console.WriteLine(ex.Message);
                                    Console.WriteLine(ex.StackTrace);
                                    Console.ResetColor();
                                }
                                finally
                                {
                                    Console.ForegroundColor = ConsoleColor.Magenta;
                                    Console.WriteLine("A FATAL ERROR HAS OCCURED DURING CODE GENERATION : CANNOT CREATE INSTRUCTION WITHOUT AN OPCODE OR OPERANDS ");
                                    Console.ResetColor();
                                    System.Threading.Thread.Sleep(2500);
                                    Environment.Exit(-1);
                                }

                            }
                        }
                        Instruction ins = new Instruction((int)EnumOpcodes.ADD, ops.ToArray<string>());
                        break;

                    }

                case EnumOperator.UNARY_MINUS:
                    {
                        for (int i = 0; i < branches.Count; i++)
                        {
                            if (Regex.IsMatch((string)branches.ElementAt(i).Value, "([0-9])"))
                            {
                                ops.Add((string)branches.ElementAt(i).Value);
                                //if(Regex.IsMatch((string)this.tree.getroot(tree).Value,"([0-9])"))
                                //{
                                //    ops.Add((string)this.tree.getroot(tree).Value);
                                //}
                                for (int j = 0; j < this.thetree.ASTbranches.Count; j++)
                                {
                                    if (Regex.IsMatch((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value, "([0-9])"))
                                    {
                                        ops.Add((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value);
                                    }
                                    else
                                    {
                                        continue;
                                    }
                                }
                            }
                            else
                            {
                                continue;
                            }
                            if (ops.Count < 1)
                            {
                                try
                                {
                                    throw new InvalidOperationException("Cannot Create Specified instruction type with no operands");
                                }
                                catch (InvalidOperationException ex)
                                {
                                    Console.ForegroundColor = ConsoleColor.DarkRed;
                                    Console.WriteLine(ex.GetType());
                                    Console.WriteLine(ex.Message);
                                    Console.WriteLine(ex.StackTrace);
                                    Console.ResetColor();
                                }
                                finally
                                {
                                    Console.ForegroundColor = ConsoleColor.Magenta;
                                    Console.WriteLine("A FATAL ERROR HAS OCCURED DURING CODE GENERATION : CANNOT CREATE INSTRUCTION WITHOUT AN OPCODE OR OPERANDS ");
                                    Console.ResetColor();
                                    System.Threading.Thread.Sleep(2500);
                                    Environment.Exit(-1);
                                }

                            }
                        }
                        Instruction ins = new Instruction((int)EnumOpcodes.SUB, ops.ToArray<string>());
                        break;
                    }
                case EnumOperator.UNARY_MULTIPLY:
                    {
                        bool issigned = false;
                        for (int i = 0; i < branches.Count; i++)
                        {
                            if (Regex.IsMatch((string)branches.ElementAt(i).Value, "([0-9])"))
                            {
                                if ((int)branches.ElementAt(i).Value < 0)
                                {
                                    issigned = true;
                                }
                                ops.Add((string)branches.ElementAt(i).Value);
                                //if(Regex.IsMatch((string)this.tree.getroot(tree).Value,"([0-9])"))
                                //{
                                //    ops.Add((string)this.tree.getroot(tree).Value);
                                //}
                                for (int j = 0; j < this.thetree.ASTbranches.Count; j++)
                                {
                                    if (Regex.IsMatch((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value, "([0-9])"))
                                    {
                                        ops.Add((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value);
                                    }
                                    else
                                    {
                                        continue;
                                    }
                                }
                            }
                            else
                            {
                                continue;
                            }
                            if (ops.Count < 1)
                            {
                                try
                                {
                                    throw new InvalidOperationException("Cannot Create Specified instruction type with no operands");
                                }
                                catch (InvalidOperationException ex)
                                {
                                    Console.ForegroundColor = ConsoleColor.DarkRed;
                                    Console.WriteLine(ex.GetType());
                                    Console.WriteLine(ex.Message);
                                    Console.WriteLine(ex.StackTrace);
                                    Console.ResetColor();
                                }
                                finally
                                {
                                    Console.ForegroundColor = ConsoleColor.Magenta;
                                    Console.WriteLine("A FATAL ERROR HAS OCCURED DURING CODE GENERATION : CANNOT CREATE INSTRUCTION WITHOUT AN OPCODE OR OPERANDS ");
                                    Console.ResetColor();
                                    System.Threading.Thread.Sleep(2500);
                                    Environment.Exit(-1);
                                }

                            }
                        }
                        if (issigned)
                        {
                            Instruction ins = new Instruction((int)EnumOpcodes.IMUL, ops.ToArray<string>());
                        }
                        else
                        {
                            Instruction ins = new Instruction((int)EnumOpcodes.MUL,ops.ToArray<string>());
                        }

                        break;
                    }
                case EnumOperator.UNARY_DIVIDE:
                    {
                        bool issigned = false;
                        for (int i = 0; i < branches.Count; i++)
                        {
                            if (Regex.IsMatch((string)branches.ElementAt(i).Value, "([0-9])"))
                            {
                                if ((int)branches.ElementAt(i).Value < 0)
                                {
                                    issigned = true;
                                }
                                ops.Add((string)branches.ElementAt(i).Value);
                                //if(Regex.IsMatch((string)this.tree.getroot(tree).Value,"([0-9])"))
                                //{
                                //    ops.Add((string)this.tree.getroot(tree).Value);
                                //}
                                for (int j = 0; j < this.thetree.ASTbranches.Count; j++)
                                {
                                    if (Regex.IsMatch((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value, "([0-9])"))
                                    {
                                        ops.Add((string)this.thetree.ASTbranches.ElementAt<ASTBranch<dynamic, dynamic, dynamic, dynamic>>(j).Value);
                                    }
                                    else
                                    {
                                        continue;
                                    }
                                }
                            }
                            else
                            {
                                continue;
                            }
                            if (ops.Count < 1)
                            {
                                try
                                {
                                    throw new InvalidOperationException("Cannot Create Specified instruction type with no operands");
                                }
                                catch (InvalidOperationException ex)
                                {
                                    Console.ForegroundColor = ConsoleColor.DarkRed;
                                    Console.WriteLine(ex.GetType());
                                    Console.WriteLine(ex.Message);
                                    Console.WriteLine(ex.StackTrace);
                                    Console.ResetColor();
                                }
                                finally
                                {
                                    Console.ForegroundColor = ConsoleColor.Magenta;
                                    Console.WriteLine("A FATAL ERROR HAS OCCURED DURING CODE GENERATION : CANNOT CREATE INSTRUCTION WITHOUT AN OPCODE OR OPERANDS ");
                                    Console.ResetColor();
                                    System.Threading.Thread.Sleep(2500);
                                    Environment.Exit(-1);
                                }

                            }
                        }
                        if (issigned)
                        {
                            Instruction ins = new Instruction((int)EnumOpcodes.IDIV, ops.ToArray<string>());
                        }
                        else
                        {
                            Instruction ins = new Instruction((int)EnumOpcodes.DIV, ops.ToArray<string>());
                        }
                        break;
                    }
            }
            return;
        }
예제 #23
0
 private int GetOperation(EnumOperator Operator)
 {
     return (int)Operator;
 }
        public void GetEnumDescriptionByInt_Null_Test()
        {
            var description = EnumOperator.GetEnumDescriptionByInt(null);

            Assert.IsTrue(description == PackageStoredTypeEnum.UnKnown.GetDescription());
        }
        public void GetEnumDescriptionByInt_InEnum_Test()
        {
            var description = EnumOperator.GetEnumDescriptionByInt(1);

            Assert.IsTrue(description == PackageStoredTypeEnum.Normal.GetDescription());
        }
예제 #26
0
 public Filter(string property, object value, EnumOperator operatorType)
 {
     Property = property;
     Value = value;
     OperatorType = operatorType;
 }
예제 #27
0
 private void CreateAlphaNumericalInstruction(EnumTypes Type, EnumOperator operation, string name, dynamic val)
 {
     DefineVariable(Type, name, null);
 }
예제 #28
0
 private void CreateBinaryInstruction(EnumTypes Type, EnumOperator operation, string name, dynamic val)
 {
     List<string> ops = new List<string>(0);
     DefineVariable(Type, name, null);
     switch(operation)
     {
         case EnumOperator.ASSIGNMEMT:
             {
                 for (int i = 0; i < branches.Count; i++)
                 {
                     ops.Add(this.thetree.ASTbranches.ElementAt(i).name);
                     ops.Add((string)this.thetree.ASTbranches.ElementAt(i).Value);
                 }
             }
             break;
     }
 }