Example #1
0
        /// <inheritdoc />
        public override void VisitAnyStringValue(AnyStringValue 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:
                if (Comparison.IsOperationComparison(operation))
                {
                    // TODO: 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.
                    result = OutSet.AnyBooleanValue;
                    break;
                }

                result = ArithmeticOperation.AbstractFloatArithmetic(Snapshot, operation);
                if (result != null)
                {
                    // A string can be converted into floating point number too.
                    break;
                }

                base.VisitAnyStringValue(value);
                break;
            }
        }
Example #2
0
        /// <inheritdoc />
        public override void VisitAnyStringValue(AnyStringValue value)
        {
            switch (operation)
            {
            case Operations.Plus:
                // It can be integer or float
                result = OutSet.AnyValue;
                break;

            case Operations.Minus:
                // It can be integer or float
                result = OutSet.AnyValue;
                break;

            case Operations.LogicNegation:
                result = OutSet.AnyBooleanValue;
                break;

            case Operations.BitNegation:
                // Bit negation is defined for every character, not for the entire string
                result = value;
                break;

            default:
                base.VisitAnyStringValue(value);
                break;
            }
        }
Example #3
0
        /// <inheritdoc />
        protected override Value cloneValue()
        {
            AnyStringValue value = new AnyStringValue();

            value.setStorage(getStorage());
            return(value);
        }
Example #4
0
        /// <inheritdoc />
        public override void VisitAnyStringValue(AnyStringValue 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)
                {
                    break;
                }

                result = ArithmeticOperation.AbstractFloatArithmetic(Snapshot, operation);
                if (result != null)
                {
                    // A string can be converted into floating point number too.
                    break;
                }

                base.VisitAnyStringValue(value);
                break;
            }
        }
Example #5
0
        /// <inheritdoc />
        public override void VisitAnyStringValue(AnyStringValue value)
        {
            switch (operation)
            {
            case Operations.Equal:
            case Operations.NotEqual:
            case Operations.GreaterThanOrEqual:
            case Operations.LessThan:
            case Operations.Or:
            case Operations.Xor:
                result = OutSet.AnyBooleanValue;
                break;

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

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

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

                base.VisitAnyStringValue(value);
                break;
            }
        }
Example #6
0
        /// <inheritdoc />
        public override void VisitAnyStringValue(AnyStringValue value)
        {
            isConcrete = false;

            isNotConvertibleToInteger = true;

            base.VisitAnyStringValue(value);
        }
Example #7
0
        /// <inheritdoc />
        public override void VisitAnyStringValue(AnyStringValue value)
        {
            result = ArithmeticOperation.AbstractFloatArithmetic(Snapshot, operation);
            if (result != null)
            {
                // A string can be converted into floating point number too.
                return;
            }

            base.VisitAnyStringValue(value);
        }
Example #8
0
        /// <inheritdoc />
        public override void VisitAnyStringValue(AnyStringValue value)
        {
            result = ArithmeticOperation.RightAbstractArithmetic(flow, operation, leftOperand.Value);
            if (result != null)
            {
                // A string can be converted into floating point number too.
                return;
            }

            base.VisitAnyStringValue(value);
        }
Example #9
0
        /// <inheritdoc />
        public override void VisitAnyStringValue(AnyStringValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                result = ModuloOperation.AbstractModulo(flow);
                break;

            default:
                base.VisitAnyStringValue(value);
                break;
            }
        }
Example #10
0
        /// <inheritdoc />
        public override void VisitAnyStringValue(AnyStringValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                // Ommitted warnings messages that objects cannot be converted to integers
                result = ModuloOperation.AbstractModulo(flow);
                break;

            default:
                base.VisitAnyStringValue(value);
                break;
            }
        }
Example #11
0
        /// <inheritdoc />
        public override void VisitAnyValue(AnyValue value)
        {
            // TODO: This is possible fatal error
            result = null;

            if (value.GetInfo <Flags>() != null)
            {
                var flags    = FlagsHandler.GetFlagsFromValues(value);
                var flagInfo = new Flags(flags);
                abstractResult = (AnyStringValue)OutSet.AnyStringValue.SetInfo(flagInfo);
            }
            else
            {
                abstractResult = OutSet.AnyStringValue;
            }
        }
Example #12
0
        /// <inheritdoc />
        public override void VisitAnyStringValue(AnyStringValue value)
        {
            switch (operation)
            {
            case Operations.Mod:
                result = ModuloOperation.AbstractModulo(flow);
                break;

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

                base.VisitAnyStringValue(value);
                break;
            }
        }
Example #13
0
        /// <inheritdoc />
        public override void VisitAnyStringValue(AnyStringValue value)
        {
            switch (operation)
            {
            case Operations.Identical:
            case Operations.NotIdentical:
                result = OutSet.AnyBooleanValue;
                break;

            case Operations.BitAnd:
            case Operations.BitOr:
            case Operations.BitXor:
                // Bit operations are defined for every character, not for the entire string
                result = OutSet.AnyStringValue;
                break;

            case Operations.ShiftLeft:
            case Operations.ShiftRight:
                result = OutSet.AnyIntegerValue;
                break;

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

                result = ArithmeticOperation.AbstractFloatArithmetic(Snapshot, operation);
                if (result != null)
                {
                    // Strings can be converted into floating point number too.
                    break;
                }

                base.VisitAnyStringValue(value);
                break;
            }
        }
