diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index 6c94dc932cb..d671242c6e0 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -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 diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java index 83d128cd171..33aff2c3e82 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.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; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog index 45eecb360fd..d7ba0bf16c2 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog @@ -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. diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatingPointValue.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatingPointValue.java index e64b814ff49..47f68d02a69 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatingPointValue.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatingPointValue.java @@ -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; } } diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index a5e4cde993f..e967d15a083 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -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 diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java index 8a22a045145..ff2742d4605 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/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 );