Exemple #1
0
 public BitwiseExprNode(OPERATOR _op, ExprNode _lhs, ExprNode _rhs)
 {
     type = OILType.BitwiseExpr;
     op   = _op;
     lhs  = _lhs;
     rhs  = _rhs;
 }
Exemple #2
0
 public LogicalExprNode(OPERATOR _op, ExprNode _lhs, ExprNode _rhs)
 {
     type = OILType.LogicalExpr;
     op   = _op;
     lhs  = _lhs;
     rhs  = _rhs;
 }
Exemple #3
0
 public ArithmeticExprNode(OPERATOR _op, ExprNode _lhs, ExprNode _rhs)
 {
     type = OILType.ArithmeticExpr;
     op   = _op;
     lhs  = _lhs;
     rhs  = _rhs;
 }
Exemple #4
0
 public ComparisonExprNode(OPERATOR _op, ExprNode _lhs, ExprNode _rhs)
 {
     type = OILType.CompareExpr;
     op   = _op;
     lhs  = _lhs;
     rhs  = _rhs;
 }
        public virtual bool Write2buffer_Instructions(ref List <byte> bf)
        {
            try
            {
                StructFile sf_operator;
                OPERAND    _operand;
                for (int j = 0; j < instructionlist.Count; j++)
                {
                    sf_operator = new StructFile(typeof(OPERATOR));
                    OPERATOR _operator = instructionlist[j].Operator;
                    //_operator.ReturnType = Common.ntohi(_operator.ReturnType);
                    //_operator.OpCode = Common.ntohi(_operator.OpCode);
                    _operator.Res2 = 2;
                    _operator.Res3 = 3;
                    sf_operator.WriteStructure(ref bf, (object)_operator);

                    for (int k = 0; k < instructionlist[j].OperandList.Count; k++)
                    {
                        sf_operator = new StructFile(typeof(OPERAND));
                        _operand    = instructionlist[j].OperandList[k];
                        //_operand.Index = Common.ntohl(_operand.Index);
                        instructionlist[j].OperandList[k] = _operand;
                        sf_operator.WriteStructure(ref bf, (object)instructionlist[j].OperandList[k]);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
        }
        /// <summary>
        /// Inverses the operator provided
        /// </summary>
        /// <param name="Operator"></param>
        /// <returns></returns>
        public static OPERATOR Inverse(OPERATOR Operator)
        {
            OPERATOR retVal = Operator;

            switch (Operator)
            {
            case OPERATOR.GREATER:
                retVal = OPERATOR.LESS_OR_EQUAL;
                break;

            case OPERATOR.GREATER_OR_EQUAL:
                retVal = OPERATOR.LESS;
                break;

            case OPERATOR.LESS:
                retVal = OPERATOR.GREATER_OR_EQUAL;
                break;

            case OPERATOR.LESS_OR_EQUAL:
                retVal = OPERATOR.GREATER;
                break;

            default:
                throw new Exception("Cannot inverse operator " + Operator);
            }

            return(retVal);
        }
Exemple #7
0
        /// <summary>
        /// Test if an int parameter fulfils a condition
        /// </summary>
        /// <param name="_key"></param>
        /// <param name="_condition"></param>
        /// <param name="_marker"></param>
        /// <returns></returns>
        public bool TestInt(string _key, OPERATOR _condition, int _marker)
        {
            if (intValues.dictionary.ContainsKey(_key) == false)
            {
                Debug.LogError("Int key not found");
                return(false);
            }
            int value = intValues.dictionary[_key];

            switch (_condition)
            {
            case OPERATOR.less:
                return(value < _marker);

            case OPERATOR.greater:
                return(value > _marker);

            case OPERATOR.equals:
                return(value == _marker);

            default:
                Debug.LogError("The current condition cannot be tested on an integer value");
                return(false);
            }
        }
Exemple #8
0
 public AssignExprNode(OPERATOR _op, ExprNode _lhs, ExprNode _rhs)
 {
     type = OILType.AssignExpr;
     op   = _op;
     lhs  = _lhs;
     rhs  = _rhs;
 }
Exemple #9
0
        private ITEM_LIST MakeListItem(OPERATOR op)
        {
            ITEM_LIST temp = new ITEM_LIST();

            temp.SetOperator(op);

            return(temp);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="left"></param>
        /// <param name="op"></param>
        /// <param name="right"></param>
        public BinaryExpression(ModelElement root, Expression left, OPERATOR op, Expression right)
            : base(root)
        {
            Left = left;
            Left.Enclosing = this;

            Operation = op;
            Right = right;
            Right.Enclosing = this;
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="left"></param>
        /// <param name="op"></param>
        /// <param name="right"></param>
        public BinaryExpression(ModelElement root, Expression left, OPERATOR op, Expression right)
            : base(root)
        {
            Left           = left;
            Left.Enclosing = this;

            Operation       = op;
            Right           = right;
            Right.Enclosing = this;
        }
Exemple #12
0
        /// <summary>
        /// Test if a bool parameter fulfils a condition
        /// </summary>
        /// <param name="_key"></param>
        /// <param name="_condition"></param>
        /// <param name="_marker"></param>
        /// <returns></returns>
        public bool TestBool(string _key, OPERATOR _condition, bool _marker)
        {
            if (boolValues.dictionary.ContainsKey(_key) == false)
            {
                Debug.LogError("Bool key not found");
                return(false);
            }
            bool value = boolValues.dictionary[_key];

            return(value == _marker);
        }
        /// <summary>
        /// Provides the image of a given operator
        /// </summary>
        /// <param name="op"></param>
        /// <returns></returns>
        public static string Image(OPERATOR op)
        {
            string retVal = null;

            for (int i = 0; i < Operators.Length; i++)
            {
                if (op == Operators[i])
                {
                    retVal = OperatorsImages[i];
                    break;
                }
            }

            return(retVal);
        }
        /// <summary>
        /// Provides the operator, based on its image
        /// </summary>
        /// <param name="op"></param>
        /// <returns></returns>
        public static OPERATOR FindOperatorByName(string op)
        {
            OPERATOR retVal = OPERATOR.UNDEF;

            for (int i = 0; i < Operators.Length; i++)
            {
                if (OperatorsImages[i].CompareTo(op) == 0)
                {
                    retVal = Operators[i];
                    break;
                }
            }

            return(retVal);
        }
Exemple #15
0
        private void oPERATORBindingSource_CurrentChanged(object sender, EventArgs e)
        {
            OPERATOR rec = (OPERATOR)OperatorBindingSource.Current;

            if (OperatorBindingSource.Current != null)
            {
                GridControlAdditionalContacts.DataSource = (from contRec in context.CONTACT
                                                            where contRec.LINK_TABLE == "OPERATOR" && contRec.LINK_VALUE == rec.CODE && contRec.RECTYPE == "OPRCONTACT"
                                                            select contRec).Distinct();
                enableNavigator(true);
            }
            else
            {
                enableNavigator(false);
            }
        }
Exemple #16
0
 internal TOKINFO(
     string text,
     TOKFLAGS flags,
     int len,
     CParser.PARSERTYPE parser,
     PREDEFTYPE predef,
     OPERATOR binary,
     OPERATOR unary,
     OPERATOR self
     )
 {
     this.Text            = text;
     this.Flags           = flags;
     this.Length          = len;
     this.StatementParser = parser;
     this.PredefinedType  = predef;
     this.BinaryOperator  = binary;
     this.UnaryOperator   = unary;
     this.SelfOperator    = self;
 }
Exemple #17
0
        //______CONDITION TESTERS______//

        /// <summary>
        /// Test if a float parameter fulfils a condition
        /// </summary>
        /// <param name="_key"></param>
        /// <param name="_condition"></param>
        /// <param name="_marker"></param>
        /// <returns></returns>
        public bool TestFloat(string _key, OPERATOR _condition, float _marker)
        {
            if (floatValues.dictionary.ContainsKey(_key) == false)
            {
                Debug.LogError("Float key not found");
                return(false);
            }
            float value = floatValues.dictionary[_key];

            switch (_condition)
            {
            case OPERATOR.less:
                return(value < _marker);

            case OPERATOR.greater:
                return(value > _marker);

            default:
                Debug.LogError("The current condition cannot be tested on a float value");
                return(false);
            }
        }
Exemple #18
0
 /// <summary>
 /// Constructor for an Expression
 /// </summary>
 /// <param name="truthValues">Strings representing the paramaters for evaluation</param>
 /// <param name="op">Logical Operater for the Expression.</param>
 public Expression(List <String> truthValues, OPERATOR op)
 {
     _truthValues = truthValues;
     _op          = op;
 }
Exemple #19
0
 public bool SetOperator(OPERATOR op)
 {
     this.op  = op;
     this.knd = ExprKind.OPERATOR;
     return(true);
 }
Exemple #20
0
 public UnaryExpr(Expr r, OPERATOR op)
 {
     Right = r; OP = op;
 }
Exemple #21
0
 public BinaryExpr(Expr l, Expr r, OPERATOR op)
 {
     Left = l; Right = r; OP = op;
 }
Exemple #22
0
 public UnaryExpr(Expr r, OPERATOR op)
 {
     Right = new BinaryExpr(new Number(0),
                            r, op);
 }
        static string DoParse(string str, int val)
        {
            int      i                  = 0;
            bool     inParse            = false;
            bool     formattingResNum   = false;
            bool     lookingForOperator = false;
            bool     escapingChar       = false;
            OPERATOR op                 = OPERATOR.NOOP;
            string   operand            = "";
            string   stringOut          = "";
            int      res                = 0;
            string   numFmt             = "{0,0:D0}";
            string   zeroString         = "";
            string   operators          = "#+-/*";
            string   strIn              = str + '\0'; // ensures that last character is parsed

            for (i = 0; i < strIn.Length; i++)
            {
                if (formattingResNum)
                {
                    if (strIn[i] == '#')
                    {
                        zeroString += '0';
                    }
                    else
                    {
                        numFmt             = string.Format("{{0:{0}}}", zeroString);
                        zeroString         = "";
                        formattingResNum   = false;
                        lookingForOperator = true;
                    }
                }

                if (inParse)
                {
                    if ((strIn[i] >= '0') && (strIn[i] <= '9'))
                    {
                        operand += strIn[i];
                    }
                    else
                    {
                        switch (op)
                        {
                        case OPERATOR.NOOP:
                            res = val;
                            break;

                        case OPERATOR.ADD:
                            res = val + int.Parse(operand);
                            break;

                        case OPERATOR.SUB:
                            res = val - int.Parse(operand);
                            break;

                        case OPERATOR.DIV:
                            res = val / int.Parse(operand);
                            break;

                        case OPERATOR.MULT:
                            res = val * int.Parse(operand);
                            break;
                        }
                        stringOut += string.Format(numFmt, res);
                        operand    = "";
                        inParse    = false;
                    }
                }
                else if (lookingForOperator)
                {
                    if (operators.IndexOf(strIn[i]) > -1)
                    {
                        if (strIn[i] == '#')
                        {
                            formattingResNum   = true;
                            zeroString         = "00";
                            lookingForOperator = false;
                        }
                        else
                        {
                            if (strIn[i] == '+')
                            {
                                op = OPERATOR.ADD;
                            }
                            else if (strIn[i] == '-')
                            {
                                op = OPERATOR.SUB;
                            }
                            else if (strIn[i] == '*')
                            {
                                op = OPERATOR.MULT;
                            }
                            else if (strIn[i] == '/')
                            {
                                op = OPERATOR.DIV;
                            }
                            inParse            = true;
                            lookingForOperator = false;
                        }
                    }
                    else
                    {
                        stringOut         += string.Format(numFmt, val);
                        lookingForOperator = false;
                    }
                }

                if (escapingChar || (strIn[i] != '\\'))
                {
                    if (strIn[i] == '#')
                    {
                        if (!formattingResNum)
                        {
                            lookingForOperator = true;
                        }
                    }
                    else if ((!formattingResNum) &&
                             (!inParse) &&
                             (!lookingForOperator) &&
                             (strIn[i] != '\0'))
                    {
                        stringOut += strIn[i];
                    }

                    escapingChar = false;
                }
                else
                {
                    escapingChar = true;
                }
            }

            return(stringOut);
        }
        /// <summary>
        ///     Constructor
        /// </summary>
        /// <param name="left"></param>
        /// <param name="op"></param>
        /// <param name="right"></param>
        /// <param name="start">The start character for this expression in the original string</param>
        /// <param name="end">The end character for this expression in the original string</param>
        public BinaryExpression(ModelElement root, ModelElement log, Expression left, OPERATOR op, Expression right,
            int start, int end)
            : base(root, log, start, end)
        {
            Left = left;
            Left.Enclosing = this;

            Operation = op;
            Right = right;
            Right.Enclosing = this;
        }
        /// <summary>
        /// Inverses the operator provided
        /// </summary>
        /// <param name="Operator"></param>
        /// <returns></returns>
        public static OPERATOR Inverse(OPERATOR Operator)
        {
            OPERATOR retVal = Operator;

            switch (Operator)
            {
                case OPERATOR.GREATER:
                    retVal = OPERATOR.LESS_OR_EQUAL;
                    break;

                case OPERATOR.GREATER_OR_EQUAL:
                    retVal = OPERATOR.LESS;
                    break;

                case OPERATOR.LESS:
                    retVal = OPERATOR.GREATER_OR_EQUAL;
                    break;

                case OPERATOR.LESS_OR_EQUAL:
                    retVal = OPERATOR.GREATER;
                    break;

                default:
                    throw new Exception("Cannot inverse operator " + Operator);
            }

            return retVal;
        }
Exemple #26
0
        //------------------------------------------------------------
        // FUNCBREC.OperatorToExpressionType
        //
        /// <summary></summary>
        /// <param name="op"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        internal ExpressionType OperatorToExpressionType(OPERATOR op)
        {
            switch (op)
            {
            case OPERATOR.NONE:
                //return ExpressionType;
                break;

            case OPERATOR.ASSIGN:
                return(ExpressionType.Assign);

            case OPERATOR.ADDEQ:
                return(ExpressionType.AddAssign);

            case OPERATOR.SUBEQ:
                return(ExpressionType.SubtractAssign);

            case OPERATOR.MULEQ:
                return(ExpressionType.MultiplyAssign);

            case OPERATOR.DIVEQ:
                return(ExpressionType.DivideAssign);

            case OPERATOR.MODEQ:
                return(ExpressionType.ModuloAssign);

            case OPERATOR.ANDEQ:
                return(ExpressionType.AndAssign);

            case OPERATOR.XOREQ:
                return(ExpressionType.ExclusiveOrAssign);

            case OPERATOR.OREQ:
                return(ExpressionType.OrAssign);

            case OPERATOR.LSHIFTEQ:
                return(ExpressionType.LeftShiftAssign);

            case OPERATOR.RSHIFTEQ:
                return(ExpressionType.RightShiftAssign);

            case OPERATOR.QUESTION:
                //return ExpressionType;
                break;

            case OPERATOR.VALORDEF:
                //return ExpressionType;
                break;

            case OPERATOR.LOGOR:
                return(ExpressionType.Or);

            case OPERATOR.LOGAND:
                return(ExpressionType.And);

            case OPERATOR.BITOR:
            //return ExpressionType;
            case OPERATOR.BITXOR:
            //return ExpressionType;
            case OPERATOR.BITAND:
                //return ExpressionType;
                break;

            case OPERATOR.EQ:
                return(ExpressionType.Equal);

            case OPERATOR.NEQ:
                return(ExpressionType.NotEqual);

            case OPERATOR.LT:
                return(ExpressionType.LessThan);

            case OPERATOR.LE:
                return(ExpressionType.LessThanOrEqual);

            case OPERATOR.GT:
                return(ExpressionType.GreaterThan);

            case OPERATOR.GE:
                return(ExpressionType.GreaterThanOrEqual);

            case OPERATOR.IS:
                return(ExpressionType.TypeIs);

            case OPERATOR.AS:
                return(ExpressionType.TypeAs);

            case OPERATOR.LSHIFT:
                return(ExpressionType.LeftShift);

            case OPERATOR.RSHIFT:
                return(ExpressionType.RightShift);

            case OPERATOR.ADD:
                return(ExpressionType.Add);

            case OPERATOR.SUB:
                return(ExpressionType.Subtract);

            case OPERATOR.MUL:
                return(ExpressionType.Multiply);

            case OPERATOR.DIV:
                return(ExpressionType.Divide);

            case OPERATOR.MOD:
                return(ExpressionType.Modulo);

            case OPERATOR.NOP:
                //return ExpressionType;
                break;

            case OPERATOR.UPLUS:
                return(ExpressionType.UnaryPlus);

            case OPERATOR.NEG:
                return(ExpressionType.Negate);

            case OPERATOR.BITNOT:
                return(ExpressionType.OnesComplement);

            case OPERATOR.LOGNOT:
                return(ExpressionType.Not);

            case OPERATOR.PREINC:
                return(ExpressionType.PreIncrementAssign);

            case OPERATOR.PREDEC:
                return(ExpressionType.PreDecrementAssign);

            case OPERATOR.TYPEOF:
            //return ExpressionType;
            case OPERATOR.SIZEOF:
            //return ExpressionType;
            case OPERATOR.CHECKED:
            //return ExpressionType;
            case OPERATOR.UNCHECKED:
            //return ExpressionType;
            case OPERATOR.MAKEREFANY:
            //return ExpressionType;
            case OPERATOR.REFVALUE:
            //return ExpressionType;
            case OPERATOR.REFTYPE:
            //return ExpressionType;
            case OPERATOR.ARGS:
            //return ExpressionType;
            case OPERATOR.CAST:
            //return ExpressionType;
            case OPERATOR.INDIR:
            //return ExpressionType;
            case OPERATOR.ADDR:
            //return ExpressionType;
            case OPERATOR.COLON:
            //return ExpressionType;
            case OPERATOR.THIS:
            //return ExpressionType;
            case OPERATOR.BASE:
            //return ExpressionType;
            case OPERATOR.NULL:
            //return ExpressionType;
            case OPERATOR.TRUE:
            //return ExpressionType;
            case OPERATOR.FALSE:
            //return ExpressionType;
            case OPERATOR.CALL:
            //return ExpressionType;
            case OPERATOR.DEREF:
            //return ExpressionType;
            case OPERATOR.PAREN:
                //return ExpressionType;
                break;

            case OPERATOR.POSTINC:
                return(ExpressionType.PostIncrementAssign);

            case OPERATOR.POSTDEC:
                return(ExpressionType.PostDecrementAssign);

            case OPERATOR.DOT:
            //return ExpressionType;
            case OPERATOR.IMPLICIT:
            //return ExpressionType;
            case OPERATOR.EXPLICIT:
            //return ExpressionType;
            case OPERATOR.EQUALS:
            //return ExpressionType;
            case OPERATOR.COMPARE:
            //return ExpressionType;
            case OPERATOR.DEFAULT:
                //return ExpressionType;
                break;

            // CS3
            case OPERATOR.LAMBDA:
                return(ExpressionType.Lambda);

            default:
                break;
            }
            DebugUtil.Assert(false);
            return((ExpressionType)(-1));
        }
        /// <summary>
        /// Provides the image of a given operator
        /// </summary>
        /// <param name="op"></param>
        /// <returns></returns>
        public static string[] Images(OPERATOR[] ops)
        {
            string[] retVal = new string[ops.Length];

            for (int i = 0; i < ops.Length; i++)
            {
                retVal[i] = Image(ops[i]);
            }

            return retVal;
        }
        /// <summary>
        /// Provides the image of a given operator
        /// </summary>
        /// <param name="op"></param>
        /// <returns></returns>
        public static string Image(OPERATOR op)
        {
            string retVal = null;

            for (int i = 0; i < Operators.Length; i++)
            {
                if (op == Operators[i])
                {
                    retVal = OperatorsImages[i];
                    break;
                }
            }

            return retVal;
        }
 public UnaryExp(Exp a, OPERATOR op)
 {
     _ex1 = new BinaryExp(new NumericConstant(0), a, _op);
 }
Exemple #30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <param name="op"></param>

        public BinaryExp(Exp a, Exp b, OPERATOR op)
        {
            _ex1 = a;
            _ex2 = b;
            _op  = op;
        }
Exemple #31
0
 public void InsertOp(OPERATOR op)
 {
 }
Exemple #32
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <param name="op"></param>

        public UnaryExp(Exp a, OPERATOR op)
        {
            _ex1 = a;
            _op  = op;
        }
Exemple #33
0
 public JsonResult CrudOperator(OPERATOR opr, string type)
 {
     return(Json(ppicdb.CrudOperator(opr, type), JsonRequestBehavior.AllowGet));
 }