Sfoglia il codice sorgente

Merge System/MonoType.cs into ReferenceSources/RuntimeType.cs, use th… (#3045)

* Merge System/MonoType.cs into ReferenceSources/RuntimeType.cs, use the latter in the runtime code.

* [sdb] Fix a test which referenced System.MonoType.
Zoltan Varga 9 anni fa
parent
commit
d88424370f

+ 1 - 1
mcs/class/Mono.Debugger.Soft/Test/dtest.cs

@@ -1424,7 +1424,7 @@ public class DebuggerTests
 
 		TypeMirror t = o.Type;
 
-		Assert.AreEqual ("MonoType", t.GetTypeObject ().Type.Name);
+		Assert.AreEqual ("RuntimeType", t.GetTypeObject ().Type.Name);
 	}
 
 	[Test]

+ 100 - 9
mcs/class/corlib/ReferenceSources/RuntimeType.cs

@@ -41,14 +41,84 @@ using System.Runtime.Serialization;
 
 namespace System
 {
+	// Contains information about the type which is expensive to compute
+	[StructLayout (LayoutKind.Sequential)]
+	internal class MonoTypeInfo {
+		// this is the displayed form: special characters
+		// ,+*&*[]\ in the identifier portions of the names
+		// have been escaped with a leading backslash (\)
+		public string full_name;
+		public MonoCMethod default_ctor;
+	}
+
+	[StructLayout (LayoutKind.Sequential)]
 	partial class RuntimeType
 	{
+		[NonSerialized]
+		MonoTypeInfo type_info;
+
 		internal Object GenericCache;
 
-		internal virtual MonoCMethod GetDefaultConstructor ()
+		[MethodImplAttribute(MethodImplOptions.InternalCall)]
+		private static extern void type_from_obj (RuntimeType type, Object obj);
+
+		internal RuntimeType (Object obj)
+		{
+			// this should not be used - lupus
+			type_from_obj (this, obj);
+
+			throw new NotImplementedException ();
+		}
+
+		internal MonoCMethod GetDefaultConstructor ()
 		{
-			// TODO: Requires MonoType
-			throw new NotSupportedException ();
+			MonoCMethod ctor = null;
+
+			if (type_info == null)
+				type_info = new MonoTypeInfo ();
+			else
+				ctor = type_info.default_ctor;
+
+			if (ctor == null) {
+				var ctors = GetConstructors (BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
+
+				for (int i = 0; i < ctors.Length; ++i) {
+					if (ctors [i].GetParametersCount () == 0) {
+						type_info.default_ctor = ctor = (MonoCMethod) ctors [i];
+						break;
+					}
+				}
+			}
+
+			return ctor;
+		}
+
+		[MethodImplAttribute(MethodImplOptions.InternalCall)]
+		extern MethodInfo GetCorrespondingInflatedMethod (MethodInfo generic);
+
+		[MethodImplAttribute(MethodImplOptions.InternalCall)]
+		extern ConstructorInfo GetCorrespondingInflatedConstructor (ConstructorInfo generic);
+
+		internal override MethodInfo GetMethod (MethodInfo fromNoninstanciated)
+                {
+			if (fromNoninstanciated == null)
+				throw new ArgumentNullException ("fromNoninstanciated");
+                        return GetCorrespondingInflatedMethod (fromNoninstanciated);
+                }
+
+		internal override ConstructorInfo GetConstructor (ConstructorInfo fromNoninstanciated)
+		{
+			if (fromNoninstanciated == null)
+				throw new ArgumentNullException ("fromNoninstanciated");
+                        return GetCorrespondingInflatedConstructor (fromNoninstanciated);
+		}
+
+		internal override FieldInfo GetField (FieldInfo fromNoninstanciated)
+		{
+			/* create sensible flags from given FieldInfo */
+			BindingFlags flags = fromNoninstanciated.IsStatic ? BindingFlags.Static : BindingFlags.Instance;
+			flags |= fromNoninstanciated.IsPublic ? BindingFlags.Public : BindingFlags.NonPublic;
+			return GetField (fromNoninstanciated.Name, flags);
 		}
 
 		string GetDefaultMemberName ()
@@ -586,12 +656,6 @@ namespace System
 			get;
 		}
 
-		public override string FullName {
-			get {
-				throw new NotImplementedException ();
-			}
-		}
-
 		public extern override string Name {
 			[MethodImplAttribute(MethodImplOptions.InternalCall)]
 			get;
@@ -624,5 +688,32 @@ namespace System
 			get { return get_core_clr_security_level () == 1; }
 		}
 #endif
+
+		public override int GetHashCode()
+		{
+			Type t = UnderlyingSystemType;
+			if (t != null && t != this)
+				return t.GetHashCode ();
+			return (int)_impl.Value;
+		}
+
+		public override string FullName {
+			get {
+				string fullName;
+				// This doesn't need locking
+				if (type_info == null)
+					type_info = new MonoTypeInfo ();
+				if ((fullName = type_info.full_name) == null)
+					fullName = type_info.full_name = getFullName (true, false);
+
+				return fullName;
+			}
+		}
+
+		internal override bool IsUserType {
+			get {
+				return false;
+			}
+		}
 	}
 }

+ 1 - 1
mcs/class/corlib/System.Reflection/MonoMethod.cs

