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. 71
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PropertyVariable.cs
  4. 15
      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 @@
<Compile Include="Src\Interop\MetaData\COR_FIELD_OFFSET.cs" /> <Compile Include="Src\Interop\MetaData\COR_FIELD_OFFSET.cs" />
<Compile Include="Src\Variables\Evals\EvalEventArgs.cs" /> <Compile Include="Src\Variables\Evals\EvalEventArgs.cs" />
<Compile Include="Src\Variables\Evals\NDebugger-Evals.cs" /> <Compile Include="Src\Variables\Evals\NDebugger-Evals.cs" />
<Compile Include="Src\Variables\VariableEventArgs.cs" />
<Compile Include="Src\Variables\VariableMagicValue.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="README.TXT" /> <Content Include="README.TXT" />

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

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

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

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

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

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

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

@ -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 @@
// <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