diff options
author | Zoltan Varga <vargaz@gmail.com> | 2018-11-07 21:44:50 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2018-11-07 21:44:50 +0300 |
commit | f0fe3fc42615e5c63630f80911cf9c0aef084f13 (patch) | |
tree | d0bca634b42434b5388d4c6a6daddf11d6dbe052 | |
parent | ab9c940dffc9095d8bb317a4d70502a0de0aacc0 (diff) |
[corlib] Move the runtime internal state to MonoModule from Module. Bump corlib version. (#11586)
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs | 14 | ||||
-rw-r--r-- | mcs/class/corlib/System.Reflection/Module.cs | 24 | ||||
-rw-r--r-- | mcs/class/corlib/System.Reflection/MonoModule.cs | 19 | ||||
-rw-r--r-- | mono/metadata/custom-attrs.c | 2 | ||||
-rw-r--r-- | mono/metadata/reflection.c | 2 |
6 files changed, 45 insertions, 18 deletions
diff --git a/configure.ac b/configure.ac index c196023b558..54b567bd6e4 100644 --- a/configure.ac +++ b/configure.ac @@ -46,7 +46,7 @@ MONO_VERSION_BUILD=`echo $VERSION | cut -d . -f 3` # There is no ordering of corlib versions, no old or new, # the runtime expects an exact match. # -MONO_CORLIB_VERSION=109afe51-a298-4c14-a076-cfc83a5e755a +MONO_CORLIB_VERSION=0CC970F6-6F25-4218-9427-3E4C3DC8DE33 # # Put a quoted #define in config.h. diff --git a/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs index 3d402d387a2..bb8e56ef3bf 100644 --- a/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs +++ b/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs @@ -77,6 +77,16 @@ namespace System.Reflection.Emit { #pragma warning disable 169, 414 #region Sync with object-internals.h + // This class inherits from Module, but the runtime expects it to have the same layout as MonoModule + #region Sync with MonoModule + internal IntPtr _impl; /* a pointer to a MonoImage */ + internal Assembly assembly; + internal string fqname; + internal string name; + internal string scopename; + internal bool is_resource; + internal int token; + #endregion private UIntPtr dynamic_image; /* GC-tracked */ private int num_types; private TypeBuilder[] types; @@ -1226,6 +1236,10 @@ namespace System.Reflection.Emit { return get_MetadataToken (this); } } + + internal override IntPtr GetImpl () { + return _impl; + } } internal class ModuleBuilderTokenGenerator : TokenGenerator { diff --git a/mcs/class/corlib/System.Reflection/Module.cs b/mcs/class/corlib/System.Reflection/Module.cs index a972e683849..cc869d81482 100644 --- a/mcs/class/corlib/System.Reflection/Module.cs +++ b/mcs/class/corlib/System.Reflection/Module.cs @@ -56,16 +56,6 @@ namespace System.Reflection { public static readonly TypeFilter FilterTypeName = new TypeFilter (filter_by_type_name); public static readonly TypeFilter FilterTypeNameIgnoreCase = new TypeFilter (filter_by_type_name_ignore_case); -#pragma warning disable 649 - internal IntPtr _impl; /* a pointer to a MonoImage */ - internal Assembly assembly; - internal string fqname; - internal string name; - internal string scopename; - internal bool is_resource; - internal int token; -#pragma warning restore 649 - const BindingFlags defaultBindingFlags = BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance; @@ -75,7 +65,7 @@ namespace System.Reflection { public ModuleHandle ModuleHandle { get { - return new ModuleHandle (_impl); + return new ModuleHandle (GetImpl ()); } } @@ -142,7 +132,7 @@ namespace System.Reflection { public override string ToString () { - return name; + return Name; } internal Guid MvId { @@ -153,9 +143,9 @@ namespace System.Reflection { internal Exception resolve_token_exception (int metadataToken, ResolveTokenError error, string tokenType) { if (error == ResolveTokenError.OutOfRange) - return new ArgumentOutOfRangeException ("metadataToken", String.Format ("Token 0x{0:x} is not valid in the scope of module {1}", metadataToken, name)); + return new ArgumentOutOfRangeException ("metadataToken", String.Format ("Token 0x{0:x} is not valid in the scope of module {1}", metadataToken, Name)); else - return new ArgumentException (String.Format ("Token 0x{0:x} is not a valid {1} token in the scope of module {2}", metadataToken, tokenType, name), "metadataToken"); + return new ArgumentException (String.Format ("Token 0x{0:x} is not a valid {1} token in the scope of module {2}", metadataToken, tokenType, Name), "metadataToken"); } internal IntPtr[] ptrs_from_types (Type[] types) { @@ -192,7 +182,7 @@ namespace System.Reflection { { ResolveTokenError error; - IntPtr handle = ResolveTypeToken (module._impl, token, null, null, out error); + IntPtr handle = ResolveTypeToken (module.GetImpl (), token, null, null, out error); if (handle == IntPtr.Zero) return null; else @@ -446,5 +436,9 @@ namespace System.Reflection { public virtual IEnumerable<CustomAttributeData> CustomAttributes { get { return GetCustomAttributesData (); } } + + internal virtual IntPtr GetImpl () { + throw CreateNIE (); + } } } diff --git a/mcs/class/corlib/System.Reflection/MonoModule.cs b/mcs/class/corlib/System.Reflection/MonoModule.cs index 25bde841e99..d111b20c1cc 100644 --- a/mcs/class/corlib/System.Reflection/MonoModule.cs +++ b/mcs/class/corlib/System.Reflection/MonoModule.cs @@ -47,8 +47,23 @@ namespace System.Reflection { [ComDefaultInterfaceAttribute (typeof (_Module))] [Serializable] [ClassInterface(ClassInterfaceType.None)] + [StructLayout (LayoutKind.Sequential)] class MonoModule : RuntimeModule { +#pragma warning disable 649 + #region Sync with object-internals.h + #region Sync with ModuleBuilder + internal IntPtr _impl; /* a pointer to a MonoImage */ + internal Assembly assembly; + internal string fqname; + internal string name; + internal string scopename; + internal bool is_resource; + internal int token; + #endregion + #endregion +#pragma warning restore 649 + public override Assembly Assembly { @@ -312,5 +327,9 @@ namespace System.Reflection { { return (RuntimeAssembly)assembly; } + + internal override IntPtr GetImpl () { + return _impl; + } } } diff --git a/mono/metadata/custom-attrs.c b/mono/metadata/custom-attrs.c index 0b946095f4b..e78c64b5082 100644 --- a/mono/metadata/custom-attrs.c +++ b/mono/metadata/custom-attrs.c @@ -2070,7 +2070,7 @@ mono_reflection_get_custom_attrs_info_checked (MonoObjectHandle obj, MonoError * MonoReflectionAssemblyHandle rassembly = MONO_HANDLE_CAST (MonoReflectionAssembly, obj); cinfo = mono_custom_attrs_from_assembly_checked (MONO_HANDLE_GETVAL (rassembly, assembly), FALSE, error); goto_if_nok (error, leave); - } else if (strcmp ("Module", klass_name) == 0 || strcmp ("MonoModule", klass_name) == 0) { + } else if (strcmp ("MonoModule", klass_name) == 0) { MonoReflectionModuleHandle module = MONO_HANDLE_CAST (MonoReflectionModule, obj); cinfo = mono_custom_attrs_from_module (MONO_HANDLE_GETVAL (module, image), error); goto_if_nok (error, leave); diff --git a/mono/metadata/reflection.c b/mono/metadata/reflection.c index 24d941b248b..e11c104a315 100644 --- a/mono/metadata/reflection.c +++ b/mono/metadata/reflection.c @@ -2367,7 +2367,7 @@ mono_reflection_get_token_checked (MonoObjectHandle obj, MonoError *error) MonoMethod *method = MONO_HANDLE_GETVAL (MONO_HANDLE_CAST (MonoReflectionMethod, member_impl), method); token = mono_method_get_param_token (method, MONO_HANDLE_GETVAL (p, PositionImpl)); - } else if (strcmp (klass_name, "Module") == 0 || strcmp (klass_name, "MonoModule") == 0 || strcmp (klass_name, "ModuleBuilder") == 0) { + } else if (strcmp (klass_name, "MonoModule") == 0 || strcmp (klass_name, "ModuleBuilder") == 0) { MonoReflectionModuleHandle m = MONO_HANDLE_CAST (MonoReflectionModule, obj); token = MONO_HANDLE_GETVAL (m, token); |