Example #14
0
        /// <inheritdoc />
        public override void VisitAnyStringValue(AnyStringValue value)
        {
            switch (operation)
            {
            case Operations.Identical:
                result = OutSet.CreateBool(false);
                break;

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

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

                base.VisitAnyStringValue(value);
                break;
            }
        }
Example #15
0
        /// <summary>
        /// Converts all possible values in memory entry to string representation.
        /// </summary>
        /// <param name="entry">Memory entry with all possible values to convert.</param>
        /// <param name="abstractString">Abstract string value if any conversion fails.</param>
        /// <returns>List of strings after conversion of all possible values.</returns>
        public IEnumerable <StringValue> Evaluate(MemoryEntry entry, out AnyStringValue abstractString)
        {
            var values          = new HashSet <StringValue>();
            var abstractStrings = new HashSet <AnyStringValue>();

            foreach (var value in entry.PossibleValues)
            {
                // Gets type of value and convert to string
                value.Accept(this);

                Debug.Assert((result != null) != (abstractResult != null),
                             "Result can be either concrete or abstract string value");

                if (result != null)
                {
                    values.Add(result);
                }
                else
                {
                    abstractStrings.Add(abstractResult);
                }
            }

            if (abstractStrings.Count > 0)
            {
                var flags    = FlagsHandler.GetFlagsFromValues(abstractStrings);
                var flagInfo = new Flags(flags);
                abstractString = (AnyStringValue)OutSet.AnyStringValue.SetInfo(flagInfo);
            }
            else
            {
                abstractString = null;
            }

            return(values);
        }
Example #16
0
 /// <inheritdoc />
 public override void VisitResourceValue(ResourceValue value)
 {
     result         = TypeConversion.ToString(OutSet, value);
     abstractResult = null;
 }
Example #17
0
 public override void VisitAnyStringValue(AnyStringValue value)
 {
     ContainsDefinedValue = true;
     locations.Add(new AnyStringValueLocation(containingIndex, index, value));
 }
Example #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AnyStringValueLocation"/> class.
 /// </summary>
 /// <param name="containingIndex">Index of the containing.</param>
 /// <param name="index">The index.</param>
 /// <param name="value">The value.</param>
 public AnyStringValueLocation(MemoryIndex containingIndex, MemberIdentifier index, AnyStringValue value)
 {
     this.containingIndex = containingIndex;
     this.index           = index;
     this.value           = value;
 }
Example #19
0
 /// <inheritdoc />
 public override void VisitAnyStringValue(AnyStringValue value)
 {
     Result = StaticObjectVisitorResult.MULTIPLE_RESULTS;
 }
Example #20
0
 /// <inheritdoc />
 public override void VisitGenericIntervalValue <T>(IntervalValue <T> value)
 {
     result         = null;
     abstractResult = OutSet.AnyStringValue;
 }
Example #21
0
 /// <inheritdoc />
 public override void VisitAnyStringValue(AnyStringValue value)
 {
     result         = null;
     abstractResult = value;
 }
Example #22
0
 /// <inheritdoc />
 public override void VisitAnyStringValue(AnyStringValue value)
 {
     strings.Add(value);
 }
Example #23
0
 /// <inheritdoc />
 public override void VisitAnyStringValue(AnyStringValue value)
 {
     stringFound();
 }
Example #24
0
 /// <inheritdoc />
 public override void VisitAnyObjectValue(AnyObjectValue value)
 {
     // TODO: Object can be converted only if it has __toString magic method implemented
     result         = null;
     abstractResult = OutSet.AnyStringValue;
 }
Example #25
0
 /// <inheritdoc />
 public override void VisitAnyStringValue(AnyStringValue value)
 {
     result = value;
 }
Example #26
0
 /// <inheritdoc />
 public override void VisitAnyArrayValue(AnyArrayValue value)
 {
     result         = TypeConversion.ToString(OutSet, value);
     abstractResult = null;
 }
Example #27
0
 /// <inheritdoc />
 public override void VisitAnyResourceValue(AnyResourceValue value)
 {
     result         = null;
     abstractResult = OutSet.AnyStringValue;
 }
Example #28
0
 /// <inheritdoc />
 public override void VisitAnyStringValue(AnyStringValue value)
 {
     anyStringVisitor.SetLeftOperand(value);
     visitor = anyStringVisitor;
 }
Example #29
0
 /// <inheritdoc />
 public override void VisitUndefinedValue(UndefinedValue value)
 {
     result         = TypeConversion.ToString(OutSet, value);
     abstractResult = null;
 }
Example #30
0
 public override void VisitAnyStringValue(AnyStringValue value)
 {
     this.AddLocation(new AnyStringValueLocation(null, index, value));
 }