diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index 42cb51de293..7c49f62865b 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,9 @@ +2003-06-05 Mikhail Khodjaiants + Removed the redundant methods from the 'ICDIFloatingPointValue' interface. + * ICDIFloatingPointValue.java + * CValue.java + * CVariable.java + 2003-06-04 Mikhail Khodjaiants Implementing the core support of the detail panel. * ICValue.java diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/type/ICDIFloatingPointValue.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/type/ICDIFloatingPointValue.java index fbdd0d3d5e0..52e5980dea1 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/type/ICDIFloatingPointValue.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/cdi/model/type/ICDIFloatingPointValue.java @@ -20,10 +20,4 @@ public interface ICDIFloatingPointValue extends ICDIValue { float floatValue() throws CDIException; double doubleValue() throws CDIException; - - long longValue() throws CDIException; - - boolean isNaN(); - - boolean isInfinite(); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java index cf159790a79..5d811dfcfb0 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java @@ -417,10 +417,11 @@ public class CValue extends CDebugElement implements ICValue private String getFloatValueString( ICDIFloatValue value ) throws CDIException { - if ( value.isNaN() ) - return ""; float floatValue = value.floatValue(); - long longValue = value.longValue(); + Float flt = new Float( floatValue ); + if ( flt.isNaN() || flt.isInfinite() ) + return ""; + long longValue = flt.longValue(); switch( getParentVariable().getFormat() ) { case ICDIFormat.NATURAL: @@ -440,14 +441,15 @@ public class CValue extends CDebugElement implements ICValue private String getDoubleValueString( ICDIDoubleValue value ) throws CDIException { - if ( value.isNaN() ) - return ""; double doubleValue = value.doubleValue(); - long longValue = value.longValue(); + Double dbl = new Double( doubleValue ); + if ( dbl.isNaN() || dbl.isInfinite() ) + return ""; + long longValue = dbl.longValue(); switch( getParentVariable().getFormat() ) { case ICDIFormat.NATURAL: - return Double.toString( doubleValue ); + return dbl.toString(); case ICDIFormat.DECIMAL: return Long.toString( longValue ); case ICDIFormat.HEXADECIMAL: diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java index d3a854461fd..c21c5fac127 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java @@ -20,8 +20,9 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayType; import org.eclipse.cdt.debug.core.cdi.model.type.ICDICharType; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIDerivedType; +import org.eclipse.cdt.debug.core.cdi.model.type.ICDIDoubleValue; +import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatValue; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatingPointType; -import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatingPointValue; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIPointerType; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIStructType; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType; @@ -676,8 +677,15 @@ public abstract class CVariable extends CDebugElement { try { - return ( getCDIVariable().getValue() instanceof ICDIFloatingPointValue ) ? - ((ICDIFloatingPointValue)getCDIVariable().getValue()).isNaN() : false; + ICDIValue value = getCDIVariable().getValue(); + if ( value instanceof ICDIDoubleValue ) + { + return Double.isNaN( ((ICDIDoubleValue)value).doubleValue() ); + } + if ( value instanceof ICDIFloatValue ) + { + return Float.isNaN( ((ICDIFloatValue)value).floatValue() ); + } } catch( CDIException e ) { diff --git a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog index d98b6cb05e8..2cf2eb71e39 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog @@ -1,3 +1,7 @@ +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 + 2003-06-04 Mikhail Khodjaiants Correction in the parsing of reference value. * src/org/eclipse/cdt/debug/mi/core/cdi/model/type/ReferenceValue.java 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 d457a31a802..9ebcd950b73 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,10 +26,14 @@ public abstract class FloatingPointValue extends Value implements ICDIFloatingPo */ public double doubleValue() throws CDIException { double result = 0; - try { - result = Double.parseDouble( getValueString() ); - } - catch (NumberFormatException e) { + if ( isNaN() ) + result = Double.NaN; + else { + try { + result = Double.parseDouble( getValueString() ); + } + catch (NumberFormatException e) { + } } return result; } @@ -39,40 +43,20 @@ public abstract class FloatingPointValue extends Value implements ICDIFloatingPo */ public float floatValue() throws CDIException { float result = 0; - try { - result = Float.parseFloat( getValueString() ); - } - catch (NumberFormatException e) { + if ( isNaN() ) + result = Float.NaN; + else { + try { + result = Float.parseFloat( getValueString() ); + } + catch (NumberFormatException e) { + } } return result; } - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatingPointValue#longValue() - */ - public long longValue() throws CDIException { - Double dbl = new Double( doubleValue() ); - return dbl.longValue(); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatingPointValue#isInfinite() - */ - public boolean isInfinite() { - // TODO Auto-generated method stub - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatingPointValue#isNaN() - */ - public boolean isNaN() { - String valueString = null; - try { - valueString = getValueString(); - } - catch (CDIException e) { - } + private boolean isNaN() throws CDIException { + String valueString = getValueString(); return ( valueString != null ) ? valueString.indexOf( "nan" ) != -1 : false; } }