Example #1
0
        /// <inheritdoc />
        public override void VisitUndefinedValue(UndefinedValue value)
        {
            switch (operation)
            {
            case Operations.Identical:
            case Operations.And:
                result = OutSet.CreateBool(false);
                break;

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

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

            case Operations.Div:
                result = ArithmeticOperation.DivisionByNull(flow);
                break;

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

            default:
                base.VisitUndefinedValue(value);
                break;
            }
        }
Example #2
0
        /// <inheritdoc />
        public override void VisitUndefinedValue(UndefinedValue value)
        {
            // When comparing, both operands are converted to boolean
            switch (operation)
            {
            case Operations.Identical:
            case Operations.LessThan:
            case Operations.And:
                result = OutSet.CreateBool(false);
                break;

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

            case Operations.Equal:
            case Operations.LessThanOrEqual:
                bool convertedValue;
                if (TypeConversion.TryConvertToBoolean(leftOperand, out convertedValue))
                {
                    result = OutSet.CreateBool(!convertedValue);
                }
                else
                {
                    result = OutSet.AnyBooleanValue;
                }
                break;

            case Operations.NotEqual:
            case Operations.GreaterThan:
            case Operations.Or:
            case Operations.Xor:
                result = TypeConversion.ToBoolean(OutSet, leftOperand);
                break;

            case Operations.Add:
            case Operations.Sub:
                result = leftOperand;
                break;

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

            case Operations.Div:
                result = ArithmeticOperation.DivisionByNull(flow);
                break;

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

            default:
                base.VisitUndefinedValue(value);
                break;
            }
        }
Example #3
0
        /// <inheritdoc />
        public override void VisitUndefinedValue(UndefinedValue value)
        {
            switch (operation)
            {
            case Operations.Identical:
            case Operations.LessThan:
            case Operations.And:
                result = OutSet.CreateBool(false);
                break;

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

            case Operations.Equal:
            case Operations.LessThanOrEqual:
                result = OutSet.CreateBool(!TypeConversion.ToNativeBoolean(Snapshot, leftOperand));
                break;

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

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

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

            case Operations.Div:
                result = ArithmeticOperation.DivisionByNull(flow);
                break;

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

            default:
                base.VisitUndefinedValue(value);
                break;
            }
        }
Example #4
0
        /// <inheritdoc />
        public override void VisitUndefinedValue(UndefinedValue value)
        {
            switch (operation)
            {
            case Operations.Identical:
            case Operations.Equal:
            case Operations.LessThan:
            case Operations.LessThanOrEqual:
            case Operations.And:
                result = OutSet.CreateBool(false);
                break;

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

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

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

            case Operations.Div:
                result = ArithmeticOperation.DivisionByNull(flow);
                break;

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

            default:
                base.VisitUndefinedValue(value);
                break;
            }
        }
Example #5
0
        /// <inheritdoc />
        public override void VisitUndefinedValue(UndefinedValue value)
        {
            // When comparing, both operands are converted to boolean
            switch (operation)
            {
            case Operations.Identical:
            case Operations.LessThan:
            case Operations.And:
                result = OutSet.CreateBool(false);
                break;

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

            case Operations.Equal:
            case Operations.NotEqual:
            case Operations.GreaterThan:
            case Operations.LessThanOrEqual:
            case Operations.Or:
            case Operations.Xor:
                result = OutSet.AnyBooleanValue;
                break;

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

            case Operations.Div:
                result = ArithmeticOperation.DivisionByNull(flow);
                break;

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

            default:
                base.VisitUndefinedValue(value);
                break;
            }
        }
Example #6
0
        /// <inheritdoc />
        public override void VisitUndefinedValue(UndefinedValue value)
        {
            switch (operation)
            {
            case Operations.Equal:
            case Operations.Identical:
            case Operations.LessThan:
            case Operations.LessThanOrEqual:
            case Operations.And:
                result = OutSet.CreateBool(false);
                break;

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

            default:
                switch (operation)
                {
                case Operations.Mul:
                case Operations.BitAnd:
                    SetWarning("Object cannot be converted to integer",
                               AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER);
                    result = OutSet.CreateInt(0);
                    break;

                case Operations.Add:
                case Operations.Sub:
                case Operations.BitOr:
                case Operations.BitXor:
                case Operations.ShiftLeft:
                case Operations.ShiftRight:
                    SetWarning("Object cannot be converted to integer",
                               AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER);
                    result = OutSet.AnyIntegerValue;
                    break;

                case Operations.Div:
                    SetWarning("Object cannot be converted to integer",
                               AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER);
                    result = ArithmeticOperation.DivisionByNull(flow);
                    break;

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

                default:
                    base.VisitUndefinedValue(value);
                    break;
                }
                break;
            }
        }