mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Minimize the number of the "evaluate expression" requests when changing the value of the floating point types.
This commit is contained in:
parent
95b11e1171
commit
5ad84a932b
6 changed files with 62 additions and 59 deletions
|
@ -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
|
||||
Refactoring: moved the 'isNaN', 'isPositiveInfinity' and 'isNegativeInfinity' to the 'CDebugUtils' class.
|
||||
* ICValue.java
|
||||
|
|
|
@ -344,7 +344,7 @@ public class CDebugUtils
|
|||
return null;
|
||||
}
|
||||
|
||||
public static boolean isNaN( ICValue value )
|
||||
public static Number getFloatingPointValue( ICValue value )
|
||||
{
|
||||
if ( value instanceof CValue )
|
||||
{
|
||||
|
@ -353,66 +353,55 @@ public class CDebugUtils
|
|||
ICDIValue cdiValue = ((CValue)value).getUnderlyingValue();
|
||||
if ( cdiValue instanceof ICDIDoubleValue )
|
||||
{
|
||||
return Double.isNaN( ((ICDIDoubleValue)cdiValue).doubleValue() );
|
||||
return new Double( ((ICDIDoubleValue)cdiValue).doubleValue() );
|
||||
}
|
||||
if ( cdiValue instanceof ICDIFloatValue )
|
||||
{
|
||||
return Float.isNaN( ((ICDIFloatValue)cdiValue).floatValue() );
|
||||
return new Float( ((ICDIFloatValue)cdiValue).floatValue() );
|
||||
}
|
||||
}
|
||||
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
|
||||
{
|
||||
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 ((Double)value).isNaN();
|
||||
}
|
||||
if ( value instanceof Float )
|
||||
{
|
||||
return ((Float)value).isNaN();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isNegativeInfinity( ICValue value )
|
||||
public static boolean isPositiveInfinity( Number value )
|
||||
{
|
||||
if ( value instanceof CValue )
|
||||
if ( value instanceof Double )
|
||||
{
|
||||
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 ( ((Double)value).isInfinite() && value.doubleValue() == Double.POSITIVE_INFINITY );
|
||||
}
|
||||
if ( value instanceof Float )
|
||||
{
|
||||
return ( ((Float)value).isInfinite() && value.floatValue() == Float.POSITIVE_INFINITY );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isNegativeInfinity( Number value )
|
||||
{
|
||||
if ( value instanceof Double )
|
||||
{
|
||||
return ( ((Double)value).isInfinite() && value.doubleValue() == Double.NEGATIVE_INFINITY );
|
||||
}
|
||||
if ( value instanceof Float )
|
||||
{
|
||||
return ( ((Float)value).isInfinite() && value.floatValue() == Float.NEGATIVE_INFINITY );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
Catch the use of cli command "detach" and fire the appropriate events.
|
||||
|
|
|
@ -26,15 +26,16 @@ public abstract class FloatingPointValue extends Value implements ICDIFloatingPo
|
|||
*/
|
||||
public double doubleValue() throws CDIException {
|
||||
double result = 0;
|
||||
if (isNaN())
|
||||
String valueString = getValueString();
|
||||
if (isNaN(valueString))
|
||||
result = Double.NaN;
|
||||
else if (isNegativeInfinity())
|
||||
else if (isNegativeInfinity(valueString))
|
||||
result = Double.NEGATIVE_INFINITY;
|
||||
else if (isPositiveInfinity())
|
||||
else if (isPositiveInfinity(valueString))
|
||||
result = Double.POSITIVE_INFINITY;
|
||||
else {
|
||||
try {
|
||||
result = Double.parseDouble(getValueString());
|
||||
result = Double.parseDouble(valueString);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
|
@ -46,33 +47,31 @@ public abstract class FloatingPointValue extends Value implements ICDIFloatingPo
|
|||
*/
|
||||
public float floatValue() throws CDIException {
|
||||
float result = 0;
|
||||
if (isNaN())
|
||||
String valueString = getValueString();
|
||||
if (isNaN(valueString))
|
||||
result = Float.NaN;
|
||||
else if (isNegativeInfinity())
|
||||
else if (isNegativeInfinity(valueString))
|
||||
result = Float.NEGATIVE_INFINITY;
|
||||
else if (isPositiveInfinity())
|
||||
else if (isPositiveInfinity(valueString))
|
||||
result = Float.POSITIVE_INFINITY;
|
||||
else {
|
||||
try {
|
||||
result = Float.parseFloat(getValueString());
|
||||
result = Float.parseFloat(valueString);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean isPositiveInfinity() throws CDIException {
|
||||
String valueString = getValueString();
|
||||
private boolean isPositiveInfinity(String valueString) {
|
||||
return (valueString != null) ? valueString.indexOf("inf") != -1 : false;
|
||||
}
|
||||
|
||||
private boolean isNegativeInfinity() throws CDIException {
|
||||
String valueString = getValueString();
|
||||
private boolean isNegativeInfinity(String valueString) {
|
||||
return (valueString != null) ? valueString.indexOf("-inf") != -1 : false;
|
||||
}
|
||||
|
||||
private boolean isNaN() throws CDIException {
|
||||
String valueString = getValueString();
|
||||
private boolean isNaN(String valueString) {
|
||||
return (valueString != null) ? valueString.indexOf("nan") != -1 : false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
Refactoring: moved the 'isNaN', 'isPositiveInfinity' and 'isNegativeInfinity' to the 'CDebugUtils' class.
|
||||
* CDTDebugModelPresentation.java
|
||||
|
|
|
@ -590,11 +590,12 @@ public class CDTDebugModelPresentation extends LabelProvider
|
|||
}
|
||||
else if ( type != null && type.isFloatingPointType() )
|
||||
{
|
||||
if ( CDebugUtils.isNaN( (ICValue)value ) )
|
||||
Number floatingPointValue = CDebugUtils.getFloatingPointValue( (ICValue)value );
|
||||
if ( CDebugUtils.isNaN( floatingPointValue ) )
|
||||
valueString = "NAN";
|
||||
if ( CDebugUtils.isPositiveInfinity( (ICValue)value ) )
|
||||
if ( CDebugUtils.isPositiveInfinity( floatingPointValue ) )
|
||||
valueString = "Infinity";
|
||||
if ( CDebugUtils.isNegativeInfinity( (ICValue)value ) )
|
||||
if ( CDebugUtils.isNegativeInfinity( floatingPointValue ) )
|
||||
valueString = "-Infinity";
|
||||
label.append( "= " );
|
||||
label.append( valueString );
|
||||
|
|
Loading…
Add table
Reference in a new issue