Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public override void VisitAnyArrayValue(AnyArrayValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                result = ModuloOperation.AbstractModulo(flow);
                break;

            default:
                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;
            }
        }
Ejemplo n.º 3
0
        /// <inheritdoc />
        public override void VisitAssociativeArray(AssociativeArray value)
        {
            switch (operation)
            {
            case Operations.Equal:
            case Operations.GreaterThanOrEqual:
                result = OutSet.CreateBool(!TypeConversion.ToNativeBoolean(Snapshot, value));
                break;

            case Operations.NotEqual:
            case Operations.LessThan:
            case Operations.Or:
            case Operations.Xor:
                result = TypeConversion.ToBoolean(Snapshot, value);
                break;

            case Operations.BitAnd:
            case Operations.ShiftLeft:
            case Operations.ShiftRight:
                result = OutSet.CreateInt(0);
                break;

            case Operations.BitOr:
            case Operations.BitXor:
                result = TypeConversion.ToInteger(Snapshot, value);
                break;

            case Operations.Mod:
                if (TypeConversion.ToNativeBoolean(Snapshot, value))
                {
                    // 0 (null) divided or modulo by anything is always 0
                    result = OutSet.CreateInt(0);
                }
                else
                {
                    SetWarning("Division by zero (converted from array)",
                               AnalysisWarningCause.DIVISION_BY_ZERO);

                    // Division or modulo by zero returns false boolean value
                    result = OutSet.CreateBool(false);
                }
                break;

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

                base.VisitAssociativeArray(value);
                break;
            }
        }
Ejemplo n.º 4
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;
            }
        }
Ejemplo n.º 5
0
        /// <inheritdoc />
        public override void VisitAssociativeArray(AssociativeArray value)
        {
            if (ArithmeticOperation.IsArithmetic(operation))
            {
                // TODO: This must be fatal error
                SetWarning("Unsupported operand type: Arithmetic of array and scalar type");
                result = OutSet.AnyValue;
                return;
            }

            base.VisitAssociativeArray(value);
        }
Ejemplo n.º 6
0
        /// <inheritdoc />
        public override void VisitValue(Value value)
        {
            if (ArithmeticOperation.IsArithmetic(operation))
            {
                // Ommitted warning message that object cannot be converted to integer
                // TODO: This must be fatal error
                SetWarning("Unsupported operand type: Arithmetic of two arrays");
                result = OutSet.AnyValue;
                return;
            }

            base.VisitValue(value);
        }
Ejemplo n.º 7
0
        /// <inheritdoc />
        public override void VisitAnyArrayValue(AnyArrayValue 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.RightAlwaysGreater(OutSet, operation);
                if (result != null)
                {
                    break;
                }

                result = LogicalOperation.AbstractLogical(OutSet, operation,
                                                          TypeConversion.ToBoolean(leftOperand));
                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 object type");
                    result = OutSet.AnyValue;
                    break;
                }

                base.VisitAnyArrayValue(value);
                break;
            }
        }
Ejemplo n.º 8
0
        /// <inheritdoc />
        public override void VisitAnyArrayValue(AnyArrayValue value)
        {
            switch (operation)
            {
            case Operations.Equal:
            case Operations.NotEqual:
            case Operations.LessThan:
            case Operations.GreaterThanOrEqual:
            case Operations.Or:
            case Operations.Xor:
                result = OutSet.AnyBooleanValue;
                break;

            case Operations.BitAnd:
            case Operations.ShiftLeft:
            case Operations.ShiftRight:
                result = OutSet.CreateInt(0);
                break;

            case Operations.BitOr:
            case Operations.BitXor:
                result = TypeConversion.AnyArrayToIntegerInterval(OutSet);
                break;

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

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

                base.VisitAnyArrayValue(value);
                break;
            }
        }
Ejemplo n.º 9
0
        /// <inheritdoc />
        public override void VisitAssociativeArray(AssociativeArray value)
        {
            switch (operation)
            {
            case Operations.Mod:
                // Ommitted warnings messages that objects cannot be converted to integers
                result = ModuloOperation.AbstractModulo(flow,
                                                        TypeConversion.ToNativeInteger(Snapshot, value));
                break;

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

                result = BitwiseOperation.Bitwise(OutSet, operation);
                if (result != null)
                {
                    // Ommitted warnings messages that objects cannot be converted to integers
                    break;
                }

                if (ArithmeticOperation.IsArithmetic(operation))
                {
                    // Ommitted warning message that object cannot be converted to integer
                    // TODO: This must be fatal error
                    SetWarning("Unsupported operand type: Arithmetic of array and other value");
                    result = OutSet.AnyValue;
                    break;
                }

                base.VisitAssociativeArray(value);
                break;
            }
        }
Ejemplo n.º 10
0
        /// <inheritdoc />
        public override void VisitAnyArrayValue(AnyArrayValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                // Ommitted warning message that object cannot be converted to integer
                result = ModuloOperation.AbstractModulo(flow);
                break;

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

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

                if (ArithmeticOperation.IsArithmetic(operation))
                {
                    // Ommitted warning message that object cannot be converted to integer
                    // TODO: This must be fatal error
                    SetWarning("Unsupported operand type: Arithmetic of array and other type");
                    result = OutSet.AnyValue;
                    break;
                }

                base.VisitAnyArrayValue(value);
                break;
            }
        }
Ejemplo n.º 11
0
        /// <inheritdoc />
        public override void VisitAssociativeArray(AssociativeArray value)
        {
            switch (operation)
            {
            case Operations.Mod:
                result = ModuloOperation.AbstractModulo(flow,
                                                        TypeConversion.ToNativeInteger(Snapshot, value));
                break;

            default:
                result = LogicalOperation.Logical(OutSet, operation,
                                                  TypeConversion.ToBoolean(leftOperand),
                                                  TypeConversion.ToNativeBoolean(Snapshot, value));
                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 resource type");
                    result = OutSet.AnyValue;
                    break;
                }

                base.VisitAssociativeArray(value);
                break;
            }
        }