mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Refactoring: moved the 'isNaN', 'isPositiveInfinity' and 'isNegativeInfinity' to the 'CDebugUtils' class.
This commit is contained in:
parent
622186c83c
commit
460eff2253
6 changed files with 92 additions and 82 deletions
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,10 +17,4 @@ import org.eclipse.debug.core.model.IValue;
|
|||
public interface ICValue extends IValue
|
||||
{
|
||||
String evaluateAsExpression();
|
||||
|
||||
boolean isNaN();
|
||||
|
||||
boolean isPositiveInfinity();
|
||||
|
||||
boolean isNegativeInfinity();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 );
|
||||
|
|
Loading…
Add table
Reference in a new issue