[fix] 修复计算桥接函数未考虑到泛型类的成员函数中可能包含Native2Manager调用

main
walon 2023-07-12 23:09:58 +08:00
parent 52bab856ed
commit 679c21da43
3 changed files with 5 additions and 23 deletions

View File

@ -93,6 +93,8 @@ namespace HybridCLR.Editor.Meta
case ElementType.SZArray: return corTypes.Object;
case ElementType.Array: return corTypes.Object;
case ElementType.ValueType: return typeSig;
case ElementType.Var:
case ElementType.MVar:
case ElementType.Class: return corTypes.Object;
case ElementType.GenericInst:
{

View File

@ -22,15 +22,6 @@ namespace HybridCLR.Editor.Meta
public void WalkMethod(MethodDef method, List<TypeSig> klassGenericInst, List<TypeSig> methodGenericInst)
{
if (klassGenericInst != null || methodGenericInst != null)
{
//var typeSig = klassGenericInst != null ? new GenericInstSig(method.DeclaringType.ToTypeSig().ToClassOrValueTypeSig(), klassGenericInst) : method.DeclaringType?.ToTypeSig();
//Debug.Log($"== walk generic method {typeSig}::{method.Name} {method.MethodSig}");
}
else
{
//Debug.Log($"== walk not geneeric method:{method}");
}
var ctx = new GenericArgumentContext(klassGenericInst, methodGenericInst);
if (_methodEffectInsts.TryGetValue(method, out var effectInsts))

View File

@ -149,23 +149,16 @@ namespace HybridCLR.Editor.MethodBridge
for (uint rid = 1, n = ass.Metadata.TablesStream.TypeSpecTable.Rows; rid <= n; rid++)
{
var ts = ass.ResolveTypeSpec(rid);
if (!ts.ContainsGenericParameter)
var cs = GenericClass.ResolveClass(ts, null)?.ToGenericShare();
if (cs != null)
{
var cs = GenericClass.ResolveClass(ts, null)?.ToGenericShare();
if (cs != null)
{
TryAddAndWalkGenericType(cs);
}
TryAddAndWalkGenericType(cs);
}
}
for (uint rid = 1, n = ass.Metadata.TablesStream.MethodSpecTable.Rows; rid <= n; rid++)
{
var ms = ass.ResolveMethodSpec(rid);
if(ms.DeclaringType.ContainsGenericParameter || ms.GenericInstMethodSig.ContainsGenericParameter)
{
continue;
}
var gm = GenericMethod.ResolveMethod(ms, null)?.ToGenericShare();
if (gm == null)
{
@ -176,10 +169,6 @@ namespace HybridCLR.Editor.MethodBridge
{
_newMethods.Add(gm);
}
//if (gm.KlassInst != null)
//{
// TryAddAndWalkGenericType(new GenericClass(gm.Method.DeclaringType, gm.KlassInst));
//}
}
}
Debug.Log($"PostPrepare allMethods:{_notGenericMethods.Count} newMethods:{_newMethods.Count}");