Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 6
0
        /// <inheritdoc />
        public override void VisitUndefinedValue(UndefinedValue value)
        {
            switch (operation)
            {
            case Operations.Equal:
            case Operations.NotEqual:
            case Operations.GreaterThan:
            case Operations.LessThanOrEqual:
                result = OutSet.AnyBooleanValue;
                break;

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

            case Operations.LessThan:
                result = OutSet.CreateBool(false);
                break;

            case Operations.Add:
            case Operations.Sub:
                // Ommitted warning message that object cannot be converted to integer
                // Ommitted error report that array is unsupported operand in arithmetic operation
                result = OutSet.AnyFloatValue;
                break;

            case Operations.Mul:
                // Ommitted warning message that object cannot be converted to integer
                // Ommitted error report that array is unsupported operand in arithmetic operation
                result = OutSet.CreateDouble(0.0);
                break;

            case Operations.Div:
                // Ommitted warning message that object cannot be converted to integer
                // Ommitted warning message of division by zero
                // Ommitted error report that array is unsupported operand in arithmetic operation
                result = OutSet.AnyValue;
                break;

            case Operations.Mod:
                // Ommitted warning message that object cannot be converted to integer
                result = ModuloOperation.ModuloByNull(flow);
                break;

            case Operations.BitAnd:
                // Ommitted warning message that object cannot be converted to integer
                result = OutSet.CreateInt(0);
                break;

            case Operations.BitOr:
            case Operations.BitXor:
            case Operations.ShiftLeft:
            case Operations.ShiftRight:
                // Ommitted warning message that object cannot be converted to integer
                result = OutSet.AnyIntegerValue;
                break;

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

                base.VisitUndefinedValue(value);
                break;
            }
        }
Ejemplo n.º 7
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;
            }
        }