Browse Source

Port debugger libraries to use new NRefactory.

pull/191/merge
Eusebiu Marcu 15 years ago
parent
commit
a0ca895498
  1. 2
      Debugger/Debugger.Core/Debugger.Core.csproj
  2. 186
      Debugger/Debugger.Core/NRefactory/Ast/ExpressionExtensionMethods.cs
  3. 333
      Debugger/Debugger.Core/NRefactory/Visitors/ExpressionEvaluator.cs
  4. 1
      Debugger/ILSpy.Debugger/AvalonEdit/IconBarMargin.cs
  5. 2
      Debugger/ILSpy.Debugger/Bookmarks/BookmarkManager.cs
  6. 6
      Debugger/ILSpy.Debugger/Models/TreeModel/ChildNodesOfObject.cs
  7. 1
      Debugger/ILSpy.Debugger/Models/TreeModel/StackFrameNode.cs
  8. 4
      Debugger/ILSpy.Debugger/Services/Debugger/DebuggerHelper.cs
  9. 4
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/BinaryOperatorExpression.cs

2
Debugger/Debugger.Core/Debugger.Core.csproj

@ -19,7 +19,7 @@
<FileAlignment>4096</FileAlignment> <FileAlignment>4096</FileAlignment>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<OutputPath>\bin</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks> <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<PublishUrl>http://localhost/Debugger.Core/</PublishUrl> <PublishUrl>http://localhost/Debugger.Core/</PublishUrl>
<Install>true</Install> <Install>true</Install>

186
Debugger/Debugger.Core/NRefactory/Ast/ExpressionExtensionMethods.cs

