Exemple #1
0
        /// <inheritdoc />
        public override void VisitAnyResourceValue(AnyResourceValue value)
        {
            var rightBoolean = TypeConversion.ToBoolean(value);

            result = Comparison.LeftAbstractBooleanCompare(OutSet, operation, rightBoolean);
            if (result != null)
            {
                return;
            }

            result = LogicalOperation.AbstractLogical(OutSet, operation, rightBoolean);
            if (result != null)
            {
                return;
            }

            result = ArithmeticOperation.LeftAbstractBooleanArithmetic(flow, operation);
            if (result != null)
            {
                // Arithmetic with resources is nonsence
                return;
            }

            base.VisitAnyResourceValue(value);
        }
Exemple #2
0
        /// <inheritdoc />
        public override void VisitBooleanValue(BooleanValue value)
        {
            switch (operation)
            {
            case Operations.Identical:
            case Operations.NotIdentical:
                result = leftOperand;
                break;

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

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

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

                base.VisitBooleanValue(value);
                break;
            }
        }
Exemple #3
0
        /// <inheritdoc />
        public override void VisitAnyObjectValue(AnyObjectValue value)
        {
            var rightBoolean = TypeConversion.ToBoolean(value);

            result = Comparison.LeftAbstractBooleanCompare(OutSet, operation, rightBoolean);
            if (result != null)
            {
                return;
            }

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

            result = LogicalOperation.AbstractLogical(OutSet, operation, rightBoolean);
            if (result != null)
            {
                return;
            }

            base.VisitAnyObjectValue(value);
        }
Exemple #4
0
        /// <inheritdoc />
        public override void VisitIntervalFloatValue(FloatIntervalValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                result = ModuloOperation.AbstractModulo(flow, value);
                break;

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

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

                base.VisitIntervalFloatValue(value);
                break;
            }
        }
Exemple #5
0
        /// <inheritdoc />
        public override void VisitFloatValue(FloatValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                // When dividend is true and divisor != +-1, result is 1, otherwise 0
                result = ModuloOperation.LeftAbstractBooleanModulo(flow, value.Value);
                break;

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

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

                result = LogicalOperation.AbstractLogical(OutSet, operation, rightBoolean);
                if (result != null)
                {
                    break;
                }

                base.VisitFloatValue(value);
                break;
            }
        }
Exemple #6
0
        /// <inheritdoc />
        public override void VisitAnyIntegerValue(AnyIntegerValue value)
        {
            result = ArithmeticOperation.LeftAbstractBooleanArithmetic(flow, operation);
            if (result != null)
            {
                return;
            }

            base.VisitAnyIntegerValue(value);
        }
Exemple #7
0
        /// <inheritdoc />
        public override void VisitStringValue(StringValue value)
        {
            switch (operation)
            {
            case Operations.Identical:
                result = OutSet.CreateBool(false);
                break;

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

            case Operations.Mod:
                // When dividend is true and divisor != +-1, result is 1, otherwise 0
                result = ModuloOperation.LeftAbstractBooleanModulo(flow, value.Value);
                break;

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

                result = LogicalOperation.AbstractLogical(OutSet, operation, rightBoolean);
                if (result != null)
                {
                    break;
                }

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

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

                if (result != null)
                {
                    break;
                }

                base.VisitStringValue(value);
                break;
            }
        }