Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Infinite values of the floating point types.

 
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/ChangeLog,v
retrieving revision 1.140
diff -u -r1.140 ChangeLog
--- ChangeLog	5 Jun 2003 19:22:52 -0000	1.140
+++ ChangeLog	5 Jun 2003 21:12:38 -0000
@@ -1,4 +1,10 @@
 2003-06-05 Mikhail Khodjaiants
+	gdb/mi support of infinite values of the floating point types.
+	* DoubleValue.java
+	* FloatingPointValue.java
+	* FloatValue.java
+
+2003-06-05 Mikhail Khodjaiants
 	Removed the redundant methods from the 'ICDIFloatingPointValue' interface.
 	* src/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatingPointValue.java
 
Index: src/org/eclipse/cdt/debug/mi/core/cdi/model/type/DoubleValue.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/type/DoubleValue.java,v
retrieving revision 1.2
diff -u -r1.2 DoubleValue.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/model/type/DoubleValue.java	4 Jun 2003 16:13:35 -0000	1.2
+++ src/org/eclipse/cdt/debug/mi/core/cdi/model/type/DoubleValue.java	5 Jun 2003 21:12:38 -0000
@@ -5,7 +5,6 @@
 
 package org.eclipse.cdt.debug.mi.core.cdi.model.type;
 
-import org.eclipse.cdt.debug.core.cdi.CDIException;
 import org.eclipse.cdt.debug.core.cdi.model.type.ICDIDoubleValue;
 import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
 
@@ -18,22 +17,5 @@
 	 */
 	public DoubleValue(Variable v) {
 		super(v);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatingPointValue#isNaN()
-	 */
-	public boolean isNaN() {
-		// Identify this value as Not-a-Number if parsing fails.
-		try {
-			Double.parseDouble( getValueString() );
-		}
-		catch (NumberFormatException e) {
-			return true;
-		}
-		catch (CDIException e) {
-			return true;
-		}
-		return false;
 	}
 }
Index: src/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatValue.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatValue.java,v
retrieving revision 1.2
diff -u -r1.2 FloatValue.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatValue.java	4 Jun 2003 16:13:35 -0000	1.2
+++ src/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatValue.java	5 Jun 2003 21:12:38 -0000
@@ -5,7 +5,6 @@
 
 package org.eclipse.cdt.debug.mi.core.cdi.model.type;
 
-import org.eclipse.cdt.debug.core.cdi.CDIException;
 import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatValue;
 import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
 
@@ -18,22 +17,5 @@
 	 */
 	public FloatValue(Variable v) {
 		super(v);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatingPointValue#isNaN()
-	 */
-	public boolean isNaN() {
-		// Identify this value as Not-a-Number if parsing fails.
-		try {
-			Float.parseFloat( getValueString() );
-		}
-		catch (NumberFormatException e) {
-			return true;
-		}
-		catch (CDIException e) {
-			return true;
-		}
-		return false;
 	}
 }
Index: src/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatingPointValue.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatingPointValue.java,v
retrieving revision 1.3
diff -u -r1.3 FloatingPointValue.java
--- src/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatingPointValue.java	5 Jun 2003 19:22:52 -0000	1.3
+++ src/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatingPointValue.java	5 Jun 2003 21:12:38 -0000
@@ -26,13 +26,16 @@
 	 */
 	public double doubleValue() throws CDIException {
 		double result = 0;
-		if ( isNaN() )
+		if (isNaN())
 			result = Double.NaN;
+		else if (isNegativeInfinity())
+			result = Double.NEGATIVE_INFINITY;
+		else if (isPositiveInfinity())
+			result = Double.POSITIVE_INFINITY;
 		else {		
 			try {
-				result = Double.parseDouble( getValueString() );
-			}
-			catch (NumberFormatException e) {
+				result = Double.parseDouble(getValueString());
+			} catch (NumberFormatException e) {
 			}
 		}
 		return result;
@@ -43,20 +46,33 @@
 	 */
 	public float floatValue() throws CDIException {
 		float result = 0;
-		if ( isNaN() )
+		if (isNaN())
 			result = Float.NaN;
+		else if (isNegativeInfinity())
+			result = Float.NEGATIVE_INFINITY;
+		else if (isPositiveInfinity())
+			result = Float.POSITIVE_INFINITY;
 		else {		
 			try {
-				result = Float.parseFloat( getValueString() );
-			}
-			catch (NumberFormatException e) {
+				result = Float.parseFloat(getValueString());
+			} catch (NumberFormatException e) {
 			}
 		}
 		return result;
 	}
 
+	private boolean isPositiveInfinity() throws CDIException {
+		String valueString = getValueString();
+		return (valueString != null) ? valueString.indexOf("inf") != -1 : false;
+	}
+
+	private boolean isNegativeInfinity() throws CDIException {
+		String valueString = getValueString();
+		return (valueString != null) ? valueString.indexOf("-inf") != -1 : false;
+	}
+
 	private boolean isNaN() throws CDIException {
 		String valueString = getValueString();
-		return ( valueString != null ) ? valueString.indexOf( "nan" ) != -1 : false;
+		return (valueString != null) ? valueString.indexOf("nan") != -1 : false;
 	}
 }
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/ChangeLog,v
retrieving revision 1.154
diff -u -r1.154 ChangeLog
--- ChangeLog	5 Jun 2003 20:47:15 -0000	1.154
+++ ChangeLog	5 Jun 2003 21:13:41 -0000
@@ -1,4 +1,8 @@
 2003-06-05 Mikhail Khodjaiants
