예제 #1
0
        /// <inheritdoc />
        public override void VisitAnyIntegerValue(AnyIntegerValue value)
        {
            result = ArithmeticOperation.AbstractIntegerArithmetic(flow, operation);
            if (result != null)
            {
                return;
            }

            base.VisitAnyIntegerValue(value);
        }
예제 #2
0
        /// <inheritdoc />
        public override void VisitAnyResourceValue(AnyResourceValue value)
        {
            result = ArithmeticOperation.AbstractIntegerArithmetic(flow, operation);
            if (result != null)
            {
                // Arithmetic with resources is nonsence
                return;
            }

            base.VisitAnyResourceValue(value);
        }
예제 #3
0
        /// <inheritdoc />
        public override void VisitAnyObjectValue(AnyObjectValue value)
        {
            result = ArithmeticOperation.AbstractIntegerArithmetic(flow, operation);
            if (result != null)
            {
                SetWarning("Object cannot be converted to integer by arithmetic operation",
                           AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER);
                return;
            }

            base.VisitAnyObjectValue(value);
        }
예제 #4
0
        /// <inheritdoc />
        public override void VisitAnyResourceValue(AnyResourceValue 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);
                break;

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

                result = ArithmeticOperation.AbstractIntegerArithmetic(flow, operation);
                if (result != null)
                {
                    // Arithmetic objects and resources is nonsence
                    SetWarning("Object cannot be converted to integer by arithmetic operation",
                               AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER);
                    break;
                }

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

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

                base.VisitAnyResourceValue(value);
                break;
            }
        }
예제 #5
0
        /// <inheritdoc />
        public override void VisitObjectValue(ObjectValue value)
        {
            switch (operation)
            {
            case Operations.Identical:
            case Operations.NotIdentical:
                // TODO: Compare if two objects are the same instances of the same class
                result = OutSet.AnyBooleanValue;
                break;

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

            default:
                if (Comparison.IsOperationComparison(operation))
                {
                    // TODO: Two object instances are equal if they have the same attributes
                    // and their values, and are instances of the same class.
                    result = OutSet.AnyBooleanValue;
                    break;
                }

                result = ArithmeticOperation.AbstractIntegerArithmetic(flow, operation);
                if (result != null)
                {
                    SetWarning("Both objects cannot be converted to integers by arithmetic operation",
                               AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER);
                    break;
                }

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

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

                base.VisitObjectValue(value);
                break;
            }
        }
예제 #6
0
        /// <inheritdoc />
        public override void VisitAnyObjectValue(AnyObjectValue value)
        {
            switch (operation)
            {
            case Operations.Identical:
            case Operations.NotIdentical:
                // It cannot be decided if they are identical or not.
                result = OutSet.AnyBooleanValue;
                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.AbstractCompare(OutSet, operation);
                if (result != null)
                {
                    break;
                }

                result = ArithmeticOperation.AbstractIntegerArithmetic(flow, operation);
                if (result != null)
                {
                    SetWarning("Both objects cannot be converted to integers by arithmetic operation",
                               AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER);
                    break;
                }

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

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

                base.VisitAnyObjectValue(value);
                break;
            }
        }
예제 #7
0
        /// <inheritdoc />
        public override void VisitAnyResourceValue(AnyResourceValue value)
        {
            switch (operation)
            {
            case Operations.Identical:
            case Operations.NotIdentical:
                result = OutSet.AnyBooleanValue;
                break;

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

            default:
                result = Comparison.AbstractCompare(OutSet, operation);
                if (result != null)
                {
                    // Comapring of resource and integer makes no sence.
                    break;
                }

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

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

                result = BitwiseOperation.Bitwise(OutSet, operation);
                if (result != null)
                {
                    // Bitwise operation with resource can give any integer
                    break;
                }

                base.VisitAnyResourceValue(value);
                break;
            }
        }
예제 #8
0
        /// <inheritdoc />
        public override void VisitAnyIntegerValue(AnyIntegerValue value)
        {
            switch (operation)
            {
            case Operations.Identical:
            case Operations.NotIdentical:
                result = OutSet.AnyBooleanValue;
                break;

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

                base.VisitAnyIntegerValue(value);
                break;
            }
        }
예제 #9
0
        /// <inheritdoc />
        public override void VisitObjectValue(ObjectValue 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);
                break;

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

                result = ArithmeticOperation.AbstractIntegerArithmetic(flow, operation);
                if (result != null)
                {
                    SetWarning("Object cannot be converted to integer by arithmetic operation",
                               AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER);
                    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.VisitObjectValue(value);
                break;
            }
        }