[corlib] GetGenericArguments from reference sources
authorMarek Safar <marek.safar@gmail.com>
Thu, 9 Apr 2015 09:37:33 +0000 (11:37 +0200)
committerMarek Safar <marek.safar@gmail.com>
Thu, 9 Apr 2015 09:38:20 +0000 (11:38 +0200)
external/referencesource
mcs/class/corlib/ReferenceSources/RuntimeType.cs
mcs/class/corlib/ReferenceSources/TypeBuilderInstantiation.cs [new file with mode: 0644]
mcs/class/corlib/System/Environment.cs
mcs/class/corlib/corlib.dll.sources
mono/metadata/appdomain.c
mono/metadata/class-internals.h
mono/metadata/domain.c
mono/metadata/icall-def.h
mono/metadata/icall.c

index a8bf9ebd8c7d32a6ae0c74f8c379cad26eb38c7e..7d6aea73bb44fa0e3fa51221106571b51a3425e5 160000 (submodule)
@@ -1 +1 @@
-Subproject commit a8bf9ebd8c7d32a6ae0c74f8c379cad26eb38c7e
+Subproject commit 7d6aea73bb44fa0e3fa51221106571b51a3425e5
index 3557e77817c6b392af4e19cf509d4d6ee0219264..a2673c348866c13732e8bb43d50474d217519693 100644 (file)
@@ -394,44 +394,6 @@ namespace System
                        return constraints;
                }
 
-               public override Type MakeGenericType (params Type[] typeArguments)
-               {
-                       if (IsUserType)
-                               throw new NotSupportedException ();
-                       if (!IsGenericTypeDefinition)
-                               throw new InvalidOperationException ("not a generic type definition");
-                       if (typeArguments == null)
-                               throw new ArgumentNullException ("typeArguments");
-                       if (GetGenericArguments().Length != typeArguments.Length)
-                               throw new ArgumentException (String.Format ("The type or method has {0} generic parameter(s) but {1} generic argument(s) where provided. A generic argument must be provided for each generic parameter.", GetGenericArguments ().Length, typeArguments.Length), "typeArguments");
-
-                       bool hasUserType = false;
-
-                       Type[] systemTypes = new Type[typeArguments.Length];
-                       for (int i = 0; i < typeArguments.Length; ++i) {
-                               Type t = typeArguments [i];
-                               if (t == null)
-                                       throw new ArgumentNullException ("typeArguments");
-
-                               if (!(t is MonoType))
-                                       hasUserType = true;
-                               systemTypes [i] = t;
-                       }
-
-                       if (hasUserType) {
-#if FULL_AOT_RUNTIME
-                               throw new NotSupportedException ("User types are not supported under full aot");
-#else
-                               return new MonoGenericClass (this, typeArguments);
-#endif
-                       }
-
-                       Type res = MakeGenericType (this, systemTypes);
-                       if (res == null)
-                               throw new TypeLoadException ();
-                       return res;
-               }
-
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                static extern Type MakeGenericType (Type gt, Type [] types);
 