+	UI support of infinite values of the floating point types.
+	* CDTDebugModelPresentation.java
+
+2003-06-05 Mikhail Khodjaiants
 	Evaluate expressions of detail panel asynchronously.
 	* CDTValueDetailProvider.java
 
Index: src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java,v
retrieving revision 1.58
diff -u -r1.58 CDTDebugModelPresentation.java
--- src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java	4 Jun 2003 22:04:25 -0000	1.58
+++ src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java	5 Jun 2003 21:13:41 -0000
@@ -565,14 +565,29 @@
 						label.append( ']' );					
 					}
 				}
-
-				else if ( !((ICVariable)var).isStructure() &&  value.getValueString() != null )
+				else if ( ((ICVariable)var).isCharacter() && value.getValueString() != null )
 				{
 					String valueString = value.getValueString().trim();
-					if ( valueString.length() == 0 && ((ICVariable)var).isCharacter() )
+					if ( valueString.length() == 0 )
 						valueString = ".";
+					label.append( "= " );
+					label.append( valueString );
+				}
+				else if ( ((ICVariable)var).isFloatingPointType() && value.getValueString() != null )
+				{
+					String valueString = value.getValueString().trim();
 					if ( ((ICVariable)var).isNaN() )
 						valueString = "NAN";
+					if ( ((ICVariable)var).isPositiveInfinity() )
+						valueString = "Infinity";
+					if ( ((ICVariable)var).isNegativeInfinity() )
+						valueString = "-Infinity";
+					label.append( "= " );
+					label.append( valueString );
+				}
+				else if ( !((ICVariable)var).isStructure() && value.getValueString() != null )
+				{
+					String valueString = value.getValueString().trim();
 					if ( valueString.length() > 0 )
 					{
 						label.append( "= " );
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/ChangeLog,v
retrieving revision 1.197
diff -u -r1.197 ChangeLog
--- ChangeLog	5 Jun 2003 20:44:45 -0000	1.197
+++ ChangeLog	5 Jun 2003 21:10:25 -0000
@@ -1,4 +1,9 @@
 2003-06-05 Mikhail Khodjaiants
+	Core support of infinite values of the floating point types.
+	* ICVariable.java
+	* CVariable.java
+
+2003-06-05 Mikhail Khodjaiants
 	Renamed the 'computeDetail' method of the 'ICValue' interface to 'evaluateAsExpression'.
 	* ICValue.java
 	* CArrayPartitionValue.java
Index: src/org/eclipse/cdt/debug/core/model/ICVariable.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICVariable.java,v
retrieving revision 1.5
diff -u -r1.5 ICVariable.java
--- src/org/eclipse/cdt/debug/core/model/ICVariable.java	4 Jun 2003 22:02:47 -0000	1.5
+++ src/org/eclipse/cdt/debug/core/model/ICVariable.java	5 Jun 2003 21:10:25 -0000
@@ -38,6 +38,10 @@
 
 	boolean isNaN();
 
+	boolean isPositiveInfinity();
+
+	boolean isNegativeInfinity();
+
 	boolean isPointer();
 
 	String getQualifiedName() throws DebugException;
Index: src/org/eclipse/cdt/debug/internal/core/model/CVariable.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java,v
retrieving revision 1.29
diff -u -r1.29 CVariable.java
--- src/org/eclipse/cdt/debug/internal/core/model/CVariable.java	5 Jun 2003 19:22:49 -0000	1.29
+++ src/org/eclipse/cdt/debug/internal/core/model/CVariable.java	5 Jun 2003 21:10:26 -0000
@@ -694,6 +694,56 @@
 	}
 
 	/* (non-Javadoc)
+	 * @see org.eclipse.cdt.debug.core.model.ICVariable#isNegativeInfinity()
+	 */
+	public boolean isNegativeInfinity()
+	{
+		try 
+		{
+			ICDIValue value = getCDIVariable().getValue();
+			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.ICVariable#isPositiveInfinity()
+	 */
+	public boolean isPositiveInfinity()
+	{
+		try 
+		{
+			ICDIValue value = getCDIVariable().getValue();
+			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;
+	}
+
+	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.debug.core.model.ICVariable#isFloatingPointType()
 	 */
 	public boolean isFloatingPointType() 

Back to the top