From 184af2410d63d1b69f991a3e0874854f4b9b9bf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Srbeck=C3=BD?= Date: Fri, 11 Jan 2008 19:13:59 +0000 Subject: [PATCH] Custom Abstract Syntax Tree for debugger expression independent of NRefactory. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2815 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/Service/WindowsDebugger.cs | 1 + .../Project/Src/TreeModel/ArrayRangeNode.cs | 1 + .../Src/TreeModel/ChildNodesOfObject.cs | 1 + .../Project/Src/TreeModel/ExpressionNode.cs | 1 + .../Project/Src/TreeModel/StackFrameNode.cs | 1 + .../Project/Debugger.Core.csproj | 14 +- .../Ast/FieldReferenceExpression.cs | 36 -- .../Expressions/Ast/IndexerExpression.cs | 72 +++ .../Ast/LocalVariableIdentifierExpression.cs | 27 +- .../Ast/MemberReferenceExpression.cs | 102 ++++ .../Ast/ParameterIdentifierExpression.cs | 41 +- .../Expressions/Ast/PrimitiveExpression.cs | 40 ++ .../Ast/PropertyReferenceExpression.cs | 36 -- .../Ast/ThisReferenceExpression.cs | 28 + .../Expressions/EvaluateAstVisitor.cs | 83 --- .../Expressions/Expression.Create.cs | 30 +- .../Expressions/Expression.Evaluate.cs | 30 - .../Src/Variables/Expressions/Expression.cs | 60 +- .../Expressions/ExpressionCollection.cs | 7 +- .../ExpressionEvaluateException.cs | 37 ++ .../Expressions/NotImplementedAstVisitor.cs | 575 ------------------ .../Src/Variables/Values/Value.Object.cs | 18 + 22 files changed, 384 insertions(+), 857 deletions(-) delete mode 100644 src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/FieldReferenceExpression.cs create mode 100644 src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/IndexerExpression.cs create mode 100644 src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/MemberReferenceExpression.cs create mode 100644 src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/PrimitiveExpression.cs delete mode 100644 src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/PropertyReferenceExpression.cs create mode 100644 src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/ThisReferenceExpression.cs delete mode 100644 src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/EvaluateAstVisitor.cs delete mode 100644 src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.Evaluate.cs create mode 100644 src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/ExpressionEvaluateException.cs delete mode 100644 src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/NotImplementedAstVisitor.cs diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs index 7093bc908c..a8eeab9528 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs @@ -42,6 +42,7 @@ using System.Diagnostics; using System.Windows.Forms; using Debugger; +using Debugger.Expressions; using Debugger.AddIn.TreeModel; using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Gui; diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ArrayRangeNode.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ArrayRangeNode.cs index b28b10cf41..575c98c755 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ArrayRangeNode.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ArrayRangeNode.cs @@ -11,6 +11,7 @@ using System.Collections.Generic; using ICSharpCode.Core; using Debugger; +using Debugger.Expressions; namespace Debugger.AddIn.TreeModel { diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ChildNodesOfObject.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ChildNodesOfObject.cs index 44c3d91976..9378b5a0be 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ChildNodesOfObject.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ChildNodesOfObject.cs @@ -11,6 +11,7 @@ using System.Collections.Generic; using ICSharpCode.Core; using Debugger; +using Debugger.Expressions; namespace Debugger.AddIn.TreeModel { diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ExpressionNode.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ExpressionNode.cs index f994ed7b2d..95d2c76e9f 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ExpressionNode.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ExpressionNode.cs @@ -14,6 +14,7 @@ using ICSharpCode.SharpDevelop.Debugging; using ICSharpCode.SharpDevelop.Services; using Debugger; +using Debugger.Expressions; namespace Debugger.AddIn.TreeModel { diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/StackFrameNode.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/StackFrameNode.cs index 400d80f986..04c228be71 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/StackFrameNode.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/StackFrameNode.cs @@ -9,6 +9,7 @@ using System.Collections; using System.Collections.Generic; using Debugger; +using Debugger.Expressions; namespace Debugger.AddIn.TreeModel { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj index fb18b90013..fbe0a3cc83 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj @@ -217,16 +217,16 @@ - + + - - + + - - + @@ -414,10 +414,6 @@ - - {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195} - NRefactory - \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/FieldReferenceExpression.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/FieldReferenceExpression.cs deleted file mode 100644 index 126a0f3652..0000000000 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/FieldReferenceExpression.cs +++ /dev/null @@ -1,36 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Collections.Generic; - -using Debugger; - -namespace ICSharpCode.NRefactory.Ast -{ - /// - /// Reference to a class field - /// - public class FieldReferenceExpression: MemberReferenceExpression - { - FieldInfo fieldInfo; - - public FieldInfo FieldInfo { - get { return fieldInfo; } - } - - public FieldReferenceExpression(Expression targetObject, FieldInfo fieldInfo) - :base (targetObject, fieldInfo.Name) - { - this.fieldInfo = fieldInfo; - } - - public override string ToString() { - return string.Format("[FieldReferenceExpression TargetObject={0} FieldName={1} TypeArguments={2}]", TargetObject, FieldName, GetCollectionString(TypeArguments)); - } - } -} diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/IndexerExpression.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/IndexerExpression.cs new file mode 100644 index 0000000000..a26d5740f0 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/IndexerExpression.cs @@ -0,0 +1,72 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Text; +using System.Collections.Generic; + +namespace Debugger.Expressions +{ + public class IndexerExpression: Expression + { + Expression targetObject; + Expression[] arguments; + + public Expression TargetObject { + get { return targetObject; } + } + + public Expression[] Arguments { + get { return arguments; } + } + + public IndexerExpression(Expression targetObject, Expression[] arguments) + { + this.targetObject = targetObject; + this.arguments = arguments; + } + + public override string Code { + get { + StringBuilder sb = new StringBuilder(); + sb.Append(targetObject.Code); + sb.Append("["); + bool isFirst = true; + foreach(Expression argument in arguments) { + if (isFirst) { + isFirst = false; + } else { + sb.Append(", "); + } + sb.Append(argument.Code); + } + sb.Append("]"); + return sb.ToString(); + } + } + + protected override Value EvaluateInternal(StackFrame context) + { + Value targetValue = targetObject.Evaluate(context); + List indicies = new List(); + foreach(Expression argument in arguments) { + if (argument is PrimitiveExpression) { + PrimitiveExpression primitiveExpression = (PrimitiveExpression)argument; + if (primitiveExpression.Value is int) { + indicies.Add((int)primitiveExpression.Value); + } + } + throw new ExpressionEvaluateException(this, "Integer index expected"); + } + try { + return targetValue.GetArrayElement(indicies.ToArray()); + } catch (CannotGetValueException e) { + throw new ExpressionEvaluateException(this, e.Message); + } + } + } +} diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/LocalVariableIdentifierExpression.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/LocalVariableIdentifierExpression.cs index 7f6280e194..bb899732a7 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/LocalVariableIdentifierExpression.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/LocalVariableIdentifierExpression.cs @@ -10,27 +10,42 @@ using System.Collections.Generic; using Debugger.Wrappers.CorSym; -namespace ICSharpCode.NRefactory.Ast +namespace Debugger.Expressions { /// /// Identifier of a local variable /// - public class LocalVariableIdentifierExpression: IdentifierExpression + public class LocalVariableIdentifierExpression: Expression { + MethodInfo method; ISymUnmanagedVariable symVar; + public MethodInfo Method { + get { return method; } + } + public ISymUnmanagedVariable SymVar { get { return symVar; } } - public LocalVariableIdentifierExpression(ISymUnmanagedVariable symVar) - :base (symVar.Name) + public LocalVariableIdentifierExpression(MethodInfo method, ISymUnmanagedVariable symVar) { + this.method = method; this.symVar = symVar; } - public override string ToString() { - return string.Format("[LocalVariableIdentifierExpression Identifier={0} TypeArguments={1}]", Identifier, GetCollectionString(TypeArguments)); + public override string Code { + get { + return this.SymVar.Name; + } + } + + protected override Value EvaluateInternal(StackFrame context) + { + if (context.MethodInfo != this.Method) { + throw new ExpressionEvaluateException(this, "Method " + this.Method.FullName + " expected, " + context.MethodInfo.FullName + " seen"); + } + return context.GetLocalVariableValue(this.SymVar); } } } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/MemberReferenceExpression.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/MemberReferenceExpression.cs new file mode 100644 index 0000000000..490ddc458a --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/MemberReferenceExpression.cs @@ -0,0 +1,102 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using System.Text; + +namespace Debugger.Expressions +{ + public class MemberReferenceExpression: Expression + { + Expression targetObject; + MemberInfo memberInfo; + Expression[] arguments; + + public Expression TargetObject { + get { return targetObject; } + } + + public MemberInfo MemberInfo { + get { return memberInfo; } + } + + public Expression[] Arguments { + get { return arguments; } + } + + public MemberReferenceExpression(Expression targetObject, MemberInfo memberInfo) + :this(targetObject, memberInfo, new Expression[0]) + { + } + + public MemberReferenceExpression(Expression targetObject, MemberInfo memberInfo, Expression[] arguments) + { + this.targetObject = targetObject; + this.memberInfo = memberInfo; + this.arguments = arguments; + } + + public override string Code { + get { + StringBuilder sb = new StringBuilder(); + if (targetObject != null) { + sb.Append(targetObject.Code); + } else { + sb.Append(memberInfo.DeclaringType.FullName); + } + sb.Append("."); + sb.Append(memberInfo.Name); + if (memberInfo is MethodInfo) { + sb.Append("("); + bool isFirst = true; + foreach(Expression argument in arguments) { + if (isFirst) { + isFirst = false; + } else { + sb.Append(", "); + } + sb.Append(argument.Code); + } + sb.Append(")"); + } + return sb.ToString(); + } + } + + protected override Value EvaluateInternal(StackFrame context) + { + if (memberInfo.IsStatic) { + if (targetObject != null) { + throw new ExpressionEvaluateException(this, "Target not expected for static member"); + } + } else { + if (targetObject == null) { + throw new ExpressionEvaluateException(this, "Target expected for instance member"); + } + } + List argumentValues = new List(); + foreach(Expression argument in arguments) { + argumentValues.Add(argument.Evaluate(context)); + } + if (memberInfo.IsStatic) { + try { + return Value.GetMemberValue(null, memberInfo, argumentValues.ToArray()); + } catch (CannotGetValueException e) { + throw new ExpressionEvaluateException(this, e.Message); + } + } else { + Value targetValue = targetObject.Evaluate(context); + try { + return targetValue.GetMemberValue(memberInfo, argumentValues.ToArray()); + } catch (CannotGetValueException e) { + throw new ExpressionEvaluateException(this, e.Message); + } + } + } + } +} diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/ParameterIdentifierExpression.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/ParameterIdentifierExpression.cs index 70f403ae69..7313465059 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/ParameterIdentifierExpression.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/ParameterIdentifierExpression.cs @@ -8,27 +8,48 @@ using System; using System.Collections.Generic; -namespace ICSharpCode.NRefactory.Ast +namespace Debugger.Expressions { /// /// Identifier of a method parameter /// - public class ParameterIdentifierExpression: IdentifierExpression + public class ParameterIdentifierExpression: Expression { - int parameterIndex; + MethodInfo method; + int index; + string name; - public int ParameterIndex { - get { return parameterIndex; } + public MethodInfo Method { + get { return method; } } - public ParameterIdentifierExpression(int parameterIndex, string identifier) - :base (identifier) + public int Index { + get { return index; } + } + + public string Name { + get { return name; } + } + + public ParameterIdentifierExpression(MethodInfo method, int index, string name) { - this.parameterIndex = parameterIndex; + this.method = method; + this.index = index; + this.name = name; } - public override string ToString() { - return string.Format("[ParameterIdentifierExpression Index={0} Identifier={1} TypeArguments={2}]", ParameterIndex, Identifier, GetCollectionString(TypeArguments)); + public override string Code { + get { + return this.Name; + } + } + + protected override Value EvaluateInternal(StackFrame context) + { + if (context.MethodInfo != this.Method) { + throw new ExpressionEvaluateException(this, "Method " + this.Method.FullName + " expected, " + context.MethodInfo.FullName + " seen"); + } + return context.GetArgument(this.Index); } } } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/PrimitiveExpression.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/PrimitiveExpression.cs new file mode 100644 index 0000000000..412e397ac6 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/PrimitiveExpression.cs @@ -0,0 +1,40 @@ +// +// +// +// +// $Revision$ +// + +using System; + +namespace Debugger.Expressions +{ + public class PrimitiveExpression: Expression + { + object value; + + public object Value { + get { return value; } + } + + public PrimitiveExpression(object value) + { + this.value = value; + } + + public override string Code { + get { + if (value == null) { + return "null"; + } else { + return value.ToString(); + } + } + } + + protected override Value EvaluateInternal(StackFrame context) + { + throw new ExpressionEvaluateException(this, "Primitive value can not be evaluated"); + } + } +} diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/PropertyReferenceExpression.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/PropertyReferenceExpression.cs deleted file mode 100644 index abf5adf3f8..0000000000 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/PropertyReferenceExpression.cs +++ /dev/null @@ -1,36 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Collections.Generic; - -using Debugger; - -namespace ICSharpCode.NRefactory.Ast -{ - /// - /// Reference to a class property - /// - public class PropertyReferenceExpression: MemberReferenceExpression - { - PropertyInfo propertyInfo; - - public PropertyInfo PropertyInfo { - get { return propertyInfo; } - } - - public PropertyReferenceExpression(Expression targetObject, PropertyInfo propertyInfo) - :base (targetObject, propertyInfo.Name) - { - this.propertyInfo = propertyInfo; - } - - public override string ToString() { - return string.Format("[PropertyReferenceExpression TargetObject={0} FieldName={1} TypeArguments={2}]", TargetObject, FieldName, GetCollectionString(TypeArguments)); - } - } -} diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/ThisReferenceExpression.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/ThisReferenceExpression.cs new file mode 100644 index 0000000000..b4b04127c2 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/ThisReferenceExpression.cs @@ -0,0 +1,28 @@ +// +// +// +// +// $Revision$ +// + +using System; + +namespace Debugger.Expressions +{ + public class ThisReferenceExpression: Expression + { + public override string Code { + get { + return "this"; + } + } + + protected override Value EvaluateInternal(StackFrame context) + { + if (context.MethodInfo.IsStatic) { + throw new ExpressionEvaluateException(this, "'this' is not valid in static method"); + } + return context.ThisValue; + } + } +} diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/EvaluateAstVisitor.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/EvaluateAstVisitor.cs deleted file mode 100644 index be74fbd303..0000000000 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/EvaluateAstVisitor.cs +++ /dev/null @@ -1,83 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Collections.Generic; - -using ICSharpCode.NRefactory; -using ICSharpCode.NRefactory.PrettyPrinter; -using ICSharpCode.NRefactory.Ast; -using Ast = ICSharpCode.NRefactory.Ast; -using Debugger.Wrappers.CorSym; - -namespace Debugger -{ - class EvaluateAstVisitor: NotImplementedAstVisitor - { - StackFrame stackFrame; - - public StackFrame StackFrame { - get { return stackFrame; } - } - - public EvaluateAstVisitor(StackFrame stackFrame) - { - this.stackFrame = stackFrame; - } - - public override object VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, object data) - { - return this.StackFrame.ThisValue; - } - - public override object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data) - { - if (identifierExpression is LocalVariableIdentifierExpression) { - LocalVariableIdentifierExpression localVariableIdentifierExpression = (LocalVariableIdentifierExpression)identifierExpression; - return this.StackFrame.GetLocalVariableValue(localVariableIdentifierExpression.SymVar); - } else if (identifierExpression is ParameterIdentifierExpression) { - ParameterIdentifierExpression parameterIdentifierExpression = (ParameterIdentifierExpression)identifierExpression; - return this.StackFrame.GetArgument(parameterIdentifierExpression.ParameterIndex); - } else { - return this.StackFrame.GetValue(identifierExpression.Identifier); - } - } - - public override object VisitIndexerExpression(IndexerExpression indexerExpression, object data) - { - Value target = (Value)indexerExpression.TargetObject.AcceptVisitor(this, data); - List indexes = new List(); - foreach(Ast.Expression indexExpr in indexerExpression.Indexes) { - if (indexExpr is PrimitiveExpression) { - PrimitiveExpression primitiveExpression = (PrimitiveExpression)indexExpr; - indexes.Add(int.Parse(primitiveExpression.StringValue)); - } else { - Value indexValue = (Value)indexExpr.AcceptVisitor(this, data); - if (!indexValue.IsInteger) { - throw new DebuggerException("Integer expected"); - } - indexes.Add((int)indexValue.PrimitiveValue); - } - } - return target.GetArrayElement(indexes.ToArray()); - } - - public override object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data) - { - Value target = (Value)memberReferenceExpression.TargetObject.AcceptVisitor(this, data); - if (memberReferenceExpression is FieldReferenceExpression) { - FieldReferenceExpression fieldReferenceExpression = (FieldReferenceExpression)memberReferenceExpression; - return target.GetFieldValue(fieldReferenceExpression.FieldInfo); - } else if (memberReferenceExpression is PropertyReferenceExpression) { - PropertyReferenceExpression propertyReferenceExpression = (PropertyReferenceExpression)memberReferenceExpression; - return target.GetPropertyValue(propertyReferenceExpression.PropertyInfo); - } else { - return target.GetMember(memberReferenceExpression.FieldName); - } - } - } -} diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.Create.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.Create.cs index 27da94adb9..dd11e9d6cf 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.Create.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.Create.cs @@ -8,25 +8,19 @@ using System; using System.Collections.Generic; -using ICSharpCode.NRefactory; -using ICSharpCode.NRefactory.PrettyPrinter; -using Ast = ICSharpCode.NRefactory.Ast; using Debugger.Wrappers.CorSym; -namespace Debugger +namespace Debugger.Expressions { public partial class Expression: DebuggerObject { public Expression AppendIndexer(params int[] indices) { - List indicesAst = new List(); + List indicesAst = new List(); foreach(int indice in indices) { - indicesAst.Add(new Ast.PrimitiveExpression(indice, indice.ToString())); + indicesAst.Add(new PrimitiveExpression(indice)); } - return new Ast.IndexerExpression( - this.AbstractSynatxTree, - indicesAst - ); + return new IndexerExpression(this, indicesAst.ToArray()); } public ExpressionCollection AppendIndexers(ArrayDimensions dimensions) @@ -40,18 +34,12 @@ namespace Debugger public Expression AppendFieldReference(FieldInfo fieldInfo) { - return new Ast.FieldReferenceExpression( - this.AbstractSynatxTree, - fieldInfo - ); + return new MemberReferenceExpression(this, fieldInfo); } public Expression AppendPropertyReference(PropertyInfo propertyInfo) { - return new Ast.PropertyReferenceExpression( - this.AbstractSynatxTree, - propertyInfo - ); + return new MemberReferenceExpression(this, propertyInfo); } public ExpressionCollection AppendObjectMembers(DebugType type, BindingFlags bindingFlags) @@ -87,7 +75,7 @@ namespace Debugger { if (methodInfo.IsStatic) throw new DebuggerException(methodInfo.FullName + " is static method"); - return new Ast.ThisReferenceExpression(); + return new ThisReferenceExpression(); } /// Get parameters of a method @@ -96,7 +84,7 @@ namespace Debugger ExpressionCollection pars = new ExpressionCollection(); for(int i = 0; i < methodInfo.ParameterCount; i++) { - pars.Add(new Ast.ParameterIdentifierExpression(i, methodInfo.GetParameterName(i))); + pars.Add(new ParameterIdentifierExpression(methodInfo, i, methodInfo.GetParameterName(i))); } return pars; @@ -108,7 +96,7 @@ namespace Debugger ExpressionCollection vars = new ExpressionCollection(); foreach(ISymUnmanagedVariable var in methodInfo.LocalVariables) { - vars.Add(new Ast.LocalVariableIdentifierExpression(var)); + vars.Add(new LocalVariableIdentifierExpression(methodInfo, var)); } return vars; diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.Evaluate.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.Evaluate.cs deleted file mode 100644 index 2b3b5bbea3..0000000000 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.Evaluate.cs +++ /dev/null @@ -1,30 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Collections.Generic; - -using ICSharpCode.NRefactory; -using ICSharpCode.NRefactory.PrettyPrinter; -using Ast = ICSharpCode.NRefactory.Ast; -using Debugger.Wrappers.CorSym; - -namespace Debugger -{ - public partial class Expression: DebuggerObject - { - public Value Evaluate(StackFrame context) - { - if (context == null) throw new ArgumentNullException("context"); - - EvaluateAstVisitor astVisitor = new EvaluateAstVisitor(context); - Value result = (Value)this.AbstractSynatxTree.AcceptVisitor(astVisitor, null); - context.Process.TraceMessage("Evaluated " + this.Code); - return result; - } - } -} diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.cs index b9dfeed073..efb6369792 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.cs @@ -8,64 +8,34 @@ using System; using System.Collections.Generic; -using ICSharpCode.NRefactory; -using ICSharpCode.NRefactory.PrettyPrinter; -using Ast = ICSharpCode.NRefactory.Ast; -using Debugger.Wrappers.CorSym; - -namespace Debugger +namespace Debugger.Expressions { /// /// Represents a piece of code that can be evaluated. /// For example "a[15] + 15". /// - public partial class Expression: DebuggerObject + public abstract partial class Expression: DebuggerObject { - Ast.Expression abstractSynatxTree; - - public string Code { - get { - if (abstractSynatxTree != null) { - CSharpOutputVisitor csOutVisitor = new CSharpOutputVisitor(); - abstractSynatxTree.AcceptVisitor(csOutVisitor, null); - return csOutVisitor.Text; - } else { - return string.Empty; - } - } - } - - public Ast.Expression AbstractSynatxTree { - get { return abstractSynatxTree; } - } - - public Expression(Ast.Expression abstractSynatxTree) - { - this.abstractSynatxTree = abstractSynatxTree; - } - - public Expression(string code) - { - throw new NotImplementedException(); + public abstract string Code { + get; } - public static implicit operator Expression(Ast.Expression abstractSynatxTree) + public override string ToString() { - return new Expression(abstractSynatxTree); + return this.Code; } - public static implicit operator Ast.Expression(Expression expression) + public Value Evaluate(StackFrame context) { - if (expression == null) { - return null; - } else { - return expression.AbstractSynatxTree; - } + if (context == null) throw new ArgumentNullException("context"); + if (context.HasExpired) throw new DebuggerException("context is expired StackFrame"); + + Value result = EvaluateInternal(context); + + context.Process.TraceMessage("Evaluated " + this.Code); + return result; } - public override string ToString() - { - return this.Code; - } + protected abstract Value EvaluateInternal(StackFrame context); } } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/ExpressionCollection.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/ExpressionCollection.cs index 1afe88cffb..fdd5936ce3 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/ExpressionCollection.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/ExpressionCollection.cs @@ -8,12 +8,7 @@ using System; using System.Collections.Generic; -using ICSharpCode.NRefactory; -using ICSharpCode.NRefactory.PrettyPrinter; -using Ast = ICSharpCode.NRefactory.Ast; -using Debugger.Wrappers.CorSym; - -namespace Debugger +namespace Debugger.Expressions { public class ExpressionCollection: List { diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/ExpressionEvaluateException.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/ExpressionEvaluateException.cs new file mode 100644 index 0000000000..0ebbf9ce56 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/ExpressionEvaluateException.cs @@ -0,0 +1,37 @@ +// +// +// +// +// $Revision$ +// + +using System; + +namespace Debugger.Expressions +{ + public class ExpressionEvaluateException: System.Exception + { + Expression expression; + string error; + + public Expression Expression { + get { return expression; } + } + + public string Error { + get { return error; } + } + + public ExpressionEvaluateException(Expression expression, string error) + :base(GetErrorMessage(expression, error)) + { + this.expression = expression; + this.error = error; + } + + public static string GetErrorMessage(Expression expression, string error) + { + return String.Format("Error evaluating \"{0}\": {1}", expression.Code, error); + } + } +} diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/NotImplementedAstVisitor.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/NotImplementedAstVisitor.cs deleted file mode 100644 index 7d8cb83392..0000000000 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/NotImplementedAstVisitor.cs +++ /dev/null @@ -1,575 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Collections.Generic; - -using ICSharpCode.NRefactory; -using ICSharpCode.NRefactory.PrettyPrinter; -using ICSharpCode.NRefactory.Ast; -using Debugger.Wrappers.CorSym; - -namespace Debugger -{ - abstract class NotImplementedAstVisitor: IAstVisitor - { - public virtual object VisitAddHandlerStatement(AddHandlerStatement addHandlerStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitAddressOfExpression(AddressOfExpression addressOfExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitAssignmentExpression(AssignmentExpression assignmentExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitAttribute(ICSharpCode.NRefactory.Ast.Attribute attribute, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitAttributeSection(AttributeSection attributeSection, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitBlockStatement(BlockStatement blockStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitBreakStatement(BreakStatement breakStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitCaseLabel(CaseLabel caseLabel, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitCastExpression(CastExpression castExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitCatchClause(CatchClause catchClause, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitCheckedExpression(CheckedExpression checkedExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitCheckedStatement(CheckedStatement checkedStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitClassReferenceExpression(ClassReferenceExpression classReferenceExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitCollectionInitializerExpression(CollectionInitializerExpression collectionInitializerExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitCompilationUnit(CompilationUnit compilationUnit, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitConditionalExpression(ConditionalExpression conditionalExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitContinueStatement(ContinueStatement continueStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitDeclareDeclaration(DeclareDeclaration declareDeclaration, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitDestructorDeclaration(DestructorDeclaration destructorDeclaration, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitDirectionExpression(DirectionExpression directionExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitDoLoopStatement(DoLoopStatement doLoopStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitElseIfSection(ElseIfSection elseIfSection, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitEmptyStatement(EmptyStatement emptyStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitEndStatement(EndStatement endStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitEraseStatement(EraseStatement eraseStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitErrorStatement(ErrorStatement errorStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitEventAddRegion(EventAddRegion eventAddRegion, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitEventDeclaration(EventDeclaration eventDeclaration, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitEventRaiseRegion(EventRaiseRegion eventRaiseRegion, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitEventRemoveRegion(EventRemoveRegion eventRemoveRegion, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitExitStatement(ExitStatement exitStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitExpressionStatement(ExpressionStatement expressionStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitFixedStatement(FixedStatement fixedStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitForeachStatement(ForeachStatement foreachStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitForNextStatement(ForNextStatement forNextStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitForStatement(ForStatement forStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitGotoCaseStatement(GotoCaseStatement gotoCaseStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitGotoStatement(GotoStatement gotoStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitIfElseStatement(IfElseStatement ifElseStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitIndexerExpression(IndexerExpression indexerExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitInnerClassTypeReference(InnerClassTypeReference innerClassTypeReference, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitInterfaceImplementation(InterfaceImplementation interfaceImplementation, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitInvocationExpression(InvocationExpression invocationExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitLabelStatement(LabelStatement labelStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitLambdaExpression(LambdaExpression lambdaExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitLocalVariableDeclaration(LocalVariableDeclaration localVariableDeclaration, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitLockStatement(LockStatement lockStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitMethodDeclaration(MethodDeclaration methodDeclaration, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitOnErrorStatement(OnErrorStatement onErrorStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitOptionDeclaration(OptionDeclaration optionDeclaration, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitParameterDeclarationExpression(ParameterDeclarationExpression parameterDeclarationExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitPropertyGetRegion(PropertyGetRegion propertyGetRegion, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitPropertySetRegion(PropertySetRegion propertySetRegion, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitQueryExpression(QueryExpression queryExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitQueryExpressionFromClause(QueryExpressionFromClause queryExpressionFromClause, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitQueryExpressionGroupClause(QueryExpressionGroupClause queryExpressionGroupClause, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitQueryExpressionIntoClause(QueryExpressionIntoClause queryExpressionIntoClause, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitQueryExpressionJoinClause(QueryExpressionJoinClause queryExpressionJoinClause, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitQueryExpressionLetClause(QueryExpressionLetClause queryExpressionLetClause, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitQueryExpressionOrdering(QueryExpressionOrdering queryExpressionOrdering, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitQueryExpressionSelectClause(QueryExpressionSelectClause queryExpressionSelectClause, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitQueryExpressionWhereClause(QueryExpressionWhereClause queryExpressionWhereClause, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitRaiseEventStatement(RaiseEventStatement raiseEventStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitReDimStatement(ReDimStatement reDimStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitRemoveHandlerStatement(RemoveHandlerStatement removeHandlerStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitResumeStatement(ResumeStatement resumeStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitReturnStatement(ReturnStatement returnStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitSizeOfExpression(SizeOfExpression sizeOfExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitStackAllocExpression(StackAllocExpression stackAllocExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitStopStatement(StopStatement stopStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitSwitchSection(SwitchSection switchSection, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitSwitchStatement(SwitchStatement switchStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitTemplateDefinition(TemplateDefinition templateDefinition, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitThrowStatement(ThrowStatement throwStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitTypeOfExpression(TypeOfExpression typeOfExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitTypeOfIsExpression(TypeOfIsExpression typeOfIsExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitTypeReference(TypeReference typeReference, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitUncheckedExpression(UncheckedExpression uncheckedExpression, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitUncheckedStatement(UncheckedStatement uncheckedStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitUnsafeStatement(UnsafeStatement unsafeStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitUsing(Using @using, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitUsingDeclaration(UsingDeclaration usingDeclaration, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitUsingStatement(UsingStatement usingStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitVariableDeclaration(VariableDeclaration variableDeclaration, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitWithStatement(WithStatement withStatement, object data) - { - throw new NotImplementedException(); - } - - public virtual object VisitYieldStatement(YieldStatement yieldStatement, object data) - { - throw new NotImplementedException(); - } - } -} diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.Object.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.Object.cs index bf4900e9b4..d8e531e198 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.Object.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.Object.cs @@ -31,6 +31,24 @@ namespace Debugger } } + /// + /// Get the value of given member. + /// + public Value GetMemberValue(MemberInfo memberInfo, Value[] arguments) + { + return GetMemberValue(this, memberInfo, arguments); + } + + public static Value GetMemberValue(Value objectInstance, MemberInfo memberInfo, Value[] arguments) + { + if (memberInfo is FieldInfo) { + return GetFieldValue(objectInstance, (FieldInfo)memberInfo); + } else if (memberInfo is PropertyInfo) { + return GetPropertyValue(objectInstance, (PropertyInfo)memberInfo); + } + throw new DebuggerException("Bad member type: " + memberInfo.GetType()); + } + /// /// Get the value of given field. /// Field may be static