diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index c74be6434fb..6c94dc932cb 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,9 @@ +2003-07-28 Mikhail Khodjaiants + Refactoring: moved the 'isNaN', 'isPositiveInfinity' and 'isNegativeInfinity' to the 'CDebugUtils' class. + * ICValue.java + * CValue.java + * CDebugUtils.java + 2003-07-28 Mikhail Khodjaiants Refactoring: moved the 'CDebugUtils' class to the 'org.eclipse.cdt.debug.core' package - the methods of this class are mostly used in UI plugins. diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java index 9a666b1c546..83d128cd171 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java @@ -17,6 +17,12 @@ import org.apache.xml.serialize.SerializerFactory; import org.eclipse.cdt.core.model.IFunction; import org.eclipse.cdt.core.model.IMethod; import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.debug.core.cdi.CDIException; +import org.eclipse.cdt.debug.core.cdi.model.ICDIValue; +import org.eclipse.cdt.debug.core.cdi.model.type.ICDIDoubleValue; +import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatValue; +import org.eclipse.cdt.debug.core.model.ICValue; +import org.eclipse.cdt.debug.internal.core.model.CValue; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; @@ -337,4 +343,77 @@ public class CDebugUtils { return null; } + + public static boolean isNaN( ICValue value ) + { + if ( value instanceof CValue ) + { + try + { + ICDIValue cdiValue = ((CValue)value).getUnderlyingValue(); + if ( cdiValue instanceof ICDIDoubleValue ) + { + return Double.isNaN( ((ICDIDoubleValue)cdiValue).doubleValue() ); + } + if ( cdiValue instanceof ICDIFloatValue ) + { + return Float.isNaN( ((ICDIFloatValue)cdiValue).floatValue() ); + } + } + catch( CDIException e ) + { + } + } + return false; + } + + public static boolean isPositiveInfinity( ICValue value ) + { + if ( value instanceof CValue ) + { + try + { + ICDIValue cdiValue = ((CValue)value).getUnderlyingValue(); + if ( cdiValue instanceof ICDIDoubleValue ) + { + double dbl = ((ICDIDoubleValue)cdiValue).doubleValue(); + return ( Double.isInfinite( dbl ) && Double.POSITIVE_INFINITY == dbl ); + } + if ( cdiValue instanceof ICDIFloatValue ) + { + float flt = ((ICDIFloatValue)cdiValue).floatValue(); + return ( Float.isInfinite( flt ) && Float.POSITIVE_INFINITY == flt ); + } + } + catch( CDIException e ) + { + } + } + return false; + } + + public static boolean isNegativeInfinity( ICValue value ) + { + if ( value instanceof CValue ) + { + try + { + ICDIValue cdiValue = ((CValue)value).getUnderlyingValue(); + if ( cdiValue instanceof ICDIDoubleValue ) + { + double dbl = ((ICDIDoubleValue)cdiValue).doubleValue(); + return ( Double.isInfinite( dbl ) && Double.NEGATIVE_INFINITY == dbl ); + } + if ( cdiValue instanceof ICDIFloatValue ) + { + float flt = ((ICDIFloatValue)cdiValue).floatValue(); + return ( Float.isInfinite( flt ) && Float.NEGATIVE_INFINITY == flt ); + } + } + catch( CDIException e ) + { + } + } + return false; + } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICValue.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICValue.java index c6c1f669cb4..48da065e6ba 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICValue.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICValue.java @@ -17,10 +17,4 @@ import org.eclipse.debug.core.model.IValue; public interface ICValue extends IValue { String evaluateAsExpression(); - - boolean isNaN(); - - boolean isPositiveInfinity(); - - boolean isNegativeInfinity(); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java index 9bd9502ba49..1de7873b2ab 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java @@ -547,77 +547,4 @@ public class CValue extends CDebugElement implements ICValue ((CVariable)it.next()).reset(); } } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.model.ICValue#isNaN() - */ - public boolean isNaN() - { - try - { - ICDIValue value = getUnderlyingValue(); - if ( value instanceof ICDIDoubleValue ) - { - return Double.isNaN( ((ICDIDoubleValue)value).doubleValue() ); - } - if ( value instanceof ICDIFloatValue ) - { - return Float.isNaN( ((ICDIFloatValue)value).floatValue() ); - } - } - catch( CDIException e ) - { - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.model.ICValue#isNegativeInfinity() - */ - public boolean isNegativeInfinity() - { - try - { - ICDIValue value = getUnderlyingValue(); - if ( value instanceof ICDIDoubleValue ) - { - double dbl = ((ICDIDoubleValue)value).doubleValue(); - return ( Double.isInfinite( dbl ) && Double.NEGATIVE_INFINITY == dbl ); - } - if ( value instanceof ICDIFloatValue ) - { - float flt = ((ICDIFloatValue)value).floatValue(); - return ( Float.isInfinite( flt ) && Float.NEGATIVE_INFINITY == flt ); - } - } - catch( CDIException e ) - { - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.model.ICValue#isPositiveInfinity() - */ - public boolean isPositiveInfinity() - { - try - { - ICDIValue value = getUnderlyingValue(); - if ( value instanceof ICDIDoubleValue ) - { - double dbl = ((ICDIDoubleValue)value).doubleValue(); - return ( Double.isInfinite( dbl ) && Double.POSITIVE_INFINITY == dbl ); - } - if ( value instanceof ICDIFloatValue ) - { - float flt = ((ICDIFloatValue)value).floatValue(); - return ( Float.isInfinite( flt ) && Float.POSITIVE_INFINITY == flt ); - } - } - catch( CDIException e ) - { - } - return false; - } } diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index cf51ad74b5b..a5e4cde993f 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,7 @@ +2003-07-28 Mikhail Khodjaiants + Refactoring: moved the 'isNaN', 'isPositiveInfinity' and 'isNegativeInfinity' to the 'CDebugUtils' class. + * CDTDebugModelPresentation.java + 2003-07-28 Mikhail Khodjaiants Refactoring: moved the 'CDebugUtils' class to the 'org.eclipse.cdt.debug.core' package - the methods of this class are mostly used in UI plugins. diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java index 9f194b626d2..8a22a045145 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java @@ -590,11 +590,11 @@ public class CDTDebugModelPresentation extends LabelProvider } else if ( type != null && type.isFloatingPointType() ) { - if ( ((ICValue)value).isNaN() ) + if ( CDebugUtils.isNaN( (ICValue)value ) ) valueString = "NAN"; - if ( ((ICValue)value).isPositiveInfinity() ) + if ( CDebugUtils.isPositiveInfinity( (ICValue)value ) ) valueString = "Infinity"; - if ( ((ICValue)value).isNegativeInfinity() ) + if ( CDebugUtils.isNegativeInfinity( (ICValue)value ) ) valueString = "-Infinity"; label.append( "= " ); label.append( valueString );