/// <inheritdoc /> public override void VisitAnyIntegerValue(AnyIntegerValue value) { result = ArithmeticOperation.AbstractIntegerArithmetic(flow, operation); if (result != null) { return; } base.VisitAnyIntegerValue(value); }
/// <inheritdoc /> public override void VisitAnyResourceValue(AnyResourceValue value) { result = ArithmeticOperation.AbstractIntegerArithmetic(flow, operation); if (result != null) { // Arithmetic with resources is nonsence return; } base.VisitAnyResourceValue(value); }
/// <inheritdoc /> public override void VisitAnyObjectValue(AnyObjectValue value) { result = ArithmeticOperation.AbstractIntegerArithmetic(flow, operation); if (result != null) { SetWarning("Object cannot be converted to integer by arithmetic operation", AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER); return; } base.VisitAnyObjectValue(value); }
/// <inheritdoc /> public override void VisitAnyResourceValue(AnyResourceValue 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.LeftAlwaysGreater(OutSet, operation); if (result != null) { break; } result = ArithmeticOperation.AbstractIntegerArithmetic(flow, operation); if (result != null) { // Arithmetic objects and resources is nonsence SetWarning("Object cannot be converted to integer by arithmetic operation", AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER); break; } result = LogicalOperation.Logical(OutSet, operation, TypeConversion.ToBoolean(leftOperand), TypeConversion.ToBoolean(value)); if (result != null) { break; } result = BitwiseOperation.Bitwise(OutSet, operation); if (result != null) { // Bitwise operation with resource can give any integer SetWarning("Object cannot be converted to integer by bitwise operation", AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER); break; } base.VisitAnyResourceValue(value); break; } }
/// <inheritdoc /> public override void VisitObjectValue(ObjectValue value) { switch (operation) { case Operations.Identical: case Operations.NotIdentical: // TODO: Compare if two objects are the same instances of the same class result = OutSet.AnyBooleanValue; break; case Operations.Mod: SetWarning("Both objects cannot be converted to integers by modulo operation", AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER); result = ModuloOperation.AbstractModulo(flow); break; default: if (Comparison.IsOperationComparison(operation)) { // TODO: Two object instances are equal if they have the same attributes // and their values, and are instances of the same class. result = OutSet.AnyBooleanValue; break; } result = ArithmeticOperation.AbstractIntegerArithmetic(flow, operation); if (result != null) { SetWarning("Both objects cannot be converted to integers by arithmetic operation", AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER); break; } result = LogicalOperation.Logical(OutSet, operation, TypeConversion.ToBoolean(leftOperand), TypeConversion.ToBoolean(value)); if (result != null) { break; } result = BitwiseOperation.Bitwise(OutSet, operation); if (result != null) { SetWarning("Both objects cannot be converted to integers by bitwise operation", AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER); break; } base.VisitObjectValue(value); break; } }
/// <inheritdoc /> public override void VisitAnyObjectValue(AnyObjectValue value) { switch (operation) { case Operations.Identical: case Operations.NotIdentical: // It cannot be decided if they are identical or not. result = OutSet.AnyBooleanValue; break; case Operations.Mod: SetWarning("Object cannot be converted to integer by modulo operation", AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER); result = ModuloOperation.AbstractModulo(flow); break; default: result = Comparison.AbstractCompare(OutSet, operation); if (result != null) { break; } result = ArithmeticOperation.AbstractIntegerArithmetic(flow, operation); if (result != null) { SetWarning("Both objects cannot be converted to integers by arithmetic operation", AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER); break; } result = LogicalOperation.Logical(OutSet, operation, TypeConversion.ToBoolean(leftOperand), TypeConversion.ToBoolean(value)); if (result != null) { break; } result = BitwiseOperation.Bitwise(OutSet, operation); if (result != null) { SetWarning("Both objects cannot be converted to integers by bitwise operation", AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER); break; } base.VisitAnyObjectValue(value); break; } }
/// <inheritdoc /> public override void VisitAnyResourceValue(AnyResourceValue value) { switch (operation) { case Operations.Identical: case Operations.NotIdentical: result = OutSet.AnyBooleanValue; break; case Operations.Mod: result = ModuloOperation.AbstractModulo(flow); break; default: result = Comparison.AbstractCompare(OutSet, operation); if (result != null) { // Comapring of resource and integer makes no sence. break; } result = ArithmeticOperation.AbstractIntegerArithmetic(flow, operation); if (result != null) { // Arithmetic with resources is nonsence break; } result = LogicalOperation.Logical(OutSet, operation, TypeConversion.ToBoolean(leftOperand), TypeConversion.ToBoolean(value)); if (result != null) { break; } result = BitwiseOperation.Bitwise(OutSet, operation); if (result != null) { // Bitwise operation with resource can give any integer break; } base.VisitAnyResourceValue(value); break; } }
/// <inheritdoc /> public override void VisitAnyIntegerValue(AnyIntegerValue value) { switch (operation) { case Operations.Identical: case Operations.NotIdentical: result = OutSet.AnyBooleanValue; break; default: result = ArithmeticOperation.AbstractIntegerArithmetic(flow, operation); if (result != null) { break; } base.VisitAnyIntegerValue(value); break; } }
/// <inheritdoc /> public override void VisitObjectValue(ObjectValue 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: result = LogicalOperation.Logical(OutSet, operation, TypeConversion.ToBoolean(leftOperand), TypeConversion.ToBoolean(value)); if (result != null) { break; } result = ArithmeticOperation.AbstractIntegerArithmetic(flow, operation); if (result != null) { SetWarning("Object cannot be converted to integer by arithmetic operation", AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER); break; } result = BitwiseOperation.Bitwise(OutSet, operation); if (result != null) { SetWarning("Object cannot be converted to integer by bitwise operation", AnalysisWarningCause.OBJECT_CONVERTED_TO_INTEGER); break; } base.VisitObjectValue(value); break; } }