Example #1
0
 private static void InitalizeInternals(ISnapshotReadWrite snapshot)
 {
     if (booleanInterval == null)
     {
         booleanInterval = TypeConversion.AnyBooleanToIntegerInterval(snapshot);
     }
 }
Example #2
0
        /// <inheritdoc />
        public override void VisitAnyBooleanValue(AnyBooleanValue value)
        {
            switch (operation)
            {
            case Operations.Equal:
            case Operations.NotEqual:
            case Operations.GreaterThanOrEqual:
            case Operations.LessThan:
            case Operations.Or:
            case Operations.Xor:
                result = value;
                break;

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

            case Operations.Sub:
                var booleanInterval = TypeConversion.AnyBooleanToIntegerInterval(OutSet);
                result = OutSet.CreateIntegerInterval(-booleanInterval.End, -booleanInterval.Start);
                break;

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

            case Operations.Div:
                SetWarning("Possible division by zero (converted from boolean false)",
                           AnalysisWarningCause.DIVISION_BY_ZERO);

                // Division or modulo by false returns false boolean value
                result = OutSet.AnyValue;
                break;

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

            default:
                base.VisitAnyBooleanValue(value);
                break;
            }
        }
Example #3
0
        /// <inheritdoc />
        public override void VisitUndefinedValue(UndefinedValue value)
        {
            switch (operation)
            {
            case Operations.Add:
            case Operations.Sub:
            case Operations.BitOr:
            case Operations.BitXor:
            case Operations.ShiftLeft:
            case Operations.ShiftRight:
                result = TypeConversion.AnyBooleanToIntegerInterval(OutSet);
                break;

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

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