Browse Source

Added an Expression class which will be used to store AST expression for each value

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2762 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 18 years ago
parent
commit
62bbea7ef0
  1. 4
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj
  2. 7
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Variables/ValueItem.cs
  3. 5
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
  4. 7
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs
  5. 52
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Expression.cs
  6. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/NamedValue.cs
  7. 23
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/Value.cs
  8. 15
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variables/ArrayElement.cs
  9. 3
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variables/LocalVariable.cs
  10. 6
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variables/MemberValue.cs
  11. 3
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variables/MethodArgument.cs

4
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj

@ -118,6 +118,10 @@ @@ -118,6 +118,10 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Src\Variables" />
<ProjectReference Include="..\..\..\..\..\Libraries\NRefactory\Project\NRefactory.csproj">
<Project>{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}</Project>
<Name>NRefactory</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\Libraries\TreeViewAdv\Aga.Controls\Aga.Controls.csproj">
<Project>{E73BB233-D88B-44A7-A98F-D71EE158381D}</Project>
<Name>Aga.Controls</Name>

7
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Variables/ValueItem.cs

@ -79,7 +79,12 @@ namespace Debugger @@ -79,7 +79,12 @@ namespace Debugger
public override string Name {
get {
return val.Name;
//return val.Name;
if (val.Expression != null) {
return val.Expression.Code;
} else {
return "N/A";
}
}
}

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

@ -221,6 +221,7 @@ @@ -221,6 +221,7 @@
<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\Expression.cs" />
<Compile Include="Src\Variables\Types\BindingFlags.cs" />
<Compile Include="Src\Variables\Types\DebugType-Helpers.cs" />
<Compile Include="Src\Variables\Types\DebugType.cs" />
@ -411,6 +412,10 @@ @@ -411,6 +412,10 @@
<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>

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

@ -438,6 +438,7 @@ namespace Debugger @@ -438,6 +438,7 @@ namespace Debugger
thisValueCache = new NamedValue(
"this",
process,
ThisExpresson,
new IExpirable[] {this},
new IMutable[] {},
delegate { return ThisCorValue; }
@ -447,6 +448,12 @@ namespace Debugger @@ -447,6 +448,12 @@ namespace Debugger
}
}
static private Expression ThisExpresson {
get {
return new Expression(new ICSharpCode.NRefactory.Ast.ThisReferenceExpression());
}
}
ICorDebugValue ThisCorValue {
get {
if (this.HasExpired) throw new CannotGetValueException("Function has expired");

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

@ -0,0 +1,52 @@ @@ -0,0 +1,52 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision: 2285 $</version>
// </file>
using System;
using System.Collections.Generic;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.PrettyPrinter;
using Ast = ICSharpCode.NRefactory.Ast;
namespace Debugger
{
/// <summary>
/// Represents a piece of code that can be evaluated.
/// For example "a[15] + 15".
/// </summary>
public class Expression
{
Ast.Expression expressionAst;
public string Code {
get {
CSharpOutputVisitor csOutVisitor = new CSharpOutputVisitor();
expressionAst.AcceptVisitor(csOutVisitor, null);
return csOutVisitor.Text;
}
}
public Ast.Expression ExpressionAst {
get { return expressionAst; }
}
public Expression(ICSharpCode.NRefactory.Ast.Expression expressionAst)
{
this.expressionAst = expressionAst;
}
public static implicit operator Expression(ICSharpCode.NRefactory.Ast.Expression expressionAst)
{
return new Expression(expressionAst);
}
public override string ToString()
{
return this.Code;
}
}
}

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Values/NamedValue.cs

@ -29,10 +29,12 @@ namespace Debugger @@ -29,10 +29,12 @@ namespace Debugger
internal NamedValue(string name,
Process process,
Expression expression,
IExpirable[] expireDependencies,
IMutable[] mutateDependencies,
CorValueGetter corValueGetter)
:base (process,
expression,
expireDependencies,
mutateDependencies,
corValueGetter)

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

@ -37,6 +37,7 @@ namespace Debugger @@ -37,6 +37,7 @@ namespace Debugger
public partial class Value: DebuggerObject, IExpirable, IMutable
{
Process process;
Expression expression;
CorValueGetter corValueGetter;
@ -99,6 +100,13 @@ namespace Debugger @@ -99,6 +100,13 @@ namespace Debugger
}
}
/// <summary> Expression that has lead to this value. </summary>
/// <returns> Expression or null if the exression can not
/// be obtained. </returns>
public Expression Expression {
get { return expression; }
}
/// <summary> Returns true if the Value have expired
/// and can not be used anymore </summary>
public bool HasExpired {
@ -147,11 +155,26 @@ namespace Debugger @@ -147,11 +155,26 @@ namespace Debugger
}
internal Value(Process process,
IExpirable[] expireDependencies,
IMutable[] mutateDependencies,
CorValueGetter corValueGetter):
this(process,
null,
expireDependencies,
mutateDependencies,
corValueGetter)
{
}
internal Value(Process process,
Expression expression,
IExpirable[] expireDependencies,
IMutable[] mutateDependencies,
CorValueGetter corValueGetter)
{
this.process = process;
this.expression = expression;
AddExpireDependency(process);
foreach(IExpirable exp in expireDependencies) {

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

@ -8,6 +8,8 @@ @@ -8,6 +8,8 @@
using System;
using System.Collections.Generic;
using Ast = ICSharpCode.NRefactory.Ast;
using Debugger.Wrappers.CorDebug;
namespace Debugger
@ -36,6 +38,7 @@ namespace Debugger @@ -36,6 +38,7 @@ namespace Debugger
CorValueGetter corValueGetter)
:base (GetNameFromIndices(indicies),
process,
GetExpressionFromIndices(indicies),
expireDependencies,
mutateDependencies,
corValueGetter)
@ -52,5 +55,17 @@ namespace Debugger @@ -52,5 +55,17 @@ namespace Debugger
elementName = elementName.TrimEnd(new char[] {','}) + "]";
return elementName;
}
static Expression GetExpressionFromIndices(uint[] indices)
{
List<Ast.Expression> indicesAst = new List<Ast.Expression>();
foreach(uint indice in indices) {
indicesAst.Add(new Ast.PrimitiveExpression(indice, indice.ToString()));
}
return new Ast.IndexerExpression(
new Ast.IdentifierExpression("parent"), // TODO
indicesAst
);
}
}
}

