Exemplo n.º 1
0
        /// <inheritdoc />
        public override void VisitIntervalFloatValue(FloatIntervalValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                SetWarning("Object cannot be converted to integer by modulo operation",
                           AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER);
                result = ModuloOperation.AbstractModulo(flow, value);
                break;

            default:
                result = ArithmeticOperation.LeftAbstractArithmetic(flow, operation, value);
                if (result != null)
                {
                    break;
                }

                result = LogicalOperation.Logical(OutSet, operation,
                                                  TypeConversion.ToBoolean(leftOperand), value);
                if (result != null)
                {
                    break;
                }

                base.VisitIntervalFloatValue(value);
                break;
            }
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        public override void VisitIntervalFloatValue(FloatIntervalValue value)
        {
            switch (operation)
            {
            case Operations.Identical:
                result = OutSet.CreateBool(false);
                break;

            case Operations.NotIdentical:
                result = OutSet.CreateBool(true);
                break;

            case Operations.Mod:
                result = ModuloOperation.AbstractModulo(flow, value);
                break;

            default:
                result = ArithmeticOperation.LeftAbstractArithmetic(flow, operation, value);
                if (result != null)
                {
                    break;
                }

                base.VisitIntervalFloatValue(value);
                break;
            }
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        public override void VisitStringValue(StringValue value)
        {
            result = Comparison.AbstractCompare(OutSet, operation);
            if (result != null)
            {
                return;
            }

            int    integerValue;
            double floatValue;
            bool   isInteger;

            TypeConversion.TryConvertToNumber(value.Value, true, out integerValue,
                                              out floatValue, out isInteger);

            result = isInteger
                ? ArithmeticOperation.LeftAbstractArithmetic(flow, operation, integerValue)
                : ArithmeticOperation.LeftAbstractArithmetic(flow, operation, floatValue);

            if (result != null)
            {
                return;
            }

            base.VisitStringValue(value);
        }
Exemplo n.º 4
0
        /// <inheritdoc />
        public override void VisitBooleanValue(BooleanValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                result = ModuloOperation.ModuloByBooleanValue(flow, value.Value);
                break;

            default:
                var leftBoolean = TypeConversion.ToBoolean(leftOperand);
                result = Comparison.Compare(OutSet, operation, leftBoolean, value.Value);
                if (result != null)
                {
                    break;
                }

                result = ArithmeticOperation.LeftAbstractArithmetic(flow, operation,
                                                                    TypeConversion.ToInteger(value.Value));
                if (result != null)
                {
                    break;
                }

                result = LogicalOperation.Logical(OutSet, operation, leftBoolean, value.Value);
                if (result != null)
                {
                    break;
                }

                base.VisitBooleanValue(value);
                break;
            }
        }
Exemplo n.º 5
0
        /// <inheritdoc />
        public override void VisitFloatValue(FloatValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                result = ModuloOperation.AbstractModulo(flow, value.Value);
                break;

            default:
                result = ArithmeticOperation.LeftAbstractArithmetic(flow, operation, value.Value);
                if (result != null)
                {
                    break;
                }

                result = LogicalOperation.Logical(OutSet, operation,
                                                  TypeConversion.ToBoolean(leftOperand), TypeConversion.ToBoolean(value.Value));
                if (result != null)
                {
                    break;
                }

                base.VisitFloatValue(value);
                break;
            }
        }
Exemplo n.º 6
0
        /// <inheritdoc />
        public override void VisitBooleanValue(BooleanValue value)
        {
            result = ArithmeticOperation.LeftAbstractArithmetic(flow, operation,
                                                                TypeConversion.ToInteger(value.Value));
            if (result != null)
            {
                return;
            }

            base.VisitBooleanValue(value);
        }
