1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-02 05:45:58 +02:00

Cache the 'hasVariables' flag for global values and the type names for all variables.

This commit is contained in:
Mikhail Khodjaiants 2002-10-02 19:25:14 +00:00
parent 38953a8a19
commit 8f3469b849
6 changed files with 102 additions and 16 deletions

View file

@ -0,0 +1,38 @@
package org.eclipse.cdt.debug.internal.core.model;
import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
import org.eclipse.debug.core.DebugException;
/**
*
* Enter type comment.
*
* @since: Oct 2, 2002
*/
public class CGlobalValue extends CValue
{
private Boolean fHasChildren = null;
/**
* Constructor for CGlobalValue.
* @param parent
* @param cdiValue
*/
public CGlobalValue( CVariable parent, ICDIValue cdiValue )
{
super( parent, cdiValue );
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IValue#hasVariables()
*/
public boolean hasVariables() throws DebugException
{
if ( fHasChildren == null )
{
fHasChildren = new Boolean( super.hasVariables() );
}
return fHasChildren.booleanValue();
}
}

View file

@ -0,0 +1,39 @@
package org.eclipse.cdt.debug.internal.core.model;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IValue;
/**
*
* Enter type comment.
*
* @since: Oct 2, 2002
*/
public class CGlobalVariable extends CModificationVariable
{
/**
* Constructor for CGlobalVariable.
* @param parent
* @param cdiVariable
*/
public CGlobalVariable( CDebugElement parent, ICDIVariable cdiVariable )
{
super( parent, cdiVariable );
}
/**
* Returns the current value of this variable. The value
* is cached.
*
* @see org.eclipse.debug.core.model.IVariable#getValue()
*/
public IValue getValue() throws DebugException
{
if ( fValue == null )
{
fValue = CValueFactory.createGlobalValue( this, getCurrentValue() );
}
return fValue;
}
}

View file

@ -6,7 +6,6 @@
package org.eclipse.cdt.debug.internal.core.model; package org.eclipse.cdt.debug.internal.core.model;
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegister; import org.eclipse.cdt.debug.core.cdi.model.ICDIRegister;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IRegister; import org.eclipse.debug.core.model.IRegister;
import org.eclipse.debug.core.model.IRegisterGroup; import org.eclipse.debug.core.model.IRegisterGroup;
@ -17,7 +16,7 @@ import org.eclipse.debug.core.model.IRegisterGroup;
* *
* @since Sep 16, 2002 * @since Sep 16, 2002
*/ */
public class CRegister extends CModificationVariable implements IRegister public class CRegister extends CGlobalVariable implements IRegister
{ {
/** /**
* Constructor for CRegister. * Constructor for CRegister.

View file

@ -6,7 +6,6 @@
package org.eclipse.cdt.debug.internal.core.model; package org.eclipse.cdt.debug.internal.core.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -84,11 +83,13 @@ public class CRegisterGroup extends CDebugElement implements IRegisterGroup
fRegisters.add( new CRegister( this, regs[i] ) ); fRegisters.add( new CRegister( this, regs[i] ) );
} }
} }
/*
else if ( fRefresh ) else if ( fRefresh )
{ {
updateRegisters(); updateRegisters();
} }
fRefresh = false; fRefresh = false;
*/
return fRegisters; return fRegisters;
} }

View file

@ -22,4 +22,9 @@ public class CValueFactory
{ {
return new CValue( parent, cdiValue ); return new CValue( parent, cdiValue );
} }
static public ICValue createGlobalValue( CVariable parent, ICDIValue cdiValue ) throws DebugException
{
return new CGlobalValue( parent, cdiValue );
}
} }

View file

@ -5,8 +5,6 @@
*/ */
package org.eclipse.cdt.debug.internal.core.model; package org.eclipse.cdt.debug.internal.core.model;
import java.text.MessageFormat;
import org.eclipse.cdt.debug.core.ICValue; import org.eclipse.cdt.debug.core.ICValue;
import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.event.ICDIChangedEvent; import org.eclipse.cdt.debug.core.cdi.event.ICDIChangedEvent;
@ -44,7 +42,7 @@ public abstract class CVariable extends CDebugElement
/** /**
* Cache of current value - see #getValue(). * Cache of current value - see #getValue().
*/ */
private ICValue fValue; protected ICValue fValue;
/** /**
* Counter corresponding to this variable's debug target * Counter corresponding to this variable's debug target
@ -60,6 +58,11 @@ public abstract class CVariable extends CDebugElement
*/ */
private boolean fChanged = false; private boolean fChanged = false;
/**
* The type name of this variable.
*/
private String fTypeName = null;
/** /**
* Constructor for CVariable. * Constructor for CVariable.
* @param target * @param target
@ -81,10 +84,9 @@ public abstract class CVariable extends CDebugElement
*/ */
public IValue getValue() throws DebugException public IValue getValue() throws DebugException
{ {
ICDIValue currentValue = getCurrentValue();
if ( fValue == null ) if ( fValue == null )
{ {
fValue = CValueFactory.createValue( this, currentValue ); fValue = CValueFactory.createValue( this, getCurrentValue() );
} }
return fValue; return fValue;
} }
@ -321,16 +323,18 @@ public abstract class CVariable extends CDebugElement
*/ */
public String getReferenceTypeName() throws DebugException public String getReferenceTypeName() throws DebugException
{ {
String type = null; if ( fTypeName == null )
{
try try
{ {
type = getCDIVariable().getTypeName(); fTypeName = getCDIVariable().getTypeName();
} }
catch( CDIException e ) catch( CDIException e )
{ {
targetRequestFailed( e.getMessage(), null ); targetRequestFailed( e.getMessage(), null );
} }
return type; }
return fTypeName;
} }
protected void updateParentVariable( CValue parentValue ) throws DebugException protected void updateParentVariable( CValue parentValue ) throws DebugException