Skip to content

Commit c87d233

Browse files
committed
Allow runtime internals to reference value types
1 parent 1c5c455 commit c87d233

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

il2cpp/MethodGenerator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ internal class MethodGenerator
155155
public const string PrefixVMet = "vmet_";
156156
public const string PrefixVFtn = "vftn_";
157157

158-
private readonly GeneratorContext GenContext;
159-
private readonly MethodX CurrMethod;
158+
public readonly GeneratorContext GenContext;
159+
public readonly MethodX CurrMethod;
160160

161161
// 类型栈
162162
private Stack<StackType> TypeStack = new Stack<StackType>();
@@ -890,7 +890,7 @@ private bool GenerateRuntimeImpl(CodePrinter prt)
890890
// throw new NotImplementedException();
891891
}
892892
else
893-
return RuntimeInternals.GenInternalMethod(CurrMethod, prt, GenContext);
893+
return RuntimeInternals.GenInternalMethod(this, prt);
894894

895895
return false;
896896
}
@@ -2996,7 +2996,7 @@ private void RefTypeImpl(TypeX tyX)
29962996
ImplDepends.Add(GenContext.GetTypeName(tyX));
29972997
}
29982998

2999-
private void RefValueTypeImpl(TypeSig tySig)
2999+
public void RefValueTypeImpl(TypeSig tySig)
30003000
{
30013001
if (tySig.IsValueType)
30023002
RefTypeImpl(tySig);

il2cpp/RuntimeInternals.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ namespace il2cpp
55
{
66
internal static class RuntimeInternals
77
{
8-
public static bool GenInternalMethod(MethodX metX, CodePrinter prt, GeneratorContext genContext)
8+
public static bool GenInternalMethod(MethodGenerator metGen, CodePrinter prt)
99
{
10+
MethodX metX = metGen.CurrMethod;
11+
GeneratorContext genContext = metGen.GenContext;
12+
1013
string typeName = metX.DeclType.GetNameKey();
1114
string metName = metX.Def.Name;
1215

@@ -98,6 +101,7 @@ public static bool GenInternalMethod(MethodX metX, CodePrinter prt, GeneratorCon
98101
}
99102
else if (metName == "FastCompareBits")
100103
{
104+
metGen.RefValueTypeImpl(metX.ParamTypes[0].Next);
101105
prt.AppendLine("return IL2CPP_MEMCMP(arg_0, arg_1, sizeof(*arg_0)) == 0 ? 1 : 0;");
102106
return true;
103107
}

0 commit comments

Comments
 (0)