mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-12 18:55:38 +02:00
Infinite values of the floating point types.
This commit is contained in:
parent
1d3ef1c353
commit
4890f5b3c1
9 changed files with 112 additions and 48 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2003-06-05 Mikhail Khodjaiants
|
||||||
|
Core support of infinite values of the floating point types.
|
||||||
|
* ICVariable.java
|
||||||
|
* CVariable.java
|
||||||
|
|
||||||
2003-06-05 Mikhail Khodjaiants
|
2003-06-05 Mikhail Khodjaiants
|
||||||
Renamed the 'computeDetail' method of the 'ICValue' interface to 'evaluateAsExpression'.
|
Renamed the 'computeDetail' method of the 'ICValue' interface to 'evaluateAsExpression'.
|
||||||
* ICValue.java
|
* ICValue.java
|
||||||
|
|
|
@ -38,6 +38,10 @@ public interface ICVariable extends IVariable
|
||||||
|
|
||||||
boolean isNaN();
|
boolean isNaN();
|
||||||
|
|
||||||
|
boolean isPositiveInfinity();
|
||||||
|
|
||||||
|
boolean isNegativeInfinity();
|
||||||
|
|
||||||
boolean isPointer();
|
boolean isPointer();
|
||||||
|
|
||||||
String getQualifiedName() throws DebugException;
|
String getQualifiedName() throws DebugException;
|
||||||
|
|
|
@ -693,6 +693,56 @@ public abstract class CVariable extends CDebugElement
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (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)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.debug.core.model.ICVariable#isFloatingPointType()
|
* @see org.eclipse.cdt.debug.core.model.ICVariable#isFloatingPointType()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
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
|
2003-06-05 Mikhail Khodjaiants
|
||||||
Removed the redundant methods from the 'ICDIFloatingPointValue' interface.
|
Removed the redundant methods from the 'ICDIFloatingPointValue' interface.
|
||||||
* src/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatingPointValue.java
|
* src/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatingPointValue.java
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.debug.mi.core.cdi.model.type;
|
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.core.cdi.model.type.ICDIDoubleValue;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
|
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
|
||||||
|
|
||||||
|
@ -19,21 +18,4 @@ public class DoubleValue extends FloatingPointValue implements ICDIDoubleValue {
|
||||||
public DoubleValue(Variable v) {
|
public DoubleValue(Variable v) {
|
||||||
super(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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.debug.mi.core.cdi.model.type;
|
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.core.cdi.model.type.ICDIFloatValue;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
|
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
|
||||||
|
|
||||||
|
@ -19,21 +18,4 @@ public class FloatValue extends FloatingPointValue implements ICDIFloatValue {
|
||||||
public FloatValue(Variable v) {
|
public FloatValue(Variable v) {
|
||||||
super(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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,13 +26,16 @@ public abstract class FloatingPointValue extends Value implements ICDIFloatingPo
|
||||||
*/
|
*/
|
||||||
public double doubleValue() throws CDIException {
|
public double doubleValue() throws CDIException {
|
||||||
double result = 0;
|
double result = 0;
|
||||||
if ( isNaN() )
|
if (isNaN())
|
||||||
result = Double.NaN;
|
result = Double.NaN;
|
||||||
|
else if (isNegativeInfinity())
|
||||||
|
result = Double.NEGATIVE_INFINITY;
|
||||||
|
else if (isPositiveInfinity())
|
||||||
|
result = Double.POSITIVE_INFINITY;
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
result = Double.parseDouble( getValueString() );
|
result = Double.parseDouble(getValueString());
|
||||||
}
|
} catch (NumberFormatException e) {
|
||||||
catch (NumberFormatException e) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -43,20 +46,33 @@ public abstract class FloatingPointValue extends Value implements ICDIFloatingPo
|
||||||
*/
|
*/
|
||||||
public float floatValue() throws CDIException {
|
public float floatValue() throws CDIException {
|
||||||
float result = 0;
|
float result = 0;
|
||||||
if ( isNaN() )
|
if (isNaN())
|
||||||
result = Float.NaN;
|
result = Float.NaN;
|
||||||
|
else if (isNegativeInfinity())
|
||||||
|
result = Float.NEGATIVE_INFINITY;
|
||||||
|
else if (isPositiveInfinity())
|
||||||
|
result = Float.POSITIVE_INFINITY;
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
result = Float.parseFloat( getValueString() );
|
result = Float.parseFloat(getValueString());
|
||||||
}
|
} catch (NumberFormatException e) {
|
||||||
catch (NumberFormatException e) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
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 {
|
private boolean isNaN() throws CDIException {
|
||||||
String valueString = getValueString();
|
String valueString = getValueString();
|
||||||
return ( valueString != null ) ? valueString.indexOf( "nan" ) != -1 : false;
|
return (valueString != null) ? valueString.indexOf("nan") != -1 : false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2003-06-05 Mikhail Khodjaiants
|
||||||
|
UI support of infinite values of the floating point types.
|
||||||
|
* CDTDebugModelPresentation.java
|
||||||
|
|
||||||
2003-06-05 Mikhail Khodjaiants
|
2003-06-05 Mikhail Khodjaiants
|
||||||
Evaluate expressions of detail panel asynchronously.
|
Evaluate expressions of detail panel asynchronously.
|
||||||
* CDTValueDetailProvider.java
|
* CDTValueDetailProvider.java
|
||||||
|
|
|
@ -565,14 +565,29 @@ public class CDTDebugModelPresentation extends LabelProvider
|
||||||
label.append( ']' );
|
label.append( ']' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ( ((ICVariable)var).isCharacter() && value.getValueString() != null )
|
||||||
else if ( !((ICVariable)var).isStructure() && value.getValueString() != null )
|
|
||||||
{
|
{
|
||||||
String valueString = value.getValueString().trim();
|
String valueString = value.getValueString().trim();
|
||||||
if ( valueString.length() == 0 && ((ICVariable)var).isCharacter() )
|
if ( valueString.length() == 0 )
|
||||||
valueString = ".";
|
valueString = ".";
|
||||||
|
label.append( "= " );
|
||||||
|
label.append( valueString );
|
||||||
|
}
|
||||||
|
else if ( ((ICVariable)var).isFloatingPointType() && value.getValueString() != null )
|
||||||
|
{
|
||||||
|
String valueString = value.getValueString().trim();
|
||||||
if ( ((ICVariable)var).isNaN() )
|
if ( ((ICVariable)var).isNaN() )
|
||||||
valueString = "NAN";
|
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 )
|
if ( valueString.length() > 0 )
|
||||||
{
|
{
|
||||||
label.append( "= " );
|
label.append( "= " );
|
||||||
|
|
Loading…
Add table
Reference in a new issue