Exemplo n.º 1
0
        public static bool TryGetLogicalExpressionCommandFast(List <string> sOperands, List <string> operators, out DHJassCommand value)
        {
            List <DHJassCommand> operands = new List <DHJassCommand>(sOperands.Count);

            //////////////////////////////////
            //  collect operands
            //////////////////////////////////
            foreach (string ccOperand in sOperands)
            {
                //DHJassBoolean operand = new DHJassBoolean();
                //operand.SetValue(ccOperand.Value);
                DHJassCommand operand = new DHJassGetValueCommand(ccOperand);
                operands.Add(operand);
            }

            //////////////////////////////////////
            //  process expression
            //////////////////////////////////////

            if (operands.Count == 0)
            {
                value = null;
                return(false);
            }

            DHJassCommand operand2;
            DHJassCommand result;

            result = operands[0];

            for (int i = 0; i < operators.Count; i++)
            {
                string Operator = operators[i];

                if (Operator == "and")
                {
                    operand2 = operands[i + 1];
                    result   = new DHJassOperationCommand(result, operand2, AnyOperation.AND);
                }
                else
                if (Operator == "or")
                {
                    operand2 = operands[i + 1];
                    result   = new DHJassOperationCommand(result, operand2, AnyOperation.OR);
                }
                else
                {
                    continue;
                }
            }

            value = result;
            return(true);
        }
Exemplo n.º 2
0
        public static bool TryGetRelationalExpressionCommandFast(List <string> sOperands, List <string> operators, out DHJassCommand value)
        {
            List <DHJassCommand> operands = new List <DHJassCommand>(sOperands.Count);

            //////////////////////////////////
            //  collect operands
            //////////////////////////////////
            foreach (string ccOperand in sOperands)
            {
                //DHJassValue operand = DHJassValue.CreateValueFromCode(ccOperand.Value);
                DHJassCommand operand = new DHJassGetValueCommand(ccOperand);
                operands.Add(operand);
            }

            //////////////////////////////////////
            //  process expression
            //////////////////////////////////////

            if (operands.Count == 0)
            {
                value = null;
                return(false);
            }

            //DHJassBoolean operand1;
            DHJassCommand operand2;
            DHJassCommand result;

            result = operands[0];

            for (int i = 0; i < operators.Count; i++)
            {
                string Operator = operators[i];
                operand2 = operands[i + 1];

                switch (Operator)
                {
                case ">":
                    result = new DHJassOperationCommand(result, operand2, AnyOperation.Greater);
                    break;

                case ">=":
                    result = new DHJassOperationCommand(result, operand2, AnyOperation.GreaterOrEqual);
                    break;

                case "<":
                    result = new DHJassOperationCommand(result, operand2, AnyOperation.Less);
                    break;

                case "<=":
                    result = new DHJassOperationCommand(result, operand2, AnyOperation.LessOrEqual);
                    break;

                case "==":
                    result = new DHJassOperationCommand(result, operand2, AnyOperation.Equal);
                    break;

                case "!=":
                    result = new DHJassOperationCommand(result, operand2, AnyOperation.NotEqual);
                    break;
                }
            }

            value = result;
            return(true);
        }
Exemplo n.º 3
0
        public static bool TryGetArithmeticExpressionCommandFast(List <string> sOperands, List <string> operators, out DHJassCommand value)
        {
            List <DHJassCommand> operands = new List <DHJassCommand>(sOperands.Count);

            //////////////////////////////////
            //  collect operands
            //////////////////////////////////
            foreach (string ccOperand in sOperands)
            {
                DHJassCommand operand = new DHJassGetValueCommand(ccOperand);
                operands.Add(operand);
            }

            //////////////////////////////////////
            //  process expression
            //////////////////////////////////////

            if (operands.Count == 0)
            {
                value = null;
                return(false);
            }

            DHJassCommand operand1;
            DHJassCommand operand2;
            DHJassCommand result;

            // process '*' and '/' first

            for (int i = 0; i < operators.Count; i++)
            {
                string Operator = operators[i];

                if (Operator == "*")
                {
                    operand1 = operands[i];
                    operand2 = operands[i + 1];
                    result   = new DHJassOperationCommand(operand1, operand2, AnyOperation.Multiply);
                }
                else
                if (Operator == "/")
                {
                    operand1 = operands[i];
                    operand2 = operands[i + 1];
                    result   = new DHJassOperationCommand(operand1, operand2, AnyOperation.Divide);
                }
                else
                {
                    continue;
                }

                operands[i] = result;
                operands.RemoveAt(i + 1);
                operators.RemoveAt(i);
                i--;
            }

            // now '+' and '-'

            result = operands[0];

            for (int i = 0; i < operators.Count; i++)
            {
                string Operator = operators[i];

                if (Operator == "+")
                {
                    operand2 = operands[i + 1];
                    result   = new DHJassOperationCommand(result, operand2, AnyOperation.Add);
                }
                else
                if (Operator == "-")
                {
                    operand2 = operands[i + 1];
                    result   = new DHJassOperationCommand(result, operand2, AnyOperation.Subtract);
                }
                else
                {
                    continue;
                }
            }

            value = result;
            return(true);
        }
