Browse Source

Refactored some long anonymous methods

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1270 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
436025b78c
  1. 23
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs
  2. 7
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ArrayValue.cs
  3. 43
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValue.cs
  4. 7
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PropertyVariable.cs

23
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs

@ -412,28 +412,26 @@ namespace Debugger @@ -412,28 +412,26 @@ namespace Debugger
}
}
internal ICorDebugValue GetArgumentValue(int index)
{
// Non-static functions include 'this' as first argument
return CorILFrame.GetArgument((uint)(IsStatic? index : (index + 1)));
}
public Variable GetArgumentVariable(int index)
{
return new Variable(debugger,
GetParameterName(index),
delegate {
delegate { return GetArgumentValue(index); });
}
Value GetArgumentValue(int index)
{
if (this.HasExpired) {
return new UnavailableValue(debugger, "Function has expired");
} else {
try {
return Value.CreateValue(debugger, GetArgumentValue(index));
// Non-static functions include 'this' as first argument
return Value.CreateValue(debugger, CorILFrame.GetArgument((uint)(IsStatic? index : (index + 1))));
} catch (COMException e) {
if ((uint)e.ErrorCode == 0x80131304) return new UnavailableValue(debugger, "Unavailable in optimized code");
throw;
}
}
});
}
public IEnumerable<Variable> ArgumentVariables {
@ -473,7 +471,11 @@ namespace Debugger @@ -473,7 +471,11 @@ namespace Debugger
{
return new Variable(debugger,
symVar.Name,
delegate {
delegate { return GetValueOfLocalVariable(symVar); });
}
Value GetValueOfLocalVariable(ISymUnmanagedVariable symVar)
{
if (this.HasExpired) {
return new UnavailableValue(debugger, "Function has expired");
} else {
@ -486,7 +488,6 @@ namespace Debugger @@ -486,7 +488,6 @@ namespace Debugger
}
return Value.CreateValue(debugger, corValue);
}
});
}
}
}

7
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ArrayValue.cs

@ -106,7 +106,11 @@ namespace Debugger @@ -106,7 +106,11 @@ namespace Debugger
return new Variable(debugger,
elementName,
delegate {
delegate { return GetValueOfItem(indices, getter); });
}
Value GetValueOfItem(uint[] indices, ValueGetter getter)
{
ArrayValue updatedVal = getter() as ArrayValue;
if (this.IsEquivalentValue(updatedVal)) {
ICorDebugValue element;
@ -119,7 +123,6 @@ namespace Debugger @@ -119,7 +123,6 @@ namespace Debugger
} else {
return new UnavailableValue(debugger, "Value is not array");
}
});
}
public override bool MayHaveSubVariables {

43
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectValue.cs

@ -146,7 +146,12 @@ namespace Debugger @@ -146,7 +146,12 @@ namespace Debugger
field.Name,
field.IsStatic,
field.IsPublic,
delegate {
delegate { return GetValueOfField(field, getter); });
}
}
Value GetValueOfField(FieldProps field, ValueGetter getter)
{
Value updatedVal = getter();
if (updatedVal is UnavailableValue) return updatedVal;
if (this.IsEquivalentValue(updatedVal)) {
@ -154,8 +159,6 @@ namespace Debugger @@ -154,8 +159,6 @@ namespace Debugger
} else {
return new UnavailableValue(debugger, "Object type changed");
}
});
}
}
public IEnumerable<Variable> GetPropertyVariables(ValueGetter getter)
@ -167,24 +170,26 @@ namespace Debugger @@ -167,24 +170,26 @@ namespace Debugger
method.Name.Remove(0, 4),
method.IsStatic,
method.IsPublic,
delegate {
delegate { return CreatePropertyEval(method, getter); });
}
}
}
Eval CreatePropertyEval(MethodProps method, ValueGetter getter)
{
Value updatedVal = getter();
if (updatedVal is UnavailableValue) return null;
if (this.IsEquivalentValue(updatedVal) && ((ObjectValue)updatedVal).SoftReference != null) {
return CreatePropertyEval(method, getter);
ICorDebugFunction evalCorFunction = Module.CorModule.GetFunctionFromToken(method.Token);
return new Eval(debugger, evalCorFunction, delegate { return GetArgsForEval(method, getter); });
} else {
return null;
}
});
}
}
}
Eval CreatePropertyEval(MethodProps method, ValueGetter getter)
ICorDebugValue[] GetArgsForEval(MethodProps method, ValueGetter getter)
{
ICorDebugFunction evalCorFunction = Module.CorModule.GetFunctionFromToken(method.Token);
return new Eval(debugger, evalCorFunction, delegate {
Value updatedVal = getter();
if (this.IsEquivalentValue(updatedVal) && ((ObjectValue)updatedVal).SoftReference != null) {
if (method.IsStatic) {
@ -195,7 +200,6 @@ namespace Debugger @@ -195,7 +200,6 @@ namespace Debugger
} else {
return null;
}
});
}
public override bool IsEquivalentValue(Value val)
@ -231,7 +235,14 @@ namespace Debugger @@ -231,7 +235,14 @@ namespace Debugger
if (HasBaseClass) {
return new Variable(debugger,
"<Base class>",
delegate {
delegate { return GetBaseClassValue(getter); });
} else {
return null;
}
}
Value GetBaseClassValue(ValueGetter getter)
{
Value updatedVal = getter();
if (updatedVal is UnavailableValue) return updatedVal;
if (this.IsEquivalentValue(updatedVal)) {
@ -239,10 +250,6 @@ namespace Debugger @@ -239,10 +250,6 @@ namespace Debugger
} else {
return new UnavailableValue(debugger, "Object type changed");
}
});
} else {
return null;
}
}
public unsafe ObjectValue BaseClass {

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

@ -24,13 +24,16 @@ namespace Debugger @@ -24,13 +24,16 @@ namespace Debugger
internal PropertyVariable(NDebugger debugger, string name, bool isStatic, bool isPublic, EvalCreator evalCreator):base(debugger, name, isStatic, isPublic, null)
{
this.evalCreator = evalCreator;
this.valueGetter = delegate {
this.valueGetter = delegate { return GetValueOfResult(); };
}
Value GetValueOfResult()
{
if (Eval != null) {
return Eval.Result;
} else {
return new UnavailableValue(debugger, "Property has expired");
}
};
}
public bool IsEvaluated {

Loading…
Cancel
Save