@@ -438,7 +438,7 @@ namespace System.Reflection {
 			foreach (Type type in methodInstantiation) {
 				if (type == null)
 					throw new ArgumentNullException ();
-				if (!(type is MonoType))
+				if (!(type is RuntimeType))
 					hasUserType = true;
 			}
 

+ 1 - 1
mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs

@@ -477,7 +477,7 @@ namespace System.Runtime.Remoting
 		public static bool IsMethodOverloaded(IMethodMessage msg)
 		{
 			const BindingFlags bfinst = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
-			MonoType type = (MonoType) msg.MethodBase.DeclaringType;
+			RuntimeType type = (RuntimeType) msg.MethodBase.DeclaringType;
 			return type.GetMethodsByName (msg.MethodName, bfinst, false, type).Length > 1;
 		}
 

+ 1 - 1
mcs/class/corlib/System/Environment.cs

@@ -57,7 +57,7 @@ namespace System {
 		 * of icalls, do not require an increment.
 		 */
 #pragma warning disable 169
-		private const int mono_corlib_version = 147;
+		private const int mono_corlib_version = 148;
 #pragma warning restore 169
 
 		[ComVisible (true)]

+ 3 - 3
mcs/class/corlib/System/MonoCustomAttrs.cs

@@ -49,14 +49,14 @@ namespace System
 		[ThreadStatic]
 		static Dictionary<Type, AttributeUsageAttribute> usage_cache;
 
-		/* Treat as user types all corlib types extending System.Type that are not MonoType and TypeBuilder */
+		/* Treat as user types all corlib types extending System.Type that are not RuntimeType and TypeBuilder */
 		static bool IsUserCattrProvider (object obj)
 		{
 			Type type = obj as Type;
 #if !FULL_AOT_RUNTIME
-			if ((type is MonoType) || (type is TypeBuilder))
+			if ((type is RuntimeType) || (type is TypeBuilder))
 #else
-			if (type is MonoType)
+			if (type is RuntimeType)
 #endif
 				return false;
 			if ((obj is Type))

+ 2 - 101
mcs/class/corlib/System/MonoType.cs

@@ -48,110 +48,11 @@ using System.Runtime;
 
 namespace System
 {
-	// Contains information about the type which is expensive to compute
-	[StructLayout (LayoutKind.Sequential)]
-	internal class MonoTypeInfo {
-		// this is the displayed form: special characters
-		// ,+*&*[]\ in the identifier portions of the names
-		// have been escaped with a leading backslash (\)
-		public string full_name;
-		public MonoCMethod default_ctor;
-	}
-
+	// Dummy type kept because lots of external code uses
+	// this to check whenever it is running on mono.
 	[Serializable]
 	[StructLayout (LayoutKind.Sequential)]
 	class MonoType : RuntimeType, ISerializable
 	{
-		[NonSerialized]
-		MonoTypeInfo type_info;
-
-		[MethodImplAttribute(MethodImplOptions.InternalCall)]
-		private static extern void type_from_obj (MonoType type, Object obj);
-		
-		internal MonoType (Object obj)
-		{
-			// this should not be used - lupus
-			type_from_obj (this, obj);
-			
-			throw new NotImplementedException ();
-		}
-
-		internal override MonoCMethod GetDefaultConstructor ()
-		{
-			MonoCMethod ctor = null;
-			
-			if (type_info == null)
-				type_info = new MonoTypeInfo ();
-			else
-				ctor = type_info.default_ctor;
-
-			if (ctor == null) {
-				var ctors = GetConstructors (BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
-
-				for (int i = 0; i < ctors.Length; ++i) {
-					if (ctors [i].GetParametersCount () == 0) {
-						type_info.default_ctor = ctor = (MonoCMethod) ctors [i];
-						break;
-					}
-				}
-			}
-
-			return ctor;
-		}
-
-		[MethodImplAttribute(MethodImplOptions.InternalCall)]
-		extern MethodInfo GetCorrespondingInflatedMethod (MethodInfo generic);
-
-		[MethodImplAttribute(MethodImplOptions.InternalCall)]
-		extern ConstructorInfo GetCorrespondingInflatedConstructor (ConstructorInfo generic);
-
-		internal override MethodInfo GetMethod (MethodInfo fromNoninstanciated)
-                {
-			if (fromNoninstanciated == null)
-				throw new ArgumentNullException ("fromNoninstanciated");
-                        return GetCorrespondingInflatedMethod (fromNoninstanciated);
-                }
-
-		internal override ConstructorInfo GetConstructor (ConstructorInfo fromNoninstanciated)
-		{
-			if (fromNoninstanciated == null)
-				throw new ArgumentNullException ("fromNoninstanciated");
-                        return GetCorrespondingInflatedConstructor (fromNoninstanciated);
-		}
-
-		internal override FieldInfo GetField (FieldInfo fromNoninstanciated)
-		{
-			/* create sensible flags from given FieldInfo */
-			BindingFlags flags = fromNoninstanciated.IsStatic ? BindingFlags.Static : BindingFlags.Instance;
-			flags |= fromNoninstanciated.IsPublic ? BindingFlags.Public : BindingFlags.NonPublic;
-			return GetField (fromNoninstanciated.Name, flags);
-		}
-
-		public override int GetHashCode()
-		{
-			Type t = UnderlyingSystemType;
-			if (t != null && t != this)
-				return t.GetHashCode ();
-			return (int)_impl.Value;
-		}
-
-		public override string FullName {
-			get {
-				string fullName;
-				// This doesn't need locking
-				if (type_info == null)
-					type_info = new MonoTypeInfo ();
-				if ((fullName = type_info.full_name) == null)
-					fullName = type_info.full_name = getFullName (true, false);
-
-				return fullName;
-			}
-		}
-
-		internal override bool IsUserType {
-			get {
-				return false;
-			}
-		}
 	}
 }

+ 2 - 2
mcs/class/corlib/System/RuntimeTypeHandle.cs

@@ -62,7 +62,7 @@ namespace System
 			if (info == null)
 				throw new ArgumentNullException ("info");
 
-			MonoType mt = ((MonoType) info.GetValue ("TypeObj", typeof (MonoType)));
+			RuntimeType mt = ((RuntimeType) info.GetValue ("TypeObj", typeof (RuntimeType)));
 			value = mt.TypeHandle.Value;
 			if (value == IntPtr.Zero)
 				throw new SerializationException (Locale.GetText ("Insufficient state."));
@@ -82,7 +82,7 @@ namespace System
 			if (value == IntPtr.Zero)
 				throw new SerializationException ("Object fields may not be properly initialized");
 
-			info.AddValue ("TypeObj", Type.GetTypeHandle (this), typeof (MonoType));
+			info.AddValue ("TypeObj", Type.GetTypeHandle (this), typeof (RuntimeType));
 		}
 
 		[ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]

+ 1 - 1
mcs/class/corlib/Test/System.Threading/ThreadTest.cs

@@ -109,7 +109,7 @@ namespace MonoTests.System.Threading
 			}
 
 			// check a class in mscorlib to determine if we're running on Mono
-			if (Type.GetType ("System.MonoType", false) != null)
+			if (Type.GetType ("Mono.Runtime", false) != null)
 				is_mono = true;
 		}
 

+ 2 - 0
mcs/class/referencesource/mscorlib/system/rttype.cs

@@ -5028,10 +5028,12 @@ namespace System
             return obj == (object)this;
         }
 
