Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/ILCompiler.Compiler/src/Compiler/TypeExtensions.cs')
-rw-r--r--src/ILCompiler.Compiler/src/Compiler/TypeExtensions.cs27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/ILCompiler.Compiler/src/Compiler/TypeExtensions.cs b/src/ILCompiler.Compiler/src/Compiler/TypeExtensions.cs
index 5cf56d172..99b0de66c 100644
--- a/src/ILCompiler.Compiler/src/Compiler/TypeExtensions.cs
+++ b/src/ILCompiler.Compiler/src/Compiler/TypeExtensions.cs
@@ -31,14 +31,11 @@ namespace ILCompiler
{
if (type.IsArray)
{
- var arrayType = (ArrayType)type;
- TypeDesc elementType = arrayType.ElementType;
- if (arrayType.IsSzArray && !elementType.IsPointer && !elementType.IsFunctionPointer)
- {
- MetadataType arrayShadowType = type.Context.SystemModule.GetKnownType("System", "Array`1");
- return arrayShadowType.MakeInstantiatedType(elementType);
- }
- return type.Context.GetWellKnownType(WellKnownType.Array);
+ if (type.IsArrayTypeWithoutGenericInterfaces())
+ return type.Context.GetWellKnownType(WellKnownType.Array);
+
+ MetadataType arrayShadowType = type.Context.SystemModule.GetKnownType("System", "Array`1");
+ return arrayShadowType.MakeInstantiatedType(((ArrayType)type).ElementType);
}
Debug.Assert(type is DefType);
@@ -183,5 +180,19 @@ namespace ILCompiler
return false;
}
+
+ /// <summary>
+ /// Determines whether an array type does implements the generic collection interfaces. This is the case
+ /// for multi-dimensional arrays, and arrays of pointers.
+ /// </summary>
+ public static bool IsArrayTypeWithoutGenericInterfaces(this TypeDesc type)
+ {
+ if (!type.IsArray)
+ return false;
+
+ var arrayType = (ArrayType)type;
+ TypeDesc elementType = arrayType.ElementType;
+ return type.IsMdArray || elementType.IsPointer || elementType.IsFunctionPointer;
+ }
}
}