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

github.com/mono/debugger-libs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornosami <jasonimison@gmail.com>2022-10-24 19:38:45 +0300
committernosami <jasonimison@gmail.com>2022-10-25 13:44:29 +0300
commit2bc2c4fcc1ae47b1da5b54005798c3d17b777388 (patch)
tree3f41fa42f349df00a7861800bf9f184deefd6d3d /Mono.Debugging
parent474ca36ee1c463c495c9dace94d90dd4ac52d8c6 (diff)
Fix nested generic type evaluation
Diffstat (limited to 'Mono.Debugging')
-rw-r--r--Mono.Debugging/Mono.Debugging.Evaluation/LambdaBodyOutputVisitor.cs3
-rw-r--r--Mono.Debugging/Mono.Debugging.Evaluation/NRefactoryExpressionEvaluatorVisitor.cs83
2 files changed, 40 insertions, 46 deletions
diff --git a/Mono.Debugging/Mono.Debugging.Evaluation/LambdaBodyOutputVisitor.cs b/Mono.Debugging/Mono.Debugging.Evaluation/LambdaBodyOutputVisitor.cs
index 8c27de3..2e98ef8 100644
--- a/Mono.Debugging/Mono.Debugging.Evaluation/LambdaBodyOutputVisitor.cs
+++ b/Mono.Debugging/Mono.Debugging.Evaluation/LambdaBodyOutputVisitor.cs
@@ -293,7 +293,8 @@ namespace Mono.Debugging.Evaluation
public override void DefaultVisit (SyntaxNode node)
{
- throw NotSupportedToConsistency ();
+ if(!(node is MemberAccessExpressionSyntax))
+ throw NotSupportedToConsistency();
}
#endregion
}
diff --git a/Mono.Debugging/Mono.Debugging.Evaluation/NRefactoryExpressionEvaluatorVisitor.cs b/Mono.Debugging/Mono.Debugging.Evaluation/NRefactoryExpressionEvaluatorVisitor.cs
index ef69199..befdb54 100644
--- a/Mono.Debugging/Mono.Debugging.Evaluation/NRefactoryExpressionEvaluatorVisitor.cs
+++ b/Mono.Debugging/Mono.Debugging.Evaluation/NRefactoryExpressionEvaluatorVisitor.cs
@@ -832,7 +832,8 @@ namespace Mono.Debugging.Evaluation
throw ParseError (message);
}
- throw ParseError ("Unknown identifier: {0}", name);
+ // Assume a namespace
+ return new NamespaceValueReference(ctx, name);
}
public override ValueReference VisitElementAccessExpression (ElementAccessExpressionSyntax node)
@@ -1045,42 +1046,42 @@ namespace Mono.Debugging.Evaluation
public override ValueReference VisitMemberAccessExpression (MemberAccessExpressionSyntax node)
{
if (node.Name is GenericNameSyntax gns) {
- object[] typeArgs = new object[gns.TypeArgumentList.Arguments.Count];
+ var expr = Visit (node.Expression);
+
+ if (expr is TypeValueReference tvr && node.Expression is GenericNameSyntax gnsOuter) {
+ // Thing<string>.Done<int> is
+ // Thing`1.Done`1 with type arguments System.String and System.Int32
+ // Thing`1 is node.Expression
+ // Done`1 is node.Name
+ var outer = MakeGenericTypeName (gnsOuter, gnsOuter.Identifier.ValueText);
+
+ var typeArgsOuter = GetGenericTypeArgs(gnsOuter);
+ var inner = MakeGenericTypeName(gns, gns.Identifier.ValueText);
+ var typeArgsInner = GetGenericTypeArgs(gns);
+
+ string nestedTypeName = $"{outer}.{inner}";
+ var nestedType = ctx.Adapter.GetType(ctx, nestedTypeName, typeArgsOuter.Concat(typeArgsInner).ToArray());
+ return new TypeValueReference(ctx, nestedType);
- for (var i = 0; i < gns.TypeArgumentList.Arguments.Count; i++) {
- var typeArg = Visit(gns.TypeArgumentList.Arguments[i]);
- typeArgs[i] = typeArg.Type;
}
- string typeName = $"{ResolveTypeName(node)}`{gns.TypeArgumentList.Arguments.Count}";
- var type1 = ctx.Adapter.GetType(ctx, typeName, typeArgs);
- return new TypeValueReference(ctx, type1);
+ var typeArgs = GetGenericTypeArgs (gns);
+ string typeName = $"{ResolveTypeName (node)}`{gns.TypeArgumentList.Arguments.Count}";
+
+ var type1 = ctx.Adapter.GetType (ctx, typeName, typeArgs);
+ return new TypeValueReference (ctx, type1);
}
- if (node.Name is IdentifierNameSyntax ins)
+ if (node.Name is IdentifierNameSyntax)
{
- //var type = this.Visit(ins);
var name = ResolveTypeName(node);
var type = ctx.Adapter.GetType(ctx, name);
if (type != null)
return new TypeValueReference(ctx, type);
-
- if (node.Expression is MemberAccessExpressionSyntax)
- return new NamespaceValueReference(ctx, name);
}
var target = Visit (node.Expression);
- //if (target is TypeValueReference) {
-
- // var name = ResolveTypeName(node);
- // var type = ctx.Adapter.GetType(ctx, name);
-
- // if (type != null)
- // return new TypeValueReference(ctx, type);
- // // Assume it is a namespace
- // return new NamespaceValueReference(ctx, name);
- //}
var member = target.GetChild(node.Name.Identifier.ValueText, ctx.Options);
if (member != null)
@@ -1094,6 +1095,18 @@ namespace Mono.Debugging.Evaluation
}
+ object [] GetGenericTypeArgs (GenericNameSyntax gns)
+ {
+ object [] typeArgs = new object [gns.TypeArgumentList.Arguments.Count];
+
+ for (var i = 0; i < gns.TypeArgumentList.Arguments.Count; i++) {
+ var typeArg = Visit (gns.TypeArgumentList.Arguments [i]);
+ typeArgs [i] = typeArg.Type;
+ }
+
+ return typeArgs;
+ }
+
public override ValueReference VisitLiteralExpression (LiteralExpressionSyntax node)
{
if (node.Kind() == SyntaxKind.NullLiteralExpression)
@@ -1150,23 +1163,6 @@ namespace Mono.Debugging.Evaluation
return LiteralValueReference.CreateTargetObjectLiteral (ctx, name, result);
}
- //public ValueReference VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression)
- //{
- // var type = typeReferenceExpression.Type.Resolve(ctx);
-
- // if (type != null)
- // {
- // ctx.Adapter.ForceLoadType(ctx, type);
-
- // return new TypeValueReference(ctx, type);
- // }
-
- // var name = ResolveTypeName(typeReferenceExpression.Type);
-
- // // Assume it is a namespace.
- // return new NamespaceValueReference(ctx, name);
- //}
-
public override ValueReference VisitPostfixUnaryExpression (PostfixUnaryExpressionSyntax node)
{
var vref = Visit (node.Operand);
@@ -1315,7 +1311,8 @@ namespace Mono.Debugging.Evaluation
if (node.Parent is QualifiedNameSyntax qns2 && qns2.Left is QualifiedNameSyntax left)
return $"{left}.{typeName}`{node.TypeArgumentList.Arguments.Count}";
- return typeName;
+ return $"{typeName}`{node.TypeArgumentList.Arguments.Count}";
+;
}
public override ValueReference VisitQualifiedName(QualifiedNameSyntax node)
@@ -1333,10 +1330,6 @@ namespace Mono.Debugging.Evaluation
{
return LiteralValueReference.CreateObjectLiteral(ctx, expression, syntax.Token.Value);
}
- //if (node is RangeExpressionSyntax res)
- //{
-
- // }
throw NotSupported();
}
#endregion