コード例 #1
0
        /// <inheritdoc />
        public override void VisitAssociativeArray(AssociativeArray value)
        {
            result = Comparison.RightAlwaysGreater(OutSet, operation);
            if (result != null)
            {
                return;
            }

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

            result = BitwiseOperation.Bitwise(OutSet, operation);
            if (result != null)
            {
                return;
            }

            if (ArithmeticOperation.IsArithmetic(operation))
            {
                // TODO: This must be fatal error
                SetWarning("Unsupported operand type: Arithmetic of array and numeric type");
                result = OutSet.AnyValue;
                return;
            }

            base.VisitAssociativeArray(value);
        }
コード例 #2
0
        /// <inheritdoc />
        public override void VisitAnyObjectValue(AnyObjectValue value)
        {
            var rightBoolean = TypeConversion.ToBoolean(value);

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

            result = ArithmeticOperation.RightAbstractArithmetic(flow, operation,
                                                                 TypeConversion.ToInteger(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, leftOperand.Value, rightBoolean);
            if (result != null)
            {
                return;
            }

            base.VisitAnyObjectValue(value);
        }
コード例 #3
0
        /// <inheritdoc />
        public override void VisitAnyResourceValue(AnyResourceValue value)
        {
            var rightBoolean = TypeConversion.ToBoolean(value);

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

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

            result = ArithmeticOperation.RightAbstractArithmetic(flow, operation,
                                                                 TypeConversion.ToInteger(leftOperand.Value));
            if (result != null)
            {
                // Arithmetic with resources is nonsence
                return;
            }

            base.VisitAnyResourceValue(value);
        }
コード例 #4
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;
            }
        }
コード例 #5
0
        /// <inheritdoc />
        public override void VisitIntervalFloatValue(FloatIntervalValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                result = ModuloOperation.Modulo(flow,
                                                TypeConversion.ToInteger(leftOperand.Value), value);
                break;

            default:
                var leftFloat = TypeConversion.ToFloat(leftOperand.Value);
                result = Comparison.IntervalCompare(OutSet, operation, leftFloat, value);
                if (result != null)
                {
                    break;
                }

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

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

                base.VisitIntervalFloatValue(value);
                break;
            }
        }
コード例 #6
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;
            }
        }
コード例 #7
0
        /// <inheritdoc />
        public override void VisitBooleanValue(BooleanValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                result = ModuloOperation.ModuloByBooleanValue(flow, value.Value);
                break;

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

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

                result = BitwiseOperation.Bitwise(OutSet, operation,
                                                  TypeConversion.ToNativeInteger(Snapshot, leftOperand),
                                                  TypeConversion.ToInteger(value.Value));
                if (result != null)
                {
                    break;
                }

                base.VisitBooleanValue(value);
                break;
            }
        }
コード例 #8
0
        /// <inheritdoc />
        public override void VisitStringValue(StringValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                result = ModuloOperation.Modulo(flow,
                                                TypeConversion.ToNativeInteger(Snapshot, leftOperand), value.Value);
                break;

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

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

                result = BitwiseOperation.Bitwise(OutSet, operation,
                                                  TypeConversion.ToNativeInteger(Snapshot, leftOperand), value.Value);
                if (result == null)
                {
                    base.VisitStringValue(value);
                }

                break;
            }
        }
コード例 #9
0
        /// <inheritdoc />
        public override void VisitBooleanValue(BooleanValue value)
        {
            switch (operation)
            {
            case Operations.Identical:
                result = OutSet.CreateBool(false);
                break;

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

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

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

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

                base.VisitBooleanValue(value);
                break;
            }
        }
コード例 #10
0
        /// <inheritdoc />
        public override void VisitBooleanValue(BooleanValue value)
        {
            switch (operation)
            {
            case Operations.Identical:
                result = OutSet.CreateBool(false);
                break;

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

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

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

                base.VisitBooleanValue(value);
                break;
            }
        }
コード例 #11
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;
            }
        }
コード例 #12
0
        /// <inheritdoc />
        public override void VisitStringValue(StringValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                result = ModuloOperation.AbstractModulo(flow, value.Value);
                break;

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

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

                base.VisitStringValue(value);
                break;
            }
        }
