Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from Ourpalm:master #102

Merged
merged 3 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 57 additions & 54 deletions ILRuntime/Runtime/CLRBinding/BindingCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -725,29 +725,15 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
sb.AppendLine();
}

sb.Append(" app.DelegateManager.RegisterDelegateConvertor<");
sb.Append(realClsName);
sb.AppendLine(">((act) =>");
sb.AppendLine(" {");
sb.Append(" return new ");
sb.Append(realClsName);
sb.Append("((");
first = true;
foreach (var j in miParameters)
if (!realClsName.StartsWith("System.Action<", StringComparison.Ordinal) && !realClsName.StartsWith("System.Func<", StringComparison.Ordinal))
{
if (first)
{
first = false;
}
else
sb.Append(", ");
sb.Append(j.Name);
}
sb.AppendLine(") =>");
sb.AppendLine(" {");
if (mi.ReturnType != typeof(void))
{
sb.Append(" return ((Func<");
sb.Append(" app.DelegateManager.RegisterDelegateConvertor<");
sb.Append(realClsName);
sb.AppendLine(">((act) =>");
sb.AppendLine(" {");
sb.Append(" return new ");
sb.Append(realClsName);
sb.Append("((");
first = true;
foreach (var j in miParameters)
{
Expand All @@ -757,21 +743,54 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
}
else
sb.Append(", ");
j.ParameterType.GetClassName(out paramClsName, out paramRealClsName, out paramIsByRef);
sb.Append(j.Name);
}
sb.AppendLine(") =>");
sb.AppendLine(" {");
if (mi.ReturnType != typeof(void))
{
sb.Append(" return ((Func<");
first = true;
foreach (var j in miParameters)
{
if (first)
{
first = false;
}
else
sb.Append(", ");
j.ParameterType.GetClassName(out paramClsName, out paramRealClsName, out paramIsByRef);
sb.Append(paramRealClsName);
}
if (!first)
sb.Append(", ");
mi.ReturnType.GetClassName(out paramClsName, out paramRealClsName, out paramIsByRef);
sb.Append(paramRealClsName);
sb.Append(">)act)(");
}
if (!first)
sb.Append(", ");
mi.ReturnType.GetClassName(out paramClsName, out paramRealClsName, out paramIsByRef);
sb.Append(paramRealClsName);
sb.Append(">)act)(");
}
else
{
if (miParameters.Length != 0)
sb.Append(" ((Action<");
else
sb.Append(" ((Action");
{
if (miParameters.Length != 0)
sb.Append(" ((Action<");
else
sb.Append(" ((Action");
first = true;
foreach (var j in miParameters)
{
if (first)
{
first = false;
}
else
sb.Append(", ");
j.ParameterType.GetClassName(out paramClsName, out paramRealClsName, out paramIsByRef);
sb.Append(paramRealClsName);
}
if (miParameters.Length != 0)
sb.Append(">)act)(");
else
sb.Append(")act)(");
}
first = true;
foreach (var j in miParameters)
{
Expand All @@ -781,28 +800,12 @@ public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
}
else
sb.Append(", ");
j.ParameterType.GetClassName(out paramClsName, out paramRealClsName, out paramIsByRef);
sb.Append(paramRealClsName);
}
if (miParameters.Length != 0)
sb.Append(">)act)(");
else
sb.Append(")act)(");
}
first = true;
foreach (var j in miParameters)
{
if (first)
{
first = false;
sb.Append(j.Name);
}
else
sb.Append(", ");
sb.Append(j.Name);
sb.AppendLine(");");
sb.AppendLine(" });");
sb.AppendLine(" });");
}
sb.AppendLine(");");
sb.AppendLine(" });");
sb.AppendLine(" });");

sb.AppendLine(" }");
sb.AppendLine(" }");
Expand Down
2 changes: 1 addition & 1 deletion ILRuntime/Runtime/CLRBinding/BindingGeneratorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal static bool ShouldSkipMethod(this Type type, MethodBase i)
}
else
ts = new Type[0];
var prop = type.GetProperty(t[1], ts);
var prop = type.GetProperties().FirstOrDefault(p => p.Name == t[1] && p.GetIndexParameters().Select(pp => pp.ParameterType).SequenceEqual(ts));
if (prop == null)
{
return true;
Expand Down
16 changes: 14 additions & 2 deletions ILRuntime/Runtime/Debugger/DebugService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
#endif
using System.Reflection;

using ILRuntime.Runtime.Enviorment;
#if DEBUG && !DISABLE_ILRUNTIME_DEBUG
using AutoList = System.Collections.Generic.List<object>;
#else
Expand All @@ -26,7 +26,7 @@
public class DebugService
{
BreakPointContext curBreakpoint;
DebuggerServer server;

Check warning on line 29 in ILRuntime/Runtime/Debugger/DebugService.cs

View workflow job for this annotation

GitHub Actions / build

Field 'DebugService.server' is never assigned to, and will always have its default value null

Check warning on line 29 in ILRuntime/Runtime/Debugger/DebugService.cs

View workflow job for this annotation

GitHub Actions / build

Field 'DebugService.server' is never assigned to, and will always have its default value null
Runtime.Enviorment.AppDomain domain;
Dictionary<int, LinkedList<BreakpointInfo>> activeBreakpoints = new Dictionary<int, LinkedList<BreakpointInfo>>();
Dictionary<int, BreakpointInfo> breakpointMapping = new Dictionary<int, BreakpointInfo>();
Expand All @@ -34,7 +34,7 @@
Queue<Tuple<int, int, VariableReference>> pendingEnuming = new Queue<Tuple<int, int, VariableReference>>();
Queue<Tuple<int, int, VariableReference>> pendingIndexing = new Queue<Tuple<int, int, VariableReference>>();
AutoResetEvent evt = new AutoResetEvent(false);
string breakpointParseCode = "void Method() {{ ({0}) }}"; // ()是因为a?b:c会被解析为可空类型a的类型变量声明,加小括号才会解析为条件表达式

Check warning on line 37 in ILRuntime/Runtime/Debugger/DebugService.cs

View workflow job for this annotation

GitHub Actions / build

The field 'DebugService.breakpointParseCode' is assigned but its value is never used

Check warning on line 37 in ILRuntime/Runtime/Debugger/DebugService.cs

View workflow job for this annotation

GitHub Actions / build

The field 'DebugService.breakpointParseCode' is assigned but its value is never used
public UsingInfo[] UsingInfosContext { get; set; }

public Action<string> OnBreakPoint;
Expand Down Expand Up @@ -203,7 +203,19 @@
var addr = *(long*)&arg->Value;
arg = (StackObject*)addr;
}
ILTypeInstance instance = arg->ObjectType != ObjectTypes.Null ? intepreter.Stack.ManagedStack[arg->Value] as ILTypeInstance : null;
ILTypeInstance instance = null;
if (arg->ObjectType != ObjectTypes.Null)
{
var box = intepreter.Stack.ManagedStack[arg->Value];
if (box is ILTypeInstance ilInstance)
{
instance = ilInstance;
}
else if (box is CrossBindingAdaptorType adaptor)
{
instance = adaptor.ILInstance;
}
}
if (instance == null)
return "null";
var fields = instance.Type.TypeDefinition.Fields;
Expand Down
Loading