Browse Source

PropertyVariable updated to new eval design. Variables can have 'magic' values and have OnValueChanged event.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@729 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
5d757b2ecb
  1. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
  2. 26
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs
  3. 73
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PropertyVariable.cs
  4. 25
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs
  5. 31
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableEventArgs.cs
  6. 38
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableMagicValue.cs

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj

@ -203,6 +203,8 @@ @@ -203,6 +203,8 @@
<Compile Include="Src\Interop\MetaData\COR_FIELD_OFFSET.cs" />
<Compile Include="Src\Variables\Evals\EvalEventArgs.cs" />
<Compile Include="Src\Variables\Evals\NDebugger-Evals.cs" />
<Compile Include="Src\Variables\VariableEventArgs.cs" />
<Compile Include="Src\Variables\VariableMagicValue.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="README.TXT" />

26
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs

@ -26,9 +26,11 @@ namespace Debugger @@ -26,9 +26,11 @@ namespace Debugger
ICorDebugFunction corFunction;
ICorDebugValue[] args;
bool evaluating = false;
bool completed = false;
Variable result;
public event EventHandler<EvalEventArgs> EvalStarted;
public event EventHandler<EvalEventArgs> EvalComplete;
/// <summary>
@ -40,6 +42,18 @@ namespace Debugger @@ -40,6 +42,18 @@ namespace Debugger
}
}
/// <summary>
/// True if the eval is being evaluated at the moment.
/// </summary>
public bool Evaluating {
get {
return evaluating;
}
set {
evaluating = value;
}
}
/// <summary>
/// The result of the evaluation if the evaluation is complete and has returned a value. Null otherwise.
/// </summary>
@ -76,11 +90,23 @@ namespace Debugger @@ -76,11 +90,23 @@ namespace Debugger
corEval.CallFunction(corFunction, (uint)args.Length, args);
evaluating = true;
OnEvalStarted(new EvalEventArgs(debugger, this));
return true;
}
protected virtual void OnEvalStarted(EvalEventArgs e)
{
if (EvalStarted != null) {
EvalStarted(this, e);
}
}
protected internal virtual void OnEvalComplete(EvalEventArgs e)
{
evaluating = false;
completed = true;
ICorDebugValue corValue;

73
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PropertyVariable.cs

@ -14,43 +14,62 @@ namespace Debugger @@ -14,43 +14,62 @@ namespace Debugger
public class PropertyVariable: Variable
{
Eval eval;
Variable currentValue;
public event EventHandler<DebuggerEventArgs> ValueEvaluated;
internal PropertyVariable(NDebugger debugger, Eval eval, string name):base(debugger, null, name)
{
this.eval = eval;
eval.EvalComplete += new EventHandler<EvalEventArgs>(EvalComplete);
eval.EvalStarted += EvalStarted;
eval.EvalComplete += EvalComplete;
}
public bool IsEvaluated {
get {
return currentValue != null;
return eval.Completed;
}
}
public override object Value {
public override object Value {
get {
if (!IsEvaluated) {
Evaluate();
if (IsEvaluated) {
if (eval.Result != null) {
return eval.Result.Value;
} else {
return null;
}
} else {
if (eval.Evaluating) {
return new VariableMagicValue("Evaluating...");
} else {
return new VariableMagicValue("Evaluation pending");
}
}
return currentValue.Value;
}
}
public override string Type {
get {
if (!IsEvaluated) {
Evaluate();
if (IsEvaluated) {
if (eval.Result != null) {
return eval.Result.Type;
} else {
return String.Empty;
}
} else {
return String.Empty;
}
return currentValue.Type;
}
}
public override bool MayHaveSubVariables {
get {
if (IsEvaluated) {
return currentValue.MayHaveSubVariables;
if (eval.Result != null) {
return eval.Result.MayHaveSubVariables;
} else {
return true;
}
} else {
return true;
}
@ -59,33 +78,29 @@ namespace Debugger @@ -59,33 +78,29 @@ namespace Debugger
protected override VariableCollection GetSubVariables()
{
if (!IsEvaluated) {
Evaluate();
if (IsEvaluated) {
if (eval.Result != null) {
return eval.Result.SubVariables;
} else {
return VariableCollection.Empty;
}
return currentValue.SubVariables;
}
/// <summary>
/// Executes evaluation of variable and doesn't return
/// until value is evaluated.
/// </summary>
public void Evaluate()
{
//eval.PerformEval();
} else {
return VariableCollection.Empty;
}
}
/// <summary>
/// Executes evaluation of variable and returns imideatly
/// </summary>
public void AsyncEvaluate()
void EvalStarted(object sender, EvalEventArgs args)
{
//eval.AsyncPerformEval();
OnValueChanged(new VariableEventArgs(debugger, this));
}
void EvalComplete(object sender, EvalEventArgs args)
{
currentValue = VariableFactory.CreateVariable(debugger, eval.Result.CorValue, Name);
if (eval.Result != null) {
eval.Result.Name = this.Name;
}
OnValueEvaluated();
OnValueChanged(new VariableEventArgs(debugger, this));
}
protected void OnValueEvaluated()

25
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// <file>
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
@ -15,19 +15,30 @@ namespace Debugger @@ -15,19 +15,30 @@ namespace Debugger
public abstract class Variable: RemotingObjectBase
{
protected NDebugger debugger;
readonly string name;
string name;
protected ICorDebugValue corValue;
VariableCollection subVariables;
CorElementType? corType;
public event EventHandler<VariableEventArgs> ValueChanged;
protected virtual void OnValueChanged(VariableEventArgs e)
{
if (ValueChanged != null) {
ValueChanged(this, e);
}
}
public string Name {
get{
return name;
}
}
set {
name = value;
}
}
internal ICorDebugValue CorValue {
get {
return corValue;

31
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableEventArgs.cs

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
namespace Debugger
{
[Serializable]
public class VariableEventArgs : DebuggerEventArgs
{
Variable variable;
public Variable Variable {
get {
return variable;
}
set {
variable = value;
}
}
public VariableEventArgs(NDebugger debugger, Variable variable): base(debugger)
{
this.variable = variable;
}
}
}

38
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableMagicValue.cs

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
namespace Debugger
{
/// <summary>
/// This value may be returned by Variable.Value instead of null to provide some additional information.
/// </summary>
public class VariableMagicValue
{
object @value;
public object Value {
get {
return @value;
}
set {
this.@value = value;
}
}
public VariableMagicValue(object @value)
{
this.@value = @value;
}
public override string ToString()
{
return @value.ToString();
}
}
}
Loading…
Cancel
Save