Exemple #1
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);
        }
Exemple #2
0
 /// <inheritdoc />
 public override void VisitAnyResourceValue(AnyResourceValue value)
 {
     // Skip <see cref="AnyValue" />. The type is super-type of <see cref="AnyResourceValue" />,
     // but it is concrete type and its visit method can contain code that is solving the same
     // problem as the previous visit methods. In this case, use additional method with shared code.
     VisitValue(value);
 }
Exemple #3
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);
        }
Exemple #4
0
        /// <inheritdoc />
        protected override Value cloneValue()
        {
            AnyResourceValue value = new AnyResourceValue();

            value.setStorage(getStorage());
            return(value);
        }
Exemple #5
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 = BitwiseOperation.Bitwise(OutSet, operation);
                if (result != null)
                {
                    // Bitwise operation with resource can give any integer
                    break;
                }

                base.VisitAnyResourceValue(value);
                break;
            }
        }
Exemple #6
0
        /// <inheritdoc />
        public override void VisitAnyResourceValue(AnyResourceValue value)
        {
            isConcrete = false;

            integerIndex = null;
            stringIndex  = null;
            isNotConvertibleToInteger = true;
            isCompoundValue           = false;
        }
Exemple #7
0
        /// <inheritdoc />
        public override void VisitAnyResourceValue(AnyResourceValue value)
        {
            result = Comparison.AbstractCompare(OutSet, operation);
            if (result != null)
            {
                // Comapring of resource and number makes no sence.
                return;
            }

            base.VisitAnyResourceValue(value);
        }
Exemple #8
0
        /// <inheritdoc />
        public override void VisitAnyResourceValue(AnyResourceValue value)
        {
            result = ArithmeticOperation.AbstractFloatArithmetic(Snapshot, operation);
            if (result != null)
            {
                // Arithmetic with resources is nonsence
                return;
            }

            base.VisitAnyResourceValue(value);
        }
Exemple #9
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);
        }
Exemple #10
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;
            }
        }
Exemple #11
0
        /// <inheritdoc />
        public override void VisitAnyResourceValue(AnyResourceValue value)
        {
            // Resource is always greater than null
            switch (operation)
            {
            case Operations.Equal:
            case Operations.GreaterThanOrEqual:
                result = OutSet.CreateBool(false);
                break;

            case Operations.NotEqual:
            case Operations.LessThan:
            case Operations.Or:
            case Operations.Xor:
                result = OutSet.CreateBool(true);
                break;

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

            case Operations.Add:
            case Operations.Sub:
            case Operations.BitOr:
            case Operations.BitXor:
                result = OutSet.AnyIntegerValue;
                break;

            case Operations.Div:
            case Operations.Mod:
                // We can assume that resource is not zero, because it is always true
                result = OutSet.CreateInt(0);
                break;

            default:
                if (PerformCommonAnyOperandOperations())
                {
                    break;
                }

                base.VisitAnyResourceValue(value);
                break;
            }
        }
Exemple #12
0
        /// <inheritdoc />
        public override void VisitAnyResourceValue(AnyResourceValue value)
        {
            result = Comparison.AbstractCompare(OutSet, operation);
            if (result != null)
            {
                // Comapring of resource and number makes no sence.
                return;
            }

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

            base.VisitAnyResourceValue(value);
        }
Exemple #13
0
        /// <inheritdoc />
        public override void VisitAnyResourceValue(AnyResourceValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                // Ommitted warning message that object cannot be converted to integer
                result = ModuloOperation.AbstractModulo(flow);
                break;

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

                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
                    break;
                }

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

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

                base.VisitAnyResourceValue(value);
                break;
            }
        }
Exemple #14
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 = LogicalOperation.Logical(OutSet, operation,
                                                  TypeConversion.ToNativeBoolean(Snapshot, 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;
            }
        }
Exemple #15
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.AbstractCompare(OutSet, operation);
                if (result != null)
                {
                    // Comapring of resource and number makes no sence.
                    break;
                }

                result = LogicalOperation.Logical(OutSet, operation, 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;
            }
        }
Exemple #16
0
        /// <inheritdoc />
        public override void VisitAnyResourceValue(AnyResourceValue value)
        {
            switch (operation)
            {
            case Operations.Plus:
                result = OutSet.AnyIntegerValue;
                break;

            case Operations.Minus:
                result = OutSet.AnyIntegerValue;
                break;

            case Operations.LogicNegation:
                result = OutSet.CreateBool(!TypeConversion.ToBoolean(value));
                break;

            case Operations.BitNegation:
                // TODO: This must be fatal error
                SetWarning("Unsupported operand types: Bit negation of resource reference");
                result = OutSet.AnyValue;
                break;

            case Operations.Int32Cast:
                result = OutSet.AnyIntegerValue;
                break;

            case Operations.FloatCast:
            case Operations.DoubleCast:
                result = OutSet.AnyFloatValue;
                break;

            default:
                if (PerformUsualOperation(value))
                {
                    break;
                }

                // AnyValue has its own implementation, thou must be skipped
                base.VisitAnyResourceValue(value);
                break;
            }
        }
Exemple #17
0
 /// <inheritdoc />
 public override void VisitAnyResourceValue(AnyResourceValue value)
 {
     result         = null;
     abstractResult = OutSet.AnyStringValue;
 }
Exemple #18
0
 /// <inheritdoc />
 public override void VisitAnyResourceValue(AnyResourceValue value)
 {
     resourceVisitor.SetLeftOperand(value);
     visitor = resourceVisitor;
 }
Exemple #19
0
 /// <inheritdoc />
 public override void VisitAnyResourceValue(AnyResourceValue value)
 {
     result = TypeConversion.ToBoolean(snapshot, value);
 }
Exemple #20
0
 /// <inheritdoc />
 public override void VisitAnyResourceValue(AnyResourceValue value)
 {
     result = value;
 }