Exemplo n.º 4
0
        public static bool TryGetRelationalExpressionCommandFast(List<string> sOperands, List<string> operators, out DHJassCommand value)
        {
            List<DHJassCommand> operands = new List<DHJassCommand>(sOperands.Count);

            //////////////////////////////////
            //  collect operands
            //////////////////////////////////
            foreach (string ccOperand in sOperands)
            {
                //DHJassValue operand = DHJassValue.CreateValueFromCode(ccOperand.Value);
                DHJassCommand operand = new DHJassGetValueCommand(ccOperand);
                operands.Add(operand);
            }

            //////////////////////////////////////
            //  process expression
            //////////////////////////////////////

            if (operands.Count == 0)
            {
                value = null;
                return false;
            }

            //DHJassBoolean operand1;
            DHJassCommand operand2;
            DHJassCommand result;

            result = operands[0];

            for (int i = 0; i < operators.Count; i++)
            {
                string Operator = operators[i];
                operand2 = operands[i + 1];

                switch (Operator)
                {
                    case ">":
                        result = new DHJassOperationCommand(result, operand2, AnyOperation.Greater);
                        break;

                    case ">=":
                        result = new DHJassOperationCommand(result, operand2, AnyOperation.GreaterOrEqual);
                        break;

                    case "<":
                        result = new DHJassOperationCommand(result, operand2, AnyOperation.Less);
                        break;

                    case "<=":
                        result = new DHJassOperationCommand(result, operand2, AnyOperation.LessOrEqual);
                        break;

                    case "==":
                        result = new DHJassOperationCommand(result, operand2, AnyOperation.Equal);
                        break;

                    case "!=":
                        result = new DHJassOperationCommand(result, operand2, AnyOperation.NotEqual);
                        break;
                }
            }

            value = result;
            return true;
        }
Exemplo n.º 5
0
        public static bool TryGetLogicalExpressionCommandFast(List<string> sOperands, List<string> operators, out DHJassCommand value)
        {
            List<DHJassCommand> operands = new List<DHJassCommand>(sOperands.Count);

            //////////////////////////////////
            //  collect operands
            //////////////////////////////////
            foreach (string ccOperand in sOperands)
            {
                //DHJassBoolean operand = new DHJassBoolean();
                //operand.SetValue(ccOperand.Value);
                DHJassCommand operand = new DHJassGetValueCommand(ccOperand);
                operands.Add(operand);
            }

            //////////////////////////////////////
            //  process expression
            //////////////////////////////////////

            if (operands.Count == 0)
            {
                value = null;
                return false;
            }

            DHJassCommand operand2;
            DHJassCommand result;

            result = operands[0];

            for (int i = 0; i < operators.Count; i++)
            {
                string Operator = operators[i];

                if (Operator == "and")
                {
                    operand2 = operands[i + 1];
                    result = new DHJassOperationCommand(result, operand2, AnyOperation.AND);
                }
                else
                    if (Operator == "or")
                    {
                        operand2 = operands[i + 1];
                        result = new DHJassOperationCommand(result, operand2, AnyOperation.OR);
                    }
                    else
                        continue;
            }

            value = result;
            return true;
        }
Exemplo n.º 6
0
        public static bool TryGetArithmeticExpressionCommandFast(List<string> sOperands, List<string> operators, out DHJassCommand value)
        {
            List<DHJassCommand> operands = new List<DHJassCommand>(sOperands.Count);

            //////////////////////////////////
            //  collect operands
            //////////////////////////////////
            foreach (string ccOperand in sOperands)
            {
                DHJassCommand operand = new DHJassGetValueCommand(ccOperand);
                operands.Add(operand);
            }

            //////////////////////////////////////
            //  process expression
            //////////////////////////////////////

            if (operands.Count == 0)
            {
                value = null;
                return false;
            }

            DHJassCommand operand1;
            DHJassCommand operand2;
            DHJassCommand result;

            // process '*' and '/' first

            for (int i = 0; i < operators.Count; i++)
            {
                string Operator = operators[i];

                if (Operator == "*")
                {
                    operand1 = operands[i];
                    operand2 = operands[i + 1];
                    result = new DHJassOperationCommand(operand1, operand2, AnyOperation.Multiply);
                }
                else
                    if (Operator == "/")
                    {
                        operand1 = operands[i];
                        operand2 = operands[i + 1];
                        result = new DHJassOperationCommand(operand1, operand2, AnyOperation.Divide);
                    }
                    else
                        continue;

                operands[i] = result;
                operands.RemoveAt(i + 1);
                operators.RemoveAt(i);
                i--;
            }

            // now '+' and '-'

            result = operands[0];

            for (int i = 0; i < operators.Count; i++)
            {
                string Operator = operators[i];

                if (Operator == "+")
                {
                    operand2 = operands[i + 1];
                    result = new DHJassOperationCommand(result, operand2, AnyOperation.Add);
                }
                else
                    if (Operator == "-")
                    {
                        operand2 = operands[i + 1];
                        result = new DHJassOperationCommand(result, operand2, AnyOperation.Subtract);
                    }
                    else
                        continue;
            }

            value = result;
            return true;
        }