Пример #1
0
        public override Value Interpret()
        {
            dynamic left  = LeftOperand.Interpret();
            dynamic right = RightOperand.Interpret();

            var unaryNode = LeftOperand is ExpressionUnaryNode;

            if (unaryNode && ((ExpressionUnaryNode)LeftOperand).UnaryOperator is NegativeOperatorNode)
            {
                left.Value = left.Value * -1;
            }

            var unaryNode2 = RightOperand is ExpressionUnaryNode;

            if (unaryNode2 && ((ExpressionUnaryNode)RightOperand).UnaryOperator is NegativeOperatorNode)
            {
                right.Value = right.Value * -1;
            }

            dynamic response = left.Value * right.Value;

            dynamic typeOfReturn = Validations.GetTypeValue(left, response);

            return(typeOfReturn);
        }
Пример #2
0
        public override Value Interpret()
        {
            var leftV  = LeftOperand.Interpret();
            var rightV = RightOperand.Interpret();
            var value  = leftV as IntValue;

            if (value != null)
            {
                return(new IntValue
                {
                    Value = value.Value + ((IntValue)rightV).Value
                });
            }

            var v = leftV as StringValue;

            if (v != null)
            {
                return(new StringValue
                {
                    Value = v.Value + ((StringValue)rightV).Value
                });
            }

            return(new BoolValue
            {
                Value = ((BoolValue)leftV).Value || ((BoolValue)rightV).Value
            });
        }
Пример #3
0
        public override Value Interpret()
        {
            dynamic left  = LeftOperand.Interpret();
            dynamic right = RightOperand.Interpret();

            var unaryNode = LeftOperand is ExpressionUnaryNode;

            if (unaryNode && ((ExpressionUnaryNode)LeftOperand).UnaryOperator is NegativeOperatorNode)
            {
                left.Value = left.Value * -1;
            }

            var unaryNode2 = RightOperand is ExpressionUnaryNode;

            if (unaryNode2 && ((ExpressionUnaryNode)RightOperand).UnaryOperator is NegativeOperatorNode)
            {
                right.Value = right.Value * -1;
            }

            dynamic response = left.Value + right.Value;

            dynamic typeOfReturn;

            if (left is CharValue && right is CharValue)
            {
                typeOfReturn = Validations.GetTypeValue(new StringValue(), left.Value.ToString() + right.Value.ToString());
            }
            else
            {
                typeOfReturn = Validations.GetTypeValue(left, response);
            }


            return(typeOfReturn);
        }
        public override Value Interpret()
        {
            dynamic response = LeftOperand.Interpret() + "?" + RightOperand.Interpret();

            return(new BoolValue {
                Value = response.Value
            });
        }
Пример #5
0
        public override Value Interpret()
        {
            dynamic leftV  = LeftOperand.Interpret();
            dynamic rightV = RightOperand.Interpret();

            return(new IntValue {
                Value = leftV.Value / rightV.Value
            });
        }