1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-31 04:45:38 +02:00

Minimize the number of the "evaluate expression" requests when changing the value of the floating point types.

This commit is contained in:
Mikhail Khodjaiants 2003-07-28 21:39:57 +00:00
parent 95b11e1171
commit 5ad84a932b
6 changed files with 62 additions and 59 deletions

View file

@ -1,3 +1,7 @@
2003-07-28 Mikhail Khodjaiants
Minimize the number of the "evaluate expression" requests when changing the value of the floating point types.
* CDebugUtils.java
2003-07-28 Mikhail Khodjaiants 2003-07-28 Mikhail Khodjaiants
Refactoring: moved the 'isNaN', 'isPositiveInfinity' and 'isNegativeInfinity' to the 'CDebugUtils' class. Refactoring: moved the 'isNaN', 'isPositiveInfinity' and 'isNegativeInfinity' to the 'CDebugUtils' class.
* ICValue.java * ICValue.java

View file

@ -344,7 +344,7 @@ public class CDebugUtils
return null; return null;
} }
public static boolean isNaN( ICValue value ) public static Number getFloatingPointValue( ICValue value )
{ {
if ( value instanceof CValue ) if ( value instanceof CValue )
{ {
@ -353,66 +353,55 @@ public class CDebugUtils
ICDIValue cdiValue = ((CValue)value).getUnderlyingValue(); ICDIValue cdiValue = ((CValue)value).getUnderlyingValue();
if ( cdiValue instanceof ICDIDoubleValue ) if ( cdiValue instanceof ICDIDoubleValue )
{ {
return Double.isNaN( ((ICDIDoubleValue)cdiValue).doubleValue() ); return new Double( ((ICDIDoubleValue)cdiValue).doubleValue() );
} }
if ( cdiValue instanceof ICDIFloatValue ) if ( cdiValue instanceof ICDIFloatValue )
{ {
return Float.isNaN( ((ICDIFloatValue)cdiValue).floatValue() ); return new Float( ((ICDIFloatValue)cdiValue).floatValue() );
} }
} }
catch( CDIException e ) catch( CDIException e )
{ {
} }
} }
return false; return null;
} }
public static boolean isPositiveInfinity( ICValue value ) public static boolean isNaN( Number value )
{ {
if ( value instanceof CValue ) if ( value instanceof Double )
{ {
try return ((Double)value).isNaN();
{ }
ICDIValue cdiValue = ((CValue)value).getUnderlyingValue(); if ( value instanceof Float )
if ( cdiValue instanceof ICDIDoubleValue ) {
{ return ((Float)value).isNaN();
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; return false;
} }
public static boolean isNegativeInfinity( ICValue value ) public static boolean isPositiveInfinity( Number value )
{ {
if ( value instanceof CValue ) if ( value instanceof Double )
{ {
try return ( ((Double)value).isInfinite() && value.doubleValue() == Double.POSITIVE_INFINITY );
{ }
ICDIValue cdiValue = ((CValue)value).getUnderlyingValue(); if ( value instanceof Float )
if ( cdiValue instanceof ICDIDoubleValue ) {
{ return ( ((Float)value).isInfinite() && value.floatValue() == Float.POSITIVE_INFINITY );
double dbl = ((ICDIDoubleValue)cdiValue).doubleValue(); }
return ( Double.isInfinite( dbl ) && Double.NEGATIVE_INFINITY == dbl ); return false;
} }
if ( cdiValue instanceof ICDIFloatValue )
{ public static boolean isNegativeInfinity( Number value )
float flt = ((ICDIFloatValue)cdiValue).floatValue(); {
return ( Float.isInfinite( flt ) && Float.NEGATIVE_INFINITY == flt ); if ( value instanceof Double )
} {
} return ( ((Double)value).isInfinite() && value.doubleValue() == Double.NEGATIVE_INFINITY );
catch( CDIException e ) }
{ if ( value instanceof Float )
} {
return ( ((Float)value).isInfinite() && value.floatValue() == Float.NEGATIVE_INFINITY );
} }
return false; return false;
} }

View file

@ -1,3 +1,9 @@
2003-07-28 Mikhail Khodjaiants
Minimize the number of the "evaluate expression" requests when changing the value of the floating point types.
* src/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatingPointValue.java
2003-07-17 Alain Magloire 2003-07-17 Alain Magloire
Catch the use of cli command "detach" and fire the appropriate events. Catch the use of cli command "detach" and fire the appropriate events.

View file

@ -26,15 +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()) String valueString = getValueString();
if (isNaN(valueString))
result = Double.NaN; result = Double.NaN;
else if (isNegativeInfinity()) else if (isNegativeInfinity(valueString))
result = Double.NEGATIVE_INFINITY; result = Double.NEGATIVE_INFINITY;
else if (isPositiveInfinity()) else if (isPositiveInfinity(valueString))
result = Double.POSITIVE_INFINITY; result = Double.POSITIVE_INFINITY;
else { else {
try { try {
result = Double.parseDouble(getValueString()); result = Double.parseDouble(valueString);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
} }
} }
@ -46,33 +47,31 @@ 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()) String valueString = getValueString();
if (isNaN(valueString))
result = Float.NaN; result = Float.NaN;
else if (isNegativeInfinity()) else if (isNegativeInfinity(valueString))
result = Float.NEGATIVE_INFINITY; result = Float.NEGATIVE_INFINITY;
else if (isPositiveInfinity()) else if (isPositiveInfinity(valueString))
result = Float.POSITIVE_INFINITY; result = Float.POSITIVE_INFINITY;
else { else {
try { try {
result = Float.parseFloat(getValueString()); result = Float.parseFloat(valueString);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
} }
} }
return result; return result;
} }
private boolean isPositiveInfinity() throws CDIException { private boolean isPositiveInfinity(String valueString) {
String valueString = getValueString();
return (valueString != null) ? valueString.indexOf("inf") != -1 : false; return (valueString != null) ? valueString.indexOf("inf") != -1 : false;
} }
private boolean isNegativeInfinity() throws CDIException { private boolean isNegativeInfinity(String valueString) {
String valueString = getValueString();
return (valueString != null) ? valueString.indexOf("-inf") != -1 : false; return (valueString != null) ? valueString.indexOf("-inf") != -1 : false;
} }
private boolean isNaN() throws CDIException { private boolean isNaN(String valueString) {
String valueString = getValueString();
return (valueString != null) ? valueString.indexOf("nan") != -1 : false; return (valueString != null) ? valueString.indexOf("nan") != -1 : false;
} }
} }

