Пример #1
0
        protected override string CalculateValue()
        {
            if (Type != EV3Type.Boolean)
            {
                return(null);
            }

            if (LeftCompiler.IsLiteral && RightCompiler.IsLiteral)
            {
                if (LeftCompiler.Type.IsNumber())
                {
                    float leftValue  = SmallBasicExtensions.ParseFloat(LeftCompiler.Value);
                    float rightValue = SmallBasicExtensions.ParseFloat(RightCompiler.Value);

                    switch (ParentExpression.Operator.Token)
                    {
                    case Token.Equals:
                        return(SmallBasicExtensions.FormatBoolean(leftValue == rightValue));

                    case Token.NotEqualTo:
                        return(SmallBasicExtensions.FormatBoolean(leftValue != rightValue));

                    case Token.LessThan:
                        return(SmallBasicExtensions.FormatBoolean(leftValue < rightValue));

                    case Token.LessThanEqualTo:
                        return(SmallBasicExtensions.FormatBoolean(leftValue <= rightValue));

                    case Token.GreaterThan:
                        return(SmallBasicExtensions.FormatBoolean(leftValue > rightValue));

                    case Token.GreaterThanEqualTo:
                        return(SmallBasicExtensions.FormatBoolean(leftValue >= rightValue));
                    }
                }
                else
                {
                    switch (ParentExpression.Operator.Token)
                    {
                    case Token.Equals:
                        return(SmallBasicExtensions.FormatBoolean(LeftCompiler.Value == RightCompiler.Value));

                    case Token.NotEqualTo:
                        return(SmallBasicExtensions.FormatBoolean(LeftCompiler.Value != RightCompiler.Value));
                    }
                }
            }
            return(null);
        }
Пример #2
0
        protected override string CalculateValue()
        {
            if (Type != EV3Type.Boolean)
            {
                return(null);
            }

            if (LeftCompiler.IsLiteral && RightCompiler.IsLiteral)
            {
                if (ParentExpression.Operator.Token == Token.And)
                {
                    return(SmallBasicExtensions.FormatBoolean(BooleanValue));
                }
                else
                {
                    return(SmallBasicExtensions.FormatBoolean(BooleanValue));
                }
            }
            return(null);
        }