示例#1
0
        /// <inheritdoc />
        public override void VisitAnyResourceValue(AnyResourceValue value)
        {
            result = ArithmeticOperation.RightAbstractArithmetic(flow, operation, leftOperand);
            if (result != null)
            {
                // Arithmetic with resources is nonsence
                return;
            }

            base.VisitAnyResourceValue(value);
        }
示例#2
0
        /// <inheritdoc />
        public override void VisitAnyStringValue(AnyStringValue value)
        {
            result = ArithmeticOperation.RightAbstractArithmetic(flow, operation, leftOperand.Value);
            if (result != null)
            {
                // A string can be converted into floating point number too.
                return;
            }

            base.VisitAnyStringValue(value);
        }
示例#3
0
        /// <inheritdoc />
        public override void VisitAnyIntegerValue(AnyIntegerValue value)
        {
            result = ArithmeticOperation.RightAbstractArithmetic(flow, operation,
                                                                 TypeConversion.ToInteger(leftOperand.Value));
            if (result != null)
            {
                return;
            }

            base.VisitAnyIntegerValue(value);
        }
示例#4
0
        /// <inheritdoc />
        public override void VisitAnyObjectValue(AnyObjectValue value)
        {
            result = ArithmeticOperation.RightAbstractArithmetic(flow, operation, leftOperand);
            if (result != null)
            {
                SetWarning("Object cannot be converted to integer by arithmetic operation",
                           AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER);
                return;
            }

            base.VisitAnyObjectValue(value);
        }
示例#5
0
        /// <inheritdoc />
        public override void VisitAnyResourceValue(AnyResourceValue value)
        {
            result = ArithmeticOperation.RightAbstractArithmetic(flow, operation, leftOperand.Value);
            if (result != null)
            {
                // Arithmetic with resources is nonsence
                return;
            }

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

            base.VisitAnyResourceValue(value);
        }
示例#6
0
        /// <inheritdoc />
        public override void VisitObjectValue(ObjectValue value)
        {
            result = ArithmeticOperation.RightAbstractArithmetic(flow, operation, leftOperand.Value);
            if (result != null)
            {
                SetWarning("Object cannot be converted to integer by arithmetic operation",
                           AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER);
                return;
            }

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

            base.VisitObjectValue(value);
        }
示例#7
0
        /// <inheritdoc />
        public override void VisitAnyIntegerValue(AnyIntegerValue value)
        {
            switch (operation)
            {
            case Operations.Identical:
            case Operations.NotIdentical:
                result = OutSet.AnyBooleanValue;
                break;

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

                base.VisitAnyIntegerValue(value);
                break;
            }
        }
示例#8
0
        /// <inheritdoc />
        public override void VisitAnyIntegerValue(AnyIntegerValue value)
        {
            int    integerValue;
            double floatValue;
            bool   isInteger;

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

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

            if (result != null)
            {
                return;
            }

            base.VisitAnyIntegerValue(value);
        }
示例#9
0
        /// <inheritdoc />
        public override void VisitAnyObjectValue(AnyObjectValue value)
        {
            if (Comparison.IsOperationComparison(operation))
            {
                // 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. Since we cannot
                // determine whether the abstract object has or has not the method,
                // we must return indeterminate boolean value.
                result = OutSet.AnyBooleanValue;
                return;
            }

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

            int    integerValue;
            double floatValue;
            bool   isInteger;

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

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

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

            base.VisitAnyObjectValue(value);
        }
示例#10
0
        /// <inheritdoc />
        public override void VisitAnyIntegerValue(AnyIntegerValue value)
        {
            // When comparing, both operands are converted to boolean
            switch (operation)
            {
            case Operations.BitOr:
            case Operations.BitXor:
                result = value;
                break;

            default:
                result = ArithmeticOperation.RightAbstractArithmetic(flow, operation,
                                                                     TypeConversion.ToInteger(leftOperand));
                if (result != null)
                {
                    break;
                }

                base.VisitAnyIntegerValue(value);
                break;
            }
        }