@ -3,6 +3,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection; using System.Reflection;
using Debugger; using Debugger;
@ -149,9 +151,13 @@ namespace ICSharpCode.NRefactory.Ast
public static string PrettyPrint(this AstNode code) public static string PrettyPrint(this AstNode code)
{ {
if (code == null) return string.Empty; if (code == null) return string.Empty;
CSharpOutputVisitor csOutVisitor = new CSharpOutputVisitor();
code.AcceptVisitor(csOutVisitor, null); using (var sw = new StringWriter())
return csOutVisitor.Text; {
OutputVisitor csOutVisitor = new OutputVisitor(sw, new CSharpFormattingPolicy());
code.AcceptVisitor(csOutVisitor, null);
return sw.ToString();
}
} }
public static AstType GetTypeReference(this Type type) public static AstType GetTypeReference(this Type type)
@ -190,12 +196,21 @@ namespace ICSharpCode.NRefactory.Ast
if (type.DeclaringType != null) { if (type.DeclaringType != null) {
var outterRef = type.DeclaringType.GetTypeReference(); var outterRef = type.DeclaringType.GetTypeReference();
var innerRef = new InnerClassTypeReference(outterRef, name, genTypeRefs); var innerRef = new ComposedType() {
innerRef.PointerNestingLevel = pointerNest; PointerRank = pointerNest,
innerRef.RankSpecifier = arrayRanks.ToArray(); ArraySpecifiers = arrayRanks.ConvertAll(r => new ArraySpecifier(r)),
BaseType = new MemberType() {
Target = outterRef, MemberName = name, TypeArguments = genTypeRefs }
};
return innerRef.SetStaticType((DebugType)type); return innerRef.SetStaticType((DebugType)type);
} else { } else {
return new TypeReference(name, pointerNest, arrayRanks.ToArray(), genTypeRefs).SetStaticType((DebugType)type); return (new ComposedType() {
PointerRank = pointerNest,
ArraySpecifiers = arrayRanks.ConvertAll(r => new ArraySpecifier(r)),
BaseType = new SimpleType() {
Identifier = name,
TypeArguments = genTypeRefs }}).SetStaticType((DebugType)type);
} }
} }
@ -204,61 +219,75 @@ namespace ICSharpCode.NRefactory.Ast
/// Dotted names are split into separate nodes. /// Dotted names are split into separate nodes.
/// It does not normalize generic arguments. /// It does not normalize generic arguments.
/// </summary> /// </summary>
static SimpleType NormalizeTypeReference(this AstNode expr) static AstType NormalizeTypeReference(this AstNode expr)
{ {
if (expr is IdentifierExpression) { if (expr is IdentifierExpression) {
return new SimpleType() { return new SimpleType() {
Identifier = ((IdentifierExpression)expr).Identifier, Identifier = ((IdentifierExpression)expr).Identifier,
TypeArguments = ((IdentifierExpression)expr).TypeArguments}; TypeArguments = ((IdentifierExpression)expr).TypeArguments};
} else if (expr is MemberReferenceExpression) { } else if (expr is MemberReferenceExpression) {
var outter = NormalizeTypeReference(((MemberReferenceExpression)expr).Target); var outter = NormalizeTypeReference(((MemberReferenceExpression)expr).Target);
return new InnerClassTypeReference( return new MemberType() { Target = outter,
outter, MemberName = ((MemberReferenceExpression)expr).MemberName,
((MemberReferenceExpression)expr).MemberName, TypeArguments = ((MemberReferenceExpression)expr).TypeArguments };
((MemberReferenceExpression)expr).TypeArguments
);
} else if (expr is TypeReferenceExpression) { } else if (expr is TypeReferenceExpression) {
return NormalizeTypeReference(((TypeReferenceExpression)expr).TypeReference); return NormalizeTypeReference(((TypeReferenceExpression)expr).Type);
} else if (expr is InnerClassTypeReference) { // Frist - it is also TypeReference } else if (expr is ComposedType) { // Frist - it is also TypeReference
InnerClassTypeReference typeRef = (InnerClassTypeReference)expr; var typeRef = (ComposedType)expr;
string[] names = typeRef.Type.Split('.'); string[] names = null;
var newRef = NormalizeTypeReference(typeRef.BaseType); if (typeRef.BaseType is SimpleType)
foreach(string name in names) { names = (((SimpleType)typeRef.BaseType)).Identifier.Split('.');
newRef = new InnerClassTypeReference(newRef, name, new List<TypeReference>()); else
} names = (((MemberType)typeRef.BaseType)).MemberName.Split('.');
newRef.GenericTypes.AddRange(typeRef.GenericTypes);
newRef.PointerNestingLevel = typeRef.PointerNestingLevel; var newRef = NormalizeTypeReference(typeRef.BaseType) as ComposedType;
newRef.RankSpecifier = typeRef.RankSpecifier;
return newRef;
} else if (expr is TypeReference) {
var typeRef = (TypeReference)expr;
string[] names = typeRef.Type.Split('.');
if (names.Length == 1)
return typeRef;
TypeReference newRef = null;
foreach(string name in names) { foreach(string name in names) {
if (newRef == null) { newRef = new ComposedType() {
newRef = new TypeReference(name, new List<TypeReference>()); BaseType = new SimpleType() { Identifier = name, TypeArguments = new List<AstType>() }
} else { };
newRef = new TypeReference(newRef, name, new List<TypeReference>());
}
} }
newRef.GenericTypes.AddRange(typeRef.GenericTypes); //(((MemberType)newRef).TypeArguments as List<AstType>).AddRange(typeRef.TypeArguments);
newRef.PointerNestingLevel = typeRef.PointerNestingLevel; newRef.PointerRank = typeRef.PointerRank;
newRef.RankSpecifier = typeRef.RankSpecifier; newRef.ArraySpecifiers = typeRef.ArraySpecifiers;
return newRef; return newRef;
} else { }
// else if (expr is SimpleType) {
// var typeRef = (SimpleType)expr;
// string[] names = typeRef.Identifier.Split('.');
// if (names.Length == 1)
// return typeRef;
// SimpleType newRef = null;
// foreach(string name in names) {
// if (newRef == null) {
// newRef = new SimpleType() { Identifier = name, TypeArguments = new List<AstType>() };
// } else {
// newRef = new MemberType() { Target = newRef, MemberName = name, TypeArguments = new List<AstType>() };
// }
// }
// ((List<AstType>)newRef.TypeArguments).AddRange(typeRef.TypeArguments);
// newRef.PointerNestingLevel = typeRef.PointerNestingLevel;
// newRef.RankSpecifier = typeRef.RankSpecifier;
// return newRef;
// }
else {
throw new EvaluateException(expr, "Type expected. {0} seen.", expr.GetType().FullName); throw new EvaluateException(expr, "Type expected. {0} seen.", expr.GetType().FullName);
} }
} }
static string GetNameWithArgCounts(SimpleType typeRef) static string GetNameWithArgCounts(AstType typeRef)
{ {
string name = typeRef.Type; string name = string.Empty;
if (typeRef.GenericTypes.Count > 0)
name += "`" + typeRef.GenericTypes.Count.ToString(); if (typeRef is SimpleType)
if (typeRef is InnerClassTypeReference) { {
return GetNameWithArgCounts(((InnerClassTypeReference)typeRef).BaseType) + "." + name; name = ((SimpleType)typeRef).Identifier;
if (((SimpleType)typeRef).TypeArguments.Count() > 0)
name += "`" + ((SimpleType)typeRef).TypeArguments.Count().ToString();
}
if (typeRef is MemberType) {
name = ((MemberType)typeRef).MemberName;
return GetNameWithArgCounts(((MemberType)typeRef).Target) + "." + name;
} else { } else {
return name; return name;
} }
@ -266,24 +295,26 @@ namespace ICSharpCode.NRefactory.Ast
public static DebugType ResolveType(this AstNode expr, Debugger.AppDomain appDomain) public static DebugType ResolveType(this AstNode expr, Debugger.AppDomain appDomain)
{ {
if (expr is TypeReference && expr.GetStaticType() != null) if (expr is AstType && expr.GetStaticType() != null)
return expr.GetStaticType(); return expr.GetStaticType();
if (expr is TypeReferenceExpression && ((TypeReferenceExpression)expr).TypeReference.GetStaticType() != null) if (expr is TypeReferenceExpression && ((TypeReferenceExpression)expr).Type.GetStaticType() != null)
return ((TypeReferenceExpression)expr).TypeReference.GetStaticType(); return ((TypeReferenceExpression)expr).Type.GetStaticType();
appDomain.Process.TraceMessage("Resolving {0}", expr.PrettyPrint()); appDomain.Process.TraceMessage("Resolving {0}", expr.PrettyPrint());
TypeReference typeRef = NormalizeTypeReference(expr); var typeRef = NormalizeTypeReference(expr);
List<TypeReference> genTypeRefs; List<AstType> genTypeRefs = null;
if (typeRef is InnerClassTypeReference) { if (typeRef is MemberType) {
genTypeRefs = ((InnerClassTypeReference)typeRef).CombineToNormalTypeReference().GenericTypes; //FIXME genTypeRefs = ((MemberType)typeRef).CombineToNormalTypeReference().TypeArguments as List<AstType>;
} else { } else {
genTypeRefs = typeRef.GenericTypes; if (typeRef is SimpleType) {
genTypeRefs = ((SimpleType)typeRef).TypeArguments as List<AstType>;
}
} }
List<DebugType> genArgs = new List<DebugType>(); List<DebugType> genArgs = new List<DebugType>();
foreach(TypeReference genTypeRef in genTypeRefs) { foreach(var genTypeRef in genTypeRefs) {
genArgs.Add(ResolveType(genTypeRef, appDomain)); genArgs.Add(ResolveType(genTypeRef, appDomain));
} }
@ -294,37 +325,46 @@ namespace ICSharpCode.NRefactory.Ast
/// For performance this is separate method. /// For performance this is separate method.
/// 'genArgs' should hold type for each generic parameter in 'typeRef'. /// 'genArgs' should hold type for each generic parameter in 'typeRef'.
/// </summary> /// </summary>
static DebugType ResolveTypeInternal(SimpleType typeRef, DebugType[] genArgs, Debugger.AppDomain appDomain) static DebugType ResolveTypeInternal(AstType typeRef, DebugType[] genArgs, Debugger.AppDomain appDomain)
{ {
DebugType type = null; DebugType type = null;
// Try to construct non-nested type if (typeRef is SimpleType) {
// If there are generic types up in the tree, it must be nested type // Try to construct non-nested type
if (genArgs.Length == typeRef.GenericTypes.Count) { // If there are generic types up in the tree, it must be nested type
string name = GetNameWithArgCounts(typeRef); var simple = (SimpleType)typeRef;
type = DebugType.CreateFromNameOrNull(appDomain, name, null, genArgs);
if (genArgs.Length == simple.TypeArguments.Count()) {
string name = GetNameWithArgCounts(simple);
type = DebugType.CreateFromNameOrNull(appDomain, name, null, genArgs);
}
} }
// Try to construct nested type // Try to construct nested type
if (type == null && typeRef is InnerClassTypeReference) { if (type == null && typeRef is MemberType) {
var member = (MemberType)typeRef;
DebugType[] outterGenArgs = genArgs; DebugType[] outterGenArgs = genArgs;
// Do not pass our generic arguments to outter type // Do not pass our generic arguments to outter type
Array.Resize(ref outterGenArgs, genArgs.Length - typeRef.GenericTypes.Count); Array.Resize(ref outterGenArgs, genArgs.Length - member.TypeArguments.Count());
DebugType outter = ResolveTypeInternal(((InnerClassTypeReference)typeRef).BaseType, outterGenArgs, appDomain); DebugType outter = ResolveTypeInternal(member.Target, outterGenArgs, appDomain);
string nestedName = typeRef.GenericTypes.Count == 0 ? typeRef.Type : typeRef.Type + "`" + typeRef.GenericTypes.Count; string nestedName = member.TypeArguments.Count() == 0 ?
member.MemberName : member.MemberName + "`" + member.TypeArguments.Count();
type = DebugType.CreateFromNameOrNull(appDomain, nestedName, outter, genArgs); type = DebugType.CreateFromNameOrNull(appDomain, nestedName, outter, genArgs);
} }
if (type == null) if (type == null)
throw new GetValueException("Can not resolve " + typeRef.PrettyPrint()); throw new GetValueException("Can not resolve " + typeRef.PrettyPrint());
for(int i = 0; i < typeRef.PointerNestingLevel; i++) { if (typeRef is ComposedType) {
type = (DebugType)type.MakePointerType();
} for(int i = 0; i < ((ComposedType)typeRef).PointerRank; i++) {
if (typeRef.RankSpecifier != null) { type = (DebugType)type.MakePointerType();
for(int i = typeRef.RankSpecifier.Length - 1; i >= 0; i--) { }
type = (DebugType)type.MakeArrayType(typeRef.RankSpecifier[i] + 1); if (((ComposedType)typeRef).ArraySpecifiers != null) {
var enumerator = ((ComposedType)typeRef).ArraySpecifiers.Reverse().GetEnumerator();
while (enumerator.MoveNext()) {
type = (DebugType)type.MakeArrayType(enumerator.Current.Dimensions + 1);
}
} }
} }
return type; return type;

333
Debugger/Debugger.Core/NRefactory/Visitors/ExpressionEvaluator.cs

@ -4,6 +4,7 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
@ -60,15 +61,21 @@ namespace ICSharpCode.NRefactory.Visitors
public static AstNode Parse(string code, SupportedLanguage language) public static AstNode Parse(string code, SupportedLanguage language)
{ {
SnippetParser parser = new SnippetParser(language); switch (language) {
AstNode astRoot = parser.Parse(code); case SupportedLanguage.CSharp:
if (parser.Errors.Count > 0) { var parser = new CSharpParser();
throw new GetValueException(parser.Errors.ErrorOutput); using (var textReader = new StringReader(code)) {
} AstNode astRoot = parser.ParseExpression(textReader);
if (parser.SnippetType != SnippetType.Expression && parser.SnippetType != SnippetType.Statements) { if (parser.HasErrors) {
throw new GetValueException("Code must be expression or statement"); throw new GetValueException("Parser errors");
}
return astRoot;
}
break;
default:
throw new ArgumentException("Unsuported language");
} }
return astRoot;
} }
/// <summary> Evaluate given expression. If you have expression tree already, use overloads of this method.</summary> /// <summary> Evaluate given expression. If you have expression tree already, use overloads of this method.</summary>
@ -106,16 +113,20 @@ namespace ICSharpCode.NRefactory.Visitors
/// </summary> /// </summary>
public static Expression ParseExpression(string code, SupportedLanguage language) public static Expression ParseExpression(string code, SupportedLanguage language)
{ {
SnippetParser parser = new SnippetParser(language); switch (language) {
AstNode astRoot = parser.Parse(code); case SupportedLanguage.CSharp:
if (parser.Errors.Count > 0) { var parser = new CSharpParser();
throw new GetValueException(parser.Errors.ErrorOutput); using (var textReader = new StringReader(code)) {
} AstNode astRoot = parser.ParseExpression(textReader);
Expression astExpression = astRoot as Expression; if (parser.HasErrors) {
if (astExpression == null) { throw new GetValueException("Parser errors");
throw new GetValueException("Code must be expression"); }
return astRoot as Expression;
}
default:
throw new ArgumentException("Unsuported language");
} }
return astExpression;
} }
public static string FormatValue(Value val) public static string FormatValue(Value val)
@ -279,21 +290,17 @@ namespace ICSharpCode.NRefactory.Visitors
{ {
BinaryOperatorType op; BinaryOperatorType op;
switch (assignmentExpression.Operator) { switch (assignmentExpression.Operator) {
//case AssignmentOperatorType.Assign: op = BinaryOperatorType.None; break; case AssignmentOperatorType.Add: op = BinaryOperatorType.Add; break;
case AssignmentOperatorType.Add: op = BinaryOperatorType.Add; break; case AssignmentOperatorType.Subtract: op = BinaryOperatorType.Subtract; break;
//case AssignmentOperatorType.ConcatString: op = BinaryOperatorType.Concat; break; case AssignmentOperatorType.Multiply: op = BinaryOperatorType.Multiply; break;
case AssignmentOperatorType.Subtract: op = BinaryOperatorType.Subtract; break; case AssignmentOperatorType.Divide: op = BinaryOperatorType.Divide; break;
case AssignmentOperatorType.Multiply: op = BinaryOperatorType.Multiply; break; case AssignmentOperatorType.ShiftLeft: op = BinaryOperatorType.ShiftLeft; break;
case AssignmentOperatorType.Divide: op = BinaryOperatorType.Divide; break; case AssignmentOperatorType.ShiftRight: op = BinaryOperatorType.ShiftRight; break;
//case AssignmentOperatorType.DivideInteger: op = BinaryOperatorType.DivideInteger; break; case AssignmentOperatorType.ExclusiveOr: op = BinaryOperatorType.ExclusiveOr; break;
case AssignmentOperatorType.ShiftLeft: op = BinaryOperatorType.ShiftLeft; break; case AssignmentOperatorType.Modulus: op = BinaryOperatorType.Modulus; break;
case AssignmentOperatorType.ShiftRight: op = BinaryOperatorType.ShiftRight; break; case AssignmentOperatorType.BitwiseAnd: op = BinaryOperatorType.BitwiseAnd; break;
case AssignmentOperatorType.ExclusiveOr: op = BinaryOperatorType.ExclusiveOr; break; case AssignmentOperatorType.BitwiseOr: op = BinaryOperatorType.BitwiseOr; break;
case AssignmentOperatorType.Modulus: op = BinaryOperatorType.Modulus; break; default: throw new GetValueException("Unknown operator " + assignmentExpression.Operator);
case AssignmentOperatorType.BitwiseAnd: op = BinaryOperatorType.BitwiseAnd; break;
case AssignmentOperatorType.BitwiseOr: op = BinaryOperatorType.BitwiseOr; break;
//case AssignmentOperatorType.Power: op = BinaryOperatorType.Power; break;
default: throw new GetValueException("Unknown operator " + assignmentExpression.Operator);
} }
TypedValue right; TypedValue right;
@ -343,7 +350,7 @@ namespace ICSharpCode.NRefactory.Visitors
public object VisitCastExpression(CastExpression castExpression, object data) public object VisitCastExpression(CastExpression castExpression, object data)
{ {
TypedValue val = Evaluate(castExpression.Expression); TypedValue val = Evaluate(castExpression.Expression);
DebugType castTo = castExpression.ResolveType(context.AppDomain).CastTo(); DebugType castTo = null;// FIXME castExpression.CastTo().ResolveType(context.AppDomain);
if (castTo.IsPrimitive && val.Type.IsPrimitive && castTo != val.Type) { if (castTo.IsPrimitive && val.Type.IsPrimitive && castTo != val.Type) {
object oldVal = val.PrimitiveValue; object oldVal = val.PrimitiveValue;
object newVal; object newVal;
@ -491,10 +498,10 @@ namespace ICSharpCode.NRefactory.Visitors
public object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) public object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data)
{ {
if (arrayCreateExpression.Initializer.RankSpecifier[0] != 0) if (arrayCreateExpression.AdditionalArraySpecifiers.Count() != 0)
throw new EvaluateException(arrayCreateExpression, "Multi-dimensional arrays are not suppored"); throw new EvaluateException(arrayCreateExpression, "Multi-dimensional arrays are not suppored");
DebugType type = arrayCreateExpression.CreateType.ResolveType(context.AppDomain); DebugType type = arrayCreateExpression.Type.ResolveType(context.AppDomain);
int length = 0; int length = 0;
if (arrayCreateExpression.Arguments.Count() == 1) { if (arrayCreateExpression.Arguments.Count() == 1) {
length = EvaluateAsInt(arrayCreateExpression.Arguments.First()); length = EvaluateAsInt(arrayCreateExpression.Arguments.First());
@ -592,9 +599,9 @@ namespace ICSharpCode.NRefactory.Visitors
TypedValue newValue = null; TypedValue newValue = null;
try { try {
if (op == UnaryOperatorType.Decrement || op == UnaryOperatorType.PostDecrement) if (op == UnaryOperatorType.Decrement || op == UnaryOperatorType.PostDecrement)
newValue = (TypedValue)VisitAssignmentExpression(new AssignmentExpression(unaryOperatorExpression.Expression, AssignmentOperatorType.Subtract), null); newValue = (TypedValue)VisitAssignmentExpression(new AssignmentExpression() { Right = unaryOperatorExpression.Expression, Operator = AssignmentOperatorType.Subtract }, null);
if (op == UnaryOperatorType.Increment || op == UnaryOperatorType.PostIncrement) if (op == UnaryOperatorType.Increment || op == UnaryOperatorType.PostIncrement)
newValue = (TypedValue)VisitAssignmentExpression(new AssignmentExpression(unaryOperatorExpression.Expression, AssignmentOperatorType.Add), null); newValue = (TypedValue)VisitAssignmentExpression(new AssignmentExpression(){ Right = unaryOperatorExpression.Expression, Operator = AssignmentOperatorType.Add }, null);
} catch (EvaluateException e) { } catch (EvaluateException e) {
throw new EvaluateException(unaryOperatorExpression, e.Message); throw new EvaluateException(unaryOperatorExpression, e.Message);
} }
@ -644,7 +651,7 @@ namespace ICSharpCode.NRefactory.Visitors
} }
} }
} }
throw new EvaluateException(unaryOperatorExpression, "Can not use the unary operator {0} on type {1}", op.ToString(), value.Type.FullName); throw new EvaluateException(unaryOperatorExpression, "Can not use the unary operator {0} on type {1}", op.ToString(), value.Type.FullName);
} }
@ -658,57 +665,57 @@ namespace ICSharpCode.NRefactory.Visitors
if (argType == typeof(bool)) { if (argType == typeof(bool)) {
bool a = (bool)val; bool a = (bool)val;
switch (op) { switch (op) {
case UnaryOperatorType.Not: return !a; case UnaryOperatorType.Not: return !a;
} }
} }
if (argType == typeof(float)) { if (argType == typeof(float)) {
float a = (float)val; float a = (float)val;
switch (op) { switch (op) {
case UnaryOperatorType.Minus: return -a; case UnaryOperatorType.Minus: return -a;
case UnaryOperatorType.Plus: return +a; case UnaryOperatorType.Plus: return +a;
} }
} }
if (argType == typeof(double)) { if (argType == typeof(double)) {
double a = (double)val; double a = (double)val;
switch (op) { switch (op) {
case UnaryOperatorType.Minus: return -a; case UnaryOperatorType.Minus: return -a;
case UnaryOperatorType.Plus: return +a; case UnaryOperatorType.Plus: return +a;
} }
} }
if (argType == typeof(int)) { if (argType == typeof(int)) {
int a = (int)val; int a = (int)val;
switch (op) { switch (op) {
case UnaryOperatorType.Minus: return -a; case UnaryOperatorType.Minus: return -a;
case UnaryOperatorType.Plus: return +a; case UnaryOperatorType.Plus: return +a;
case UnaryOperatorType.BitNot: return ~a; case UnaryOperatorType.BitNot: return ~a;
} }
} }
if (argType == typeof(uint)) { if (argType == typeof(uint)) {
uint a = (uint)val; uint a = (uint)val;
switch (op) { switch (op) {
case UnaryOperatorType.Plus: return +a; case UnaryOperatorType.Plus: return +a;
case UnaryOperatorType.BitNot: return ~a; case UnaryOperatorType.BitNot: return ~a;
} }
} }
if (argType == typeof(long)) { if (argType == typeof(long)) {
long a = (long)val; long a = (long)val;
switch (op) { switch (op) {
case UnaryOperatorType.Minus: return -a; case UnaryOperatorType.Minus: return -a;
case UnaryOperatorType.Plus: return +a; case UnaryOperatorType.Plus: return +a;
case UnaryOperatorType.BitNot: return ~a; case UnaryOperatorType.BitNot: return ~a;
} }
} }
if (argType == typeof(ulong)) { if (argType == typeof(ulong)) {
ulong a = (ulong)val; ulong a = (ulong)val;
switch (op) { switch (op) {
case UnaryOperatorType.Plus: return +a; case UnaryOperatorType.Plus: return +a;
case UnaryOperatorType.BitNot: return ~a; case UnaryOperatorType.BitNot: return ~a;
} }
} }
} }
@ -793,8 +800,8 @@ namespace ICSharpCode.NRefactory.Visitors
// void operator +(ulong x, long y); // void operator +(ulong x, long y);
// float operator +(float x, float y); // float operator +(float x, float y);
// double operator +(double x, double y); // double operator +(double x, double y);
// //
// &, |, ^, &&, || // &, |, ^, &&, ||
// ==, != // ==, !=
// bool operator &(bool x, bool y); // bool operator &(bool x, bool y);
@ -838,9 +845,9 @@ namespace ICSharpCode.NRefactory.Visitors
string a = (string)left; string a = (string)left;
string b = (string)right; string b = (string)right;
switch (op) { switch (op) {
case BinaryOperatorType.Equality: return a == b; case BinaryOperatorType.Equality: return a == b;
case BinaryOperatorType.InEquality: return a != b; case BinaryOperatorType.InEquality: return a != b;
case BinaryOperatorType.Add: return a + b; case BinaryOperatorType.Add: return a + b;
} }
} }
@ -848,13 +855,13 @@ namespace ICSharpCode.NRefactory.Visitors
bool a = (bool)left; bool a = (bool)left;
bool b = (bool)right; bool b = (bool)right;
switch (op) { switch (op) {
case BinaryOperatorType.Equality: return a == b; case BinaryOperatorType.Equality: return a == b;
case BinaryOperatorType.InEquality: return a != b; case BinaryOperatorType.InEquality: return a != b;
case BinaryOperatorType.ExclusiveOr: return a ^ b; case BinaryOperatorType.ExclusiveOr: return a ^ b;
case BinaryOperatorType.BitwiseAnd: return a & b; case BinaryOperatorType.BitwiseAnd: return a & b;
case BinaryOperatorType.BitwiseOr: return a | b; case BinaryOperatorType.BitwiseOr: return a | b;
case BinaryOperatorType.ConditionalAnd: return a && b; case BinaryOperatorType.ConditionalAnd: return a && b;
case BinaryOperatorType.ConditionalOr: return a || b; case BinaryOperatorType.ConditionalOr: return a || b;
} }
} }
@ -862,18 +869,18 @@ namespace ICSharpCode.NRefactory.Visitors
float a = (float)left; float a = (float)left;
float b = (float)right; float b = (float)right;
switch (op) { switch (op) {
case BinaryOperatorType.GreaterThan: return a > b; case BinaryOperatorType.GreaterThan: return a > b;
case BinaryOperatorType.GreaterThanOrEqual: return a >= b; case BinaryOperatorType.GreaterThanOrEqual: return a >= b;
case BinaryOperatorType.Equality: return a == b; case BinaryOperatorType.Equality: return a == b;
case BinaryOperatorType.InEquality: return a != b; case BinaryOperatorType.InEquality: return a != b;
case BinaryOperatorType.LessThan: return a < b; case BinaryOperatorType.LessThan: return a < b;
case BinaryOperatorType.LessThanOrEqual: return a <= b; case BinaryOperatorType.LessThanOrEqual: return a <= b;
case BinaryOperatorType.Add: return a + b; case BinaryOperatorType.Add: return a + b;
case BinaryOperatorType.Subtract: return a - b; case BinaryOperatorType.Subtract: return a - b;
case BinaryOperatorType.Multiply: return a * b; case BinaryOperatorType.Multiply: return a * b;
case BinaryOperatorType.Divide: return a / b; case BinaryOperatorType.Divide: return a / b;
case BinaryOperatorType.Modulus: return a % b; case BinaryOperatorType.Modulus: return a % b;
} }
} }
@ -881,129 +888,129 @@ namespace ICSharpCode.NRefactory.Visitors
double a = (double)left; double a = (double)left;
double b = (double)right; double b = (double)right;
switch (op) { switch (op) {
case BinaryOperatorType.GreaterThan: return a > b; case BinaryOperatorType.GreaterThan: return a > b;
case BinaryOperatorType.GreaterThanOrEqual: return a >= b; case BinaryOperatorType.GreaterThanOrEqual: return a >= b;
case BinaryOperatorType.Equality: return a == b; case BinaryOperatorType.Equality: return a == b;
case BinaryOperatorType.InEquality: return a != b; case BinaryOperatorType.InEquality: return a != b;
case BinaryOperatorType.LessThan: return a < b; case BinaryOperatorType.LessThan: return a < b;
case BinaryOperatorType.LessThanOrEqual: return a <= b; case BinaryOperatorType.LessThanOrEqual: return a <= b;
case BinaryOperatorType.Add: return a + b; case BinaryOperatorType.Add: return a + b;
case BinaryOperatorType.Subtract: return a - b; case BinaryOperatorType.Subtract: return a - b;
case BinaryOperatorType.Multiply: return a * b; case BinaryOperatorType.Multiply: return a * b;
case BinaryOperatorType.Divide: return a / b; case BinaryOperatorType.Divide: return a / b;
case BinaryOperatorType.Modulus: return a % b; case BinaryOperatorType.Modulus: return a % b;
} }
} }
if (argTypes == typeof(int)) { if (argTypes == typeof(int)) {
switch (op) { switch (op) {
case BinaryOperatorType.ShiftLeft: return (int)left << (int)right; case BinaryOperatorType.ShiftLeft: return (int)left << (int)right;
case BinaryOperatorType.ShiftRight: return (int)left >> (int)right; case BinaryOperatorType.ShiftRight: return (int)left >> (int)right;
} }
int a = (int)left; int a = (int)left;
int b = (int)right; int b = (int)right;
switch (op) { switch (op) {
case BinaryOperatorType.BitwiseAnd: return a & b; case BinaryOperatorType.BitwiseAnd: return a & b;
case BinaryOperatorType.BitwiseOr: return a | b; case BinaryOperatorType.BitwiseOr: return a | b;
case BinaryOperatorType.ExclusiveOr: return a ^ b; case BinaryOperatorType.ExclusiveOr: return a ^ b;
case BinaryOperatorType.GreaterThan: return a > b; case BinaryOperatorType.GreaterThan: return a > b;
case BinaryOperatorType.GreaterThanOrEqual: return a >= b; case BinaryOperatorType.GreaterThanOrEqual: return a >= b;
case BinaryOperatorType.Equality: return a == b; case BinaryOperatorType.Equality: return a == b;
case BinaryOperatorType.InEquality: return a != b; case BinaryOperatorType.InEquality: return a != b;
case BinaryOperatorType.LessThan: return a < b; case BinaryOperatorType.LessThan: return a < b;
case BinaryOperatorType.LessThanOrEqual: return a <= b; case BinaryOperatorType.LessThanOrEqual: return a <= b;
case BinaryOperatorType.Add: return a + b; case BinaryOperatorType.Add: return a + b;
case BinaryOperatorType.Subtract: return a - b; case BinaryOperatorType.Subtract: return a - b;
case BinaryOperatorType.Multiply: return a * b; case BinaryOperatorType.Multiply: return a * b;
case BinaryOperatorType.Divide: return a / b; case BinaryOperatorType.Divide: return a / b;
case BinaryOperatorType.Modulus: return a % b; case BinaryOperatorType.Modulus: return a % b;
} }
} }
if (argTypes == typeof(uint)) { if (argTypes == typeof(uint)) {
switch (op) { switch (op) {
case BinaryOperatorType.ShiftLeft: return (uint)left << (int)right; case BinaryOperatorType.ShiftLeft: return (uint)left << (int)right;
case BinaryOperatorType.ShiftRight: return (uint)left >> (int)right; case BinaryOperatorType.ShiftRight: return (uint)left >> (int)right;
} }
uint a = (uint)left; uint a = (uint)left;
uint b = (uint)right; uint b = (uint)right;
switch (op) { switch (op) {
case BinaryOperatorType.BitwiseAnd: return a & b; case BinaryOperatorType.BitwiseAnd: return a & b;
case BinaryOperatorType.BitwiseOr: return a | b; case BinaryOperatorType.BitwiseOr: return a | b;
case BinaryOperatorType.ExclusiveOr: return a ^ b; case BinaryOperatorType.ExclusiveOr: return a ^ b;
case BinaryOperatorType.GreaterThan: return a > b; case BinaryOperatorType.GreaterThan: return a > b;
case BinaryOperatorType.GreaterThanOrEqual: return a >= b; case BinaryOperatorType.GreaterThanOrEqual: return a >= b;
case BinaryOperatorType.Equality: return a == b; case BinaryOperatorType.Equality: return a == b;
case BinaryOperatorType.InEquality: return a != b; case BinaryOperatorType.InEquality: return a != b;
case BinaryOperatorType.LessThan: return a < b; case BinaryOperatorType.LessThan: return a < b;
case BinaryOperatorType.LessThanOrEqual: return a <= b; case BinaryOperatorType.LessThanOrEqual: return a <= b;
case BinaryOperatorType.Add: return a + b; case BinaryOperatorType.Add: return a + b;
case BinaryOperatorType.Subtract: return a - b; case BinaryOperatorType.Subtract: return a - b;
case BinaryOperatorType.Multiply: return a * b; case BinaryOperatorType.Multiply: return a * b;
case BinaryOperatorType.Divide: return a / b; case BinaryOperatorType.Divide: return a / b;
case BinaryOperatorType.Modulus: return a % b; case BinaryOperatorType.Modulus: return a % b;
} }
} }
if (argTypes == typeof(long)) { if (argTypes == typeof(long)) {
switch (op) { switch (op) {
case BinaryOperatorType.ShiftLeft: return (long)left << (int)right; case BinaryOperatorType.ShiftLeft: return (long)left << (int)right;
case BinaryOperatorType.ShiftRight: return (long)left >> (int)right; case BinaryOperatorType.ShiftRight: return (long)left >> (int)right;
} }
long a = (long)left; long a = (long)left;
long b = (long)right; long b = (long)right;
switch (op) { switch (op) {
case BinaryOperatorType.BitwiseAnd: return a & b; case BinaryOperatorType.BitwiseAnd: return a & b;
case BinaryOperatorType.BitwiseOr: return a | b; case BinaryOperatorType.BitwiseOr: return a | b;
case BinaryOperatorType.ExclusiveOr: return a ^ b; case BinaryOperatorType.ExclusiveOr: return a ^ b;
case BinaryOperatorType.GreaterThan: return a > b; case BinaryOperatorType.GreaterThan: return a > b;
case BinaryOperatorType.GreaterThanOrEqual: return a >= b; case BinaryOperatorType.GreaterThanOrEqual: return a >= b;
case BinaryOperatorType.Equality: return a == b; case BinaryOperatorType.Equality: return a == b;
case BinaryOperatorType.InEquality: return a != b; case BinaryOperatorType.InEquality: return a != b;
case BinaryOperatorType.LessThan: return a < b; case BinaryOperatorType.LessThan: return a < b;
case BinaryOperatorType.LessThanOrEqual: return a <= b; case BinaryOperatorType.LessThanOrEqual: return a <= b;
case BinaryOperatorType.Add: return a + b; case BinaryOperatorType.Add: return a + b;
case BinaryOperatorType.Subtract: return a - b; case BinaryOperatorType.Subtract: return a - b;
case BinaryOperatorType.Multiply: return a * b; case BinaryOperatorType.Multiply: return a * b;
case BinaryOperatorType.Divide: return a / b; case BinaryOperatorType.Divide: return a / b;
case BinaryOperatorType.Modulus: return a % b; case BinaryOperatorType.Modulus: return a % b;
} }
} }
if (argTypes == typeof(ulong)) { if (argTypes == typeof(ulong)) {
switch (op) { switch (op) {
case BinaryOperatorType.ShiftLeft: return (ulong)left << (int)right; case BinaryOperatorType.ShiftLeft: return (ulong)left << (int)right;
case BinaryOperatorType.ShiftRight: return (ulong)left >> (int)right; case BinaryOperatorType.ShiftRight: return (ulong)left >> (int)right;
} }
ulong a = (ulong)left; ulong a = (ulong)left;
ulong b = (ulong)right; ulong b = (ulong)right;
switch (op) { switch (op) {
case BinaryOperatorType.BitwiseAnd: return a & b; case BinaryOperatorType.BitwiseAnd: return a & b;
case BinaryOperatorType.BitwiseOr: return a | b; case BinaryOperatorType.BitwiseOr: return a | b;
case BinaryOperatorType.ExclusiveOr: return a ^ b; case BinaryOperatorType.ExclusiveOr: return a ^ b;
case BinaryOperatorType.GreaterThan: return a > b; case BinaryOperatorType.GreaterThan: return a > b;
case BinaryOperatorType.GreaterThanOrEqual: return a >= b; case BinaryOperatorType.GreaterThanOrEqual: return a >= b;
case BinaryOperatorType.Equality: return a == b; case BinaryOperatorType.Equality: return a == b;
case BinaryOperatorType.InEquality: return a != b; case BinaryOperatorType.InEquality: return a != b;
case BinaryOperatorType.LessThan: return a < b; case BinaryOperatorType.LessThan: return a < b;
case BinaryOperatorType.LessThanOrEqual: return a <= b; case BinaryOperatorType.LessThanOrEqual: return a <= b;
case BinaryOperatorType.Add: return a + b; case BinaryOperatorType.Add: return a + b;
case BinaryOperatorType.Subtract: return a - b; case BinaryOperatorType.Subtract: return a - b;
case BinaryOperatorType.Multiply: return a * b; case BinaryOperatorType.Multiply: return a * b;
case BinaryOperatorType.Divide: return a / b; case BinaryOperatorType.Divide: return a / b;
case BinaryOperatorType.Modulus: return a % b; case BinaryOperatorType.Modulus: return a % b;
} }
} }
return null; return null;
} }
} }

