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

Include lower bounds when making array type signatures #394

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
11 changes: 10 additions & 1 deletion Cpp2IL.Core/Utils/AsmResolver/AsmResolverUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static TypeSignature GetTypeSignatureFromIl2CppType(ModuleDefinition modu
break;
case Il2CppTypeEnum.IL2CPP_TYPE_ARRAY:
ret = GetTypeSignatureFromIl2CppType(module, il2CppType.GetArrayElementType())
.MakeArrayType(il2CppType.GetArrayRank());
.MakeArrayTypeWithLowerBounds(il2CppType.GetArrayRank());
break;
case Il2CppTypeEnum.IL2CPP_TYPE_SZARRAY:
ret = GetTypeSignatureFromIl2CppType(module, il2CppType.GetEncapsulatedType())
Expand Down Expand Up @@ -340,4 +340,13 @@ public static ITypeDefOrRef ImportTypeIfNeeded(this ReferenceImporter importer,
public static bool IsManagedMethodWithBody(this MethodDefinition managedMethod) =>
managedMethod.Managed && !managedMethod.IsAbstract && !managedMethod.IsPInvokeImpl
&& !managedMethod.IsInternalCall && !managedMethod.IsNative && !managedMethod.IsRuntime;

internal static ArrayTypeSignature MakeArrayTypeWithLowerBounds(this TypeSignature elementType, int rank)
{
var result = new ArrayTypeSignature(elementType, rank);
for (var i = 0; i < rank; i++)
result.Dimensions[i] = new ArrayDimension(null, 0);

return result;
}
}
2 changes: 1 addition & 1 deletion Cpp2IL.Core/Utils/AsmResolver/ContextToTypeSignature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static TypeSignature ToTypeSignature(this ByRefTypeAnalysisContext contex

public static TypeSignature ToTypeSignature(this ArrayTypeAnalysisContext context, ModuleDefinition parentModule)
{
return context.ElementType.ToTypeSignature(parentModule).MakeArrayType(context.Rank);
return context.ElementType.ToTypeSignature(parentModule).MakeArrayTypeWithLowerBounds(context.Rank);
}

public static TypeSignature ToTypeSignature(this ParameterAnalysisContext context, ModuleDefinition parentModule)
Expand Down
Loading