コード例 #13
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:
                result = ModuloOperation.AbstractModulo(flow, value.Value);
                break;

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

                base.VisitStringValue(value);
                break;
            }
        }
コード例 #14
0
        /// <inheritdoc />
        public override void VisitBooleanValue(BooleanValue value)
        {
            var leftBoolean = TypeConversion.ToBoolean(leftOperand.Value);

            result = Comparison.Compare(OutSet, operation, leftBoolean, value.Value);
            if (result != null)
            {
                return;
            }

            var rightInteger = TypeConversion.ToInteger(value.Value);

            result = ArithmeticOperation.Arithmetic(flow, operation,
                                                    leftOperand.Value, rightInteger);
            if (result != null)
            {
                return;
            }

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

            result = BitwiseOperation.Bitwise(OutSet, operation, leftOperand.Value, rightInteger);
            if (result != null)
            {
                return;
            }

            base.VisitBooleanValue(value);
        }
コード例 #15
0
        /// <inheritdoc />
        public override void VisitAnyScalarValue(AnyScalarValue value)
        {
            switch (operation)
            {
            case Operations.Identical:
                result = OutSet.CreateBool(false);
                break;

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

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

                result = BitwiseOperation.Bitwise(OutSet, operation);
                if (result != null)
                {
                    break;
                }

                base.VisitAnyScalarValue(value);
                break;
            }
        }
コード例 #16
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.AbstractLogical(OutSet, operation, TypeConversion.ToBoolean(value));
            if (result != null)
            {
                return;
            }

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

            base.VisitAnyObjectValue(value);
        }
コード例 #17
0
        /// <inheritdoc />
        public override void VisitAssociativeArray(AssociativeArray value)
        {
            switch (operation)
            {
            case Operations.Mod:
                result = ModuloOperation.Modulo(flow, leftOperand.Value,
                                                TypeConversion.ToNativeInteger(Snapshot, value));
                break;

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

                result = BitwiseOperation.Bitwise(OutSet, operation, leftOperand.Value,
                                                  TypeConversion.ToNativeInteger(Snapshot, value));
                if (result != null)
                {
                    break;
                }

                base.VisitAssociativeArray(value);
                break;
            }
        }
コード例 #18
0
        /// <inheritdoc />
        public override void VisitAnyScalarValue(AnyScalarValue value)
        {
            result = Comparison.AbstractCompare(OutSet, operation);
            if (result != null)
            {
                // Ommitted warning message that object cannot be converted to integer
                return;
            }

            result = ArithmeticOperation.AbstractFloatArithmetic(Snapshot, operation);
            if (result != null)
            {
                // Ommitted warning message that object cannot be converted to integer
                // Ommitted error report that array is unsupported operand in arithmetic operation
                return;
            }

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

            result = BitwiseOperation.Bitwise(OutSet, operation);
            if (result != null)
            {
                // Ommitted warning message that object cannot be converted to integer
                return;
            }

            base.VisitAnyScalarValue(value);
        }
コード例 #19
0
        /// <inheritdoc />
        public override void VisitBooleanValue(BooleanValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                // Ommitted warning message that object cannot be converted to integer
                result = ModuloOperation.ModuloByBooleanValue(flow, value.Value);
                break;

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

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

                base.VisitBooleanValue(value);
                break;
            }
        }
コード例 #20
0
        /// <inheritdoc />
        public override void VisitAnyArrayValue(AnyArrayValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                result = ModuloOperation.AbstractModulo(flow);
                break;

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

                result = BitwiseOperation.Bitwise(OutSet, operation);
                if (result != null)
                {
                    break;
                }

                if (ArithmeticOperation.IsArithmetic(operation))
                {
                    // TODO: This must be fatal error
                    SetWarning("Unsupported operand type: Arithmetic of array and scalar type");
                    result = OutSet.AnyValue;
                    break;
                }

                base.VisitAnyArrayValue(value);
                break;
            }
        }