@@ -612,7 +574,7 @@ namespace System
                internal extern string getFullName(bool full_name, bool assembly_qualified);
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               public extern override Type [] GetGenericArguments ();
+               extern Type[] GetGenericArgumentsInternal (bool runtimeArray);
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                extern GenericParameterAttributes GetGenericParameterAttributes ();
diff --git a/mcs/class/corlib/ReferenceSources/TypeBuilderInstantiation.cs b/mcs/class/corlib/ReferenceSources/TypeBuilderInstantiation.cs
new file mode 100644 (file)
index 0000000..9e82664
--- /dev/null
@@ -0,0 +1,14 @@
+namespace System.Reflection.Emit
+{
+       abstract class TypeBuilderInstantiation : TypeInfo
+       {
+               internal static Type MakeGenericType (Type type, Type[] typeArguments)
+               {
+#if FULL_AOT_RUNTIME
+                       throw new NotSupportedException ("User types are not supported under full aot");
+#else
+                       return new MonoGenericClass (type, typeArguments);
+#endif
+               }
+       }
+}
\ No newline at end of file
index ddbd37a5e27b405a9485c8495f309cbec47840cd..96c8dd3da62891f42c3ec418443d8ed705df11e9 100644 (file)
@@ -57,7 +57,7 @@ namespace System {
                 * of icalls, do not require an increment.
                 */
 #pragma warning disable 169
-               private const int mono_corlib_version = 125;
+               private const int mono_corlib_version = 126;
 #pragma warning restore 169
 
                [ComVisible (true)]
index 571c35737889ded572973cb991245c2e3f44dac0..4aef1fb9ff7dc0415da6ed70f256dd51a555b790 100644 (file)
@@ -1130,6 +1130,7 @@ ReferenceSources/MonoRuntimeWorkItem.cs
 ReferenceSources/MethodBase.cs
 ReferenceSources/RuntimeHandles.cs
 ReferenceSources/CompareInfo.cs
+ReferenceSources/TypeBuilderInstantiation.cs
 
 ../../../external/referencesource/mscorlib/system/__filters.cs
 ../../../external/referencesource/mscorlib/system/__hresults.cs
index b959cb96b044c12c25bc6400171af99f58e92842..b7bf90d203cdfb43c632ced3d3da709fee941e96 100644 (file)
@@ -78,7 +78,7 @@
  * Changes which are already detected at runtime, like the addition
  * of icalls, do not require an increment.
  */
-#define MONO_CORLIB_VERSION 125
+#define MONO_CORLIB_VERSION 126
 
 typedef struct
 {
index 36080792d107ea526d24586b69dd865113d6cf60..f69a2e7685ae2c8323ac887b3227f550ae962df3 100644 (file)
@@ -1091,6 +1091,7 @@ typedef struct {
        MonoClass *methodhandle_class;
        MonoClass *systemtype_class;
        MonoClass *monotype_class;
+       MonoClass *runtimetype_class;
        MonoClass *exception_class;
        MonoClass *threadabortexception_class;
        MonoClass *thread_class;
index 801d58e41629f0b6beefca40b87d97271b9d2ba1..6bd4f86a1b44bd31e7f9cdd752b6c8ef06549a0c 100755 (executable)
@@ -716,6 +716,10 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *
                 mono_defaults.corlib, "System", "MonoType");
        g_assert (mono_defaults.monotype_class != 0);
 
+       mono_defaults.runtimetype_class = mono_class_from_name (
+                mono_defaults.corlib, "System", "RuntimeType");
+       g_assert (mono_defaults.runtimetype_class != 0);
+
        mono_defaults.exception_class = mono_class_from_name (
                 mono_defaults.corlib, "System", "Exception");
        g_assert (mono_defaults.exception_class != 0);
index 87bb85e566447bb2dec2f28fb270b6035a4fb0e1..e7e661190d1772cbf9a3f68a4c8f1a9611870d01 100644 (file)
@@ -733,7 +733,7 @@ ICALL(RT_1, "CreateInstanceInternal", ves_icall_System_Activator_CreateInstanceI
 ICALL(RT_2, "GetConstructors_internal", ves_icall_Type_GetConstructors_internal)
 ICALL(RT_3, "GetEvents_internal", ves_icall_Type_GetEvents_internal)
 ICALL(RT_5, "GetFields_internal", ves_icall_Type_GetFields_internal)
-ICALL(RT_6, "GetGenericArguments", ves_icall_MonoType_GetGenericArguments)
+ICALL(RT_6, "GetGenericArgumentsInternal", ves_icall_MonoType_GetGenericArguments)
 ICALL(RT_7, "GetGenericParameterAttributes", ves_icall_Type_GetGenericParameterAttributes)
 ICALL(RT_8, "GetGenericParameterConstraints_impl", ves_icall_Type_GetGenericParameterConstraints)
 ICALL(RT_9, "GetGenericParameterPosition", ves_icall_Type_GetGenericParameterPosition)
index 8f0f4dfbdabcef0ca60ff54d22609239eae90a33..1132dbfeb0f4eba101f555610b72279e79141cbd 100644 (file)
@@ -2293,31 +2293,38 @@ ves_icall_MonoType_GetArrayRank (MonoReflectionType *type)
        return class->rank;
 }
 
+static MonoArray*
+create_type_array (MonoDomain *domain, MonoBoolean runtimeTypeArray, int count)
+{
+       MonoArray *res;
+       res = mono_array_new (domain, runtimeTypeArray ? mono_defaults.runtimetype_class : mono_defaults.systemtype_class, count);
+       return res;
+}
+
 ICALL_EXPORT MonoArray*
-ves_icall_MonoType_GetGenericArguments (MonoReflectionType *type)
+ves_icall_MonoType_GetGenericArguments (MonoReflectionType *type, MonoBoolean runtimeTypeArray)
 {
        MonoArray *res;
        MonoClass *klass, *pklass;
        MonoDomain *domain = mono_object_domain (type);
-       MonoVTable *array_vtable = mono_class_vtable_full (domain, mono_array_class_get_cached (mono_defaults.systemtype_class, 1), TRUE);
        int i;
 
        klass = mono_class_from_mono_type (type->type);
 
        if (klass->generic_container) {
                MonoGenericContainer *container = klass->generic_container;
-               res = mono_array_new_specific (array_vtable, container->type_argc);
+               res = create_type_array (domain, runtimeTypeArray, container->type_argc);
                for (i = 0; i < container->type_argc; ++i) {
                        pklass = mono_class_from_generic_parameter (mono_generic_container_get_param (container, i), klass->image, FALSE);
                        mono_array_setref (res, i, mono_type_get_object (domain, &pklass->byval_arg));
                }
        } else if (klass->generic_class) {
                MonoGenericInst *inst = klass->generic_class->context.class_inst;
-               res = mono_array_new_specific (array_vtable, inst->type_argc);
+               res = create_type_array (domain, runtimeTypeArray, inst->type_argc);
                for (i = 0; i < inst->type_argc; ++i)
                        mono_array_setref (res, i, mono_type_get_object (domain, inst->type_argv [i]));
        } else {
-               res = mono_array_new_specific (array_vtable, 0);
+               res = NULL;
        }
        return res;
 }