未验证 提交 37e9d4b1 编写于 作者: Z Zoltan Varga 提交者: GitHub

[mono] Log a warning instead of crashing when encountering function pointer...

[mono] Log a warning instead of crashing when encountering function pointer types in the wasm pinvoke generator. (#56837)
上级 c16cb0ed
......@@ -92,12 +92,21 @@ private void EmitPInvokeTable(StreamWriter w, Dictionary<string, string> modules
foreach (var pinvoke in pinvokes.OrderBy(l => l.EntryPoint))
{
if (modules.ContainsKey(pinvoke.Module)) {
var decl = GenPInvokeDecl(pinvoke);
if (decls.Contains(decl))
continue;
try
{
var decl = GenPInvokeDecl(pinvoke);
if (decls.Contains(decl))
continue;
w.WriteLine(decl);
decls.Add(decl);
w.WriteLine(decl);
decls.Add(decl);
}
catch (NotSupportedException)
{
// See the FIXME in GenPInvokeDecl
Log.LogWarning($"Cannot handle function pointer arguments/return value in pinvoke method '{pinvoke.Method}' in type '{pinvoke.Method.DeclaringType}'.");
pinvoke.Skip = true;
}
}
}
......@@ -107,7 +116,7 @@ private void EmitPInvokeTable(StreamWriter w, Dictionary<string, string> modules
w.WriteLine("static PinvokeImport " + symbol + " [] = {");
var assemblies_pinvokes = pinvokes.
Where(l => l.Module == module).
Where(l => l.Module == module && !l.Skip).
OrderBy(l => l.EntryPoint).
GroupBy(d => d.EntryPoint).
Select (l => "{\"" + l.Key + "\", " + l.Key + "}, // " + string.Join (", ", l.Select(c => c.Method.DeclaringType!.Module!.Assembly!.GetName ()!.Name!).Distinct()));
......@@ -340,6 +349,7 @@ public PInvoke(string entryPoint, string module, MethodInfo method)
public string EntryPoint;
public string Module;
public MethodInfo Method;
public bool Skip;
}
internal class PInvokeCallback
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册