Skip to content

Commit

Permalink
Some small fixes
Browse files Browse the repository at this point in the history
* Ldelema, Ldelem, and Stelem have type operands
* Fail for value-type newarr
  • Loading branch information
ds5678 committed Oct 6, 2024
1 parent 7b6c503 commit 3cfe08b
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions Il2CppInterop.Generator/Utils/UnstripTranslator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,6 @@ public static bool TranslateMethod(MethodDefinition original, MethodDefinition t
imports.Module.DefaultImporter.ImportMethod(imports.Il2CppArrayBase_get_Length.Value));
break;

case CilCode.Ldelema:
//This is Il2CppArrayBase<T>.Pointer + index * sizeof(T) but the T is not known because the operand is null.
return false;

case CilCode.Ldelem:
//This is Il2CppArrayBase<T>.set_Item but the T is not known because the operand is null.
return false;

case CilCode.Stelem:
//This is Il2CppArrayBase<T>.set_Item but the T is not known because the operand is null.
return false;

case CilCode.Ldelem_Ref:
//This is Il2CppReferenceArray<T>.get_Item but the T is not known because the operand is null.
return false;
Expand Down Expand Up @@ -286,7 +274,7 @@ public static bool TranslateMethod(MethodDefinition original, MethodDefinition t
imports.Module.DefaultImporter.ImportMethod(imports.Il2CppObjectBase_TryCast.Value.MakeGenericInstanceMethod(targetType)));
instructionMap.Add(bodyInstruction, newInstruction);
}
else if (bodyInstruction.OpCode == OpCodes.Newarr && !targetType.IsValueType)
else if (bodyInstruction.OpCode == OpCodes.Newarr)
{
var newInstruction = targetBuilder.Add(OpCodes.Conv_I8);

Expand All @@ -307,6 +295,21 @@ public static bool TranslateMethod(MethodDefinition original, MethodDefinition t
ReferenceCreator.CreateInstanceMethodReference(".ctor", imports.Module.Void(), il2cppTypeArray, imports.Module.Long())));
instructionMap.Add(bodyInstruction, newInstruction);
}
else if (bodyInstruction.OpCode == OpCodes.Ldelema)
{
// Not implemented
return false;
}
else if (bodyInstruction.OpCode == OpCodes.Ldelem)
{
// Not implemented
return false;
}
else if (bodyInstruction.OpCode == OpCodes.Stelem)
{
// Not implemented
return false;
}
else
{
var newInstruction = targetBuilder.Add(bodyInstruction.OpCode, targetType.ToTypeDefOrRef());
Expand Down

0 comments on commit 3cfe08b

Please sign in to comment.