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

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/sdks
diff options
context:
space:
mode:
authorLarry Ewing <lewing@microsoft.com>2020-06-19 20:14:51 +0300
committerGitHub <noreply@github.com>2020-06-19 20:14:51 +0300
commit9954695c4c4e76a37753aec796b1971230315c22 (patch)
tree25b8d3bf891464cf50ab0d0c774b4168c5824ac9 /sdks
parent99794efa11b8ab583161044e7bdaeaceefde98e8 (diff)
assume double numbers (#19714)
Diffstat (limited to 'sdks')
-rw-r--r--sdks/wasm/Mono.WebAssembly.DebuggerProxy/EvaluateExpression.cs46
1 files changed, 31 insertions, 15 deletions
diff --git a/sdks/wasm/Mono.WebAssembly.DebuggerProxy/EvaluateExpression.cs b/sdks/wasm/Mono.WebAssembly.DebuggerProxy/EvaluateExpression.cs
index fb7e776ed90..7bcf6f81174 100644
--- a/sdks/wasm/Mono.WebAssembly.DebuggerProxy/EvaluateExpression.cs
+++ b/sdks/wasm/Mono.WebAssembly.DebuggerProxy/EvaluateExpression.cs
@@ -78,42 +78,58 @@ namespace WebAssembly.Net.Debugging {
if (value == null)
throw new Exception ($"The name {var.Identifier.Text} does not exist in the current context");
- values.Add (ConvertJSToCSharpType (value ["value"] ["value"].ToString (), value ["value"] ["type"].ToString ()));
+ values.Add (ConvertJSToCSharpType (value ["value"]));
var updatedMethod = method.AddParameterListParameters (
SyntaxFactory.Parameter (
SyntaxFactory.Identifier (var.Identifier.Text))
- .WithType (SyntaxFactory.ParseTypeName (GetTypeFullName(value["value"]["type"].ToString()))));
+ .WithType (SyntaxFactory.ParseTypeName (GetTypeFullName(value["value"]))));
root = root.ReplaceNode (method, updatedMethod);
}
syntaxTree = syntaxTree.WithRootAndOptions (root, syntaxTree.Options);
return syntaxTree;
}
- private object ConvertJSToCSharpType (string v, string type)
+ private object ConvertJSToCSharpType (JToken variable)
{
+ var value = variable["value"];
+ var type = variable["type"].Value<string>();
+ var subType = variable["subtype"]?.Value<string>();
+
switch (type) {
- case "number":
- return Convert.ChangeType (v, typeof (int));
- case "string":
- return v;
+ case "string":
+ return value?.Value<string> ();
+ case "number":
+ return value?.Value<double> ();
+ case "boolean":
+ return value?.Value<bool> ();
+ case "object":
+ if (subType == "null")
+ return null;
+ break;
}
-
throw new Exception ($"Evaluate of this datatype {type} not implemented yet");
}
- private string GetTypeFullName (string type)
+ private string GetTypeFullName (JToken variable)
{
+ var type = variable["type"].ToString ();
+ var subType = variable["subtype"]?.Value<string>();
+ object value = ConvertJSToCSharpType (variable);
+
switch (type) {
- case "number":
- return typeof (int).FullName;
- case "string":
- return typeof (string).FullName;
+ case "object": {
+ if (subType == "null")
+ return variable["className"].Value<string>();
+ break;
+ }
+ default:
+ return value.GetType ().FullName;
}
-
throw new Exception ($"Evaluate of this datatype {type} not implemented yet");
}
}
+
static SyntaxNode GetExpressionFromSyntaxTree (SyntaxTree syntaxTree)
{
CompilationUnitSyntax root = syntaxTree.GetCompilationUnitRoot ();
@@ -126,6 +142,7 @@ namespace WebAssembly.Net.Debugging {
ParenthesizedExpressionSyntax expressionParenthesized = expressionMember.Expression as ParenthesizedExpressionSyntax;
return expressionParenthesized.Expression;
}
+
internal static async Task<string> CompileAndRunTheExpression (MonoProxy proxy, MessageId msg_id, int scope_id, string expression, CancellationToken token)
{
FindVariableNMethodCall findVarNMethodCall = new FindVariableNMethodCall ();
@@ -172,7 +189,6 @@ namespace WebAssembly.Net.Debugging {
BindingFlags.Default | BindingFlags.InvokeMethod,
null,
obj,
- //new object [] { 10 }
findVarNMethodCall.values.ToArray ());
retString = ret.ToString ();
}