Exemplo n.º 7
0
        /// <inheritdoc />
        public override void VisitStringValue(StringValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                SetWarning("Object cannot be converted to integer by modulo operation",
                           AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER);
                result = ModuloOperation.AbstractModulo(flow, value.Value);
                break;

            default:
                if (Comparison.IsOperationComparison(operation))
                {
                    // TODO: The comparison of string with object depends upon whether the object has
                    // the "__toString" magic method implemented. If so, the string comparison is
                    // performed. Otherwise, the object is always greater than string.
                    result = OutSet.AnyBooleanValue;
                    break;
                }

                result = LogicalOperation.Logical(OutSet, operation,
                                                  TypeConversion.ToBoolean(leftOperand), TypeConversion.ToBoolean(value.Value));
                if (result != null)
                {
                    break;
                }

                int    integerValue;
                double floatValue;
                bool   isInteger;
                TypeConversion.TryConvertToNumber(value.Value, true, out integerValue,
                                                  out floatValue, out isInteger);

                result = isInteger
                        ? ArithmeticOperation.LeftAbstractArithmetic(flow, operation, integerValue)
                        : ArithmeticOperation.LeftAbstractArithmetic(flow, operation, floatValue);

                if (result != null)
                {
                    SetWarning("Object cannot be converted to integer by arithmetic operation",
                               AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER);
                    break;
                }

                base.VisitStringValue(value);
                break;
            }
        }
Exemplo n.º 8
0
        /// <inheritdoc />
        public override void VisitIntervalIntegerValue(IntegerIntervalValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                result = ModuloOperation.AbstractModulo(flow, value);
                break;

            default:
                result = ArithmeticOperation.LeftAbstractArithmetic(flow, operation, value);
                if (result != null)
                {
                    break;
                }

                base.VisitIntervalIntegerValue(value);
                break;
            }
        }
Exemplo n.º 9
0
        /// <inheritdoc />
        public override void VisitIntegerValue(IntegerValue value)
        {
            switch (operation)
            {
            case Operations.Identical:
            case Operations.NotIdentical:
                result = OutSet.AnyBooleanValue;
                break;

            default:
                result = ArithmeticOperation.LeftAbstractArithmetic(flow, operation, value.Value);
                if (result != null)
                {
                    break;
                }

                base.VisitIntegerValue(value);
                break;
            }
        }
Exemplo n.º 10
0
        /// <inheritdoc />
        public override void VisitStringValue(StringValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                result = ModuloOperation.AbstractModulo(flow, value.Value);
                break;

            default:
                result = Comparison.AbstractCompare(OutSet, operation);
                if (result != null)
                {
                    break;
                }

                result = LogicalOperation.Logical(OutSet, operation,
                                                  TypeConversion.ToBoolean(leftOperand), TypeConversion.ToBoolean(value.Value));
                if (result != null)
                {
                    break;
                }

                int    integerValue;
                double floatValue;
                bool   isInteger;
                TypeConversion.TryConvertToNumber(value.Value, true, out integerValue,
                                                  out floatValue, out isInteger);

                result = isInteger
                        ? ArithmeticOperation.LeftAbstractArithmetic(flow, operation, integerValue)
                        : ArithmeticOperation.LeftAbstractArithmetic(flow, operation, floatValue);

                if (result != null)
                {
                    break;
                }

                base.VisitStringValue(value);
                break;
            }
        }
Exemplo n.º 11
0
        /// <inheritdoc />
        public override void VisitBooleanValue(BooleanValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                SetWarning("Object cannot be converted to integer by modulo operation",
                           AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER);
                result = ModuloOperation.ModuloByBooleanValue(flow, value.Value);
                break;

            default:
                var leftBoolean = TypeConversion.ToBoolean(leftOperand);
                result = Comparison.Compare(OutSet, operation, leftBoolean, value.Value);
                if (result != null)
                {
                    break;
                }

                result = ArithmeticOperation.LeftAbstractArithmetic(flow, operation,
                                                                    TypeConversion.ToInteger(value.Value));
                if (result != null)
                {
                    SetWarning("Object cannot be converted to integer by arithmetic operation",
                               AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER);
                    break;
                }

                result = LogicalOperation.Logical(OutSet, operation, leftBoolean, value.Value);
                if (result != null)
                {
                    break;
                }

                base.VisitBooleanValue(value);
                break;
            }
        }