Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@novell.com>2009-06-11 18:43:55 +0400
committerLluis Sanchez <lluis@novell.com>2009-06-11 18:43:55 +0400
commit49bbb6a298831656e9ea86ab20b4c924745d1560 (patch)
tree99fa15d51fbb95519f118afe88f1ca2092b216db /extras/MonoDevelop.Debugger.Mdb
parentdad72da6634d90cc426b0799860bff16c20a04ea (diff)
* Mono.Debugging.Server.Mdb/Makefile:
* Mono.Debugging.Server.Mdb/NRefactoryEvaluator.cs: * Mono.Debugging.Server.Mdb/UserVariableReference.cs: * Mono.Debugging.Server.Mdb/Mono.Debugging.Server.Mdb.csproj: Added support for defining variables. svn path=/trunk/monodevelop/; revision=135928
Diffstat (limited to 'extras/MonoDevelop.Debugger.Mdb')
-rw-r--r--extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/ChangeLog8
-rw-r--r--extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/Makefile1
-rw-r--r--extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/Mono.Debugging.Server.Mdb.csproj1
-rw-r--r--extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/NRefactoryEvaluator.cs120
-rw-r--r--extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/UserVariableReference.cs74
5 files changed, 186 insertions, 18 deletions
diff --git a/extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/ChangeLog b/extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/ChangeLog
index 4e65cb4430..40ec0cd502 100644
--- a/extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/ChangeLog
+++ b/extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/ChangeLog
@@ -1,3 +1,11 @@
+2009-06-11 Lluis Sanchez Gual <lluis@novell.com>
+
+ * Makefile:
+ * NRefactoryEvaluator.cs:
+ * UserVariableReference.cs:
+ * Mono.Debugging.Server.Mdb.csproj: Added support for defining
+ variables.
+
2009-06-04 Lluis Sanchez Gual <lluis@novell.com>
* Makefile:
diff --git a/extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/Makefile b/extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/Makefile
index e83f45840e..c99c55f357 100644
--- a/extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/Makefile
+++ b/extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/Makefile
@@ -73,6 +73,7 @@ FILES = \
TimedEvaluator.cs \
TimeOutException.cs \
TypeValueReference.cs \
+ UserVariableReference.cs \
Util.cs \
ValueReference.cs \
VariableReference.cs
diff --git a/extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/Mono.Debugging.Server.Mdb.csproj b/extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/Mono.Debugging.Server.Mdb.csproj
index e47d0db7bd..ac2bd9a798 100644
--- a/extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/Mono.Debugging.Server.Mdb.csproj
+++ b/extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/Mono.Debugging.Server.Mdb.csproj
@@ -165,6 +165,7 @@
<Compile Include="RuntimeInvokeManager.cs" />
<Compile Include="MdbAdaptor.cs" />
<Compile Include="MdbAdaptorFactory.cs" />
+ <Compile Include="UserVariableReference.cs" />
</ItemGroup>
<ItemGroup>
<None Include="ChangeLog" />
diff --git a/extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/NRefactoryEvaluator.cs b/extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/NRefactoryEvaluator.cs
index dbbbab038f..f027840b70 100644
--- a/extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/NRefactoryEvaluator.cs
+++ b/extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/NRefactoryEvaluator.cs
@@ -41,12 +41,35 @@ namespace DebuggerServer
{
public class NRefactoryEvaluator: ExpressionEvaluator
{
+ Dictionary<string,ValueReference> userVariables = new Dictionary<string, ValueReference> ();
+
public override ValueReference Evaluate (EvaluationContext ctx, string exp, EvaluationOptions options)
{
+ if (exp.StartsWith ("var ")) {
+ exp = exp.Substring (4).Trim (' ','\t');
+ string var = null;
+ for (int n=0; n<exp.Length; n++) {
+ if (!char.IsLetterOrDigit (exp[n]) && exp[n] != '_') {
+ var = exp.Substring (0, n);
+ if (!exp.Substring (n).Trim (' ','\t').StartsWith ("="))
+ var = null;
+ break;
+ }
+ if (n == exp.Length - 1) {
+ var = exp;
+ exp = null;
+ break;
+ }
+ }
+ if (!string.IsNullOrEmpty (var))
+ userVariables [var] = new UserVariableReference (ctx, var);
+ if (exp == null)
+ return null;
+ }
StringReader codeStream = new StringReader (exp);
IParser parser = ParserFactory.CreateParser (SupportedLanguage.CSharp, codeStream);
Expression expObj = parser.ParseExpression ();
- EvaluatorVisitor ev = new EvaluatorVisitor (ctx, exp, options);
+ EvaluatorVisitor ev = new EvaluatorVisitor (ctx, exp, options, userVariables);
return (ValueReference) expObj.AcceptVisitor (ev, null);
}
}
@@ -56,12 +79,14 @@ namespace DebuggerServer
EvaluationContext ctx;
string name;
EvaluationOptions options;
+ Dictionary<string,ValueReference> userVariables;
- public EvaluatorVisitor (EvaluationContext ctx, string name, EvaluationOptions options)
+ public EvaluatorVisitor (EvaluationContext ctx, string name, EvaluationOptions options, Dictionary<string,ValueReference> userVariables)
{
this.ctx = ctx;
this.name = name;
this.options = options;
+ this.userVariables = userVariables;
}
public override object VisitUnaryOperatorExpression (ICSharpCode.NRefactory.Ast.UnaryOperatorExpression unaryOperatorExpression, object data)
@@ -87,6 +112,29 @@ namespace DebuggerServer
break;
case UnaryOperatorType.Plus:
break;
+
+ case UnaryOperatorType.Decrement:
+ case UnaryOperatorType.Increment: {
+ if (!options.CanEvaluateMethods)
+ throw CreateNotSupportedError ();
+ object origVal = vref.ObjectValue;
+ long newVal = Convert.ToInt64 (origVal);
+ newVal += (unaryOperatorExpression.Op == UnaryOperatorType.Increment) ? 1 : -1;
+ LiteralValueReference nvref = new LiteralValueReference (ctx, name, Convert.ChangeType (newVal, origVal.GetType ()));
+ vref.Value = nvref.Value;
+ return nvref;
+ }
+ case UnaryOperatorType.PostDecrement:
+ case UnaryOperatorType.PostIncrement: {
+ if (!options.CanEvaluateMethods)
+ throw CreateNotSupportedError ();
+ object origVal = vref.ObjectValue;
+ long newVal = Convert.ToInt64 (origVal);
+ newVal += (unaryOperatorExpression.Op == UnaryOperatorType.PostIncrement) ? 1 : -1;
+ LiteralValueReference nvref = new LiteralValueReference (ctx, name, Convert.ChangeType (newVal, origVal.GetType ()));
+ vref.Value = nvref.Value;
+ return new LiteralValueReference (ctx, name, origVal);
+ }
default:
throw CreateNotSupportedError ();
}
@@ -335,6 +383,10 @@ namespace DebuggerServer
{
string name = identifierExpression.Identifier;
+ ValueReference userVar;
+ if (userVariables.TryGetValue (name, out userVar))
+ return userVar;
+
// Look in variables
foreach (TargetVariable var in ctx.Frame.Method.GetLocalVariables (ctx.Thread)) {
@@ -446,25 +498,29 @@ namespace DebuggerServer
public override object VisitBinaryOperatorExpression (ICSharpCode.NRefactory.Ast.BinaryOperatorExpression binaryOperatorExpression, object data)
{
ValueReference left = (ValueReference) binaryOperatorExpression.Left.AcceptVisitor (this, data);
-
+ return EvaluateBinaryOperatorExpression (left, binaryOperatorExpression.Right, binaryOperatorExpression.Op, data);
+ }
+
+ object EvaluateBinaryOperatorExpression (ValueReference left, ICSharpCode.NRefactory.Ast.Expression rightExp, BinaryOperatorType oper, object data)
+ {
// Shortcut ops
- switch (binaryOperatorExpression.Op) {
+ switch (oper) {
case BinaryOperatorType.LogicalAnd: {
if (!(bool)left.ObjectValue)
return left;
- return binaryOperatorExpression.Right.AcceptVisitor (this, data);
+ return rightExp.AcceptVisitor (this, data);
}
case BinaryOperatorType.LogicalOr: {
if ((bool)left.ObjectValue)
return left;
- return binaryOperatorExpression.Right.AcceptVisitor (this, data);
+ return rightExp.AcceptVisitor (this, data);
}
}
- ValueReference right = (ValueReference) binaryOperatorExpression.Right.AcceptVisitor (this, data);
+ ValueReference right = (ValueReference) rightExp.AcceptVisitor (this, data);
- if (binaryOperatorExpression.Op == BinaryOperatorType.Add || binaryOperatorExpression.Op == BinaryOperatorType.Concat) {
+ if (oper == BinaryOperatorType.Add || oper == BinaryOperatorType.Concat) {
if (left.Type == ctx.Frame.Language.StringType || right.Type == ctx.Frame.Language.StringType)
return new LiteralValueReference (ctx, name, left.CallToString () + right.CallToString ());
}
@@ -472,10 +528,10 @@ namespace DebuggerServer
object val1 = left.ObjectValue;
object val2 = right.ObjectValue;
- if ((binaryOperatorExpression.Op == BinaryOperatorType.ExclusiveOr) && (val1 is bool) && !(val2 is bool))
+ if ((oper == BinaryOperatorType.ExclusiveOr) && (val1 is bool) && !(val2 is bool))
return new LiteralValueReference (ctx, name, (bool)val1 ^ (bool)val2);
- switch (binaryOperatorExpression.Op) {
+ switch (oper) {
case BinaryOperatorType.Equality:
return new LiteralValueReference (ctx, name, val1.Equals (val2));
case BinaryOperatorType.InEquality:
@@ -492,7 +548,7 @@ namespace DebuggerServer
long v2 = Convert.ToInt64 (right.ObjectValue);
object res;
- switch (binaryOperatorExpression.Op) {
+ switch (oper) {
case BinaryOperatorType.Add: res = v1 + v2; break;
case BinaryOperatorType.BitwiseAnd: res = v1 & v2; break;
case BinaryOperatorType.BitwiseOr: res = v1 | v2; break;
@@ -552,6 +608,41 @@ namespace DebuggerServer
public override object VisitAssignmentExpression (ICSharpCode.NRefactory.Ast.AssignmentExpression assignmentExpression, object data)
{
+ if (!options.CanEvaluateMethods)
+ throw CreateNotSupportedError ();
+
+ ValueReference left = (ValueReference) assignmentExpression.Left.AcceptVisitor (this, data);
+
+ if (assignmentExpression.Op == AssignmentOperatorType.Assign) {
+ ValueReference right = (ValueReference) assignmentExpression.Right.AcceptVisitor (this, data);
+ left.Value = right.Value;
+ } else {
+ BinaryOperatorType bop = BinaryOperatorType.None;
+ switch (assignmentExpression.Op) {
+ case AssignmentOperatorType.Add: bop = BinaryOperatorType.Add; break;
+ case AssignmentOperatorType.BitwiseAnd: bop = BinaryOperatorType.BitwiseAnd; break;
+ case AssignmentOperatorType.BitwiseOr: bop = BinaryOperatorType.BitwiseOr; break;
+ case AssignmentOperatorType.ConcatString: bop = BinaryOperatorType.Concat; break;
+ case AssignmentOperatorType.Divide: bop = BinaryOperatorType.Divide; break;
+ case AssignmentOperatorType.DivideInteger: bop = BinaryOperatorType.DivideInteger; break;
+ case AssignmentOperatorType.ExclusiveOr: bop = BinaryOperatorType.ExclusiveOr; break;
+ case AssignmentOperatorType.Modulus: bop = BinaryOperatorType.Modulus; break;
+ case AssignmentOperatorType.Multiply: bop = BinaryOperatorType.Multiply; break;
+ case AssignmentOperatorType.Power: bop = BinaryOperatorType.Power; break;
+ case AssignmentOperatorType.ShiftLeft: bop = BinaryOperatorType.ShiftLeft; break;
+ case AssignmentOperatorType.ShiftRight: bop = BinaryOperatorType.ShiftRight; break;
+ case AssignmentOperatorType.Subtract: bop = BinaryOperatorType.Subtract; break;
+ }
+ ValueReference val = (ValueReference) EvaluateBinaryOperatorExpression (left, assignmentExpression.Right, bop, data);
+ left.Value = val.Value;
+ }
+ return left;
+ }
+
+ #region Unsupported expressions
+
+ public override object VisitVariableDeclaration (ICSharpCode.NRefactory.Ast.VariableDeclaration variableDeclaration, object data)
+ {
throw CreateNotSupportedError ();
}
@@ -560,8 +651,6 @@ namespace DebuggerServer
throw CreateNotSupportedError ();
}
- #region Unsupported expressions
-
public override object VisitPointerReferenceExpression (ICSharpCode.NRefactory.Ast.PointerReferenceExpression pointerReferenceExpression, object data)
{
throw CreateNotSupportedError ();
@@ -587,11 +676,6 @@ namespace DebuggerServer
throw CreateNotSupportedError ();
}
- public override object VisitVariableDeclaration (ICSharpCode.NRefactory.Ast.VariableDeclaration variableDeclaration, object data)
- {
- throw CreateNotSupportedError ();
- }
-
public override object VisitUsing (ICSharpCode.NRefactory.Ast.Using @using, object data)
{
throw CreateNotSupportedError ();
diff --git a/extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/UserVariableReference.cs b/extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/UserVariableReference.cs
new file mode 100644
index 0000000000..c82b92858d
--- /dev/null
+++ b/extras/MonoDevelop.Debugger.Mdb/Mono.Debugging.Server.Mdb/UserVariableReference.cs
@@ -0,0 +1,74 @@
+//
+// UserVariableReference.cs
+//
+// Author:
+// Lluis Sanchez Gual <lluis@novell.com>
+//
+// Copyright (c) 2009 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using Mono.Debugging.Client;
+using Mono.Debugger.Languages;
+
+namespace DebuggerServer
+{
+ public class UserVariableReference: ValueReference
+ {
+ string name;
+ TargetObject currentValue;
+
+ public UserVariableReference (EvaluationContext ctx, string name): base (ctx)
+ {
+ this.name = name;
+ }
+
+ public override string Name {
+ get {
+ return name;
+ }
+ }
+
+ public override TargetObject Value {
+ get {
+ if (currentValue != null)
+ return currentValue;
+ else
+ throw new EvaluatorException ("Value undefined.");
+ }
+ set {
+ currentValue = value;
+ }
+ }
+
+ public override TargetType Type {
+ get {
+ return Value.Type;
+ }
+ }
+
+ public override ObjectValueFlags Flags {
+ get {
+ return ObjectValueFlags.Variable;
+ }
+ }
+
+ }
+}