View file

@ -1,3 +1,7 @@
2003-07-28 Mikhail Khodjaiants
Minimize the number of the "evaluate expression" requests when changing the value of the floating point types.
* CDTDebugModelPresentation.java
2003-07-28 Mikhail Khodjaiants 2003-07-28 Mikhail Khodjaiants
Refactoring: moved the 'isNaN', 'isPositiveInfinity' and 'isNegativeInfinity' to the 'CDebugUtils' class. Refactoring: moved the 'isNaN', 'isPositiveInfinity' and 'isNegativeInfinity' to the 'CDebugUtils' class.
* CDTDebugModelPresentation.java * CDTDebugModelPresentation.java

View file

@ -590,11 +590,12 @@ public class CDTDebugModelPresentation extends LabelProvider
} }
else if ( type != null && type.isFloatingPointType() ) else if ( type != null && type.isFloatingPointType() )
{ {
if ( CDebugUtils.isNaN( (ICValue)value ) ) Number floatingPointValue = CDebugUtils.getFloatingPointValue( (ICValue)value );
if ( CDebugUtils.isNaN( floatingPointValue ) )
valueString = "NAN"; valueString = "NAN";
if ( CDebugUtils.isPositiveInfinity( (ICValue)value ) ) if ( CDebugUtils.isPositiveInfinity( floatingPointValue ) )
valueString = "Infinity"; valueString = "Infinity";
if ( CDebugUtils.isNegativeInfinity( (ICValue)value ) ) if ( CDebugUtils.isNegativeInfinity( floatingPointValue ) )
valueString = "-Infinity"; valueString = "-Infinity";
label.append( "= " ); label.append( "= " );
label.append( valueString ); label.append( valueString );