1
Debugger/ILSpy.Debugger/AvalonEdit/IconBarMargin.cs

@ -25,6 +25,7 @@ using System.Windows.Media;
using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Rendering; using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.AvalonEdit.Utils; using ICSharpCode.AvalonEdit.Utils;
using ICSharpCode.Decompiler.Disassembler;
using ILSpy.Debugger.Bookmarks; using ILSpy.Debugger.Bookmarks;
using ILSpy.Debugger.Services; using ILSpy.Debugger.Services;
using Mono.Cecil; using Mono.Cecil;

2
Debugger/ILSpy.Debugger/Bookmarks/BookmarkManager.cs

@ -119,7 +119,7 @@ namespace ILSpy.Debugger.Bookmarks
} }
} }
// no bookmark at that line: create a new bookmark // no bookmark at that line: create a new bookmark
BookmarkManager.AddMark(bookmarkFactory(new AstLocation(0, line))); BookmarkManager.AddMark(bookmarkFactory(new AstLocation(line, 0)));
} }
public static event BookmarkEventHandler Removed; public static event BookmarkEventHandler Removed;

6
Debugger/ILSpy.Debugger/Models/TreeModel/ChildNodesOfObject.cs

@ -97,11 +97,7 @@ namespace ILSpy.Debugger.Models.TreeModel
public static IEnumerable<TreeNode> LazyGetItemsOfIList(Expression targetObject) public static IEnumerable<TreeNode> LazyGetItemsOfIList(Expression targetObject)
{ {
// This is needed for expanding IEnumerable<T> // This is needed for expanding IEnumerable<T>
targetObject = new CastExpression( targetObject = new CastExpression() { Expression = targetObject, Type = new SimpleType() { Identifier = typeof(IList).FullName } };
new TypeReference(typeof(IList).FullName),
targetObject,
CastType.Cast
);
int count = 0; int count = 0;
GetValueException error = null; GetValueException error = null;
try { try {

1
Debugger/ILSpy.Debugger/Models/TreeModel/StackFrameNode.cs

@ -4,6 +4,7 @@ using System.Collections.Generic;
using Debugger; using Debugger;
using Debugger.MetaData; using Debugger.MetaData;
using ICSharpCode.NRefactory.Ast; using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory.CSharp;
namespace ILSpy.Debugger.Models.TreeModel namespace ILSpy.Debugger.Models.TreeModel
{ {

4
Debugger/ILSpy.Debugger/Services/Debugger/DebuggerHelper.cs

@ -27,8 +27,8 @@ namespace ILSpy.Debugger.Services.Debugger
listType = DebugType.CreateFromType(itemType.AppDomain, typeof(System.Collections.Generic.List<>), itemType); listType = DebugType.CreateFromType(itemType.AppDomain, typeof(System.Collections.Generic.List<>), itemType);
var iEnumerableType = DebugType.CreateFromType(itemType.AppDomain, typeof(IEnumerable<>), itemType); var iEnumerableType = DebugType.CreateFromType(itemType.AppDomain, typeof(IEnumerable<>), itemType);
// explicitely cast the variable to IEnumerable<T>, where T is itemType // explicitely cast the variable to IEnumerable<T>, where T is itemType
Expression iEnumerableVariableExplicitCast = new CastExpression(iEnumerableType.GetTypeReference() , iEnumerableVariable, CastType.Cast); Expression iEnumerableVariableExplicitCast = new CastExpression { Expression = iEnumerableVariable , Type = iEnumerableType.GetTypeReference() };
return new ObjectCreateExpression(listType.GetTypeReference(), iEnumerableVariableExplicitCast.ToList()); return new ObjectCreateExpression() { Type = listType.GetTypeReference(), Arguments = iEnumerableVariableExplicitCast.ToList() };
} }
/// <summary> /// <summary>

4
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/BinaryOperatorExpression.cs

@ -167,6 +167,8 @@ namespace ICSharpCode.NRefactory.CSharp
ShiftRight, ShiftRight,
/// <summary>left ?? right</summary> /// <summary>left ?? right</summary>
NullCoalescing NullCoalescing,
None
} }
} }

Loading…
Cancel
Save