3
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variables/LocalVariable.cs

@ -10,6 +10,8 @@ using System.Collections.Generic; @@ -10,6 +10,8 @@ using System.Collections.Generic;
using Debugger.Wrappers.CorDebug;
using Ast = ICSharpCode.NRefactory.Ast;
namespace Debugger
{
/// <summary>
@ -24,6 +26,7 @@ namespace Debugger @@ -24,6 +26,7 @@ namespace Debugger
CorValueGetter corValueGetter)
:base (name,
process,
new Ast.IdentifierExpression(name),
expireDependencies,
mutateDependencies,
corValueGetter)

6
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variables/MemberValue.cs

@ -10,6 +10,8 @@ using System.Collections.Generic; @@ -10,6 +10,8 @@ using System.Collections.Generic;
using Debugger.Wrappers.CorDebug;
using Ast = ICSharpCode.NRefactory.Ast;
namespace Debugger
{
/// <summary>
@ -37,6 +39,10 @@ namespace Debugger @@ -37,6 +39,10 @@ namespace Debugger
CorValueGetter corValueGetter)
:base (memberInfo.Name,
process,
new Ast.MemberReferenceExpression(
new Ast.IdentifierExpression("parent"), // TODO
memberInfo.Name
),
expireDependencies,
mutateDependencies,
corValueGetter)

3
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variables/MethodArgument.cs

@ -10,6 +10,8 @@ using System.Collections.Generic; @@ -10,6 +10,8 @@ using System.Collections.Generic;
using Debugger.Wrappers.CorDebug;
using Ast = ICSharpCode.NRefactory.Ast;
namespace Debugger
{
/// <summary>
@ -40,6 +42,7 @@ namespace Debugger @@ -40,6 +42,7 @@ namespace Debugger
CorValueGetter corValueGetter)
:base (name,
process,
new Ast.IdentifierExpression(name),
expireDependencies,
mutateDependencies,
corValueGetter)

Loading…
Cancel
Save