+#if !MONO
         public override int GetHashCode() 
         {
             return RuntimeHelpers.GetHashCode(this);
         }
+#endif
 
 #if !FEATURE_CORECLR
         public static bool operator ==(RuntimeType left, RuntimeType right)

+ 1 - 1
mono/metadata/appdomain.c

@@ -81,7 +81,7 @@
  * Changes which are already detected at runtime, like the addition
  * of icalls, do not require an increment.
  */
-#define MONO_CORLIB_VERSION 147
+#define MONO_CORLIB_VERSION 148
 
 typedef struct
 {

+ 0 - 1
mono/metadata/class-internals.h

@@ -1097,7 +1097,6 @@ typedef struct {
 	MonoClass *fieldhandle_class;
 	MonoClass *methodhandle_class;
 	MonoClass *systemtype_class;
-	MonoClass *monotype_class;
 	MonoClass *runtimetype_class;
 	MonoClass *exception_class;
 	MonoClass *threadabortexception_class;

+ 1 - 4
mono/metadata/domain.c

@@ -707,9 +707,6 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *
 	mono_defaults.systemtype_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "Type");
 
-	mono_defaults.monotype_class = mono_class_load_from_name (
-                mono_defaults.corlib, "System", "MonoType");
-
 	mono_defaults.runtimetype_class = mono_class_load_from_name (
                 mono_defaults.corlib, "System", "RuntimeType");
 
@@ -1054,7 +1051,7 @@ unregister_vtable_reflection_type (MonoVTable *vtable)
 {
 	MonoObject *type = (MonoObject *)vtable->type;
 
-	if (type->vtable->klass != mono_defaults.monotype_class)
+	if (type->vtable->klass != mono_defaults.runtimetype_class)
 		MONO_GC_UNREGISTER_ROOT_IF_MOVING (vtable->type);
 }
 

+ 25 - 27
mono/metadata/icall-def.h

@@ -398,11 +398,6 @@ ICALL(MCATTR_1, "GetCustomAttributesDataInternal", ves_icall_MonoCustomAttrs_Get
 ICALL(MCATTR_2, "GetCustomAttributesInternal", custom_attrs_get_by_type)
 ICALL(MCATTR_3, "IsDefinedInternal", custom_attrs_defined_internal)
 
-ICALL_TYPE(MTYPE, "System.MonoType", MTYPE_1)
-ICALL(MTYPE_1, "GetCorrespondingInflatedConstructor", ves_icall_MonoType_GetCorrespondingInflatedMethod)
-ICALL(MTYPE_2, "GetCorrespondingInflatedMethod", ves_icall_MonoType_GetCorrespondingInflatedMethod)
-ICALL(MTYPE_3, "type_from_obj", ves_icall_MonoType_type_from_obj)
-
 #ifndef DISABLE_SOCKETS
 ICALL_TYPE(NDNS, "System.Net.Dns", NDNS_1)
 ICALL(NDNS_1, "GetHostByAddr_internal(string,string&,string[]&,string[]&)", ves_icall_System_Net_Dns_GetHostByAddr_internal)
@@ -737,32 +732,35 @@ ICALL(MHAN_1, "GetFunctionPointer", ves_icall_RuntimeMethodHandle_GetFunctionPoi
 
 ICALL_TYPE(RT, "System.RuntimeType", RT_1)
 ICALL(RT_1, "CreateInstanceInternal", ves_icall_System_Activator_CreateInstanceInternal)
-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, "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)
-ICALL(RT_10, "GetInterfaceMapData", ves_icall_Type_GetInterfaceMapData)
-ICALL(RT_11, "GetInterfaces", ves_icall_Type_GetInterfaces)
-ICALL(RT_12, "GetMethodsByName", ves_icall_Type_GetMethodsByName)
-ICALL(RT_13, "GetNestedTypes_internal", ves_icall_Type_GetNestedTypes)
-ICALL(RT_14, "GetPacking", ves_icall_Type_GetPacking)
-ICALL(RT_15, "GetPropertiesByName", ves_icall_Type_GetPropertiesByName)
+ICALL(RT_2, "GetConstructors_internal", ves_icall_RuntimeType_GetConstructors_internal)
+ICALL(RT_30, "GetCorrespondingInflatedConstructor", ves_icall_RuntimeType_GetCorrespondingInflatedMethod)
+ICALL(RT_31, "GetCorrespondingInflatedMethod", ves_icall_RuntimeType_GetCorrespondingInflatedMethod)
+ICALL(RT_3, "GetEvents_internal", ves_icall_RuntimeType_GetEvents_internal)
+ICALL(RT_5, "GetFields_internal", ves_icall_RuntimeType_GetFields_internal)
+ICALL(RT_6, "GetGenericArgumentsInternal", ves_icall_RuntimeType_GetGenericArguments)
+ICALL(RT_7, "GetGenericParameterAttributes", ves_icall_RuntimeType_GetGenericParameterAttributes)
+ICALL(RT_8, "GetGenericParameterConstraints_impl", ves_icall_RuntimeType_GetGenericParameterConstraints)
+ICALL(RT_9, "GetGenericParameterPosition", ves_icall_RuntimeType_GetGenericParameterPosition)
+ICALL(RT_10, "GetInterfaceMapData", ves_icall_RuntimeType_GetInterfaceMapData)
+ICALL(RT_11, "GetInterfaces", ves_icall_RuntimeType_GetInterfaces)
+ICALL(RT_12, "GetMethodsByName", ves_icall_RuntimeType_GetMethodsByName)
+ICALL(RT_13, "GetNestedTypes_internal", ves_icall_RuntimeType_GetNestedTypes)
+ICALL(RT_14, "GetPacking", ves_icall_RuntimeType_GetPacking)
+ICALL(RT_15, "GetPropertiesByName", ves_icall_RuntimeType_GetPropertiesByName)
 ICALL(RT_16, "GetTypeCodeImplInternal", ves_icall_type_GetTypeCodeInternal)
 ICALL(RT_28, "IsTypeExportedToWindowsRuntime", ves_icall_System_RuntimeType_IsTypeExportedToWindowsRuntime)
 ICALL(RT_29, "IsWindowsRuntimeObjectType", ves_icall_System_RuntimeType_IsWindowsRuntimeObjectType)
-ICALL(RT_17, "MakeGenericType", ves_icall_Type_MakeGenericType)
-ICALL(RT_18, "MakePointerType", ves_icall_Type_MakePointerType)
+ICALL(RT_17, "MakeGenericType", ves_icall_RuntimeType_MakeGenericType)
+ICALL(RT_18, "MakePointerType", ves_icall_RuntimeType_MakePointerType)
 ICALL(RT_19, "getFullName", ves_icall_System_MonoType_getFullName)
-ICALL(RT_21, "get_DeclaringMethod", ves_icall_MonoType_get_DeclaringMethod)
-ICALL(RT_22, "get_DeclaringType", ves_icall_MonoType_get_DeclaringType)
-ICALL(RT_23, "get_Name", ves_icall_MonoType_get_Name)
-ICALL(RT_24, "get_Namespace", ves_icall_MonoType_get_Namespace)
-ICALL(RT_25, "get_core_clr_security_level", vell_icall_MonoType_get_core_clr_security_level)
-ICALL(RT_26, "make_array_type", ves_icall_Type_make_array_type)
-ICALL(RT_27, "make_byref_type", ves_icall_Type_make_byref_type)
+ICALL(RT_21, "get_DeclaringMethod", ves_icall_RuntimeType_get_DeclaringMethod)
+ICALL(RT_22, "get_DeclaringType", ves_icall_RuntimeType_get_DeclaringType)
+ICALL(RT_23, "get_Name", ves_icall_RuntimeType_get_Name)
+ICALL(RT_24, "get_Namespace", ves_icall_RuntimeType_get_Namespace)
+ICALL(RT_25, "get_core_clr_security_level", vell_icall_RuntimeType_get_core_clr_security_level)
+ICALL(RT_26, "make_array_type", ves_icall_RuntimeType_make_array_type)
+ICALL(RT_27, "make_byref_type", ves_icall_RuntimeType_make_byref_type)
+ICALL(RT_32, "type_from_obj", ves_icall_RuntimeType_type_from_obj)
 
 ICALL_TYPE(RTH, "System.RuntimeTypeHandle", RTH_1)
 ICALL(RTH_1, "GetArrayRank", ves_icall_RuntimeTypeHandle_GetArrayRank)

+ 33 - 33
mono/metadata/icall.c

@@ -1211,7 +1211,7 @@ ves_icall_System_Object_GetType (MonoObject *obj)
 }
 
 ICALL_EXPORT void
-ves_icall_MonoType_type_from_obj (MonoReflectionType *mtype, MonoObject *obj)
+ves_icall_RuntimeType_type_from_obj (MonoReflectionType *mtype, MonoObject *obj)
 {
 	mtype->type = &obj->vtable->klass->byval_arg;
 	g_assert (mtype->type->type);
@@ -2401,7 +2401,7 @@ get_interfaces_hash (gconstpointer v1)
 }
 
 ICALL_EXPORT MonoArray*
-ves_icall_Type_GetInterfaces (MonoReflectionType* type)
+ves_icall_RuntimeType_GetInterfaces (MonoReflectionType* type)
 {
 	MonoError error;
 	MonoClass *klass = mono_class_from_mono_type (type->type);
@@ -2432,14 +2432,14 @@ ves_icall_Type_GetInterfaces (MonoReflectionType* type)
 	if (len == 0) {
 		g_hash_table_destroy (iface_hash);
 		if (!data.domain->empty_types) {
-			data.domain->empty_types = mono_array_new_cached (data.domain, mono_defaults.monotype_class, 0, &error);
+			data.domain->empty_types = mono_array_new_cached (data.domain, mono_defaults.runtimetype_class, 0, &error);
 			if (!is_ok (&error))
 				goto fail;
 		}
 		return data.domain->empty_types;
 	}
 
-	data.iface_array = mono_array_new_cached (data.domain, mono_defaults.monotype_class, len, &error);
+	data.iface_array = mono_array_new_cached (data.domain, mono_defaults.runtimetype_class, len, &error);
 	if (!is_ok (&error))
 		goto fail;
 	g_hash_table_foreach (iface_hash, fill_iface_array, &data);
@@ -2456,7 +2456,7 @@ fail:
 }
 
 ICALL_EXPORT void
-ves_icall_Type_GetInterfaceMapData (MonoReflectionType *type, MonoReflectionType *iface, MonoArray **targets, MonoArray **methods)
+ves_icall_RuntimeType_GetInterfaceMapData (MonoReflectionType *type, MonoReflectionType *iface, MonoArray **targets, MonoArray **methods)
 {
 	gboolean variance_used;
 	MonoClass *klass = mono_class_from_mono_type (type->type);
@@ -2507,7 +2507,7 @@ ves_icall_Type_GetInterfaceMapData (MonoReflectionType *type, MonoReflectionType
 }
 
 ICALL_EXPORT void
-ves_icall_Type_GetPacking (MonoReflectionType *type, guint32 *packing, guint32 *size)
+ves_icall_RuntimeType_GetPacking (MonoReflectionType *type, guint32 *packing, guint32 *size)
 {
 	MonoError error;
 	MonoClass *klass = mono_class_from_mono_type (type->type);
@@ -2641,7 +2641,7 @@ ves_icall_RuntimeTypeHandle_GetAssembly (MonoReflectionType *type)
 }
 
 ICALL_EXPORT MonoReflectionType*
-ves_icall_MonoType_get_DeclaringType (MonoReflectionType *type)
+ves_icall_RuntimeType_get_DeclaringType (MonoReflectionType *type)
 {
 	MonoError error;
 	MonoReflectionType *ret;
@@ -2670,7 +2670,7 @@ ves_icall_MonoType_get_DeclaringType (MonoReflectionType *type)
 }
 
 ICALL_EXPORT MonoString*
-ves_icall_MonoType_get_Name (MonoReflectionType *type)
+ves_icall_RuntimeType_get_Name (MonoReflectionType *type)
 {
 	MonoDomain *domain = mono_domain_get (); 
 	MonoClass *klass = mono_class_from_mono_type (type->type);
@@ -2688,7 +2688,7 @@ ves_icall_MonoType_get_Name (MonoReflectionType *type)
 }
 
 ICALL_EXPORT MonoString*
-ves_icall_MonoType_get_Namespace (MonoReflectionType *type)
+ves_icall_RuntimeType_get_Namespace (MonoReflectionType *type)
 {
 	MonoDomain *domain = mono_domain_get (); 
 	MonoClass *klass = mono_class_from_mono_type (type->type);
@@ -2724,7 +2724,7 @@ create_type_array (MonoDomain *domain, MonoBoolean runtimeTypeArray, int count,
 }
 
 ICALL_EXPORT MonoArray*
-ves_icall_MonoType_GetGenericArguments (MonoReflectionType *type, MonoBoolean runtimeTypeArray)
+ves_icall_RuntimeType_GetGenericArguments (MonoReflectionType *type, MonoBoolean runtimeTypeArray)
 {
 	MonoError error;
 	MonoReflectionType *rt;
@@ -2816,7 +2816,7 @@ ves_icall_RuntimeTypeHandle_GetGenericTypeDefinition_impl (MonoReflectionType *t
 }
 
 ICALL_EXPORT MonoReflectionType*
-ves_icall_Type_MakeGenericType (MonoReflectionType *type, MonoArray *type_array)
+ves_icall_RuntimeType_MakeGenericType (MonoReflectionType *type, MonoArray *type_array)
 {
 	MonoError error;
 	MonoReflectionType *ret;
@@ -2874,7 +2874,7 @@ ves_icall_RuntimeTypeHandle_HasInstantiation (MonoReflectionType *type)
 }
 
 ICALL_EXPORT gint32
-ves_icall_Type_GetGenericParameterPosition (MonoReflectionType *type)
+ves_icall_RuntimeType_GetGenericParameterPosition (MonoReflectionType *type)
 {
 	if (!IS_MONOTYPE (type))
 		return -1;
@@ -2885,7 +2885,7 @@ ves_icall_Type_GetGenericParameterPosition (MonoReflectionType *type)
 }
 
 ICALL_EXPORT GenericParameterAttributes
-ves_icall_Type_GetGenericParameterAttributes (MonoReflectionType *type)
+ves_icall_RuntimeType_GetGenericParameterAttributes (MonoReflectionType *type)
 {
 	g_assert (IS_MONOTYPE (type));
 	g_assert (is_generic_parameter (type->type));
@@ -2893,7 +2893,7 @@ ves_icall_Type_GetGenericParameterAttributes (MonoReflectionType *type)
 }
 
 ICALL_EXPORT MonoArray *
-ves_icall_Type_GetGenericParameterConstraints (MonoReflectionType *type)
+ves_icall_RuntimeType_GetGenericParameterConstraints (MonoReflectionType *type)
 {
 	MonoError error;
 	MonoReflectionType *rt;
@@ -2910,7 +2910,7 @@ ves_icall_Type_GetGenericParameterConstraints (MonoReflectionType *type)
 	for (count = 0, ptr = param_info->constraints; ptr && *ptr; ptr++, count++)
 		;
 
-	res = mono_array_new_checked (domain, mono_defaults.monotype_class, count, &error);
+	res = mono_array_new_checked (domain, mono_defaults.runtimetype_class, count, &error);
 	if (mono_error_set_pending_exception (&error))
 		return NULL;
 	for (i = 0; i < count; i++) {
@@ -2945,7 +2945,7 @@ ves_icall_EnumBuilder_setup_enum_type (MonoReflectionType *enumtype,
 }
 
 ICALL_EXPORT MonoReflectionMethod*
-ves_icall_MonoType_GetCorrespondingInflatedMethod (MonoReflectionType *type, 
+ves_icall_RuntimeType_GetCorrespondingInflatedMethod (MonoReflectionType *type, 
                                                    MonoReflectionMethod* generic)
 {
 	MonoDomain *domain; 
@@ -2975,7 +2975,7 @@ ves_icall_MonoType_GetCorrespondingInflatedMethod (MonoReflectionType *type,
 }
 
 ICALL_EXPORT MonoReflectionMethod *
-ves_icall_MonoType_get_DeclaringMethod (MonoReflectionType *ref_type)
+ves_icall_RuntimeType_get_DeclaringMethod (MonoReflectionType *ref_type)
 {
 	MonoMethod *method;
 	MonoType *type = ref_type->type;
@@ -3776,7 +3776,7 @@ enum {
 };
 
 ICALL_EXPORT MonoArray*
-ves_icall_Type_GetFields_internal (MonoReflectionType *type, MonoString *name, guint32 bflags, MonoReflectionType *reftype)
+ves_icall_RuntimeType_GetFields_internal (MonoReflectionType *type, MonoString *name, guint32 bflags, MonoReflectionType *reftype)
 {
 	MonoError error;
 	MonoDomain *domain; 
@@ -4003,7 +4003,7 @@ loader_error:
 }
 
 ICALL_EXPORT MonoArray*
-ves_icall_Type_GetMethodsByName (MonoReflectionType *type, MonoString *name, guint32 bflags, MonoBoolean ignore_case, MonoReflectionType *reftype)
+ves_icall_RuntimeType_GetMethodsByName (MonoReflectionType *type, MonoString *name, guint32 bflags, MonoBoolean ignore_case, MonoReflectionType *reftype)
 {
 	static MonoClass *MethodInfo_array;
 	MonoError error;
@@ -4071,7 +4071,7 @@ failure:
 }
 
 ICALL_EXPORT MonoArray*
-ves_icall_Type_GetConstructors_internal (MonoReflectionType *type, guint32 bflags, MonoReflectionType *reftype)
+ves_icall_RuntimeType_GetConstructors_internal (MonoReflectionType *type, guint32 bflags, MonoReflectionType *reftype)
 {
 	MonoDomain *domain; 
 	MonoClass *startklass, *klass, *refklass;
@@ -4207,7 +4207,7 @@ property_accessor_nonpublic (MonoMethod* accessor, gboolean start_klass)
 }
 
 ICALL_EXPORT MonoArray*
-ves_icall_Type_GetPropertiesByName (MonoReflectionType *type, MonoString *name, guint32 bflags, MonoBoolean ignore_case, MonoReflectionType *reftype)
+ves_icall_RuntimeType_GetPropertiesByName (MonoReflectionType *type, MonoString *name, guint32 bflags, MonoBoolean ignore_case, MonoReflectionType *reftype)
 {
 	MonoError error;
 	MonoDomain *domain; 
@@ -4350,7 +4350,7 @@ event_equal (MonoEvent *event1, MonoEvent *event2)
 }
 
 ICALL_EXPORT MonoArray*
-ves_icall_Type_GetEvents_internal (MonoReflectionType *type, MonoString *name, guint32 bflags, MonoReflectionType *reftype)
+ves_icall_RuntimeType_GetEvents_internal (MonoReflectionType *type, MonoString *name, guint32 bflags, MonoReflectionType *reftype)
 {
 	MonoError error;
 	MonoDomain *domain; 
@@ -4483,7 +4483,7 @@ failure:
 }
 
 ICALL_EXPORT MonoArray*
-ves_icall_Type_GetNestedTypes (MonoReflectionType *type, MonoString *name, guint32 bflags)
+ves_icall_RuntimeType_GetNestedTypes (MonoReflectionType *type, MonoString *name, guint32 bflags)
 {
 	MonoError error;
 	MonoReflectionType *rt;
@@ -4500,7 +4500,7 @@ ves_icall_Type_GetNestedTypes (MonoReflectionType *type, MonoString *name, guint
 
 	domain = ((MonoObject *)type)->vtable->domain;
 	if (type->type->byref) {
-		MonoArray *result = mono_array_new_cached (domain, mono_defaults.monotype_class, 0, &error);
+		MonoArray *result = mono_array_new_cached (domain, mono_defaults.runtimetype_class, 0, &error);
 		mono_error_set_pending_exception (&error);
 		return result;
 	}
@@ -4549,7 +4549,7 @@ ves_icall_Type_GetNestedTypes (MonoReflectionType *type, MonoString *name, guint
 		mono_ptr_array_append (tmp_array, (MonoObject*) rt);
 	}
 
-	res = mono_array_new_cached (domain, mono_defaults.monotype_class, mono_ptr_array_size (tmp_array), &error);
+	res = mono_array_new_cached (domain, mono_defaults.runtimetype_class, mono_ptr_array_size (tmp_array), &error);
 	if (!is_ok (&error))
 		goto leave;
 
@@ -5454,7 +5454,7 @@ ves_icall_System_MonoType_getFullName (MonoReflectionType *object, gboolean full
 }
 
 ICALL_EXPORT int
-vell_icall_MonoType_get_core_clr_security_level (MonoReflectionType *rfield)
+vell_icall_RuntimeType_get_core_clr_security_level (MonoReflectionType *rfield)
 {
 	MonoError error;
 	MonoClass *klass = mono_class_from_mono_type (rfield->type);
@@ -5743,7 +5743,7 @@ mono_module_get_types (MonoDomain *domain, MonoImage *image, MonoArray **excepti
 	} else {
 		count = tdef->rows - 1;
 	}
-	res = mono_array_new_checked (domain, mono_defaults.monotype_class, count, error);
+	res = mono_array_new_checked (domain, mono_defaults.runtimetype_class, count, error);
 	return_val_if_nok (error, NULL);
 	*exceptions = mono_array_new_checked (domain, mono_defaults.exception_class, count, error);
 	return_val_if_nok (error, NULL);
@@ -5810,14 +5810,14 @@ ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly,
 					len1 = mono_array_length (res);
 					len2 = mono_array_length (res2);
 
-					res3 = mono_array_new_checked (domain, mono_defaults.monotype_class, len1 + len2, &error);
+					res3 = mono_array_new_checked (domain, mono_defaults.runtimetype_class, len1 + len2, &error);
 					if (mono_error_set_pending_exception (&error))
 						return NULL;
 					mono_array_memcpy_refs (res3, 0, res, 0, len1);
 					mono_array_memcpy_refs (res3, len1, res2, 0, len2);
 					res = res3;
 
-					ex3 = mono_array_new_checked (domain, mono_defaults.monotype_class, len1 + len2, &error);
+					ex3 = mono_array_new_checked (domain, mono_defaults.runtimetype_class, len1 + len2, &error);
 					if (mono_error_set_pending_exception (&error))
 						return NULL;
 					mono_array_memcpy_refs (ex3, 0, exceptions, 0, len1);
@@ -6005,7 +6005,7 @@ ves_icall_System_Reflection_Module_InternalGetTypes (MonoReflectionModule *modul
 	int i;
 
 	if (!module->image) {
-		MonoArray *arr = mono_array_new_checked (mono_object_domain (module), mono_defaults.monotype_class, 0, &error);
+		MonoArray *arr = mono_array_new_checked (mono_object_domain (module), mono_defaults.runtimetype_class, 0, &error);
 		mono_error_set_pending_exception (&error);
 		return arr;
 	} else {
@@ -6460,7 +6460,7 @@ check_for_invalid_type (MonoClass *klass, MonoError *error)
 
 }
 ICALL_EXPORT MonoReflectionType *
-ves_icall_Type_make_array_type (MonoReflectionType *type, int rank)
+ves_icall_RuntimeType_make_array_type (MonoReflectionType *type, int rank)
 {
 	MonoError error;
 	MonoReflectionType *ret;
@@ -6482,7 +6482,7 @@ ves_icall_Type_make_array_type (MonoReflectionType *type, int rank)
 }
 
 ICALL_EXPORT MonoReflectionType *
-ves_icall_Type_make_byref_type (MonoReflectionType *type)
+ves_icall_RuntimeType_make_byref_type (MonoReflectionType *type)
 {
 	MonoError error;
 	MonoReflectionType *ret;
@@ -6504,7 +6504,7 @@ ves_icall_Type_make_byref_type (MonoReflectionType *type)
 }
 
 ICALL_EXPORT MonoReflectionType *
-ves_icall_Type_MakePointerType (MonoReflectionType *type)
+ves_icall_RuntimeType_MakePointerType (MonoReflectionType *type)
 {
 	MonoError error;
 	MonoReflectionType *ret;

+ 1 - 0
mono/metadata/object-internals.h

@@ -263,6 +263,7 @@ struct _MonoReflectionType {
 	MonoType  *type;
 };
 
+/* This corresponds to System.RuntimeType */
 typedef struct {
 	MonoReflectionType type;
 	MonoObject *type_info;

+ 4 - 4
mono/metadata/object.c

@@ -2216,7 +2216,7 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *klass, MonoErro
 	 * re-acquire them and check if another thread has created the vtable in the meantime.
 	 */
 	/* Special case System.MonoType to avoid infinite recursion */
-	if (klass != mono_defaults.monotype_class) {
+	if (klass != mono_defaults.runtimetype_class) {
 		vt->type = mono_type_get_object_checked (domain, &klass->byval_arg, error);
 		if (!is_ok (error)) {
 			mono_domain_unlock (domain);
@@ -2224,7 +2224,7 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *klass, MonoErro
 			return NULL;
 		}
 
-		if (mono_object_get_class ((MonoObject *)vt->type) != mono_defaults.monotype_class)
+		if (mono_object_get_class ((MonoObject *)vt->type) != mono_defaults.runtimetype_class)
 			/* This is unregistered in
 			   unregister_vtable_reflection_type() in
 			   domain.c. */
@@ -2275,7 +2275,7 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *klass, MonoErro
 		klass->runtime_info = runtime_info;
 	}
 
-	if (klass == mono_defaults.monotype_class) {
+	if (klass == mono_defaults.runtimetype_class) {
 		vt->type = mono_type_get_object_checked (domain, &klass->byval_arg, error);
 		if (!is_ok (error)) {
 			mono_domain_unlock (domain);
@@ -2283,7 +2283,7 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *klass, MonoErro
 			return NULL;
 		}
 
-		if (mono_object_get_class ((MonoObject *)vt->type) != mono_defaults.monotype_class)
+		if (mono_object_get_class ((MonoObject *)vt->type) != mono_defaults.runtimetype_class)
 			/* This is unregistered in
 			   unregister_vtable_reflection_type() in
 			   domain.c. */

+ 5 - 5
mono/metadata/reflection.c

@@ -5602,7 +5602,7 @@ mono_image_create_token (MonoDynamicImage *assembly, MonoObject *obj,
 			return_val_if_nok (error, 0);
 			token = mono_metadata_token_from_dor (mono_image_typedef_or_ref (assembly, type));
 		}
-	} else if (strcmp (klass->name, "MonoType") == 0) {
+	} else if (strcmp (klass->name, "RuntimeType") == 0) {
 		MonoType *type = mono_reflection_type_get_handle ((MonoReflectionType *)obj, error);
 		return_val_if_nok (error, 0);
 		MonoClass *mc = mono_class_from_mono_type (type);
@@ -7269,7 +7269,7 @@ mono_type_get_object_checked (MonoDomain *domain, MonoType *type, MonoError *err
 		}
 	}
 	/* This is stored in vtables/JITted code so it has to be pinned */
-	res = (MonoReflectionType *)mono_object_new_pinned (domain, mono_defaults.monotype_class, error);
+	res = (MonoReflectionType *)mono_object_new_pinned (domain, mono_defaults.runtimetype_class, error);
 	if (!mono_error_ok (error))
 		return NULL;
 
@@ -8897,7 +8897,7 @@ mono_reflection_get_token_checked (MonoObject *obj, MonoError *error)
 	} else if (strcmp (klass->name, "TypeBuilder") == 0) {
 		MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder *)obj;
 		token = tb->table_idx | MONO_TOKEN_TYPE_DEF;
-	} else if (strcmp (klass->name, "MonoType") == 0) {
+	} else if (strcmp (klass->name, "RuntimeType") == 0) {
 		MonoType *type = mono_reflection_type_get_handle ((MonoReflectionType*)obj, error);
 		return_val_if_nok (error, 0);
 		MonoClass *mc = mono_class_from_mono_type (type);
@@ -10340,7 +10340,7 @@ mono_reflection_get_custom_attrs_info_checked (MonoObject *obj, MonoError *error
 	mono_error_init (error);
 
 	klass = obj->vtable->klass;
-	if (klass == mono_defaults.monotype_class) {
+	if (klass == mono_defaults.runtimetype_class) {
 		MonoType *type = mono_reflection_type_get_handle ((MonoReflectionType *)obj, error);
 		return_val_if_nok (error, NULL);
 		klass = mono_class_from_mono_type (type);
@@ -13848,7 +13848,7 @@ resolve_object (MonoImage *image, MonoObject *obj, MonoClass **handle_class, Mon
 		return_val_if_nok (error, NULL);
 		*handle_class = mono_defaults.string_class;
 		g_assert (result);
-	} else if (strcmp (obj->vtable->klass->name, "MonoType") == 0) {
+	} else if (strcmp (obj->vtable->klass->name, "RuntimeType") == 0) {
 		MonoType *type = mono_reflection_type_get_handle ((MonoReflectionType*)obj, error);
 		return_val_if_nok (error, NULL);
 		MonoClass *mc = mono_class_from_mono_type (type);

+ 1 - 1
mono/metadata/security-core-clr.c

@@ -363,7 +363,7 @@ get_caller_no_reflection_related (MonoMethod *m, gint32 no, gint32 ilo, gboolean
 
 		/* unlike most Invoke* cases InvokeMember is not inside System.Reflection[.Emit] but is SecuritySafeCritical */
 		if (((*kname == 'T') && (strcmp (kname, "Type") == 0)) || 
-			((*kname == 'M') && (strcmp (kname, "MonoType")) == 0)) {
+			((*kname == 'R') && (strcmp (kname, "RuntimeType")) == 0)) {
 
 			/* if calling InvokeMember then we can't stop the stackwalk here and need to look at the caller */
 			if (strcmp (m->name, "InvokeMember") == 0)

+ 1 - 1
mono/mini/debugger-agent.c

@@ -7787,7 +7787,7 @@ field_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
 static void
 buffer_add_cattr_arg (Buffer *buf, MonoType *t, MonoDomain *domain, MonoObject *val)
 {
-	if (val && val->vtable->klass == mono_defaults.monotype_class) {
+	if (val && val->vtable->klass == mono_defaults.runtimetype_class) {
 		/* Special case these so the client doesn't have to handle Type objects */
 		
 		buffer_add_byte (buf, VALUE_TYPE_ID_TYPE);

+ 2 - 2
mono/mini/ir-emit.h

@@ -262,7 +262,7 @@ alloc_dreg (MonoCompile *cfg, MonoStackType stack_type)
 
 #define NEW_LDSTRLITCONST(cfg,dest,val) NEW_AOTCONST ((cfg), (dest), MONO_PATCH_INFO_LDSTR_LIT, (val))
 
-#define NEW_TYPE_FROM_HANDLE_CONST(cfg,dest,image,token,generic_context) NEW_AOTCONST_TOKEN ((cfg), (dest), MONO_PATCH_INFO_TYPE_FROM_HANDLE, (image), (token), (generic_context), STACK_OBJ, mono_defaults.monotype_class)
+#define NEW_TYPE_FROM_HANDLE_CONST(cfg,dest,image,token,generic_context) NEW_AOTCONST_TOKEN ((cfg), (dest), MONO_PATCH_INFO_TYPE_FROM_HANDLE, (image), (token), (generic_context), STACK_OBJ, mono_defaults.runtimetype_class)
 
 #define NEW_LDTOKENCONST(cfg,dest,image,token,generic_context) NEW_AOTCONST_TOKEN ((cfg), (dest), MONO_PATCH_INFO_LDTOKEN, (image), (token), (generic_context), STACK_PTR, NULL)
 
@@ -448,7 +448,7 @@ handle_gsharedvt_ldaddr (MonoCompile *cfg)
 
 #define EMIT_NEW_LDSTRLITCONST(cfg,dest,val) do { NEW_AOTCONST ((cfg), (dest), MONO_PATCH_INFO_LDSTR_LIT, (val)); MONO_ADD_INS ((cfg)->cbb, (dest)); } while (0)
 
-#define EMIT_NEW_TYPE_FROM_HANDLE_CONST(cfg,dest,image,token,generic_context) do { NEW_AOTCONST_TOKEN ((cfg), (dest), MONO_PATCH_INFO_TYPE_FROM_HANDLE, (image), (token), (generic_context), STACK_OBJ, mono_defaults.monotype_class); MONO_ADD_INS ((cfg)->cbb, (dest)); } while (0)
+#define EMIT_NEW_TYPE_FROM_HANDLE_CONST(cfg,dest,image,token,generic_context) do { NEW_AOTCONST_TOKEN ((cfg), (dest), MONO_PATCH_INFO_TYPE_FROM_HANDLE, (image), (token), (generic_context), STACK_OBJ, mono_defaults.runtimetype_class); MONO_ADD_INS ((cfg)->cbb, (dest)); } while (0)
 
 #define EMIT_NEW_LDTOKENCONST(cfg,dest,image,token,generic_context) do { NEW_AOTCONST_TOKEN ((cfg), (dest), MONO_PATCH_INFO_LDTOKEN, (image), (token), (generic_context), STACK_PTR, NULL); MONO_ADD_INS ((cfg)->cbb, (dest)); } while (0)
 

+ 1 - 1
mono/mini/trace.c

@@ -534,7 +534,7 @@ mono_trace_enter_method (MonoMethod *method, char *ebp)
 					g_free (as);
 				} else if (klass == mono_defaults.int32_class) {
 					printf ("[INT32:%p:%d], ", o, *(gint32 *)((char *)o + sizeof (MonoObject)));
-				} else if (klass == mono_defaults.monotype_class) {
+				} else if (klass == mono_defaults.runtimetype_class) {
 					printf ("[TYPE:%s], ", mono_type_full_name (((MonoReflectionType*)o)->type));
 				} else
 					printf ("[%s.%s:%p], ", klass->name_space, klass->name, o);