Browse Source

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
shortcuts
David Srbecký 19 years ago
parent
commit
184af2410d
  1. 1
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs
  2. 1
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ArrayRangeNode.cs
  3. 1
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ChildNodesOfObject.cs
  4. 1
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ExpressionNode.cs
  5. 1
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/StackFrameNode.cs
  6. 14
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
  7. 36
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/FieldReferenceExpression.cs
  8. 72
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/IndexerExpression.cs
  9. 27
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/LocalVariableIdentifierExpression.cs
  10. 102
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/MemberReferenceExpression.cs
  11. 41
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/ParameterIdentifierExpression.cs
  12. 40
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/PrimitiveExpression.cs
  13. 36
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/PropertyReferenceExpression.cs
  14. 28
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/ThisReferenceExpression.cs
  15. 83
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/EvaluateAstVisitor.cs
  16. 30
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.Create.cs
  17. 30
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.Evaluate.cs
  18. 60
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.cs
  19. 7
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/ExpressionCollection.cs
  20. 37
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/ExpressionEvaluateException.cs
  21. 575
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/NotImplementedAstVisitor.cs
  22. 18
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.Object.cs

1
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs

@ -42,6 +42,7 @@ using System.Diagnostics; @@ -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;

1
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ArrayRangeNode.cs

@ -11,6 +11,7 @@ using System.Collections.Generic; @@ -11,6 +11,7 @@ using System.Collections.Generic;
using ICSharpCode.Core;
using Debugger;
using Debugger.Expressions;
namespace Debugger.AddIn.TreeModel
{

1
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ChildNodesOfObject.cs

@ -11,6 +11,7 @@ using System.Collections.Generic; @@ -11,6 +11,7 @@ using System.Collections.Generic;
using ICSharpCode.Core;
using Debugger;
using Debugger.Expressions;
namespace Debugger.AddIn.TreeModel
{

1
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ExpressionNode.cs

@ -14,6 +14,7 @@ using ICSharpCode.SharpDevelop.Debugging; @@ -14,6 +14,7 @@ using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Services;
using Debugger;
using Debugger.Expressions;
namespace Debugger.AddIn.TreeModel
{

1
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/StackFrameNode.cs

@ -9,6 +9,7 @@ using System.Collections; @@ -9,6 +9,7 @@ using System.Collections;
using System.Collections.Generic;
using Debugger;
using Debugger.Expressions;
namespace Debugger.AddIn.TreeModel
{

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

@ -217,16 +217,16 @@ @@ -217,16 +217,16 @@
<Compile Include="Src\Variables\Evals\Eval.cs" />
<Compile Include="Src\Variables\Evals\EvalEventArgs.cs" />
<Compile Include="Src\Variables\Evals\Process-Evals.cs" />
<Compile Include="Src\Variables\Expressions\Ast\FieldReferenceExpression.cs" />
<Compile Include="Src\Variables\Expressions\Ast\IndexerExpression.cs" />
<Compile Include="Src\Variables\Expressions\Ast\LocalVariableIdentifierExpression.cs" />
<Compile Include="Src\Variables\Expressions\Ast\MemberReferenceExpression.cs" />
<Compile Include="Src\Variables\Expressions\Ast\ParameterIdentifierExpression.cs" />
<Compile Include="Src\Variables\Expressions\Ast\PropertyReferenceExpression.cs" />
<Compile Include="Src\Variables\Expressions\EvaluateAstVisitor.cs" />
<Compile Include="Src\Variables\Expressions\Ast\PrimitiveExpression.cs" />
<Compile Include="Src\Variables\Expressions\Ast\ThisReferenceExpression.cs" />
<Compile Include="Src\Variables\Expressions\Expression.Create.cs" />
<Compile Include="Src\Variables\Expressions\Expression.cs" />
<Compile Include="Src\Variables\Expressions\ExpressionCollection.cs" />
<Compile Include="Src\Variables\Expressions\Expression.Evaluate.cs" />
<Compile Include="Src\Variables\Expressions\NotImplementedAstVisitor.cs" />
<Compile Include="Src\Variables\Expressions\ExpressionEvaluateException.cs" />
<Compile Include="Src\Variables\Types\BindingFlags.cs" />
<Compile Include="Src\Variables\Types\DebugType-Helpers.cs" />
<Compile Include="Src\Variables\Types\DebugType.cs" />
@ -414,10 +414,6 @@ @@ -414,10 +414,6 @@
<Folder Include="Src\Wrappers\CorSym" />
<Folder Include="Src\Wrappers\CorSym\Autogenerated" />
<Folder Include="Src\Wrappers\MetaData" />
<ProjectReference Include="..\..\..\..\..\Libraries\NRefactory\Project\NRefactory.csproj">
<Project>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</Project>
<Name>NRefactory</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
</Project>

36
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/FieldReferenceExpression.cs

@ -1,36 +0,0 @@ @@ -1,36 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using Debugger;
namespace ICSharpCode.NRefactory.Ast
{
/// <summary>
/// Reference to a class field
/// </summary>
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));
}
}
}