コード例 #21
0
        /// <inheritdoc />
        public override void VisitStringValue(StringValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                // Ommitted warning message that object cannot be converted to integer
                result = ModuloOperation.AbstractModulo(flow, value.Value);
                break;

            default:
                result = Comparison.AbstractCompare(OutSet, operation);
                if (result != null)
                {
                    // Ommitted warning message that object cannot be converted to integer
                    break;
                }

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

                base.VisitStringValue(value);
                break;
            }
        }
コード例 #22
0
        /// <inheritdoc />
        public override void VisitBooleanValue(BooleanValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                result = ModuloOperation.ModuloByBooleanValue(flow, value.Value);
                break;

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

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

                base.VisitBooleanValue(value);
                break;
            }
        }
コード例 #23
0
        /// <inheritdoc />
        public override void VisitAssociativeArray(AssociativeArray value)
        {
            switch (operation)
            {
            case Operations.Mod:
                result = ModuloOperation.AbstractModulo(flow,
                                                        TypeConversion.ToNativeInteger(Snapshot, value));
                break;

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

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

                base.VisitAssociativeArray(value);
                break;
            }
        }
コード例 #24
0
        /// <inheritdoc />
        public override void VisitAnyScalarValue(AnyScalarValue value)
        {
            switch (operation)
            {
            case Operations.Identical:
                result = OutSet.CreateBool(false);
                break;

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

            default:
                result = LogicalOperation.AbstractLogical(OutSet, operation,
                                                          TypeConversion.ToBoolean(leftOperand));
                if (result != null)
                {
                    break;
                }

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

                base.VisitAnyScalarValue(value);
                break;
            }
        }
コード例 #25
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;
            }
        }
コード例 #26
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;
            }
        }
コード例 #27
0
        /// <inheritdoc />
        public override void VisitAnyResourceValue(AnyResourceValue value)
        {
            result = Comparison.AbstractCompare(OutSet, operation);
            if (result != null)
            {
                // Comapring of resource and string makes no sence.
                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)
            {
                // Arithmetic with resources is nonsence
                return;
            }

            base.VisitAnyResourceValue(value);
        }
コード例 #28
0
        /// <inheritdoc />
        public override void VisitIntervalIntegerValue(IntegerIntervalValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                result = ModuloOperation.Modulo(flow, leftOperand.Value, value);
                break;

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

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

                if (isInteger)
                {
                    result = Comparison.IntervalCompare(OutSet, operation, integerValue, value);
                    if (result != null)
                    {
                        break;
                    }

                    result = ArithmeticOperation.Arithmetic(flow, operation, integerValue, value);
                    if (result != null)
                    {
                        break;
                    }
                }
                else
                {
                    var floatInterval = TypeConversion.ToFloatInterval(OutSet, value);
                    result = Comparison.IntervalCompare(OutSet, operation, floatValue, floatInterval);
                    if (result != null)
                    {
                        break;
                    }

                    result = ArithmeticOperation.Arithmetic(flow, operation, floatValue, floatInterval);
                    if (result != null)
                    {
                        break;
                    }
                }

                base.VisitIntervalIntegerValue(value);
                break;
            }
        }
コード例 #29
0
        /// <inheritdoc />
        public override void VisitAssociativeArray(AssociativeArray value)
        {
            switch (operation)
            {
            case Operations.Identical:
                result = OutSet.CreateBool(false);
                break;

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

            case Operations.Mod:
                SetWarning("Object cannot be converted to integer by modulo operation",
                           AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER);
                result = ModuloOperation.AbstractModulo(flow);
                break;

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

                if (ArithmeticOperation.IsArithmetic(operation))
                {
                    SetWarning("Object cannot be converted to integer by arithmetic operation",
                               AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER);

                    // TODO: This must be fatal error
                    SetWarning("Unsupported operand type: Arithmetic of array and object type");
                    result = OutSet.AnyValue;
                    break;
                }

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

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

                base.VisitAssociativeArray(value);
                break;
            }
        }
コード例 #30
0
        /// <inheritdoc />
        public override void VisitAnyScalarValue(AnyScalarValue value)
        {
            result = LogicalOperation.AbstractLogical(OutSet, operation);
            if (result != null)
            {
                return;
            }

            base.VisitAnyScalarValue(value);
        }