/// <inheritdoc /> public override void VisitIntervalFloatValue(FloatIntervalValue value) { // When comparing, both operands are converted to boolean switch (operation) { case Operations.BitOr: case Operations.BitXor: IntervalValue <int> integerInterval; if (TypeConversion.TryConvertToIntegerInterval(OutSet, value, out integerInterval)) { result = integerInterval; } else { result = OutSet.AnyIntegerValue; } break; case Operations.Mod: result = ModuloOperation.Modulo(flow, TypeConversion.ToInteger(leftOperand), value); break; default: result = ArithmeticOperation.Arithmetic(flow, operation, TypeConversion.ToFloat(leftOperand), value); if (result != null) { break; } base.VisitIntervalFloatValue(value); break; } }
/// <inheritdoc /> public override void VisitIntervalFloatValue(FloatIntervalValue 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, value); break; default: result = ArithmeticOperation.LeftAbstractArithmetic(flow, operation, value); if (result != null) { break; } base.VisitIntervalFloatValue(value); break; } }
/// <inheritdoc /> public override void VisitIntervalFloatValue(FloatIntervalValue value) { switch (operation) { case Operations.Identical: result = Comparison.Equal(OutSet, leftOperand, value); break; case Operations.NotIdentical: result = Comparison.NotEqual(OutSet, leftOperand, value); break; case Operations.Mod: result = ModuloOperation.Modulo(flow, leftOperand, value); break; default: result = Comparison.IntervalCompare(OutSet, operation, leftOperand, value); if (result != null) { break; } result = ArithmeticOperation.Arithmetic(flow, operation, leftOperand, value); if (result != null) { break; } base.VisitIntervalFloatValue(value); break; } }
/// <inheritdoc /> public override void VisitIntervalFloatValue(FloatIntervalValue value) { switch (operation) { case Operations.Mod: result = ModuloOperation.Modulo(flow, TypeConversion.ToInteger(leftOperand.Value), value); break; default: var leftFloat = TypeConversion.ToFloat(leftOperand.Value); result = Comparison.IntervalCompare(OutSet, operation, leftFloat, value); if (result != null) { break; } result = ArithmeticOperation.Arithmetic(flow, operation, leftFloat, value); if (result != null) { break; } result = LogicalOperation.Logical(OutSet, operation, leftOperand.Value, value); if (result != null) { break; } base.VisitIntervalFloatValue(value); break; } }
/// <inheritdoc /> public override void VisitIntervalFloatValue(FloatIntervalValue value) { switch (operation) { case Operations.Mod: result = ModuloOperation.AbstractModulo(flow, value); break; default: result = Comparison.LeftAbstractBooleanCompare(OutSet, operation, value); if (result != null) { break; } result = ArithmeticOperation.LeftAbstractBooleanArithmetic(flow, operation, value); if (result != null) { break; } base.VisitIntervalFloatValue(value); break; } }
/// <inheritdoc /> public override void VisitIntervalFloatValue(FloatIntervalValue 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, value); break; default: result = ArithmeticOperation.LeftAbstractArithmetic(flow, operation, value); if (result != null) { break; } result = LogicalOperation.Logical(OutSet, operation, TypeConversion.ToBoolean(leftOperand), value); if (result != null) { break; } base.VisitIntervalFloatValue(value); break; } }
/// <inheritdoc /> public override void VisitIntervalFloatValue(FloatIntervalValue value) { switch (operation) { case Operations.Identical: result = OutSet.CreateBool(false); break; case Operations.NotIdentical: result = OutSet.CreateBool(true); break; case Operations.Mod: result = ModuloOperation.Modulo(flow, leftOperand, value); break; default: var floatInterval = TypeConversion.ToFloatInterval(OutSet, leftOperand); result = Comparison.IntervalCompare(OutSet, operation, floatInterval, value); if (result != null) { break; } result = ArithmeticOperation.Arithmetic(flow, operation, leftOperand, value); if (result != null) { break; } base.VisitIntervalFloatValue(value); break; } }
/// <inheritdoc /> public override void VisitIntervalFloatValue(FloatIntervalValue value) { result = LogicalOperation.Logical(OutSet, operation, leftOperand, value); if (result != null) { return; } base.VisitIntervalFloatValue(value); }
/// <inheritdoc /> public override void VisitIntervalFloatValue(FloatIntervalValue value) { if (isIncrement) { result = OutSet.CreateFloatInterval(value.Start + 1.0, value.End + 1.0); } else { result = OutSet.CreateFloatInterval(value.Start - 1.0, value.End - 1.0); } }
/// <inheritdoc /> public override void VisitIntervalFloatValue(FloatIntervalValue value) { switch (operation) { case Operations.Mod: result = ModuloOperation.AbstractModulo(flow, value); break; default: base.VisitIntervalFloatValue(value); break; } }
/// <inheritdoc /> public override void VisitIntervalFloatValue(FloatIntervalValue value) { switch (operation) { case Operations.Mod: // Ommitted warning message that object cannot be converted to integer result = ModuloOperation.AbstractModulo(flow, value); break; default: base.VisitIntervalFloatValue(value); break; } }
bool ToRemove(Value value, FloatIntervalValue interval) { var visitor = new ToFloatConversionVisitor(valueFactory); value.Accept(visitor); var floatValue = visitor.Result; if (floatValue != null) { return(floatValue.Value < interval.Start || floatValue.Value > interval.End); } return(false); }
void IntersectValues(List <Value> values, Value newValue) { if (newValue is ConcreteValue) { //There is nothin more precise, so we can delete anything. //If there is a precise value already present, the newValue should be one of them. values.Clear(); values.Add(newValue); return; } if (newValue is IntervalValue) { FloatIntervalValue interval = TypeConversion.ToFloatInterval(valueFactory, (IntervalValue)newValue); if (interval != null) { values.RemoveAll(a => ToRemove(a, interval)); } //if there is already a concrete value, there is nothing to add, because the present conrete value is more precise. if (values.Any(a => a is ConcreteValue)) { return; } //if there are some other intarvalu values, we must delete those, which doesn't intersect the new one. We will add the intersection of those, which intersects the new one and the new one Value intersection = IntersectIntervals((IntervalValue)newValue, values.Where(a => a is IntervalValue).Select(a => (IntervalValue)a)); //we will also delete more general values (any value, anystring, anyint, ...) also the intervals are already counted in. values.Clear(); if (intersection != null) { values.Add(intersection); } } else if (newValue is AnyValue && values.Count > 0) { //There already is something, which is defitinelly more precise... or with the same precision. -- there is nothing to add } else { // in this case we are adding something more precise than anyValue. values.RemoveAll(a => a is AnyValue); values.Add(newValue); } }
/// <inheritdoc /> public override void VisitIntervalFloatValue(FloatIntervalValue value) { if (value.Start == value.End) { VisitFloatValue(OutSet.CreateDouble(value.Start)); return; } IntervalValue <int> integerInterval; switch (operation) { case Operations.Minus: result = OutSet.CreateFloatInterval(-value.End, -value.Start); break; case Operations.BitNegation: if (TypeConversion.TryConvertToIntegerInterval(OutSet, value, out integerInterval)) { result = OutSet.CreateIntegerInterval(~integerInterval.End, ~integerInterval.Start); } else { result = OutSet.AnyIntegerValue; } break; case Operations.Int32Cast: if (TypeConversion.TryConvertToIntegerInterval(OutSet, value, out integerInterval)) { result = integerInterval; } else { result = OutSet.AnyIntegerValue; } break; case Operations.FloatCast: case Operations.DoubleCast: result = value; break; default: base.VisitIntervalFloatValue(value); break; } }
/// <inheritdoc /> public override void VisitIntervalFloatValue(FloatIntervalValue value) { switch (operation) { case Operations.Identical: case Operations.NotIdentical: result = OutSet.AnyBooleanValue; break; case Operations.Mod: result = ModuloOperation.AbstractModulo(flow, value); break; default: base.VisitIntervalFloatValue(value); break; } }
/// <inheritdoc /> public override void VisitIntervalFloatValue(FloatIntervalValue value) { switch (operation) { case Operations.Mod: result = ModuloOperation.AbstractModulo(flow, value); break; default: result = LogicalOperation.AbstractLogical(OutSet, operation, value); if (result != null) { break; } base.VisitIntervalFloatValue(value); break; } }
/// <inheritdoc /> public override void VisitIntervalFloatValue(FloatIntervalValue value) { switch (operation) { case Operations.Mod: result = ModuloOperation.Modulo(flow, TypeConversion.ToNativeInteger(Snapshot, leftOperand), value); break; default: result = LogicalOperation.Logical(OutSet, operation, TypeConversion.ToNativeBoolean(Snapshot, leftOperand), value); if (result != null) { break; } base.VisitIntervalFloatValue(value); break; } }
/// <inheritdoc /> public override void VisitIntervalFloatValue(FloatIntervalValue value) { switch (operation) { case Operations.Mod: result = ModuloOperation.Modulo(flow, leftOperand.Value, value); break; default: result = LogicalOperation.Logical(OutSet, operation, TypeConversion.ToBoolean(leftOperand.Value), value); if (result != null) { break; } int integerValue; double floatValue; bool isInteger; TypeConversion.TryConvertToNumber(leftOperand.Value, true, out integerValue, out floatValue, out isInteger); result = Comparison.IntervalCompare(OutSet, operation, floatValue, value); if (result != null) { break; } result = ArithmeticOperation.Arithmetic(flow, operation, floatValue, value); if (result != null) { break; } base.VisitIntervalFloatValue(value); break; } }
/// <inheritdoc /> public override void VisitIntervalFloatValue(FloatIntervalValue value) { Result = snapshot.CreateIntegerInterval((int)value.Start, (int)value.End); }
/// <inheritdoc /> public override void VisitIntervalLongintValue(LongintIntervalValue value) { Result = snapshot.CreateFloatInterval(value.Start, value.End); }
/// <inheritdoc /> public override void VisitIntervalIntegerValue(IntegerIntervalValue value) { Result = snapshot.CreateFloatInterval(value.Start, value.End); }
/// <inheritdoc /> public override void VisitIntervalFloatValue(FloatIntervalValue value) { Result = value; }
/// <inheritdoc /> public override void VisitIntervalFloatValue(FloatIntervalValue value) { Result = snapshot.CreateLongintInterval((long)value.Start, (long)value.End); }
/// <inheritdoc /> public override void VisitIntervalFloatValue(FloatIntervalValue value) { containsFloat = true; minFloat = Math.Min(Math.Min(minFloat, value.Start), value.End); maxFloat = Math.Max(Math.Max(maxFloat, value.Start), value.End); }
/// <inheritdoc /> public override void VisitIntervalFloatValue(FloatIntervalValue value) { numberFound(); }
/// <inheritdoc /> public override void VisitIntervalFloatValue(FloatIntervalValue value) { Max = Math.Max(Max, value.End); }
/// <inheritdoc /> public override void VisitIntervalFloatValue(FloatIntervalValue value) { floatIntervalVisitor.SetLeftOperand(value); visitor = floatIntervalVisitor; }