72
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/IndexerExpression.cs

@ -0,0 +1,72 @@ @@ -0,0 +1,72 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
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<int> indicies = new List<int>();
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);
}
}
}
}

27
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/LocalVariableIdentifierExpression.cs

@ -10,27 +10,42 @@ using System.Collections.Generic; @@ -10,27 +10,42 @@ using System.Collections.Generic;
using Debugger.Wrappers.CorSym;
namespace ICSharpCode.NRefactory.Ast
namespace Debugger.Expressions
{
/// <summary>
/// Identifier of a local variable
/// </summary>
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);
}
}
}

102
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/MemberReferenceExpression.cs

@ -0,0 +1,102 @@ @@ -0,0 +1,102 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
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<Value> argumentValues = new List<Value>();
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);
}
}
}
}
}

41
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/ParameterIdentifierExpression.cs

@ -8,27 +8,48 @@ @@ -8,27 +8,48 @@
using System;
using System.Collections.Generic;
namespace ICSharpCode.NRefactory.Ast
namespace Debugger.Expressions
{
/// <summary>
/// Identifier of a method parameter
/// </summary>
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);
}
}
}

40
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/PrimitiveExpression.cs

@ -0,0 +1,40 @@ @@ -0,0 +1,40 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
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");
}
}
}

36
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/PropertyReferenceExpression.cs

@ -1,36 +0,0 @@ @@ -1,36 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using Debugger;
namespace ICSharpCode.NRefactory.Ast
{
/// <summary>
/// Reference to a class property
/// </summary>
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));
}
}
}

28
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Ast/ThisReferenceExpression.cs

@ -0,0 +1,28 @@ @@ -0,0 +1,28 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
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;
}
}
}

83
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/EvaluateAstVisitor.cs

@ -1,83 +0,0 @@ @@ -1,83 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
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<int> indexes = new List<int>();
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);
}
}
}
}

30
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.Create.cs

@ -8,25 +8,19 @@ @@ -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<Ast.Expression> indicesAst = new List<Ast.Expression>();
List<Expression> indicesAst = new List<Expression>();
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 @@ -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 @@ -87,7 +75,7 @@ namespace Debugger
{
if (methodInfo.IsStatic) throw new DebuggerException(methodInfo.FullName + " is static method");
return new Ast.ThisReferenceExpression();
return new ThisReferenceExpression();
}
/// <summary> Get parameters of a method </summary>
@ -96,7 +84,7 @@ namespace Debugger @@ -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 @@ -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;

30
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.Evaluate.cs

@ -1,30 +0,0 @@ @@ -1,30 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
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;
}
}
}

60
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/Expression.cs

@ -8,64 +8,34 @@ @@ -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
{
/// <summary>
/// Represents a piece of code that can be evaluated.
/// For example "a[15] + 15".
/// </summary>
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);
}
}

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

@ -8,12 +8,7 @@ @@ -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<Expression>
{

37
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/ExpressionEvaluateException.cs

@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
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);
}
}
}

575
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expressions/NotImplementedAstVisitor.cs

@ -1,575 +0,0 @@ @@ -1,575 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
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();
}
}
}

18
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.Object.cs

@ -31,6 +31,24 @@ namespace Debugger @@ -31,6 +31,24 @@ namespace Debugger
}
}
/// <summary>
/// Get the value of given member.
/// </summary>
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());
}
/// <summary>
/// Get the value of given field.
/// Field may be static

Loading…
Cancel
Save