diff options
Diffstat (limited to 'src/mscorlib/src/System/Reflection')
118 files changed, 8222 insertions, 13387 deletions
diff --git a/src/mscorlib/src/System/Reflection/AmbiguousMatchException.cs b/src/mscorlib/src/System/Reflection/AmbiguousMatchException.cs deleted file mode 100644 index 795a8714d1..0000000000 --- a/src/mscorlib/src/System/Reflection/AmbiguousMatchException.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -//////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// -// -// AmbiguousMatchException is thrown when binding to a method results in more -// -// than one method matching the binding criteria. This exception is thrown in -// general when something is Ambiguous. -// -// -// -// -namespace System.Reflection { - using System; - using SystemException = System.SystemException; - using System.Runtime.Serialization; - [Serializable] - public sealed class AmbiguousMatchException : SystemException - { - - public AmbiguousMatchException() - : base(Environment.GetResourceString("RFLCT.Ambiguous")) { - SetErrorCode(__HResults.COR_E_AMBIGUOUSMATCH); - } - - public AmbiguousMatchException(String message) : base(message) { - SetErrorCode(__HResults.COR_E_AMBIGUOUSMATCH); - } - - public AmbiguousMatchException(String message, Exception inner) : base(message, inner) { - SetErrorCode(__HResults.COR_E_AMBIGUOUSMATCH); - } - - internal AmbiguousMatchException(SerializationInfo info, StreamingContext context) : base(info, context) { - } - - } -} diff --git a/src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs b/src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs new file mode 100644 index 0000000000..82966dba60 --- /dev/null +++ b/src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs @@ -0,0 +1,211 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.Generic; +using System.Security.Policy; +using System.IO; +using System.Configuration.Assemblies; +using StackCrawlMark = System.Threading.StackCrawlMark; +using System.Runtime.Serialization; +using System.Diagnostics.Contracts; +using System.Runtime.Loader; + +namespace System.Reflection +{ + public abstract partial class Assembly : ICustomAttributeProvider, ISerializable + { + public static Assembly LoadFrom(String assemblyFile) + { + if (assemblyFile == null) + throw new ArgumentNullException(nameof(assemblyFile)); + string fullPath = Path.GetFullPath(assemblyFile); + return AssemblyLoadContext.Default.LoadFromAssemblyPath(fullPath); + } + + // Evidence is protected in Assembly.Load() + [Obsolete("This method is obsolete and will be removed in a future release of the .NET Framework. Please use an overload of LoadFrom which does not take an Evidence parameter. See http://go.microsoft.com/fwlink/?LinkID=155570 for more information.")] + [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod + internal static Assembly LoadFrom(String assemblyFile, + Evidence securityEvidence) + { + Contract.Ensures(Contract.Result<Assembly>() != null); + + StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; + + return RuntimeAssembly.InternalLoadFrom( + assemblyFile, + securityEvidence, + null, // hashValue + AssemblyHashAlgorithm.None, + false,// forIntrospection); + ref stackMark); + } + + [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod + public static Assembly LoadFrom(String assemblyFile, + byte[] hashValue, + AssemblyHashAlgorithm hashAlgorithm) + { + throw new NotSupportedException(SR.NotSupported_AssemblyLoadFromHash); + } + + // Locate an assembly by the long form of the assembly name. + // eg. "Toolbox.dll, version=1.1.10.1220, locale=en, publickey=1234567890123456789012345678901234567890" + [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod + public static Assembly Load(String assemblyString) + { + Contract.Ensures(Contract.Result<Assembly>() != null); + Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly); + + StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; + return RuntimeAssembly.InternalLoad(assemblyString, null, ref stackMark, false /*forIntrospection*/); + } + + // Returns type from the assembly while keeping compatibility with Assembly.Load(assemblyString).GetType(typeName) for managed types. + // Calls Type.GetType for WinRT types. + // Note: Type.GetType fails for assembly names that start with weird characters like '['. By calling it for managed types we would + // break AppCompat. + [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod + internal static Type GetType_Compat(String assemblyString, String typeName) + { + // Normally we would get the stackMark only in public APIs. This is internal API, but it is AppCompat replacement of public API + // call Assembly.Load(assemblyString).GetType(typeName), therefore we take the stackMark here as well, to be fully compatible with + // the call sequence. + StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; + + RuntimeAssembly assembly; + AssemblyName assemblyName = RuntimeAssembly.CreateAssemblyName( + assemblyString, + false /*forIntrospection*/, + out assembly); + + if (assembly == null) + { + if (assemblyName.ContentType == AssemblyContentType.WindowsRuntime) + { + return Type.GetType(typeName + ", " + assemblyString, true /*throwOnError*/, false /*ignoreCase*/); + } + + assembly = RuntimeAssembly.InternalLoadAssemblyName( + assemblyName, null, null, ref stackMark, + true /*thrownOnFileNotFound*/, false /*forIntrospection*/); + } + return assembly.GetType(typeName, true /*throwOnError*/, false /*ignoreCase*/); + } + + // Locate an assembly by its name. The name can be strong or + // weak. The assembly is loaded into the domain of the caller. + [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod + public static Assembly Load(AssemblyName assemblyRef) + { + Contract.Ensures(Contract.Result<Assembly>() != null); + Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly); + + if (assemblyRef != null && assemblyRef.CodeBase != null) + { + throw new NotSupportedException(SR.NotSupported_AssemblyLoadCodeBase); + } + + StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; + return RuntimeAssembly.InternalLoadAssemblyName(assemblyRef, null, null, ref stackMark, true /*thrownOnFileNotFound*/, false /*forIntrospection*/); + } + + // Locate an assembly by its name. The name can be strong or + // weak. The assembly is loaded into the domain of the caller. + [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod + internal static Assembly Load(AssemblyName assemblyRef, IntPtr ptrLoadContextBinder) + { + Contract.Ensures(Contract.Result<Assembly>() != null); + Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly); + + if (assemblyRef != null && assemblyRef.CodeBase != null) + { + throw new NotSupportedException(SR.NotSupported_AssemblyLoadCodeBase); + } + + StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; + return RuntimeAssembly.InternalLoadAssemblyName(assemblyRef, null, null, ref stackMark, true /*thrownOnFileNotFound*/, false /*forIntrospection*/, ptrLoadContextBinder); + } + + // Loads the assembly with a COFF based IMAGE containing + // an emitted assembly. The assembly is loaded into the domain + // of the caller. The second parameter is the raw bytes + // representing the symbol store that matches the assembly. + [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod + public static Assembly Load(byte[] rawAssembly, + byte[] rawSymbolStore) + { + Contract.Ensures(Contract.Result<Assembly>() != null); + Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly); + + AppDomain.CheckLoadByteArraySupported(); + + if (rawAssembly == null) + throw new ArgumentNullException(nameof(rawAssembly)); + AssemblyLoadContext alc = new IndividualAssemblyLoadContext(); + MemoryStream assemblyStream = new MemoryStream(rawAssembly); + MemoryStream symbolStream = (rawSymbolStore != null) ? new MemoryStream(rawSymbolStore) : null; + return alc.LoadFromStream(assemblyStream, symbolStream); + } + + private static Dictionary<string, Assembly> s_loadfile = new Dictionary<string, Assembly>(); + + public static Assembly LoadFile(String path) + { + Contract.Ensures(Contract.Result<Assembly>() != null); + Contract.Ensures(!Contract.Result<Assembly>().ReflectionOnly); + + AppDomain.CheckLoadFileSupported(); + + Assembly result = null; + if (path == null) + throw new ArgumentNullException(nameof(path)); + + if (PathInternal.IsPartiallyQualified(path)) + { + throw new ArgumentException(SR.Argument_AbsolutePathRequired, nameof(path)); + } + + string normalizedPath = Path.GetFullPath(path); + + lock (s_loadfile) + { + if (s_loadfile.TryGetValue(normalizedPath, out result)) + return result; + AssemblyLoadContext alc = new IndividualAssemblyLoadContext(); + result = alc.LoadFromAssemblyPath(normalizedPath); + s_loadfile.Add(normalizedPath, result); + } + return result; + } + + /* + * Get the assembly that the current code is running from. + */ + [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod + public static Assembly GetExecutingAssembly() + { + StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; + return RuntimeAssembly.GetExecutingAssembly(ref stackMark); + } + + [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod + public static Assembly GetCallingAssembly() + { + // LookForMyCallersCaller is not guarantee to return the correct stack frame + // because of inlining, tail calls, etc. As a result GetCallingAssembly is not + // ganranteed to return the correct result. We should document it as such. + StackCrawlMark stackMark = StackCrawlMark.LookForMyCallersCaller; + return RuntimeAssembly.GetExecutingAssembly(ref stackMark); + } + + public static Assembly GetEntryAssembly() + { + AppDomainManager domainManager = AppDomain.CurrentDomain.DomainManager; + if (domainManager == null) + domainManager = new AppDomainManager(); + return domainManager.EntryAssembly; + } + } +} diff --git a/src/mscorlib/src/System/Reflection/AssemblyAttributes.cs b/src/mscorlib/src/System/Reflection/AssemblyAttributes.cs deleted file mode 100644 index 1e6688d1f4..0000000000 --- a/src/mscorlib/src/System/Reflection/AssemblyAttributes.cs +++ /dev/null @@ -1,387 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** -** -** -** -** Purpose: For Assembly-related custom attributes. -** -** -=============================================================================*/ - -namespace System.Reflection { - - using System; - using System.Configuration.Assemblies; - using System.Diagnostics.Contracts; - - [AttributeUsage (AttributeTargets.Assembly, Inherited=false)] - public sealed class AssemblyCopyrightAttribute : Attribute - { - private String m_copyright; - - public AssemblyCopyrightAttribute(String copyright) - { - m_copyright = copyright; - } - - public String Copyright - { - get { return m_copyright; } - } - } - - - [AttributeUsage (AttributeTargets.Assembly, Inherited=false)] - public sealed class AssemblyTrademarkAttribute : Attribute - { - private String m_trademark; - - public AssemblyTrademarkAttribute(String trademark) - { - m_trademark = trademark; - } - - public String Trademark - { - get { return m_trademark; } - } - } - - - [AttributeUsage (AttributeTargets.Assembly, Inherited=false)] - public sealed class AssemblyProductAttribute : Attribute - { - private String m_product; - - public AssemblyProductAttribute(String product) - { - m_product = product; - } - - public String Product - { - get { return m_product; } - } - } - - - [AttributeUsage (AttributeTargets.Assembly, Inherited=false)] - public sealed class AssemblyCompanyAttribute : Attribute - { - private String m_company; - - public AssemblyCompanyAttribute(String company) - { - m_company = company; - } - - public String Company - { - get { return m_company; } - } - } - - - [AttributeUsage (AttributeTargets.Assembly, Inherited=false)] - public sealed class AssemblyDescriptionAttribute : Attribute - { - private String m_description; - - public AssemblyDescriptionAttribute(String description) - { - m_description = description; - } - - public String Description - { - get { return m_description; } - } - } - - - [AttributeUsage (AttributeTargets.Assembly, Inherited=false)] - public sealed class AssemblyTitleAttribute : Attribute - { - private String m_title; - - public AssemblyTitleAttribute(String title) - { - m_title = title; - } - - public String Title - { - get { return m_title; } - } - } - - - [AttributeUsage (AttributeTargets.Assembly, Inherited=false)] - public sealed class AssemblyConfigurationAttribute : Attribute - { - private String m_configuration; - - public AssemblyConfigurationAttribute(String configuration) - { - m_configuration = configuration; - } - - public String Configuration - { - get { return m_configuration; } - } - } - - - [AttributeUsage (AttributeTargets.Assembly, Inherited=false)] - public sealed class AssemblyDefaultAliasAttribute : Attribute - { - private String m_defaultAlias; - - public AssemblyDefaultAliasAttribute(String defaultAlias) - { - m_defaultAlias = defaultAlias; - } - - public String DefaultAlias - { - get { return m_defaultAlias; } - } - } - - - [AttributeUsage (AttributeTargets.Assembly, Inherited=false)] - public sealed class AssemblyInformationalVersionAttribute : Attribute - { - private String m_informationalVersion; - - public AssemblyInformationalVersionAttribute(String informationalVersion) - { - m_informationalVersion = informationalVersion; - } - - public String InformationalVersion - { - get { return m_informationalVersion; } - } - } - - - [AttributeUsage(AttributeTargets.Assembly, Inherited=false)] - public sealed class AssemblyFileVersionAttribute : Attribute - { - private String _version; - - public AssemblyFileVersionAttribute(String version) - { - if (version == null) - throw new ArgumentNullException(nameof(version)); - Contract.EndContractBlock(); - _version = version; - } - - public String Version { - get { return _version; } - } - } - - - [AttributeUsage (AttributeTargets.Assembly, Inherited=false)] - public unsafe sealed class AssemblyCultureAttribute : Attribute - { - private String m_culture; - - public AssemblyCultureAttribute(String culture) - { - m_culture = culture; - } - - public String Culture - { - get { return m_culture; } - } - } - - - [AttributeUsage (AttributeTargets.Assembly, Inherited=false)] - public unsafe sealed class AssemblyVersionAttribute : Attribute - { - private String m_version; - - public AssemblyVersionAttribute(String version) - { - m_version = version; - } - - public String Version - { - get { return m_version; } - } - } - - - [AttributeUsage (AttributeTargets.Assembly, Inherited=false)] - public sealed class AssemblyKeyFileAttribute : Attribute - { - private String m_keyFile; - - public AssemblyKeyFileAttribute(String keyFile) - { - m_keyFile = keyFile; - } - - public String KeyFile - { - get { return m_keyFile; } - } - } - - - [AttributeUsage (AttributeTargets.Assembly, Inherited=false)] - public sealed class AssemblyDelaySignAttribute : Attribute - { - private bool m_delaySign; - - public AssemblyDelaySignAttribute(bool delaySign) - { - m_delaySign = delaySign; - } - - public bool DelaySign - { get - { return m_delaySign; } - } - } - - - [AttributeUsage(AttributeTargets.Assembly, Inherited=false)] - public unsafe sealed class AssemblyAlgorithmIdAttribute : Attribute - { - private uint m_algId; - - public AssemblyAlgorithmIdAttribute(AssemblyHashAlgorithm algorithmId) - { - m_algId = (uint) algorithmId; - } - - [CLSCompliant(false)] - public AssemblyAlgorithmIdAttribute(uint algorithmId) - { - m_algId = algorithmId; - } - - [CLSCompliant(false)] - public uint AlgorithmId - { - get { return m_algId; } - } - } - - - [AttributeUsage(AttributeTargets.Assembly, Inherited=false)] - public unsafe sealed class AssemblyFlagsAttribute : Attribute - { - private AssemblyNameFlags m_flags; - - [Obsolete("This constructor has been deprecated. Please use AssemblyFlagsAttribute(AssemblyNameFlags) instead. http://go.microsoft.com/fwlink/?linkid=14202")] - [CLSCompliant(false)] - public AssemblyFlagsAttribute(uint flags) - { - m_flags = (AssemblyNameFlags)flags; - } - - [Obsolete("This property has been deprecated. Please use AssemblyFlags instead. http://go.microsoft.com/fwlink/?linkid=14202")] - [CLSCompliant(false)] - public uint Flags - { - get { return (uint)m_flags; } - } - - // This, of course, should be typed as AssemblyNameFlags. The compat police don't allow such changes. - public int AssemblyFlags - { - get { return (int)m_flags; } - } - - [Obsolete("This constructor has been deprecated. Please use AssemblyFlagsAttribute(AssemblyNameFlags) instead. http://go.microsoft.com/fwlink/?linkid=14202")] - public AssemblyFlagsAttribute(int assemblyFlags) - { - m_flags = (AssemblyNameFlags)assemblyFlags; - } - - - public AssemblyFlagsAttribute(AssemblyNameFlags assemblyFlags) - { - m_flags = assemblyFlags; - } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple=true, Inherited=false)] - public sealed class AssemblyMetadataAttribute : Attribute - { - private String m_key; - private String m_value; - - public AssemblyMetadataAttribute(string key, string value) - { - m_key = key; - m_value = value; - } - - public string Key - { - get { return m_key; } - } - - public string Value - { - get { return m_value;} - } - } - - [AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple=false)] - public sealed class AssemblySignatureKeyAttribute : Attribute - { - private String _publicKey; - private String _countersignature; - - public AssemblySignatureKeyAttribute(String publicKey, String countersignature) - { - _publicKey = publicKey; - _countersignature = countersignature; - } - - public String PublicKey - { - get { return _publicKey; } - } - - public String Countersignature - { - get { return _countersignature; } - } - } - - [AttributeUsage (AttributeTargets.Assembly, Inherited=false)] - public sealed class AssemblyKeyNameAttribute : Attribute - { - private String m_keyName; - - public AssemblyKeyNameAttribute(String keyName) - { - m_keyName = keyName; - } - - public String KeyName - { - get { return m_keyName; } - } - } - -} - diff --git a/src/mscorlib/src/System/Reflection/AssemblyName.cs b/src/mscorlib/src/System/Reflection/AssemblyName.cs index 01be855646..80fdf5d162 100644 --- a/src/mscorlib/src/System/Reflection/AssemblyName.cs +++ b/src/mscorlib/src/System/Reflection/AssemblyName.cs @@ -13,7 +13,9 @@ ** ** ===========================================================*/ -namespace System.Reflection { + +namespace System.Reflection +{ using System; using System.IO; using System.Configuration.Assemblies; @@ -33,31 +35,31 @@ namespace System.Reflection { // If you modify any of these fields, you must also update the // AssemblyBaseObject structure in object.h // - private String _Name; // Name - private byte[] _PublicKey; - private byte[] _PublicKeyToken; - private CultureInfo _CultureInfo; - private String _CodeBase; // Potential location to get the file - private Version _Version; - - private StrongNameKeyPair _StrongNameKeyPair; + private String _Name; // Name + private byte[] _PublicKey; + private byte[] _PublicKeyToken; + private CultureInfo _CultureInfo; + private String _CodeBase; // Potential location to get the file + private Version _Version; + + private StrongNameKeyPair _StrongNameKeyPair; private SerializationInfo m_siInfo; //A temporary variable which we need during deserialization. - private byte[] _HashForControl; + private byte[] _HashForControl; private AssemblyHashAlgorithm _HashAlgorithm; private AssemblyHashAlgorithm _HashAlgorithmForControl; private AssemblyVersionCompatibility _VersionCompatibility; - private AssemblyNameFlags _Flags; - + private AssemblyNameFlags _Flags; + public AssemblyName() - { + { _HashAlgorithm = AssemblyHashAlgorithm.None; _VersionCompatibility = AssemblyVersionCompatibility.SameMachine; _Flags = AssemblyNameFlags.None; } - + // Set and get the name of the assembly. If this is a weak Name // then it optionally contains a site. For strong assembly names, // the name partitions up the strong name's namespace @@ -69,10 +71,12 @@ namespace System.Reflection { public Version Version { - get { + get + { return _Version; } - set { + set + { _Version = value; } } @@ -80,30 +84,34 @@ namespace System.Reflection { // Locales, internally the LCID is used for the match. public CultureInfo CultureInfo { - get { + get + { return _CultureInfo; } - set { - _CultureInfo = value; + set + { + _CultureInfo = value; } } public String CultureName { - get { + get + { return (_CultureInfo == null) ? null : _CultureInfo.Name; } - set { + set + { _CultureInfo = (value == null) ? null : new CultureInfo(value); } } - + public String CodeBase { get { return _CodeBase; } set { _CodeBase = value; } } - + public String EscapedCodeBase { get @@ -114,18 +122,21 @@ namespace System.Reflection { return EscapeCodeBase(_CodeBase); } } - - public ProcessorArchitecture ProcessorArchitecture + + public ProcessorArchitecture ProcessorArchitecture { - get { + get + { int x = (((int)_Flags) & 0x70) >> 4; - if(x > 5) + if (x > 5) x = 0; return (ProcessorArchitecture)x; } - set { + set + { int x = ((int)value) & 0x07; - if(x <= 5) { + if (x <= 5) + { _Flags = (AssemblyNameFlags)((int)_Flags & 0xFFFFFF0F); _Flags |= (AssemblyNameFlags)(x << 4); } @@ -151,8 +162,8 @@ namespace System.Reflection { } } } - - + + // Make a copy of this assembly name. public Object Clone() @@ -168,8 +179,8 @@ namespace System.Reflection { _CodeBase, _Flags, _StrongNameKeyPair); - name._HashForControl=_HashForControl; - name._HashAlgorithmForControl=_HashAlgorithmForControl; + name._HashForControl = _HashForControl; + name._HashAlgorithmForControl = _HashAlgorithmForControl; return name; } @@ -180,7 +191,7 @@ namespace System.Reflection { */ static public AssemblyName GetAssemblyName(String assemblyFile) { - if(assemblyFile == null) + if (assemblyFile == null) throw new ArgumentNullException(nameof(assemblyFile)); Contract.EndContractBlock(); @@ -189,11 +200,11 @@ namespace System.Reflection { string fullPath = Path.GetFullPath(assemblyFile); return nGetFileInformation(fullPath); } - + internal void SetHashControl(byte[] hash, AssemblyHashAlgorithm hashAlgorithm) { - _HashForControl=hash; - _HashAlgorithmForControl=hashAlgorithm; + _HashForControl = hash; + _HashAlgorithmForControl = hashAlgorithm; } // The public key that is used to verify an assemblies @@ -239,7 +250,8 @@ namespace System.Reflection { public AssemblyNameFlags Flags { get { return (AssemblyNameFlags)((uint)_Flags & 0xFFFFF10F); } - set { + set + { _Flags &= unchecked((AssemblyNameFlags)0x00000EF0); _Flags |= (value & unchecked((AssemblyNameFlags)0xFFFFF10F)); } @@ -250,7 +262,7 @@ namespace System.Reflection { get { return _HashAlgorithm; } set { _HashAlgorithm = value; } } - + public AssemblyVersionCompatibility VersionCompatibility { get { return _VersionCompatibility; } @@ -262,21 +274,22 @@ namespace System.Reflection { get { return _StrongNameKeyPair; } set { _StrongNameKeyPair = value; } } - + public String FullName { - get { + get + { return nToString(); } } - + // Returns the stringized version of the assembly name. public override String ToString() { String s = FullName; - if(s == null) + if (s == null) return base.ToString(); - else + else return s; } @@ -291,7 +304,7 @@ namespace System.Reflection { info.AddValue("_PublicKey", _PublicKey, typeof(byte[])); info.AddValue("_PublicKeyToken", _PublicKeyToken, typeof(byte[])); #if FEATURE_USE_LCID - info.AddValue("_CultureInfo", (_CultureInfo == null) ? -1 :_CultureInfo.LCID); + info.AddValue("_CultureInfo", (_CultureInfo == null) ? -1 : _CultureInfo.LCID); #endif info.AddValue("_CodeBase", _CodeBase); info.AddValue("_Version", _Version); @@ -300,8 +313,8 @@ namespace System.Reflection { info.AddValue("_StrongNameKeyPair", _StrongNameKeyPair, typeof(StrongNameKeyPair)); info.AddValue("_VersionCompatibility", _VersionCompatibility, typeof(AssemblyVersionCompatibility)); info.AddValue("_Flags", _Flags, typeof(AssemblyNameFlags)); - info.AddValue("_HashForControl",_HashForControl,typeof(byte[])); - } + info.AddValue("_HashForControl", _HashForControl, typeof(byte[])); + } public void OnDeserialization(Object sender) { @@ -310,8 +323,8 @@ namespace System.Reflection { return; _Name = m_siInfo.GetString("_Name"); - _PublicKey = (byte[]) m_siInfo.GetValue("_PublicKey", typeof(byte[])); - _PublicKeyToken = (byte[]) m_siInfo.GetValue("_PublicKeyToken", typeof(byte[])); + _PublicKey = (byte[])m_siInfo.GetValue("_PublicKey", typeof(byte[])); + _PublicKeyToken = (byte[])m_siInfo.GetValue("_PublicKeyToken", typeof(byte[])); #if FEATURE_USE_LCID int lcid = (int)m_siInfo.GetInt32("_CultureInfo"); if (lcid != -1) @@ -319,17 +332,19 @@ namespace System.Reflection { #endif _CodeBase = m_siInfo.GetString("_CodeBase"); - _Version = (Version) m_siInfo.GetValue("_Version", typeof(Version)); - _HashAlgorithm = (AssemblyHashAlgorithm) m_siInfo.GetValue("_HashAlgorithm", typeof(AssemblyHashAlgorithm)); - _StrongNameKeyPair = (StrongNameKeyPair) m_siInfo.GetValue("_StrongNameKeyPair", typeof(StrongNameKeyPair)); + _Version = (Version)m_siInfo.GetValue("_Version", typeof(Version)); + _HashAlgorithm = (AssemblyHashAlgorithm)m_siInfo.GetValue("_HashAlgorithm", typeof(AssemblyHashAlgorithm)); + _StrongNameKeyPair = (StrongNameKeyPair)m_siInfo.GetValue("_StrongNameKeyPair", typeof(StrongNameKeyPair)); _VersionCompatibility = (AssemblyVersionCompatibility)m_siInfo.GetValue("_VersionCompatibility", typeof(AssemblyVersionCompatibility)); - _Flags = (AssemblyNameFlags) m_siInfo.GetValue("_Flags", typeof(AssemblyNameFlags)); + _Flags = (AssemblyNameFlags)m_siInfo.GetValue("_Flags", typeof(AssemblyNameFlags)); - try { - _HashAlgorithmForControl = (AssemblyHashAlgorithm) m_siInfo.GetValue("_HashAlgorithmForControl", typeof(AssemblyHashAlgorithm)); - _HashForControl = (byte[]) m_siInfo.GetValue("_HashForControl", typeof(byte[])); + try + { + _HashAlgorithmForControl = (AssemblyHashAlgorithm)m_siInfo.GetValue("_HashAlgorithmForControl", typeof(AssemblyHashAlgorithm)); + _HashForControl = (byte[])m_siInfo.GetValue("_HashForControl", typeof(byte[])); } - catch (SerializationException) { // RTM did not have these defined + catch (SerializationException) + { // RTM did not have these defined _HashAlgorithmForControl = AssemblyHashAlgorithm.None; _HashForControl = null; } @@ -341,7 +356,7 @@ namespace System.Reflection { internal AssemblyName(SerializationInfo info, StreamingContext context) { //The graph is not valid until OnDeserialization() has been called. - m_siInfo = info; + m_siInfo = info; } public AssemblyName(String assemblyName) @@ -351,32 +366,32 @@ namespace System.Reflection { Contract.EndContractBlock(); if ((assemblyName.Length == 0) || (assemblyName[0] == '\0')) - throw new ArgumentException(Environment.GetResourceString("Format_StringZeroLength")); + throw new ArgumentException(SR.Format_StringZeroLength); _Name = assemblyName; nInit(); } - static public bool ReferenceMatchesDefinition(AssemblyName reference, - AssemblyName definition) + /// <summary> + /// Compares the simple names disregarding Version, Culture and PKT. While this clearly does not + /// match the intent of this api, this api has been broken this way since its debut and we cannot + /// change its behavior now. + /// </summary> + public static bool ReferenceMatchesDefinition(AssemblyName reference, AssemblyName definition) { - // Optimization for common use case - if (Object.ReferenceEquals(reference, definition)) - { + if (object.ReferenceEquals(reference, definition)) return true; - } - return ReferenceMatchesDefinitionInternal(reference, definition, true); - } - - /// "parse" tells us to parse the simple name of the assembly as if it was the full name - /// almost never the right thing to do, but needed for compat - [MethodImplAttribute(MethodImplOptions.InternalCall)] - static internal extern bool ReferenceMatchesDefinitionInternal(AssemblyName reference, - AssemblyName definition, - bool parse); + if (reference == null) + throw new ArgumentNullException(nameof(reference)); + if (definition == null) + throw new ArgumentNullException(nameof(definition)); + string refName = reference.Name ?? string.Empty; + string defName = definition.Name ?? string.Empty; + return refName.Equals(defName, StringComparison.OrdinalIgnoreCase); + } [MethodImplAttribute(MethodImplOptions.InternalCall)] internal extern void nInit(out RuntimeAssembly assembly, bool forIntrospection, bool raiseResolveEvent); @@ -431,7 +446,7 @@ namespace System.Reflection { return ProcessorArchitecture.None; } - internal void Init(String name, + internal void Init(String name, byte[] publicKey, byte[] publicKeyToken, Version version, @@ -444,18 +459,20 @@ namespace System.Reflection { { _Name = name; - if (publicKey != null) { + if (publicKey != null) + { _PublicKey = new byte[publicKey.Length]; Array.Copy(publicKey, _PublicKey, publicKey.Length); } - - if (publicKeyToken != null) { + + if (publicKeyToken != null) + { _PublicKeyToken = new byte[publicKeyToken.Length]; Array.Copy(publicKeyToken, _PublicKeyToken, publicKeyToken.Length); } - + if (version != null) - _Version = (Version) version.Clone(); + _Version = (Version)version.Clone(); _CultureInfo = cultureInfo; _HashAlgorithm = hashAlgorithm; @@ -480,7 +497,7 @@ namespace System.Reflection { { if (codebase == null) return string.Empty; - + int position = 0; char[] dest = EscapeString(codebase, 0, codebase.Length, null, ref position, true, c_DummyChar, c_DummyChar, c_DummyChar); if (dest == null) @@ -528,7 +545,7 @@ namespace System.Reflection { { // Should be a rare case where the app tries to feed an invalid Unicode surrogates pair if (count == 1 || count == end - i) - throw new FormatException(Environment.GetResourceString("Arg_FormatException")); + throw new FormatException(SR.Arg_FormatException); // need to grab one more char as a Surrogate except when it's a bogus input ++count; } @@ -544,7 +561,7 @@ namespace System.Reflection { // This is the only exception that built in UriParser can throw after a Uri ctor. // Should not happen unless the app tries to feed an invalid Unicode String if (numberOfBytes == 0) - throw new FormatException(Environment.GetResourceString("Arg_FormatException")); + throw new FormatException(SR.Arg_FormatException); i += (count - 1); @@ -620,7 +637,7 @@ namespace System.Reflection { dest[destPos++] = pStr[prevInputPos++]; return dest; } - + internal static void EscapeAsciiChar(char ch, char[] to, ref int pos) { to[pos++] = '%'; @@ -657,7 +674,7 @@ namespace System.Reflection { ? ((int)next - (int)'A') : ((int)next - (int)'a')) + 10))); - } + } private static unsafe bool IsReservedUnreservedOrHash(char c) { @@ -688,7 +705,7 @@ namespace System.Reflection { { return IsAsciiLetter(character) || (character >= '0' && character <= '9'); } - + private static readonly char[] s_hexUpperChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; @@ -696,7 +713,7 @@ namespace System.Reflection { private const short c_MaxAsciiCharsReallocate = 40; private const short c_MaxUnicodeCharsReallocate = 40; private const short c_MaxUTF_8BytesPerUnicodeChar = 4; - private const short c_EncodedCharsPerByte = 3; + private const short c_EncodedCharsPerByte = 3; private const string RFC3986ReservedMarks = @":/?#[]@!$&'()*+,;="; private const string RFC3986UnreservedMarks = @"-._~"; } diff --git a/src/mscorlib/src/System/Reflection/AssemblyNameFlags.cs b/src/mscorlib/src/System/Reflection/AssemblyNameFlags.cs deleted file mode 100644 index b86955efa5..0000000000 --- a/src/mscorlib/src/System/Reflection/AssemblyNameFlags.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================ -** -** -** -** -** -** -** Purpose: Flags controlling how an AssemblyName is used -** during binding -** -** -===========================================================*/ -namespace System.Reflection { - - using System; - [Serializable] - [FlagsAttribute()] - public enum AssemblyNameFlags - { - None = 0x0000, - // Flag used to indicate that an assembly ref contains the full public key, not the compressed token. - // Must match afPublicKey in CorHdr.h. - PublicKey = 0x0001, - //ProcArchMask = 0x00F0, // Bits describing the processor architecture - // Accessible via AssemblyName.ProcessorArchitecture - EnableJITcompileOptimizer = 0x4000, - EnableJITcompileTracking = 0x8000, - Retargetable = 0x0100, - //ContentType = 0x0E00, // Bits describing the ContentType are accessible via AssemblyName.ContentType - } - - [Serializable] - public enum AssemblyContentType - { - Default = 0x0000, - WindowsRuntime = 0x0001 - } - - [Serializable] - public enum ProcessorArchitecture - { - None = 0x0000, - MSIL = 0x0001, - X86 = 0x0002, - IA64 = 0x0003, - Amd64 = 0x0004, - Arm = 0x0005 - } -} diff --git a/src/mscorlib/src/System/Reflection/Associates.cs b/src/mscorlib/src/System/Reflection/Associates.cs index 9eaf74a6e9..ed06cb46fc 100644 --- a/src/mscorlib/src/System/Reflection/Associates.cs +++ b/src/mscorlib/src/System/Reflection/Associates.cs @@ -4,22 +4,22 @@ // +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Diagnostics.Contracts; + namespace System.Reflection { - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Diagnostics.Contracts; - internal static class Associates { [Flags] internal enum Attributes { ComposedOfAllVirtualMethods = 0x1, - ComposedOfAllPrivateMethods = 0x2, - ComposedOfNoPublicMembers = 0x4, - ComposedOfNoStaticMembers = 0x8, + ComposedOfAllPrivateMethods = 0x2, + ComposedOfNoPublicMembers = 0x4, + ComposedOfNoStaticMembers = 0x8, } internal static bool IncludeAccessor(MethodInfo associate, bool nonPublic) @@ -51,7 +51,7 @@ namespace System.Reflection IntPtr[] genericArgumentHandles = null; int genericArgumentCount = 0; - RuntimeType [] genericArguments = declaredType.GetTypeHandleInternal().GetInstantiationInternal(); + RuntimeType[] genericArguments = declaredType.GetTypeHandleInternal().GetInstantiationInternal(); if (genericArguments != null) { genericArgumentCount = genericArguments.Length; @@ -85,7 +85,7 @@ namespace System.Reflection // the same or any property in the derived class. if ((methAttr & MethodAttributes.Virtual) != 0) { - bool declaringTypeIsClass = + bool declaringTypeIsClass = (RuntimeTypeHandle.GetAttributes(declaredType) & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Class; // It makes no sense to search for a virtual override of a method declared on an interface. @@ -99,7 +99,7 @@ namespace System.Reflection } } - RuntimeMethodInfo associateMethod = + RuntimeMethodInfo associateMethod = RuntimeType.GetMethodBase(reflectedType, associateMethodHandle) as RuntimeMethodInfo; // suppose a property was mapped to a method not in the derivation hierarchy of the reflectedTypeHandle @@ -125,13 +125,13 @@ namespace System.Reflection { addOn = removeOn = fireOn = getter = setter = null; - Attributes attributes = + Attributes attributes = Attributes.ComposedOfAllPrivateMethods | Attributes.ComposedOfAllVirtualMethods | Attributes.ComposedOfNoPublicMembers | Attributes.ComposedOfNoStaticMembers; - while(RuntimeTypeHandle.IsGenericVariable(reflectedType)) + while (RuntimeTypeHandle.IsGenericVariable(reflectedType)) reflectedType = (RuntimeType)reflectedType.BaseType; bool isInherited = declaringType != reflectedType; @@ -156,12 +156,12 @@ namespace System.Reflection continue; MethodAttributes methAttr = associateMethod.Attributes; - bool isPrivate =(methAttr & MethodAttributes.MemberAccessMask) == MethodAttributes.Private; - bool isVirtual =(methAttr & MethodAttributes.Virtual) != 0; + bool isPrivate = (methAttr & MethodAttributes.MemberAccessMask) == MethodAttributes.Private; + bool isVirtual = (methAttr & MethodAttributes.Virtual) != 0; MethodAttributes visibility = methAttr & MethodAttributes.MemberAccessMask; bool isPublic = visibility == MethodAttributes.Public; - bool isStatic =(methAttr & MethodAttributes.Static) != 0; + bool isStatic = (methAttr & MethodAttributes.Static) != 0; if (isPublic) { @@ -202,10 +202,9 @@ namespace System.Reflection bool isPseudoStatic = (attributes & Attributes.ComposedOfNoStaticMembers) == 0; bindingFlags = RuntimeType.FilterPreCalculate(isPseudoPublic, isInherited, isPseudoStatic); - composedOfAllPrivateMethods =(attributes & Attributes.ComposedOfAllPrivateMethods) != 0; + composedOfAllPrivateMethods = (attributes & Attributes.ComposedOfAllPrivateMethods) != 0; other = (otherList != null) ? otherList.ToArray() : null; } } - } diff --git a/src/mscorlib/src/System/Reflection/Binder.cs b/src/mscorlib/src/System/Reflection/Binder.cs deleted file mode 100644 index bf4545fe81..0000000000 --- a/src/mscorlib/src/System/Reflection/Binder.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -//////////////////////////////////////////////////////////////////////////////// -// -// -// This interface defines a set of methods which interact with reflection -// during the binding process. This control allows systems to apply language -// specific semantics to the binding and invocation process. -// -// -namespace System.Reflection { - using System; - using System.Runtime.InteropServices; - using CultureInfo = System.Globalization.CultureInfo; - - [Serializable] - public abstract class Binder - { - // Given a set of methods that match the basic criteria, select a method to - // invoke. When this method is finished, we should have - public abstract MethodBase BindToMethod(BindingFlags bindingAttr,MethodBase[] match,ref Object[] args, - ParameterModifier[] modifiers,CultureInfo culture,String[] names, out Object state); - - // Given a set of methods that match the basic criteria, select a method to - // invoke. When this method is finished, we should have - public abstract FieldInfo BindToField(BindingFlags bindingAttr,FieldInfo[] match, - Object value,CultureInfo culture); - - // Given a set of methods that match the base criteria, select a method based - // upon an array of types. This method should return null if no method matchs - // the criteria. - public abstract MethodBase SelectMethod(BindingFlags bindingAttr,MethodBase[] match, - Type[] types,ParameterModifier[] modifiers); - - - // Given a set of propreties that match the base criteria, select one. - public abstract PropertyInfo SelectProperty(BindingFlags bindingAttr,PropertyInfo[] match, - Type returnType,Type[] indexes,ParameterModifier[] modifiers); - - // ChangeType - // This method will convert the value into the property type. - // It throws a cast exception if this fails. - public abstract Object ChangeType(Object value,Type type,CultureInfo culture); - - public abstract void ReorderArgumentArray(ref Object[] args, Object state); - } -} diff --git a/src/mscorlib/src/System/Reflection/BindingFlags.cs b/src/mscorlib/src/System/Reflection/BindingFlags.cs deleted file mode 100644 index ae0a6d68d3..0000000000 --- a/src/mscorlib/src/System/Reflection/BindingFlags.cs +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -//////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// -// -// BindingFlags are a set of flags that control the binding and invocation process -// -// in Reflection. There are two processes. The first is selection of a Member which -// is the binding phase. The second, is invocation. These flags control how this -// process works. -// -// -namespace System.Reflection { - - using System; - [Serializable] - [Flags] - public enum BindingFlags - { - - // NOTES: We have lookup masks defined in RuntimeType and Activator. If we - // change the lookup values then these masks may need to change also. - - // a place holder for no flag specifed - Default = 0x00, - - // These flags indicate what to search for when binding - IgnoreCase = 0x01, // Ignore the case of Names while searching - DeclaredOnly = 0x02, // Only look at the members declared on the Type - Instance = 0x04, // Include Instance members in search - Static = 0x08, // Include Static members in search - Public = 0x10, // Include Public members in search - NonPublic = 0x20, // Include Non-Public members in search - FlattenHierarchy = 0x40, // Rollup the statics into the class. - - // These flags are used by InvokeMember to determine - // what type of member we are trying to Invoke. - // BindingAccess = 0xFF00; - InvokeMethod = 0x0100, - CreateInstance = 0x0200, - GetField = 0x0400, - SetField = 0x0800, - GetProperty = 0x1000, - SetProperty = 0x2000, - - // These flags are also used by InvokeMember but they should only - // be used when calling InvokeMember on a COM object. - PutDispProperty = 0x4000, - PutRefDispProperty = 0x8000, - - ExactBinding = 0x010000, // Bind with Exact Type matching, No Change type - SuppressChangeType = 0x020000, - - // DefaultValueBinding will return the set of methods having ArgCount or - // more parameters. This is used for default values, etc. - OptionalParamBinding = 0x040000, - - // These are a couple of misc attributes used - IgnoreReturn = 0x01000000, // This is used in COM Interop - } -} diff --git a/src/mscorlib/src/System/Reflection/CallingConventions.cs b/src/mscorlib/src/System/Reflection/CallingConventions.cs deleted file mode 100644 index 266dd55184..0000000000 --- a/src/mscorlib/src/System/Reflection/CallingConventions.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -//////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// -// -// CallingConventions is a set of Bits representing the calling conventions -// -// in the system. -// -// -namespace System.Reflection { - using System.Runtime.InteropServices; - using System; - [Serializable] - [Flags] - public enum CallingConventions - { - //NOTE: If you change this please update COMMember.cpp. These - // are defined there. - Standard = 0x0001, - VarArgs = 0x0002, - Any = Standard | VarArgs, - HasThis = 0x0020, - ExplicitThis = 0x0040, - } -} diff --git a/src/mscorlib/src/System/Reflection/ConstructorInfo.CoreCLR.cs b/src/mscorlib/src/System/Reflection/ConstructorInfo.CoreCLR.cs new file mode 100644 index 0000000000..c96bfb5ac1 --- /dev/null +++ b/src/mscorlib/src/System/Reflection/ConstructorInfo.CoreCLR.cs @@ -0,0 +1,11 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace System.Reflection +{ + public abstract partial class ConstructorInfo : MethodBase + { + internal virtual Type GetReturnType() { throw new NotImplementedException(); } + } +} diff --git a/src/mscorlib/src/System/Reflection/CustomAttribute.cs b/src/mscorlib/src/System/Reflection/CustomAttribute.cs index b71c7bbff3..96eb45f3e4 100644 --- a/src/mscorlib/src/System/Reflection/CustomAttribute.cs +++ b/src/mscorlib/src/System/Reflection/CustomAttribute.cs @@ -18,7 +18,7 @@ using System.Runtime.ConstrainedExecution; using System.Runtime.Versioning; using System.Diagnostics.Contracts; -namespace System.Reflection +namespace System.Reflection { [Serializable] public class CustomAttributeData @@ -268,7 +268,7 @@ namespace System.Reflection if (type.IsValueType) return CustomAttributeEncoding.Undefined; - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidKindOfTypeForCA"), nameof(type)); + throw new ArgumentException(SR.Argument_InvalidKindOfTypeForCA, nameof(type)); } private static CustomAttributeType InitCustomAttributeType(RuntimeType parameterType) { @@ -300,8 +300,8 @@ namespace System.Reflection customAttributes[i] = new CustomAttributeData(module, records[i]); return Array.AsReadOnly(customAttributes); - } - #endregion + } + #endregion #region Internal Static Members internal unsafe static CustomAttributeRecord[] GetCustomAttributeRecords(RuntimeModule module, int targetToken) @@ -361,7 +361,7 @@ namespace System.Reflection m_scope = scope; m_ctor = (RuntimeConstructorInfo)RuntimeType.GetMethodBase(scope, caRecord.tkCtor); - ParameterInfo[] parameters = m_ctor.GetParametersNoCopy(); + ParameterInfo[] parameters = m_ctor.GetParametersNoCopy(); m_ctorParams = new CustomAttributeCtorParameter[parameters.Length]; for (int i = 0; i < parameters.Length; i++) m_ctorParams[i] = new CustomAttributeCtorParameter(InitCustomAttributeType((RuntimeType)parameters[i].ParameterType)); @@ -417,8 +417,7 @@ namespace System.Reflection new CustomAttributeNamedArgument(type.GetField("CallingConvention"), dllImport.CallingConvention), new CustomAttributeNamedArgument(type.GetField("BestFitMapping"), dllImport.BestFitMapping), new CustomAttributeNamedArgument(type.GetField("ThrowOnUnmappableChar"), dllImport.ThrowOnUnmappableChar) - - }); +}); } private void Init(FieldOffsetAttribute fieldOffset) { @@ -491,11 +490,11 @@ namespace System.Reflection public override string ToString() { string ctorArgs = ""; - for (int i = 0; i < ConstructorArguments.Count; i ++) + for (int i = 0; i < ConstructorArguments.Count; i++) ctorArgs += String.Format(CultureInfo.CurrentCulture, i == 0 ? "{0}" : ", {0}", ConstructorArguments[i]); string namedArgs = ""; - for (int i = 0; i < NamedArguments.Count; i ++) + for (int i = 0; i < NamedArguments.Count; i++) namedArgs += String.Format(CultureInfo.CurrentCulture, i == 0 && ctorArgs.Length == 0 ? "{0}" : ", {0}", NamedArguments[i]); return String.Format(CultureInfo.CurrentCulture, "[{0}({1}{2})]", Constructor.DeclaringType.FullName, ctorArgs, namedArgs); @@ -514,7 +513,7 @@ namespace System.Reflection public Type AttributeType { get { return Constructor.DeclaringType; } } public virtual ConstructorInfo Constructor { get { return m_ctor; } } - + public virtual IList<CustomAttributeTypedArgument> ConstructorArguments { get @@ -605,7 +604,7 @@ namespace System.Reflection else if (property != null) type = property.PropertyType; else - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidMemberForNamedArgument")); + throw new ArgumentException(SR.Argument_InvalidMemberForNamedArgument); m_memberInfo = memberInfo; m_value = new CustomAttributeTypedArgument(type, value); @@ -627,7 +626,7 @@ namespace System.Reflection if (m_memberInfo == null) return base.ToString(); - return String.Format(CultureInfo.CurrentCulture, "{0} = {1}", MemberInfo.Name, TypedValue.ToString(ArgumentType != typeof(object))); + return String.Format(CultureInfo.CurrentCulture, "{0} = {1}", MemberInfo.Name, TypedValue.ToString(ArgumentType != typeof(object))); } public override int GetHashCode() { @@ -640,14 +639,14 @@ namespace System.Reflection #endregion #region Internal Members - internal Type ArgumentType - { - get - { - return m_memberInfo is FieldInfo ? - ((FieldInfo)m_memberInfo).FieldType : - ((PropertyInfo)m_memberInfo).PropertyType; - } + internal Type ArgumentType + { + get + { + return m_memberInfo is FieldInfo ? + ((FieldInfo)m_memberInfo).FieldType : + ((PropertyInfo)m_memberInfo).PropertyType; + } } #endregion @@ -730,8 +729,8 @@ namespace System.Reflection case (CustomAttributeEncoding.Object): return typeof(object); - default : - throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (int)encodedType), nameof(encodedType)); + default: + throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, (int)encodedType), nameof(encodedType)); } } @@ -776,7 +775,7 @@ namespace System.Reflection unsafe { return *(double*)&val; } default: - throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (int)val), nameof(val)); + throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, (int)val), nameof(val)); } } private static RuntimeType ResolveType(RuntimeModule scope, string typeName) @@ -785,7 +784,7 @@ namespace System.Reflection if (type == null) throw new InvalidOperationException( - String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Arg_CATypeResolutionFailed"), typeName)); + String.Format(CultureInfo.CurrentUICulture, SR.Arg_CATypeResolutionFailed, typeName)); return type; } @@ -848,17 +847,17 @@ namespace System.Reflection else if (encodedType == CustomAttributeEncoding.Type) { m_argumentType = typeof(Type); - + m_value = null; if (encodedArg.StringValue != null) m_value = ResolveType(scope, encodedArg.StringValue); } else if (encodedType == CustomAttributeEncoding.Array) - { + { encodedType = encodedArg.CustomAttributeType.EncodedArrayType; Type elementType; - + if (encodedType == CustomAttributeEncoding.Enum) { elementType = ResolveType(scope, encodedArg.CustomAttributeType.EnumName); @@ -869,10 +868,10 @@ namespace System.Reflection } m_argumentType = elementType.MakeArrayType(); - + if (encodedArg.ArrayValue == null) { - m_value = null; + m_value = null; } else { @@ -949,12 +948,12 @@ namespace System.Reflection return m_argumentType; } } - public object Value - { - get + public object Value + { + get { return m_value; - } + } } #endregion } @@ -994,17 +993,17 @@ namespace System.Reflection [Serializable] [StructLayout(LayoutKind.Auto)] internal struct CustomAttributeEncodedArgument - { + { #region Parser [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern void ParseAttributeArguments( - IntPtr pCa, - int cCa, + IntPtr pCa, + int cCa, ref CustomAttributeCtorParameter[] CustomAttributeCtorParameters, ref CustomAttributeNamedParameter[] CustomAttributeTypedArgument, RuntimeAssembly assembly); - internal static void ParseAttributeArguments(ConstArray attributeBlob, + internal static void ParseAttributeArguments(ConstArray attributeBlob, ref CustomAttributeCtorParameter[] customAttributeCtorParameters, ref CustomAttributeNamedParameter[] customAttributeNamedParameters, RuntimeModule customAttributeModule) @@ -1045,7 +1044,7 @@ namespace System.Reflection public string StringValue { get { return m_stringValue; } } #endregion } - + [Serializable] [StructLayout(LayoutKind.Auto)] internal struct CustomAttributeNamedParameter @@ -1077,7 +1076,7 @@ namespace System.Reflection public CustomAttributeEncodedArgument EncodedArgument { get { return m_encodedArgument; } } #endregion } - + [Serializable] [StructLayout(LayoutKind.Auto)] internal struct CustomAttributeCtorParameter @@ -1110,18 +1109,18 @@ namespace System.Reflection private CustomAttributeEncoding m_encodedType; // ...array private CustomAttributeEncoding m_encodedEnumType; // ...enum private CustomAttributeEncoding m_encodedArrayType; // ...enum type - private CustomAttributeEncoding m_padding; + private CustomAttributeEncoding m_padding; #endregion #region Constructor - public CustomAttributeType(CustomAttributeEncoding encodedType, CustomAttributeEncoding encodedArrayType, + public CustomAttributeType(CustomAttributeEncoding encodedType, CustomAttributeEncoding encodedArrayType, CustomAttributeEncoding encodedEnumType, string enumName) { m_encodedType = encodedType; m_encodedArrayType = encodedArrayType; m_encodedEnumType = encodedEnumType; m_enumName = enumName; - m_padding = m_encodedType; + m_padding = m_encodedType; } #endregion @@ -1145,7 +1144,7 @@ namespace System.Reflection { Contract.Requires(type != null); - if (type.GetElementType() != null) + if (type.GetElementType() != null) return false; if (PseudoCustomAttribute.IsDefined(type, caType)) @@ -1252,7 +1251,7 @@ namespace System.Reflection return IsCustomAttributeDefined(parameter.GetRuntimeModule(), parameter.MetadataToken, caType); } - internal static bool IsDefined(RuntimeAssembly assembly, RuntimeType caType) + internal static bool IsDefined(RuntimeAssembly assembly, RuntimeType caType) { Contract.Requires(assembly != null); Contract.Requires(caType != null); @@ -1279,8 +1278,8 @@ namespace System.Reflection Contract.Requires(type != null); Contract.Requires(caType != null); - if (type.GetElementType() != null) - return (caType.IsValueType) ? EmptyArray<Object>.Value : CreateAttributeArrayHelper(caType, 0); + if (type.GetElementType() != null) + return (caType.IsValueType) ? Array.Empty<Object>() : CreateAttributeArrayHelper(caType, 0); if (type.IsGenericType && !type.IsGenericTypeDefinition) type = type.GetGenericTypeDefinition() as RuntimeType; @@ -1323,7 +1322,7 @@ namespace System.Reflection private static bool AllowCriticalCustomAttributes(RuntimeType type) { - if (type.IsGenericParameter) + if (type.IsGenericParameter) { // Generic parameters don't have transparency state, so look at the // declaring method/type. One of declaringMethod or declaringType @@ -1331,7 +1330,7 @@ namespace System.Reflection MethodBase declaringMethod = type.DeclaringMethod; if (declaringMethod != null) { - return AllowCriticalCustomAttributes(declaringMethod); + return AllowCriticalCustomAttributes(declaringMethod); } else { @@ -1394,9 +1393,9 @@ namespace System.Reflection bool useObjectArray = (caType == null || caType.IsValueType || caType.ContainsGenericParameters); Type arrayType = useObjectArray ? typeof(object) : caType; - while (pcaCount > 0) + while (pcaCount > 0) result.Add(pca[--pcaCount]); - + while (method != null) { object[] attributes = GetCustomAttributes(method.GetRuntimeModule(), method.MetadataToken, 0, caType, mustBeInheritable, result, !AllowCriticalCustomAttributes(method)); @@ -1478,12 +1477,12 @@ namespace System.Reflection int pcaCount = 0; Attribute[] pca = PseudoCustomAttribute.GetCustomAttributes(parameter, caType, out pcaCount); - object[] attributes = GetCustomAttributes(parameter.GetRuntimeModule(), parameter.MetadataToken, pcaCount, caType, !AllowCriticalCustomAttributes(parameter)); + object[] attributes = GetCustomAttributes(parameter.GetRuntimeModule(), parameter.MetadataToken, pcaCount, caType, !AllowCriticalCustomAttributes(parameter)); if (pcaCount > 0) Array.Copy(pca, 0, attributes, attributes.Length - pcaCount, pcaCount); return attributes; } - internal static Object[] GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) + internal static Object[] GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) { Contract.Requires(assembly != null); Contract.Requires(caType != null); @@ -1497,7 +1496,7 @@ namespace System.Reflection return attributes; } - internal static Object[] GetCustomAttributes(RuntimeModule module, RuntimeType caType) + internal static Object[] GetCustomAttributes(RuntimeModule module, RuntimeType caType) { Contract.Requires(module != null); Contract.Requires(caType != null); @@ -1525,7 +1524,7 @@ namespace System.Reflection RuntimeModule decoratedModule, int decoratedMetadataToken, RuntimeType attributeFilterType, int attributeCtorToken, bool mustBeInheritable) { if (decoratedModule.Assembly.ReflectionOnly) - throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyCA")); + throw new InvalidOperationException(SR.Arg_ReflectionOnlyCA); Contract.EndContractBlock(); CustomAttributeRecord[] car = CustomAttributeData.GetCustomAttributeRecords(decoratedModule, decoratedMetadataToken); @@ -1577,11 +1576,11 @@ namespace System.Reflection } private unsafe static object[] GetCustomAttributes( - RuntimeModule decoratedModule, int decoratedMetadataToken, int pcaCount, + RuntimeModule decoratedModule, int decoratedMetadataToken, int pcaCount, RuntimeType attributeFilterType, bool mustBeInheritable, IList derivedAttributes, bool isDecoratedTargetSecurityTransparent) { if (decoratedModule.Assembly.ReflectionOnly) - throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyCA")); + throw new InvalidOperationException(SR.Arg_ReflectionOnlyCA); Contract.EndContractBlock(); MetadataImport scope = decoratedModule.MetadataImport; @@ -1614,8 +1613,8 @@ namespace System.Reflection IntPtr blobEnd = (IntPtr)((byte*)blobStart + caRecord.blob.Length); int blobLen = (int)((byte*)blobEnd - (byte*)blobStart); - if (!FilterCustomAttributeRecord(caRecord, scope, ref lastAptcaOkAssembly, - decoratedModule, decoratedMetadataToken, attributeFilterType, mustBeInheritable, + if (!FilterCustomAttributeRecord(caRecord, scope, ref lastAptcaOkAssembly, + decoratedModule, decoratedMetadataToken, attributeFilterType, mustBeInheritable, attributes, derivedAttributes, out attributeType, out ctor, out ctorHasParameters, out isVarArg)) continue; @@ -1628,16 +1627,15 @@ namespace System.Reflection } else { - } // Leverage RuntimeConstructorInfo standard .ctor verfication - RuntimeConstructorInfo.CheckCanCreateInstance(attributeType, isVarArg); + RuntimeConstructorInfo.CheckCanCreateInstance(attributeType, isVarArg); // Create custom attribute object if (ctorHasParameters) { - attribute = CreateCaObject(decoratedModule, ctor, ref blobStart, blobEnd, out cNamedArgs); + attribute = CreateCaObject(decoratedModule, ctor, ref blobStart, blobEnd, out cNamedArgs); } else { @@ -1674,7 +1672,7 @@ namespace System.Reflection bool isProperty; RuntimeType type; object value; - + IntPtr blobItr = caRecord.blob.Signature; GetPropertyOrFieldData(decoratedModule, ref blobStart, blobEnd, out name, out isProperty, out type, out value); @@ -1702,12 +1700,12 @@ namespace System.Reflection if (property == null) { throw new CustomAttributeFormatException( - String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString( - isProperty ? "RFLCT.InvalidPropFail" : "RFLCT.InvalidFieldFail"), name)); + String.Format(CultureInfo.CurrentUICulture, + isProperty ? SR.RFLCT_InvalidPropFail : SR.RFLCT_InvalidFieldFail, name)); } RuntimeMethodInfo setMethod = property.GetSetMethod(true) as RuntimeMethodInfo; - + // Public properties may have non-public setter methods if (!setMethod.IsPublic) continue; @@ -1733,8 +1731,8 @@ namespace System.Reflection catch (Exception e) { throw new CustomAttributeFormatException( - String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString( - isProperty ? "RFLCT.InvalidPropFail" : "RFLCT.InvalidFieldFail"), name), e); + String.Format(CultureInfo.CurrentUICulture, + isProperty ? SR.RFLCT_InvalidPropFail : SR.RFLCT_InvalidFieldFail, name), e); } #endregion } @@ -1756,7 +1754,7 @@ namespace System.Reflection private unsafe static bool FilterCustomAttributeRecord( CustomAttributeRecord caRecord, MetadataImport scope, - ref Assembly lastAptcaOkAssembly, + ref Assembly lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, @@ -1772,7 +1770,7 @@ namespace System.Reflection attributeType = null; ctorHasParameters = false; isVarArg = false; - + IntPtr blobStart = caRecord.blob.Signature; IntPtr blobEnd = (IntPtr)((byte*)blobStart + caRecord.blob.Length); @@ -1817,13 +1815,13 @@ namespace System.Reflection // Visibility checks MetadataToken tkParent = new MetadataToken(); - + if (decoratedToken.IsParamDef) { tkParent = new MetadataToken(scope.GetParentToken(decoratedToken)); tkParent = new MetadataToken(scope.GetParentToken(tkParent)); - } - else if (decoratedToken.IsMethodDef || decoratedToken.IsProperty || decoratedToken.IsEvent || decoratedToken.IsFieldDef) + } + else if (decoratedToken.IsMethodDef || decoratedToken.IsProperty || decoratedToken.IsEvent || decoratedToken.IsFieldDef) { tkParent = new MetadataToken(scope.GetParentToken(decoratedToken)); } @@ -1842,7 +1840,7 @@ namespace System.Reflection else { // We need to relax this when we add support for other types of decorated tokens. - Debug.Assert(decoratedToken.IsModule || decoratedToken.IsAssembly, + Debug.Assert(decoratedToken.IsModule || decoratedToken.IsAssembly, "The decoratedToken must be either an assembly, a module, a type, or a member."); } @@ -1907,7 +1905,7 @@ namespace System.Reflection if (attributeUsageAttribute != null) throw new FormatException(String.Format( - CultureInfo.CurrentUICulture, Environment.GetResourceString("Format_AttributeUsage"), attributeType)); + CultureInfo.CurrentUICulture, SR.Format_AttributeUsage, attributeType)); AttributeTargets targets; bool inherited, allowMultiple; @@ -1940,7 +1938,7 @@ namespace System.Reflection { byte* pBlob = (byte*)blob; byte* pBlobEnd = (byte*)blobEnd; - int cNamedArgs; + int cNamedArgs; object ca = _CreateCaObject(module, ctor, &pBlob, pBlobEnd, &cNamedArgs); blob = (IntPtr)pBlob; namedArgs = cNamedArgs; @@ -2025,9 +2023,9 @@ namespace System.Reflection //AllowMultiple is true for TypeForwardedToAttribute //Debug.Assert(usage.AllowMultiple == false, "Pseudo CA Error"); } -#endregion + #endregion -#region Internal Static + #region Internal Static internal static bool IsSecurityAttribute(RuntimeType type) { // TODO: Cleanup @@ -2083,12 +2081,12 @@ namespace System.Reflection if (!all && s_pca.GetValueOrDefault(caType) == null && !IsSecurityAttribute(caType)) return false; - if (all || caType == (RuntimeType)typeof(SerializableAttribute)) - { + if (all || caType == (RuntimeType)typeof(SerializableAttribute)) + { if (SerializableAttribute.IsDefined(type)) return true; } - if (all || caType == (RuntimeType)typeof(ComImportAttribute)) - { + if (all || caType == (RuntimeType)typeof(ComImportAttribute)) + { if (ComImportAttribute.IsDefined(type)) return true; } if (all || IsSecurityAttribute(caType)) @@ -2322,8 +2320,8 @@ namespace System.Reflection { if (FieldOffsetAttribute.IsDefined(field)) return true; } - if (all || caType == (RuntimeType)typeof(NonSerializedAttribute)) - { + if (all || caType == (RuntimeType)typeof(NonSerializedAttribute)) + { if (NonSerializedAttribute.IsDefined(field)) return true; } @@ -2392,6 +2390,6 @@ namespace System.Reflection { return false; } -#endregion + #endregion } } diff --git a/src/mscorlib/src/System/Reflection/CustomAttributeExtensions.cs b/src/mscorlib/src/System/Reflection/CustomAttributeExtensions.cs index c3287e17d1..24e5055b8d 100644 --- a/src/mscorlib/src/System/Reflection/CustomAttributeExtensions.cs +++ b/src/mscorlib/src/System/Reflection/CustomAttributeExtensions.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. + using System.Collections.Generic; namespace System.Reflection diff --git a/src/mscorlib/src/System/Reflection/CustomAttributeFormatException.cs b/src/mscorlib/src/System/Reflection/CustomAttributeFormatException.cs deleted file mode 100644 index 9aee911a6c..0000000000 --- a/src/mscorlib/src/System/Reflection/CustomAttributeFormatException.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -//////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// -// -// CustomAttributeFormatException is thrown when the binary format of a -// -// custom attribute is invalid. -// -// -namespace System.Reflection { - using System; - using ApplicationException = System.ApplicationException; - using System.Runtime.Serialization; - [Serializable] - public class CustomAttributeFormatException : FormatException { - - public CustomAttributeFormatException() - : base(Environment.GetResourceString("Arg_CustomAttributeFormatException")) { - SetErrorCode(__HResults.COR_E_CUSTOMATTRIBUTEFORMAT); - } - - public CustomAttributeFormatException(String message) : base(message) { - SetErrorCode(__HResults.COR_E_CUSTOMATTRIBUTEFORMAT); - } - - public CustomAttributeFormatException(String message, Exception inner) : base(message, inner) { - SetErrorCode(__HResults.COR_E_CUSTOMATTRIBUTEFORMAT); - } - - protected CustomAttributeFormatException(SerializationInfo info, StreamingContext context) : base(info, context) { - } - - } -} diff --git a/src/mscorlib/src/System/Reflection/DefaultMemberAttribute.cs b/src/mscorlib/src/System/Reflection/DefaultMemberAttribute.cs deleted file mode 100644 index 4232fcd2a1..0000000000 --- a/src/mscorlib/src/System/Reflection/DefaultMemberAttribute.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -//////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// -// -// DefaultMemberAttribute is defines the Member of a Type that is the "default" -// -// member used by Type.InvokeMember. The default member is simply a name given -// to a type. -// -// -// -// -namespace System.Reflection { - - using System; - -[Serializable] - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface)] - public sealed class DefaultMemberAttribute : Attribute - { - // The name of the member - private String m_memberName; - - // You must provide the name of the member, this is required - public DefaultMemberAttribute(String memberName) { - m_memberName = memberName; - } - - // A get accessor to return the name from the attribute. - // NOTE: There is no setter because the name must be provided - // to the constructor. The name is not optional. - public String MemberName { - get {return m_memberName;} - } - } -} diff --git a/src/mscorlib/src/System/Reflection/Emit/AQNBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/AQNBuilder.cs index fb9324902a..e7499e57f0 100644 --- a/src/mscorlib/src/System/Reflection/Emit/AQNBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/AQNBuilder.cs @@ -20,7 +20,7 @@ namespace System.Reflection.Emit FullName, AssemblyQualifiedName, } - + #region QCalls [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] [SuppressUnmanagedCodeSecurity] @@ -76,7 +76,7 @@ namespace System.Reflection.Emit if (!type.IsGenericTypeDefinition && type.ContainsGenericParameters) return null; } - + TypeNameBuilder tnb = new TypeNameBuilder(CreateTypeNameBuilder()); tnb.Clear(); tnb.ConstructAssemblyQualifiedNameWorker(type, format); @@ -100,20 +100,20 @@ namespace System.Reflection.Emit { if (elementType.HasElementType) AddElementType(elementType.GetElementType()); - + if (elementType.IsPointer) AddPointer(); else if (elementType.IsByRef) AddByRef(); - else if (elementType.IsSzArray) + else if (elementType.IsSZArray) AddSzArray(); else if (elementType.IsArray) AddArray(elementType.GetArrayRank()); } - + private void ConstructAssemblyQualifiedNameWorker(Type type, Format format) { Type rootType = type; @@ -125,13 +125,13 @@ namespace System.Reflection.Emit List<Type> nestings = new List<Type>(); for (Type t = rootType; t != null; t = t.IsGenericParameter ? null : t.DeclaringType) nestings.Add(t); - + for (int i = nestings.Count - 1; i >= 0; i--) { Type enclosingType = nestings[i]; string name = enclosingType.Name; - if (i == nestings.Count - 1 && enclosingType.Namespace != null && enclosingType.Namespace.Length != 0) + if (i == nestings.Count - 1 && enclosingType.Namespace != null && enclosingType.Namespace.Length != 0) name = enclosingType.Namespace + "." + name; AddName(name); @@ -146,7 +146,7 @@ namespace System.Reflection.Emit for (int i = 0; i < genericArguments.Length; i++) { Format genericArgumentsFormat = format == Format.FullName ? Format.AssemblyQualifiedName : format; - + OpenGenericArgument(); ConstructAssemblyQualifiedNameWorker(genericArguments[i], genericArgumentsFormat); CloseGenericArgument(); @@ -160,7 +160,7 @@ namespace System.Reflection.Emit if (format == Format.AssemblyQualifiedName) AddAssemblySpec(type.Module.Assembly.FullName); } - + private void OpenGenericArguments() { OpenGenericArguments(m_typeNameBuilder); } private void CloseGenericArguments() { CloseGenericArguments(m_typeNameBuilder); } private void OpenGenericArgument() { OpenGenericArgument(m_typeNameBuilder); } diff --git a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs index 5575e28917..6d9cb0db2f 100644 --- a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs @@ -48,11 +48,11 @@ namespace System.Reflection.Emit None = 0x00000000, // Security attributes which affect the module security descriptor - AllCritical = 0x00000001, - Aptca = 0x00000002, - Critical = 0x00000004, - Transparent = 0x00000008, - TreatAsSafe = 0x00000010, + AllCritical = 0x00000001, + Aptca = 0x00000002, + Critical = 0x00000004, + Transparent = 0x00000008, + TreatAsSafe = 0x00000010, } // When the user calls AppDomain.DefineDynamicAssembly the loader creates a new InternalAssemblyBuilder. @@ -61,7 +61,7 @@ namespace System.Reflection.Emit // Assembly to an AssemblyBuilder and emit code with the elevated permissions of the trusted code which // origionally created the AssemblyBuilder via DefineDynamicAssembly. Today, this can no longer happen // because the Assembly returned via AssemblyGetAssemblies() will be an InternalAssemblyBuilder. - + // Only the caller of DefineDynamicAssembly will get an AssemblyBuilder. // There is a 1-1 relationship between InternalAssemblyBuilder and AssemblyBuilder. // AssemblyBuilder is composed of its InternalAssemblyBuilder. @@ -94,39 +94,39 @@ namespace System.Reflection.Emit #region Methods inherited from Assembly public override String[] GetManifestResourceNames() { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly")); + throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } public override FileStream GetFile(String name) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly")); + throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } public override FileStream[] GetFiles(bool getResourceModules) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly")); + throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } public override Stream GetManifestResourceStream(Type type, String name) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly")); + throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } public override Stream GetManifestResourceStream(String name) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly")); + throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } public override ManifestResourceInfo GetManifestResourceInfo(String resourceName) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly")); + throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } public override String Location { get { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly")); + throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } } @@ -134,13 +134,13 @@ namespace System.Reflection.Emit { get { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly")); + throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } } public override Type[] GetExportedTypes() { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly")); + throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } public override String ImageRuntimeVersion @@ -177,16 +177,12 @@ namespace System.Reflection.Emit private bool m_fManifestModuleUsedAsDefinedModule; internal const string MANIFEST_MODULE_NAME = "RefEmit_InMemoryManifestModule"; -#if FEATURE_APPX - private bool m_profileAPICheck; -#endif - internal ModuleBuilder GetModuleBuilder(InternalModuleBuilder module) { Contract.Requires(module != null); Debug.Assert(this.InternalAssembly == module.Assembly); - lock(SyncRoot) + lock (SyncRoot) { // in CoreCLR there is only one module in each dynamic assembly, the manifest module if (m_manifestModuleBuilder.InternalModule == module) @@ -216,16 +212,6 @@ namespace System.Reflection.Emit { return InternalAssembly.GetNativeHandle(); } - -#if FEATURE_APPX - internal bool ProfileAPICheck - { - get - { - return m_profileAPICheck; - } - } -#endif #endregion #region Constructor @@ -242,13 +228,10 @@ namespace System.Reflection.Emit throw new ArgumentNullException(nameof(name)); if (access != AssemblyBuilderAccess.Run -#if FEATURE_REFLECTION_ONLY_LOAD - && access != AssemblyBuilderAccess.ReflectionOnly -#endif // FEATURE_REFLECTION_ONLY_LOAD && access != AssemblyBuilderAccess.RunAndCollect ) { - throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (int)access), nameof(access)); + throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, (int)access), nameof(access)); } if (securityContextSource < SecurityContextSource.CurrentAppDomain || @@ -304,14 +287,7 @@ namespace System.Reflection.Emit name.Name, access, dir); -#if FEATURE_APPX - if (AppDomain.ProfileAPICheck) - { - RuntimeAssembly creator = RuntimeAssembly.GetExecutingAssembly(ref stackMark); - if (creator != null && !creator.IsFrameworkAssembly()) - m_profileAPICheck = true; - } -#endif + // Make sure that ManifestModule is properly initialized // We need to do this before setting any CustomAttribute InitManifestModule(); @@ -331,7 +307,7 @@ namespace System.Reflection.Emit // because it hasn't been initialized. // However, it can be used to set the custom attribute on the Assembly m_manifestModuleBuilder = new ModuleBuilder(this, modBuilder); - + // We are only setting the name in the managed ModuleBuilderData here. // The name in the underlying metadata will be set when the // manifest module is created during nCreateDynamicAssembly. @@ -351,7 +327,7 @@ namespace System.Reflection.Emit * to have a strong name and a hash will be computed when the assembly * is saved. **********************************************/ - [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable + [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod public static AssemblyBuilder DefineDynamicAssembly( AssemblyName name, AssemblyBuilderAccess access) @@ -363,7 +339,7 @@ namespace System.Reflection.Emit null, ref stackMark, null, SecurityContextSource.CurrentAssembly); } - [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable + [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod public static AssemblyBuilder DefineDynamicAssembly( AssemblyName name, AssemblyBuilderAccess access, @@ -425,9 +401,9 @@ namespace System.Reflection.Emit * a transient module. * **********************************************/ - [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable + [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod public ModuleBuilder DefineDynamicModule( - String name) + String name) { Contract.Ensures(Contract.Result<ModuleBuilder>() != null); @@ -435,39 +411,39 @@ namespace System.Reflection.Emit return DefineDynamicModuleInternal(name, false, ref stackMark); } - [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable + [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod public ModuleBuilder DefineDynamicModule( - String name, - bool emitSymbolInfo) // specify if emit symbol info or not + String name, + bool emitSymbolInfo) // specify if emit symbol info or not { Contract.Ensures(Contract.Result<ModuleBuilder>() != null); StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; - return DefineDynamicModuleInternal( name, emitSymbolInfo, ref stackMark ); + return DefineDynamicModuleInternal(name, emitSymbolInfo, ref stackMark); } private ModuleBuilder DefineDynamicModuleInternal( - String name, - bool emitSymbolInfo, // specify if emit symbol info or not + String name, + bool emitSymbolInfo, // specify if emit symbol info or not ref StackCrawlMark stackMark) { - lock(SyncRoot) + lock (SyncRoot) { return DefineDynamicModuleInternalNoLock(name, emitSymbolInfo, ref stackMark); } } private ModuleBuilder DefineDynamicModuleInternalNoLock( - String name, - bool emitSymbolInfo, // specify if emit symbol info or not + String name, + bool emitSymbolInfo, // specify if emit symbol info or not ref StackCrawlMark stackMark) { if (name == null) throw new ArgumentNullException(nameof(name)); if (name.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(name)); + throw new ArgumentException(SR.Argument_EmptyName, nameof(name)); if (name[0] == '\0') - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidName"), nameof(name)); + throw new ArgumentException(SR.Argument_InvalidName, nameof(name)); Contract.Ensures(Contract.Result<ModuleBuilder>() != null); Contract.EndContractBlock(); @@ -481,7 +457,7 @@ namespace System.Reflection.Emit // create the dynamic module- only one ModuleBuilder per AssemblyBuilder can be created if (m_fManifestModuleUsedAsDefinedModule == true) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NoMultiModuleAssembly")); + throw new InvalidOperationException(SR.InvalidOperation_NoMultiModuleAssembly); // Init(...) has already been called on m_manifestModuleBuilder in InitManifestModule() dynModule = m_manifestModuleBuilder; @@ -492,7 +468,7 @@ namespace System.Reflection.Emit writer = SymWrapperCore.SymWriter.CreateSymWriter(); String fileName = "Unused"; // this symfile is never written to disk so filename does not matter. - + // Pass the "real" module to the VM pInternalSymWriter = ModuleBuilder.nCreateISymWriterForDynamicModule(dynModule.InternalModule, fileName); @@ -512,14 +488,14 @@ namespace System.Reflection.Emit return dynModule; } // DefineDynamicModuleInternalNoLock -#endregion + #endregion internal void CheckContext(params Type[][] typess) { if (typess == null) return; - - foreach(Type[] types in typess) + + foreach (Type[] types in typess) if (types != null) CheckContext(types); } @@ -528,23 +504,23 @@ namespace System.Reflection.Emit { if (types == null) return; - + foreach (Type type in types) { if (type == null) continue; if (type.Module == null || type.Module.Assembly == null) - throw new ArgumentException(Environment.GetResourceString("Argument_TypeNotValid")); + throw new ArgumentException(SR.Argument_TypeNotValid); if (type.Module.Assembly == typeof(object).Module.Assembly) continue; if (type.Module.Assembly.ReflectionOnly && !ReflectionOnly) - throw new InvalidOperationException(Environment.GetResourceString("Arugment_EmitMixedContext1", type.AssemblyQualifiedName)); + throw new InvalidOperationException(SR.Format(SR.Arugment_EmitMixedContext1, type.AssemblyQualifiedName)); if (!type.Module.Assembly.ReflectionOnly && ReflectionOnly) - throw new InvalidOperationException(Environment.GetResourceString("Arugment_EmitMixedContext2", type.AssemblyQualifiedName)); + throw new InvalidOperationException(SR.Format(SR.Arugment_EmitMixedContext2, type.AssemblyQualifiedName)); } } @@ -585,27 +561,27 @@ namespace System.Reflection.Emit { return InternalAssembly.GetManifestResourceNames(); } - + public override FileStream GetFile(String name) { return InternalAssembly.GetFile(name); } - + public override FileStream[] GetFiles(bool getResourceModules) { return InternalAssembly.GetFiles(getResourceModules); } - + public override Stream GetManifestResourceStream(Type type, String name) { return InternalAssembly.GetManifestResourceStream(type, name); } - + public override Stream GetManifestResourceStream(String name) { return InternalAssembly.GetManifestResourceStream(name); } - + public override ManifestResourceInfo GetManifestResourceInfo(String resourceName) { return InternalAssembly.GetManifestResourceInfo(resourceName); @@ -626,7 +602,7 @@ namespace System.Reflection.Emit return InternalAssembly.ImageRuntimeVersion; } } - + public override String CodeBase { get @@ -637,9 +613,9 @@ namespace System.Reflection.Emit // Override the EntryPoint method on Assembly. // This doesn't need to be synchronized because it is simple enough - public override MethodInfo EntryPoint + public override MethodInfo EntryPoint { - get + get { return m_assemblyData.m_entryPointMethod; } @@ -721,7 +697,7 @@ namespace System.Reflection.Emit return InternalAssembly.GetLoadedModules(getResourceModules); } - [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable + [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod public override Assembly GetSatelliteAssembly(CultureInfo culture) { StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; @@ -729,7 +705,7 @@ namespace System.Reflection.Emit } // Useful for binding to a very specific version of a satellite assembly - [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable + [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod public override Assembly GetSatelliteAssembly(CultureInfo culture, Version version) { StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; @@ -738,7 +714,8 @@ namespace System.Reflection.Emit public override bool IsDynamic { - get { + get + { return true; } } @@ -751,28 +728,28 @@ namespace System.Reflection.Emit * **********************************************/ public ModuleBuilder GetDynamicModule( - String name) // the name of module for the look up + String name) // the name of module for the look up { - lock(SyncRoot) + lock (SyncRoot) { return GetDynamicModuleNoLock(name); } } private ModuleBuilder GetDynamicModuleNoLock( - String name) // the name of module for the look up + String name) // the name of module for the look up { if (name == null) throw new ArgumentNullException(nameof(name)); if (name.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(name)); + throw new ArgumentException(SR.Argument_EmptyName, nameof(name)); Contract.EndContractBlock(); BCLDebug.Log("DYNIL", "## DYNIL LOGGING: AssemblyBuilder.GetDynamicModule( " + name + " )"); int size = m_assemblyData.m_moduleBuilderList.Count; for (int i = 0; i < size; i++) { - ModuleBuilder moduleBuilder = (ModuleBuilder) m_assemblyData.m_moduleBuilderList[i]; + ModuleBuilder moduleBuilder = (ModuleBuilder)m_assemblyData.m_moduleBuilderList[i]; if (moduleBuilder.m_moduleData.m_strModuleName.Equals(name)) { return moduleBuilder; @@ -792,8 +769,8 @@ namespace System.Reflection.Emit if (binaryAttribute == null) throw new ArgumentNullException(nameof(binaryAttribute)); Contract.EndContractBlock(); - - lock(SyncRoot) + + lock (SyncRoot) { SetCustomAttributeNoLock(con, binaryAttribute); } @@ -828,7 +805,7 @@ namespace System.Reflection.Emit } Contract.EndContractBlock(); - lock(SyncRoot) + lock (SyncRoot) { SetCustomAttributeNoLock(customBuilder); } @@ -837,7 +814,7 @@ namespace System.Reflection.Emit private void SetCustomAttributeNoLock(CustomAttributeBuilder customBuilder) { customBuilder.CreateCustomAttribute( - m_manifestModuleBuilder, + m_manifestModuleBuilder, AssemblyBuilderData.m_tkAssembly); // This is the AssemblyDef token // Track the CA for persistence @@ -852,11 +829,11 @@ namespace System.Reflection.Emit * Private methods * **********************************************/ - + /********************************************** * Make a private constructor so these cannot be constructed externally. * @internonly **********************************************/ - private AssemblyBuilder() {} + private AssemblyBuilder() { } } } diff --git a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderAccess.cs b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderAccess.cs index b3d1711307..ead2fafcef 100644 --- a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderAccess.cs +++ b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderAccess.cs @@ -7,16 +7,13 @@ using System; // This enumeration defines the access modes for a dynamic assembly. // EE uses these enum values..look for m_dwDynamicAssemblyAccess in Assembly.hpp -namespace System.Reflection.Emit +namespace System.Reflection.Emit { [Serializable] [Flags] public enum AssemblyBuilderAccess { Run = 1, -#if FEATURE_REFLECTION_ONLY_LOAD - ReflectionOnly = 6, // 4 | Save, -#endif // FEATURE_REFLECTION_ONLY_LOAD RunAndCollect = 8 | Run } } diff --git a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs index 7ac9daeac0..529ba54514 100644 --- a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs +++ b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs @@ -6,7 +6,8 @@ //////////////////////////////////////////////////////////////////////////////// // -namespace System.Reflection.Emit { +namespace System.Reflection.Emit +{ using System; using IList = System.Collections.IList; using System.Collections.Generic; @@ -25,10 +26,10 @@ namespace System.Reflection.Emit { internal class AssemblyBuilderData { internal AssemblyBuilderData( - InternalAssemblyBuilder assembly, - String strAssemblyName, - AssemblyBuilderAccess access, - String dir) + InternalAssemblyBuilder assembly, + String strAssemblyName, + AssemblyBuilderAccess access, + String dir) { m_assembly = assembly; m_strAssemblyName = strAssemblyName; @@ -44,8 +45,8 @@ namespace System.Reflection.Emit { m_strDir = dir; m_peFileKind = PEFileKinds.Dll; - } - + } + // Helper to add a dynamic module into the tracking list internal void AddModule(ModuleBuilder dynModule) { @@ -56,7 +57,6 @@ namespace System.Reflection.Emit { // Helper to track CAs to persist onto disk internal void AddCustomAttribute(CustomAttributeBuilder customBuilder) { - // make sure we have room for this CA if (m_CABuilders == null) { @@ -64,31 +64,30 @@ namespace System.Reflection.Emit { } if (m_iCABuilder == m_CABuilders.Length) { - CustomAttributeBuilder[] tempCABuilders = new CustomAttributeBuilder[m_iCABuilder * 2]; + CustomAttributeBuilder[] tempCABuilders = new CustomAttributeBuilder[m_iCABuilder * 2]; Array.Copy(m_CABuilders, 0, tempCABuilders, 0, m_iCABuilder); - m_CABuilders = tempCABuilders; + m_CABuilders = tempCABuilders; } m_CABuilders[m_iCABuilder] = customBuilder; - + m_iCABuilder++; } // Helper to track CAs to persist onto disk internal void AddCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) { - // make sure we have room for this CA if (m_CABytes == null) { m_CABytes = new byte[m_iInitialSize][]; - m_CACons = new ConstructorInfo[m_iInitialSize]; + m_CACons = new ConstructorInfo[m_iInitialSize]; } if (m_iCAs == m_CABytes.Length) { // enlarge the arrays - byte[][] temp = new byte[m_iCAs * 2][]; + byte[][] temp = new byte[m_iCAs * 2][]; ConstructorInfo[] tempCon = new ConstructorInfo[m_iCAs * 2]; - for (int i=0; i < m_iCAs; i++) + for (int i = 0; i < m_iCAs; i++) { temp[i] = m_CABytes[i]; tempCon[i] = m_CACons[i]; @@ -103,12 +102,12 @@ namespace System.Reflection.Emit { m_CACons[m_iCAs] = con; m_iCAs++; } - + // Helper to ensure the type name is unique underneath assemblyBuilder internal void CheckTypeNameConflict(String strTypeName, TypeBuilder enclosingType) { - BCLDebug.Log("DYNIL","## DYNIL LOGGING: AssemblyBuilderData.CheckTypeNameConflict( " + strTypeName + " )"); - for (int i = 0; i < m_moduleBuilderList.Count; i++) + BCLDebug.Log("DYNIL", "## DYNIL LOGGING: AssemblyBuilderData.CheckTypeNameConflict( " + strTypeName + " )"); + for (int i = 0; i < m_moduleBuilderList.Count; i++) { ModuleBuilder curModule = m_moduleBuilderList[i]; curModule.CheckTypeNameConflict(strTypeName, enclosingType); @@ -121,60 +120,59 @@ namespace System.Reflection.Emit { // if (enclosingType == null && m_assembly.GetType(strTypeName, false, false) != null) // { // // Cannot have two types with the same name - // throw new ArgumentException(Environment.GetResourceString("Argument_DuplicateTypeName")); + // throw new ArgumentException(SR.Argument_DuplicateTypeName); // } } - - internal List<ModuleBuilder> m_moduleBuilderList; - internal List<ResWriterData> m_resWriterList; - internal String m_strAssemblyName; - internal AssemblyBuilderAccess m_access; + + internal List<ModuleBuilder> m_moduleBuilderList; + internal List<ResWriterData> m_resWriterList; + internal String m_strAssemblyName; + internal AssemblyBuilderAccess m_access; private InternalAssemblyBuilder m_assembly; - - internal Type[] m_publicComTypeList; - internal int m_iPublicComTypeCount; - - internal bool m_isSaved; - internal const int m_iInitialSize = 16; - internal String m_strDir; + + internal Type[] m_publicComTypeList; + internal int m_iPublicComTypeCount; + + internal bool m_isSaved; + internal const int m_iInitialSize = 16; + internal String m_strDir; // hard coding the assembly def token - internal const int m_tkAssembly = 0x20000001; - + internal const int m_tkAssembly = 0x20000001; + // tracking AssemblyDef's CAs for persistence to disk internal CustomAttributeBuilder[] m_CABuilders; - internal int m_iCABuilder; - internal byte[][] m_CABytes; - internal ConstructorInfo[] m_CACons; - internal int m_iCAs; - internal PEFileKinds m_peFileKind; // assembly file kind - internal MethodInfo m_entryPointMethod; - internal Assembly m_ISymWrapperAssembly; + internal int m_iCABuilder; + internal byte[][] m_CABytes; + internal ConstructorInfo[] m_CACons; + internal int m_iCAs; + internal PEFileKinds m_peFileKind; // assembly file kind + internal MethodInfo m_entryPointMethod; + internal Assembly m_ISymWrapperAssembly; // For unmanaged resources - internal String m_strResourceFileName; - internal byte[] m_resourceBytes; - internal NativeVersionInfo m_nativeVersion; - internal bool m_hasUnmanagedVersionInfo; - internal bool m_OverrideUnmanagedVersionInfo; - + internal String m_strResourceFileName; + internal byte[] m_resourceBytes; + internal NativeVersionInfo m_nativeVersion; + internal bool m_hasUnmanagedVersionInfo; + internal bool m_OverrideUnmanagedVersionInfo; } - + /********************************************** * * Internal structure to track the list of ResourceWriter for * AssemblyBuilder & ModuleBuilder. * **********************************************/ - internal class ResWriterData + internal class ResWriterData { - internal String m_strName; - internal String m_strFileName; - internal String m_strFullFileName; - internal Stream m_memoryStream; - internal ResWriterData m_nextResWriter; - internal ResourceAttributes m_attribute; + internal String m_strName; + internal String m_strFileName; + internal String m_strFullFileName; + internal Stream m_memoryStream; + internal ResWriterData m_nextResWriter; + internal ResourceAttributes m_attribute; } internal class NativeVersionInfo @@ -191,15 +189,15 @@ namespace System.Reflection.Emit { m_strFileVersion = null; m_lcid = -1; } - - internal String m_strDescription; - internal String m_strCompany; - internal String m_strTitle; - internal String m_strCopyright; - internal String m_strTrademark; - internal String m_strProduct; - internal String m_strProductVersion; - internal String m_strFileVersion; - internal int m_lcid; + + internal String m_strDescription; + internal String m_strCompany; + internal String m_strTitle; + internal String m_strCopyright; + internal String m_strTrademark; + internal String m_strProduct; + internal String m_strProductVersion; + internal String m_strFileVersion; + internal int m_lcid; } } diff --git a/src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs index 3bc02860a1..3ca9b2eb9d 100644 --- a/src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs @@ -4,8 +4,8 @@ // -namespace System.Reflection.Emit -{ +namespace System.Reflection.Emit +{ using System; using System.Reflection; using CultureInfo = System.Globalization.CultureInfo; @@ -14,9 +14,9 @@ namespace System.Reflection.Emit using System.Security; using System.Runtime.InteropServices; using System.Diagnostics.Contracts; - + public sealed class ConstructorBuilder : ConstructorInfo - { + { private readonly MethodBuilder m_methodBuilder; internal bool m_isDefaultConstructor; @@ -25,7 +25,7 @@ namespace System.Reflection.Emit private ConstructorBuilder() { } - + internal ConstructorBuilder(String name, MethodAttributes attributes, CallingConventions callingConvention, Type[] parameterTypes, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers, ModuleBuilder mod, TypeBuilder type) { @@ -33,18 +33,18 @@ namespace System.Reflection.Emit byte[] sigBytes; MethodToken token; - m_methodBuilder = new MethodBuilder(name, attributes, callingConvention, null, null, null, + m_methodBuilder = new MethodBuilder(name, attributes, callingConvention, null, null, null, parameterTypes, requiredCustomModifiers, optionalCustomModifiers, mod, type, false); type.m_listMethods.Add(m_methodBuilder); - + sigBytes = m_methodBuilder.GetMethodSignature().InternalGetSignature(out sigLength); - + token = m_methodBuilder.GetToken(); } internal ConstructorBuilder(String name, MethodAttributes attributes, CallingConventions callingConvention, - Type[] parameterTypes, ModuleBuilder mod, TypeBuilder type) : + Type[] parameterTypes, ModuleBuilder mod, TypeBuilder type) : this(name, attributes, callingConvention, parameterTypes, null, null, mod, type) { } @@ -68,7 +68,7 @@ namespace System.Reflection.Emit { return m_methodBuilder.ToString(); } - + #endregion #region MemberInfo Overrides @@ -76,12 +76,12 @@ namespace System.Reflection.Emit { get { return m_methodBuilder.MetadataTokenInternal; } } - + public override Module Module { get { return m_methodBuilder.Module; } } - + public override Type ReflectedType { get { return m_methodBuilder.ReflectedType; } @@ -91,8 +91,8 @@ namespace System.Reflection.Emit { get { return m_methodBuilder.DeclaringType; } } - - public override String Name + + public override String Name { get { return m_methodBuilder.Name; } } @@ -100,9 +100,9 @@ namespace System.Reflection.Emit #endregion #region MethodBase Overrides - public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) + public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } [Pure] @@ -111,7 +111,7 @@ namespace System.Reflection.Emit ConstructorInfo rci = GetTypeBuilder().GetConstructor(m_methodBuilder.m_parameterTypes); return rci.GetParameters(); } - + public override MethodAttributes Attributes { get { return m_methodBuilder.Attributes; } @@ -121,20 +121,20 @@ namespace System.Reflection.Emit { return m_methodBuilder.GetMethodImplementationFlags(); } - - public override RuntimeMethodHandle MethodHandle + + public override RuntimeMethodHandle MethodHandle { get { return m_methodBuilder.MethodHandle; } } - + #endregion #region ConstructorInfo Overrides public override Object Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } - + #endregion #region ICustomAttributeProvider Implementation @@ -147,8 +147,8 @@ namespace System.Reflection.Emit { return m_methodBuilder.GetCustomAttributes(attributeType, inherit); } - - public override bool IsDefined (Type attributeType, bool inherit) + + public override bool IsDefined(Type attributeType, bool inherit) { return m_methodBuilder.IsDefined(attributeType, inherit); } @@ -160,7 +160,7 @@ namespace System.Reflection.Emit { return m_methodBuilder.GetToken(); } - + public ParameterBuilder DefineParameter(int iSequence, ParameterAttributes attributes, String strParamName) { // Theoretically we shouldn't allow iSequence to be 0 because in reflection ctors don't have @@ -171,50 +171,50 @@ namespace System.Reflection.Emit attributes = attributes & ~ParameterAttributes.ReservedMask; return m_methodBuilder.DefineParameter(iSequence, attributes, strParamName); } - - public ILGenerator GetILGenerator() + + public ILGenerator GetILGenerator() { if (m_isDefaultConstructor) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_DefaultConstructorILGen")); + throw new InvalidOperationException(SR.InvalidOperation_DefaultConstructorILGen); return m_methodBuilder.GetILGenerator(); } - + public ILGenerator GetILGenerator(int streamSize) { if (m_isDefaultConstructor) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_DefaultConstructorILGen")); + throw new InvalidOperationException(SR.InvalidOperation_DefaultConstructorILGen); return m_methodBuilder.GetILGenerator(streamSize); } - public override CallingConventions CallingConvention - { - get - { + public override CallingConventions CallingConvention + { + get + { if (DeclaringType.IsGenericType) return CallingConventions.HasThis; - - return CallingConventions.Standard; - } + + return CallingConventions.Standard; + } } - + public Module GetModule() { return m_methodBuilder.GetModule(); } - + // This always returns null. Is that what we want? - internal override Type GetReturnType() + internal override Type GetReturnType() { return m_methodBuilder.ReturnType; } - - public String Signature + + public String Signature { get { return m_methodBuilder.Signature; } } - + public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) { m_methodBuilder.SetCustomAttribute(con, binaryAttribute); @@ -225,12 +225,12 @@ namespace System.Reflection.Emit m_methodBuilder.SetCustomAttribute(customBuilder); } - public void SetImplementationFlags(MethodImplAttributes attributes) + public void SetImplementationFlags(MethodImplAttributes attributes) { m_methodBuilder.SetImplementationFlags(attributes); } - - public bool InitLocals + + public bool InitLocals { get { return m_methodBuilder.InitLocals; } set { m_methodBuilder.InitLocals = value; } diff --git a/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs index 5d08ca08f0..cf5bd11de6 100644 --- a/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs @@ -12,18 +12,19 @@ ** ** ===========================================================*/ -namespace System.Reflection.Emit { - - - using System; - using System.Reflection; - using System.IO; - using System.Text; - using System.Runtime.InteropServices; - using System.Globalization; - using System.Diagnostics; - using System.Diagnostics.Contracts; - + + +using System; +using System.Reflection; +using System.IO; +using System.Text; +using System.Runtime.InteropServices; +using System.Globalization; +using System.Diagnostics; +using System.Diagnostics.Contracts; + +namespace System.Reflection.Emit +{ public class CustomAttributeBuilder { // public constructor to form the custom attribute with constructor and constructor @@ -31,17 +32,17 @@ namespace System.Reflection.Emit { public CustomAttributeBuilder(ConstructorInfo con, Object[] constructorArgs) { InitCustomAttributeBuilder(con, constructorArgs, - new PropertyInfo[]{}, new Object[]{}, - new FieldInfo[]{}, new Object[]{}); + new PropertyInfo[] { }, new Object[] { }, + new FieldInfo[] { }, new Object[] { }); } - + // public constructor to form the custom attribute with constructor, constructor // parameters and named properties. public CustomAttributeBuilder(ConstructorInfo con, Object[] constructorArgs, PropertyInfo[] namedProperties, Object[] propertyValues) { InitCustomAttributeBuilder(con, constructorArgs, namedProperties, - propertyValues, new FieldInfo[]{}, new Object[]{}); + propertyValues, new FieldInfo[] { }, new Object[] { }); } // public constructor to form the custom attribute with constructor and constructor @@ -49,8 +50,8 @@ namespace System.Reflection.Emit { public CustomAttributeBuilder(ConstructorInfo con, Object[] constructorArgs, FieldInfo[] namedFields, Object[] fieldValues) { - InitCustomAttributeBuilder(con, constructorArgs, new PropertyInfo[]{}, - new Object[]{}, namedFields, fieldValues); + InitCustomAttributeBuilder(con, constructorArgs, new PropertyInfo[] { }, + new Object[] { }, namedFields, fieldValues); } // public constructor to form the custom attribute with constructor and constructor @@ -117,17 +118,17 @@ namespace System.Reflection.Emit { if (fieldValues == null) throw new ArgumentNullException(nameof(fieldValues)); if (namedProperties.Length != propertyValues.Length) - throw new ArgumentException(Environment.GetResourceString("Arg_ArrayLengthsDiffer"), "namedProperties, propertyValues"); + throw new ArgumentException(SR.Arg_ArrayLengthsDiffer, "namedProperties, propertyValues"); if (namedFields.Length != fieldValues.Length) - throw new ArgumentException(Environment.GetResourceString("Arg_ArrayLengthsDiffer"), "namedFields, fieldValues"); + throw new ArgumentException(SR.Arg_ArrayLengthsDiffer, "namedFields, fieldValues"); Contract.EndContractBlock(); if ((con.Attributes & MethodAttributes.Static) == MethodAttributes.Static || (con.Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private) - throw new ArgumentException(Environment.GetResourceString("Argument_BadConstructor")); + throw new ArgumentException(SR.Argument_BadConstructor); if ((con.CallingConvention & CallingConventions.Standard) != CallingConventions.Standard) - throw new ArgumentException(Environment.GetResourceString("Argument_BadConstructorCallConv")); + throw new ArgumentException(SR.Argument_BadConstructorCallConv); // Cache information used elsewhere. m_con = con; @@ -142,12 +143,12 @@ namespace System.Reflection.Emit { // Since we're guaranteed a non-var calling convention, the number of arguments must equal the number of parameters. if (paramTypes.Length != constructorArgs.Length) - throw new ArgumentException(Environment.GetResourceString("Argument_BadParameterCountsForConstructor")); + throw new ArgumentException(SR.Argument_BadParameterCountsForConstructor); // Verify that the constructor has a valid signature (custom attributes only support a subset of our type system). for (i = 0; i < paramTypes.Length; i++) if (!ValidateType(paramTypes[i])) - throw new ArgumentException(Environment.GetResourceString("Argument_BadTypeInCustomAttribute")); + throw new ArgumentException(SR.Argument_BadTypeInCustomAttribute); // Now verify that the types of the actual parameters are compatible with the types of the formal parameters. for (i = 0; i < paramTypes.Length; i++) @@ -194,11 +195,11 @@ namespace System.Reflection.Emit { // Validate property type. if (!ValidateType(propType)) - throw new ArgumentException(Environment.GetResourceString("Argument_BadTypeInCustomAttribute")); + throw new ArgumentException(SR.Argument_BadTypeInCustomAttribute); // Property has to be writable. if (!property.CanWrite) - throw new ArgumentException(Environment.GetResourceString("Argument_NotAWritableProperty")); + throw new ArgumentException(SR.Argument_NotAWritableProperty); // Property has to be from the same class or base class as ConstructorInfo. if (property.DeclaringType != con.DeclaringType @@ -216,7 +217,7 @@ namespace System.Reflection.Emit { // type is one. if (!(property.DeclaringType is TypeBuilder) || !con.DeclaringType.IsSubclassOf(((TypeBuilder)property.DeclaringType).BakedRuntimeType)) - throw new ArgumentException(Environment.GetResourceString("Argument_BadPropertyForConstructorBuilder")); + throw new ArgumentException(SR.Argument_BadPropertyForConstructorBuilder); } } @@ -252,7 +253,7 @@ namespace System.Reflection.Emit { // Validate field type. if (!ValidateType(fldType)) - throw new ArgumentException(Environment.GetResourceString("Argument_BadTypeInCustomAttribute")); + throw new ArgumentException(SR.Argument_BadTypeInCustomAttribute); // Field has to be from the same class or base class as ConstructorInfo. if (namedField.DeclaringType != con.DeclaringType @@ -270,7 +271,7 @@ namespace System.Reflection.Emit { // type is one. if (!(namedField.DeclaringType is TypeBuilder) || !con.DeclaringType.IsSubclassOf(((TypeBuilder)namedFields[i].DeclaringType).BakedRuntimeType)) - throw new ArgumentException(Environment.GetResourceString("Argument_BadFieldForConstructorBuilder")); + throw new ArgumentException(SR.Argument_BadFieldForConstructorBuilder); } } @@ -280,7 +281,7 @@ namespace System.Reflection.Emit { { VerifyTypeAndPassedObjectType(fldType, fieldValue.GetType(), $"{nameof(fieldValues)}[{i}]"); } - + // First a byte indicating that this is a field. writer.Write((byte)CustomAttributeEncoding.Field); @@ -298,11 +299,11 @@ namespace System.Reflection.Emit { { if (type != typeof(object) && Type.GetTypeCode(passedType) != Type.GetTypeCode(type)) { - throw new ArgumentException(Environment.GetResourceString("Argument_ConstantDoesntMatch")); + throw new ArgumentException(SR.Argument_ConstantDoesntMatch); } if (passedType == typeof(IntPtr) || passedType == typeof(UIntPtr)) { - throw new ArgumentException(Environment.GetResourceString("Argument_BadParameterTypeForCAB"), paramName); + throw new ArgumentException(SR.Argument_BadParameterTypeForCAB, paramName); } } @@ -452,8 +453,7 @@ namespace System.Reflection.Emit { { String typeName = TypeNameBuilder.ToString((Type)value, TypeNameBuilder.Format.AssemblyQualifiedName); if (typeName == null) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidTypeForCA", - value.GetType())); + throw new ArgumentException(SR.Format(SR.Argument_InvalidTypeForCA, value.GetType())); EmitString(writer, typeName); } } @@ -526,8 +526,8 @@ namespace System.Reflection.Emit { // value cannot be a "System.Object" object. // If we allow this we will get into an infinite recursion if (ot == typeof(object)) - throw new ArgumentException(Environment.GetResourceString("Argument_BadParameterTypeForCAB", ot.ToString())); - + throw new ArgumentException(SR.Format(SR.Argument_BadParameterTypeForCAB, ot.ToString())); + EmitType(writer, ot); EmitValue(writer, ot, value); } @@ -537,13 +537,13 @@ namespace System.Reflection.Emit { if (value != null) typename = value.GetType().ToString(); - - throw new ArgumentException(Environment.GetResourceString("Argument_BadParameterTypeForCAB", typename)); + + throw new ArgumentException(SR.Format(SR.Argument_BadParameterTypeForCAB, typename)); } } - - + + // return the byte interpretation of the custom attribute internal void CreateCustomAttribute(ModuleBuilder mod, int tkOwner) @@ -556,12 +556,12 @@ namespace System.Reflection.Emit { //************************************************* internal void CreateCustomAttribute(ModuleBuilder mod, int tkOwner, int tkAttrib, bool toDisk) { - TypeBuilder.DefineCustomAttribute(mod, tkOwner, tkAttrib, m_blob, toDisk, + TypeBuilder.DefineCustomAttribute(mod, tkOwner, tkAttrib, m_blob, toDisk, typeof(System.Diagnostics.DebuggableAttribute) == m_con.DeclaringType); } - internal ConstructorInfo m_con; - internal Object[] m_constructorArgs; - internal byte[] m_blob; + internal ConstructorInfo m_con; + internal Object[] m_constructorArgs; + internal byte[] m_blob; } } diff --git a/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs b/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs index cb2667a104..b592053f9f 100644 --- a/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs +++ b/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs @@ -6,7 +6,6 @@ namespace System.Reflection.Emit { - using System; using System.Globalization; using System.Diagnostics.SymbolStore; @@ -22,7 +21,6 @@ namespace System.Reflection.Emit internal class DynamicILGenerator : ILGenerator { - internal DynamicScope m_scope; private int m_methodSigToken; @@ -44,16 +42,6 @@ namespace System.Reflection.Emit new DynamicResolver(this)); } -#if FEATURE_APPX - private bool ProfileAPICheck - { - get - { - return ((DynamicMethod)m_methodBuilder).ProfileAPICheck; - } - } -#endif // FEATURE_APPX - // *** ILGenerator api *** public override LocalBuilder DeclareLocal(Type localType, bool pinned) @@ -66,12 +54,7 @@ namespace System.Reflection.Emit RuntimeType rtType = localType as RuntimeType; if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType")); - -#if FEATURE_APPX - if (ProfileAPICheck && (rtType.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtType.FullName)); -#endif + throw new ArgumentException(SR.Argument_MustBeRuntimeType); localBuilder = new LocalBuilder(m_localCount, localType, m_methodBuilder); // add the localType to local signature @@ -98,7 +81,7 @@ namespace System.Reflection.Emit { RuntimeMethodInfo rtMeth = meth as RuntimeMethodInfo; if (rtMeth == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), nameof(meth)); + throw new ArgumentException(SR.Argument_MustBeRuntimeMethodInfo, nameof(meth)); RuntimeType declaringType = rtMeth.GetRuntimeType(); if (declaringType != null && (declaringType.IsGenericType || declaringType.IsArray)) @@ -111,7 +94,7 @@ namespace System.Reflection.Emit // rule out not allowed operations on DynamicMethods if (opcode.Equals(OpCodes.Ldtoken) || opcode.Equals(OpCodes.Ldftn) || opcode.Equals(OpCodes.Ldvirtftn)) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOpCodeOnDynamicMethod")); + throw new ArgumentException(SR.Argument_InvalidOpCodeOnDynamicMethod); } token = GetTokenFor(dynMeth); } @@ -149,7 +132,7 @@ namespace System.Reflection.Emit RuntimeConstructorInfo rtConstructor = con as RuntimeConstructorInfo; if (rtConstructor == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), nameof(con)); + throw new ArgumentException(SR.Argument_MustBeRuntimeMethodInfo, nameof(con)); RuntimeType declaringType = rtConstructor.GetRuntimeType(); int token; @@ -178,7 +161,7 @@ namespace System.Reflection.Emit RuntimeType rtType = type as RuntimeType; if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType")); + throw new ArgumentException(SR.Argument_MustBeRuntimeType); int token = GetTokenFor(rtType); EnsureCapacity(7); @@ -194,7 +177,7 @@ namespace System.Reflection.Emit RuntimeFieldInfo runtimeField = field as RuntimeFieldInfo; if (runtimeField == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeFieldInfo"), nameof(field)); + throw new ArgumentException(SR.Argument_MustBeRuntimeFieldInfo, nameof(field)); int token; if (field.DeclaringType == null) @@ -235,7 +218,7 @@ namespace System.Reflection.Emit if (optionalParameterTypes != null) if ((callingConvention & CallingConventions.VarArgs) == 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAVarArgCallingConvention")); + throw new InvalidOperationException(SR.InvalidOperation_NotAVarArgCallingConvention); sig = GetMemberRefSignature(callingConvention, returnType, @@ -271,13 +254,13 @@ namespace System.Reflection.Emit throw new ArgumentNullException(nameof(methodInfo)); if (!(opcode.Equals(OpCodes.Call) || opcode.Equals(OpCodes.Callvirt) || opcode.Equals(OpCodes.Newobj))) - throw new ArgumentException(Environment.GetResourceString("Argument_NotMethodCallOpcode"), nameof(opcode)); + throw new ArgumentException(SR.Argument_NotMethodCallOpcode, nameof(opcode)); if (methodInfo.ContainsGenericParameters) - throw new ArgumentException(Environment.GetResourceString("Argument_GenericsInvalid"), nameof(methodInfo)); + throw new ArgumentException(SR.Argument_GenericsInvalid, nameof(methodInfo)); if (methodInfo.DeclaringType != null && methodInfo.DeclaringType.ContainsGenericParameters) - throw new ArgumentException(Environment.GetResourceString("Argument_GenericsInvalid"), nameof(methodInfo)); + throw new ArgumentException(SR.Argument_GenericsInvalid, nameof(methodInfo)); Contract.EndContractBlock(); int tk; @@ -345,7 +328,7 @@ namespace System.Reflection.Emit // Begins an exception filter block. Emits a branch instruction to the end of the current exception block. if (CurrExcStackCount == 0) - throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock")); + throw new NotSupportedException(SR.Argument_NotInExceptionBlock); __ExceptionInfo current = CurrExcStack[CurrExcStackCount - 1]; @@ -359,7 +342,7 @@ namespace System.Reflection.Emit public override void BeginCatchBlock(Type exceptionType) { if (CurrExcStackCount == 0) - throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock")); + throw new NotSupportedException(SR.Argument_NotInExceptionBlock); Contract.EndContractBlock(); __ExceptionInfo current = CurrExcStack[CurrExcStackCount - 1]; @@ -370,7 +353,7 @@ namespace System.Reflection.Emit { if (exceptionType != null) { - throw new ArgumentException(Environment.GetResourceString("Argument_ShouldNotSpecifyExceptionType")); + throw new ArgumentException(SR.Argument_ShouldNotSpecifyExceptionType); } this.Emit(OpCodes.Endfilter); @@ -384,7 +367,7 @@ namespace System.Reflection.Emit throw new ArgumentNullException(nameof(exceptionType)); if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType")); + throw new ArgumentException(SR.Argument_MustBeRuntimeType); Label endLabel = current.GetEndLabel(); this.Emit(OpCodes.Leave, endLabel); @@ -409,7 +392,7 @@ namespace System.Reflection.Emit [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override void UsingNamespace(String ns) { - throw new NotSupportedException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod")); + throw new NotSupportedException(SR.InvalidOperation_NotAllowedInDynamicMethod); } [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. @@ -419,17 +402,17 @@ namespace System.Reflection.Emit int endLine, int endColumn) { - throw new NotSupportedException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod")); + throw new NotSupportedException(SR.InvalidOperation_NotAllowedInDynamicMethod); } public override void BeginScope() { - throw new NotSupportedException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod")); + throw new NotSupportedException(SR.InvalidOperation_NotAllowedInDynamicMethod); } public override void EndScope() { - throw new NotSupportedException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod")); + throw new NotSupportedException(SR.InvalidOperation_NotAllowedInDynamicMethod); } private int GetMemberRefToken(MethodBase methodInfo, Type[] optionalParameterTypes) @@ -437,13 +420,13 @@ namespace System.Reflection.Emit Type[] parameterTypes; if (optionalParameterTypes != null && (methodInfo.CallingConvention & CallingConventions.VarArgs) == 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAVarArgCallingConvention")); + throw new InvalidOperationException(SR.InvalidOperation_NotAVarArgCallingConvention); RuntimeMethodInfo rtMeth = methodInfo as RuntimeMethodInfo; DynamicMethod dm = methodInfo as DynamicMethod; if (rtMeth == null && dm == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), nameof(methodInfo)); + throw new ArgumentException(SR.Argument_MustBeRuntimeMethodInfo, nameof(methodInfo)); ParameterInfo[] paramInfo = methodInfo.GetParametersNoCopy(); if (paramInfo != null && paramInfo.Length != 0) @@ -498,94 +481,36 @@ namespace System.Reflection.Emit #region GetTokenFor helpers private int GetTokenFor(RuntimeType rtType) { -#if FEATURE_APPX - if (ProfileAPICheck && (rtType.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtType.FullName)); -#endif - return m_scope.GetTokenFor(rtType.TypeHandle); } private int GetTokenFor(RuntimeFieldInfo runtimeField) { -#if FEATURE_APPX - if (ProfileAPICheck) - { - RtFieldInfo rtField = runtimeField as RtFieldInfo; - if (rtField != null && (rtField.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtField.FullName)); - } -#endif - return m_scope.GetTokenFor(runtimeField.FieldHandle); } private int GetTokenFor(RuntimeFieldInfo runtimeField, RuntimeType rtType) { -#if FEATURE_APPX - if (ProfileAPICheck) - { - RtFieldInfo rtField = runtimeField as RtFieldInfo; - if (rtField != null && (rtField.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtField.FullName)); - - if ((rtType.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtType.FullName)); - } -#endif - return m_scope.GetTokenFor(runtimeField.FieldHandle, rtType.TypeHandle); } private int GetTokenFor(RuntimeConstructorInfo rtMeth) { -#if FEATURE_APPX - if (ProfileAPICheck && (rtMeth.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtMeth.FullName)); -#endif - return m_scope.GetTokenFor(rtMeth.MethodHandle); } private int GetTokenFor(RuntimeConstructorInfo rtMeth, RuntimeType rtType) { -#if FEATURE_APPX - if (ProfileAPICheck) - { - if ((rtMeth.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtMeth.FullName)); - - if ((rtType.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtType.FullName)); - } -#endif - return m_scope.GetTokenFor(rtMeth.MethodHandle, rtType.TypeHandle); } private int GetTokenFor(RuntimeMethodInfo rtMeth) { -#if FEATURE_APPX - if (ProfileAPICheck && (rtMeth.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtMeth.FullName)); -#endif - return m_scope.GetTokenFor(rtMeth.MethodHandle); } private int GetTokenFor(RuntimeMethodInfo rtMeth, RuntimeType rtType) { -#if FEATURE_APPX - if (ProfileAPICheck) - { - if ((rtMeth.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtMeth.FullName)); - - if ((rtType.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtType.FullName)); - } -#endif - return m_scope.GetTokenFor(rtMeth.MethodHandle, rtType.TypeHandle); } @@ -596,10 +521,6 @@ namespace System.Reflection.Emit private int GetTokenForVarArgMethod(RuntimeMethodInfo rtMeth, SignatureHelper sig) { -#if FEATURE_APPX - if (ProfileAPICheck && (rtMeth.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtMeth.FullName)); -#endif VarArgMethod varArgMeth = new VarArgMethod(rtMeth, sig); return m_scope.GetTokenFor(varArgMeth); } @@ -962,8 +883,8 @@ namespace System.Reflection.Emit public DynamicMethod DynamicMethod { get { return m_method; } } internal DynamicScope DynamicScope { get { return m_scope; } } -#endregion -#region Public Scope Methods + #endregion + #region Public Scope Methods #endregion } @@ -1032,7 +953,7 @@ namespace System.Reflection.Emit Type t = m.DeclaringType.GetGenericTypeDefinition(); throw new ArgumentException(String.Format( - CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_MethodDeclaringTypeGenericLcg"), m, t)); + CultureInfo.CurrentCulture, SR.Argument_MethodDeclaringTypeGenericLcg, m, t)); } } @@ -1119,5 +1040,4 @@ namespace System.Reflection.Emit m_signature = signature; } } - } diff --git a/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs b/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs index f1d99d3c2c..2d2d3097a1 100644 --- a/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs +++ b/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs @@ -42,13 +42,6 @@ namespace System.Reflection.Emit // assigned by the DynamicResolver ctor internal DynamicResolver m_resolver; - // Always false unless we are in an immersive (non dev mode) process. -#if FEATURE_APPX - private bool m_profileAPICheck; - - private RuntimeAssembly m_creatorAssembly; -#endif - internal bool m_restrictedSkipVisibility; // The context when the method was created. We use this to do the RestrictedMemberAccess checks. // These checks are done when the method is compiled. This can happen at an arbitrary time, @@ -58,40 +51,33 @@ namespace System.Reflection.Emit // it is ready for use since there is not API which indictates that IL generation has completed. private static volatile InternalModuleBuilder s_anonymouslyHostedDynamicMethodsModule; private static readonly object s_anonymouslyHostedDynamicMethodsModuleLock = new object(); - + // // class initialization (ctor and init) // private DynamicMethod() { } - [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable public DynamicMethod(string name, Type returnType, Type[] parameterTypes) { - StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; - - Init(name, - MethodAttributes.Public | MethodAttributes.Static, - CallingConventions.Standard, - returnType, + Init(name, + MethodAttributes.Public | MethodAttributes.Static, + CallingConventions.Standard, + returnType, parameterTypes, null, // owner null, // m false, // skipVisibility - true, - ref stackMark); // transparentMethod + true); } - [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable public DynamicMethod(string name, Type returnType, Type[] parameterTypes, bool restrictedSkipVisibility) { - StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; - Init(name, MethodAttributes.Public | MethodAttributes.Static, CallingConventions.Standard, @@ -100,17 +86,17 @@ namespace System.Reflection.Emit null, // owner null, // m restrictedSkipVisibility, - true, - ref stackMark); // transparentMethod + true); } - [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable - public DynamicMethod(string name, - Type returnType, - Type[] parameterTypes, - Module m) { - StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; - PerformSecurityCheck(m, ref stackMark, false); + public DynamicMethod(string name, + Type returnType, + Type[] parameterTypes, + Module m) + { + if (m == null) + throw new ArgumentNullException(nameof(m)); + Init(name, MethodAttributes.Public | MethodAttributes.Static, CallingConventions.Standard, @@ -119,18 +105,18 @@ namespace System.Reflection.Emit null, // owner m, // m false, // skipVisibility - false, - ref stackMark); // transparentMethod + false); } - [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable - public DynamicMethod(string name, - Type returnType, - Type[] parameterTypes, - Module m, - bool skipVisibility) { - StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; - PerformSecurityCheck(m, ref stackMark, skipVisibility); + public DynamicMethod(string name, + Type returnType, + Type[] parameterTypes, + Module m, + bool skipVisibility) + { + if (m == null) + throw new ArgumentNullException(nameof(m)); + Init(name, MethodAttributes.Public | MethodAttributes.Static, CallingConventions.Standard, @@ -139,20 +125,20 @@ namespace System.Reflection.Emit null, // owner m, // m skipVisibility, - false, - ref stackMark); // transparentMethod + false); } - [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable - public DynamicMethod(string name, - MethodAttributes attributes, - CallingConventions callingConvention, - Type returnType, - Type[] parameterTypes, - Module m, - bool skipVisibility) { - StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; - PerformSecurityCheck(m, ref stackMark, skipVisibility); + public DynamicMethod(string name, + MethodAttributes attributes, + CallingConventions callingConvention, + Type returnType, + Type[] parameterTypes, + Module m, + bool skipVisibility) + { + if (m == null) + throw new ArgumentNullException(nameof(m)); + Init(name, attributes, callingConvention, @@ -161,93 +147,93 @@ namespace System.Reflection.Emit null, // owner m, // m skipVisibility, - false, - ref stackMark); // transparentMethod + false); } - [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable - public DynamicMethod(string name, - Type returnType, - Type[] parameterTypes, - Type owner) { - StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; - PerformSecurityCheck(owner, ref stackMark, false); - Init(name, - MethodAttributes.Public | MethodAttributes.Static, - CallingConventions.Standard, - returnType, + public DynamicMethod(string name, + Type returnType, + Type[] parameterTypes, + Type owner) + { + if (owner == null) + throw new ArgumentNullException(nameof(owner)); + + Init(name, + MethodAttributes.Public | MethodAttributes.Static, + CallingConventions.Standard, + returnType, parameterTypes, owner, // owner null, // m false, // skipVisibility - false, - ref stackMark); // transparentMethod + false); } - - [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable - public DynamicMethod(string name, - Type returnType, - Type[] parameterTypes, - Type owner, - bool skipVisibility) { - StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; - PerformSecurityCheck(owner, ref stackMark, skipVisibility); - Init(name, - MethodAttributes.Public | MethodAttributes.Static, - CallingConventions.Standard, - returnType, - parameterTypes, + + public DynamicMethod(string name, + Type returnType, + Type[] parameterTypes, + Type owner, + bool skipVisibility) + { + if (owner == null) + throw new ArgumentNullException(nameof(owner)); + + Init(name, + MethodAttributes.Public | MethodAttributes.Static, + CallingConventions.Standard, + returnType, + parameterTypes, owner, // owner null, // m skipVisibility, - false, - ref stackMark); // transparentMethod + false); } - - [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable - public DynamicMethod(string name, - MethodAttributes attributes, - CallingConventions callingConvention, - Type returnType, - Type[] parameterTypes, - Type owner, - bool skipVisibility) { - StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; - PerformSecurityCheck(owner, ref stackMark, skipVisibility); - Init(name, - attributes, - callingConvention, - returnType, - parameterTypes, + + public DynamicMethod(string name, + MethodAttributes attributes, + CallingConventions callingConvention, + Type returnType, + Type[] parameterTypes, + Type owner, + bool skipVisibility) + { + if (owner == null) + throw new ArgumentNullException(nameof(owner)); + + Init(name, + attributes, + callingConvention, + returnType, + parameterTypes, owner, // owner null, // m - skipVisibility, - false, - ref stackMark); // transparentMethod + skipVisibility, + false); } // helpers for intialization - static private void CheckConsistency(MethodAttributes attributes, CallingConventions callingConvention) { + static private void CheckConsistency(MethodAttributes attributes, CallingConventions callingConvention) + { // only static public for method attributes if ((attributes & ~MethodAttributes.MemberAccessMask) != MethodAttributes.Static) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicMethodFlags")); + throw new NotSupportedException(SR.NotSupported_DynamicMethodFlags); if ((attributes & MethodAttributes.MemberAccessMask) != MethodAttributes.Public) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicMethodFlags")); + throw new NotSupportedException(SR.NotSupported_DynamicMethodFlags); Contract.EndContractBlock(); // only standard or varargs supported if (callingConvention != CallingConventions.Standard && callingConvention != CallingConventions.VarArgs) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicMethodFlags")); - + throw new NotSupportedException(SR.NotSupported_DynamicMethodFlags); + // vararg is not supported at the moment if (callingConvention == CallingConventions.VarArgs) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicMethodFlags")); + throw new NotSupportedException(SR.NotSupported_DynamicMethodFlags); } // We create a transparent assembly to host DynamicMethods. Since the assembly does not have any // non-public fields (or any fields at all), it is a safe anonymous assembly to host DynamicMethods - [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable + [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod private static RuntimeModule GetDynamicMethodsModule() { if (s_anonymouslyHostedDynamicMethodsModule != null) @@ -259,7 +245,7 @@ namespace System.Reflection.Emit return s_anonymouslyHostedDynamicMethodsModule; ConstructorInfo transparencyCtor = typeof(SecurityTransparentAttribute).GetConstructor(Type.EmptyTypes); - CustomAttributeBuilder transparencyAttribute = new CustomAttributeBuilder(transparencyCtor, EmptyArray<Object>.Value); + CustomAttributeBuilder transparencyAttribute = new CustomAttributeBuilder(transparencyCtor, Array.Empty<Object>()); List<CustomAttributeBuilder> assemblyAttributes = new List<CustomAttributeBuilder>(); assemblyAttributes.Add(transparencyAttribute); @@ -283,38 +269,40 @@ namespace System.Reflection.Emit return s_anonymouslyHostedDynamicMethodsModule; } - private unsafe void Init(String name, - MethodAttributes attributes, - CallingConventions callingConvention, - Type returnType, - Type[] signature, - Type owner, - Module m, + private unsafe void Init(String name, + MethodAttributes attributes, + CallingConventions callingConvention, + Type returnType, + Type[] signature, + Type owner, + Module m, bool skipVisibility, - bool transparentMethod, - ref StackCrawlMark stackMark) + bool transparentMethod) { DynamicMethod.CheckConsistency(attributes, callingConvention); // check and store the signature - if (signature != null) { + if (signature != null) + { m_parameterTypes = new RuntimeType[signature.Length]; - for (int i = 0; i < signature.Length; i++) { - if (signature[i] == null) - throw new ArgumentException(Environment.GetResourceString("Arg_InvalidTypeInSignature")); + for (int i = 0; i < signature.Length; i++) + { + if (signature[i] == null) + throw new ArgumentException(SR.Arg_InvalidTypeInSignature); m_parameterTypes[i] = signature[i].UnderlyingSystemType as RuntimeType; - if ( m_parameterTypes[i] == null || !(m_parameterTypes[i] is RuntimeType) || m_parameterTypes[i] == (RuntimeType)typeof(void) ) - throw new ArgumentException(Environment.GetResourceString("Arg_InvalidTypeInSignature")); + if (m_parameterTypes[i] == null || !(m_parameterTypes[i] is RuntimeType) || m_parameterTypes[i] == (RuntimeType)typeof(void)) + throw new ArgumentException(SR.Arg_InvalidTypeInSignature); } } - else { + else + { m_parameterTypes = Array.Empty<RuntimeType>(); } - + // check and store the return value m_returnType = (returnType == null) ? (RuntimeType)typeof(void) : returnType.UnderlyingSystemType as RuntimeType; - if ( (m_returnType == null) || !(m_returnType is RuntimeType) || m_returnType.IsByRef ) - throw new NotSupportedException(Environment.GetResourceString("Arg_InvalidTypeInRetType")); + if ((m_returnType == null) || !(m_returnType is RuntimeType) || m_returnType.IsByRef) + throw new NotSupportedException(SR.Arg_InvalidTypeInRetType); if (transparentMethod) { @@ -324,11 +312,10 @@ namespace System.Reflection.Emit { m_restrictedSkipVisibility = true; } - } else { - Debug.Assert(m != null || owner != null, "PerformSecurityCheck should ensure that either m or owner is set"); + Debug.Assert(m != null || owner != null, "Constructor should ensure that either m or owner is set"); Debug.Assert(m == null || !m.Equals(s_anonymouslyHostedDynamicMethodsModule), "The user cannot explicitly use this assembly"); Debug.Assert(m == null || owner == null, "m and owner cannot both be set"); @@ -344,7 +331,7 @@ namespace System.Reflection.Emit { if (rtOwner.HasElementType || rtOwner.ContainsGenericParameters || rtOwner.IsGenericParameter || rtOwner.IsInterface) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidTypeForDynamicMethod")); + throw new ArgumentException(SR.Argument_InvalidTypeForDynamicMethod); m_typeOwner = rtOwner; m_module = rtOwner.GetRuntimeModule(); @@ -359,41 +346,18 @@ namespace System.Reflection.Emit m_fInitLocals = true; m_methodHandle = null; - if (name == null) + if (name == null) throw new ArgumentNullException(nameof(name)); -#if FEATURE_APPX - if (AppDomain.ProfileAPICheck) - { - if (m_creatorAssembly == null) - m_creatorAssembly = RuntimeAssembly.GetExecutingAssembly(ref stackMark); - - if (m_creatorAssembly != null && !m_creatorAssembly.IsFrameworkAssembly()) - m_profileAPICheck = true; - } -#endif // FEATURE_APPX - m_dynMethod = new RTDynamicMethod(this, name, attributes, callingConvention); } - private void PerformSecurityCheck(Module m, ref StackCrawlMark stackMark, bool skipVisibility) - { - if (m == null) - throw new ArgumentNullException(nameof(m)); - Contract.EndContractBlock(); - } - - private void PerformSecurityCheck(Type owner, ref StackCrawlMark stackMark, bool skipVisibility) - { - if (owner == null) - throw new ArgumentNullException(nameof(owner)); - } - // // Delegate and method creation // - public sealed override Delegate CreateDelegate(Type delegateType) { + public sealed override Delegate CreateDelegate(Type delegateType) + { if (m_restrictedSkipVisibility) { // Compile the method since accessibility checks are done as part of compilation. @@ -407,7 +371,8 @@ namespace System.Reflection.Emit return d; } - public sealed override Delegate CreateDelegate(Type delegateType, Object target) { + public sealed override Delegate CreateDelegate(Type delegateType, Object target) + { if (m_restrictedSkipVisibility) { // Compile the method since accessibility checks are done as part of compilation @@ -421,33 +386,22 @@ namespace System.Reflection.Emit return d; } -#if FEATURE_APPX - internal bool ProfileAPICheck + // This is guaranteed to return a valid handle + internal unsafe RuntimeMethodHandle GetMethodDescriptor() { - get - { - return m_profileAPICheck; - } - - [FriendAccessAllowed] - set + if (m_methodHandle == null) { - m_profileAPICheck = value; - } - } -#endif - - // This is guaranteed to return a valid handle - internal unsafe RuntimeMethodHandle GetMethodDescriptor() { - if (m_methodHandle == null) { - lock (this) { - if (m_methodHandle == null) { + lock (this) + { + if (m_methodHandle == null) + { if (m_DynamicILInfo != null) m_DynamicILInfo.GetCallableMethod(m_module, this); - else { + else + { if (m_ilGenerator == null || m_ilGenerator.ILOffset == 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadEmptyMethodBody", Name)); - + throw new InvalidOperationException(SR.Format(SR.InvalidOperation_BadEmptyMethodBody, Name)); + m_ilGenerator.GetCallableMethod(m_module, this); } } @@ -471,7 +425,7 @@ namespace System.Reflection.Emit public override Module Module { get { return m_dynMethod.Module; } } // we cannot return a MethodHandle because we cannot track it via GC so this method is off limits - public override RuntimeMethodHandle MethodHandle { get { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod")); } } + public override RuntimeMethodHandle MethodHandle { get { throw new InvalidOperationException(SR.InvalidOperation_NotAllowedInDynamicMethod); } } public override MethodAttributes Attributes { get { return m_dynMethod.Attributes; } } @@ -508,9 +462,10 @@ namespace System.Reflection.Emit get { return false; } } - public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) { + public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) + { if ((CallingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_CallToVarArg")); + throw new NotSupportedException(SR.NotSupported_CallToVarArg); Contract.EndContractBlock(); // @@ -531,7 +486,7 @@ namespace System.Reflection.Emit int formalCount = sig.Arguments.Length; int actualCount = (parameters != null) ? parameters.Length : 0; if (formalCount != actualCount) - throw new TargetParameterCountException(Environment.GetResourceString("Arg_ParmCnt")); + throw new TargetParameterCountException(SR.Arg_ParmCnt); // if we are here we passed all the previous checks. Time to look at the arguments Object retValue = null; @@ -554,7 +509,7 @@ namespace System.Reflection.Emit public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { - return m_dynMethod.GetCustomAttributes(attributeType, inherit); + return m_dynMethod.GetCustomAttributes(attributeType, inherit); } public override Object[] GetCustomAttributes(bool inherit) { return m_dynMethod.GetCustomAttributes(inherit); } @@ -571,24 +526,27 @@ namespace System.Reflection.Emit // DynamicMethod specific methods // - public ParameterBuilder DefineParameter(int position, ParameterAttributes attributes, String parameterName) { + public ParameterBuilder DefineParameter(int position, ParameterAttributes attributes, String parameterName) + { if (position < 0 || position > m_parameterTypes.Length) - throw new ArgumentOutOfRangeException(Environment.GetResourceString("ArgumentOutOfRange_ParamSequence")); + throw new ArgumentOutOfRangeException(SR.ArgumentOutOfRange_ParamSequence); position--; // it's 1 based. 0 is the return value - - if (position >= 0) { - ParameterInfo[] parameters = m_dynMethod.LoadParameters(); + + if (position >= 0) + { + RuntimeParameterInfo[] parameters = m_dynMethod.LoadParameters(); parameters[position].SetName(parameterName); parameters[position].SetAttributes(attributes); } return null; } - public ILGenerator GetILGenerator() { + public ILGenerator GetILGenerator() + { return GetILGenerator(64); } - public ILGenerator GetILGenerator(int streamSize) + public ILGenerator GetILGenerator(int streamSize) { if (m_ilGenerator == null) { @@ -599,16 +557,18 @@ namespace System.Reflection.Emit return m_ilGenerator; } - public bool InitLocals { - get {return m_fInitLocals;} - set {m_fInitLocals = value;} + public bool InitLocals + { + get { return m_fInitLocals; } + set { m_fInitLocals = value; } } // // Internal API // - - internal MethodInfo GetMethodInfo() { + + internal MethodInfo GetMethodInfo() + { return m_dynMethod; } @@ -620,109 +580,125 @@ namespace System.Reflection.Emit // This way the DynamicMethod creator is the only one responsible for DynamicMethod access, // and can control exactly who gets access to it. // - internal class RTDynamicMethod : MethodInfo { - + internal class RTDynamicMethod : MethodInfo + { internal DynamicMethod m_owner; - ParameterInfo[] m_parameters; - String m_name; - MethodAttributes m_attributes; - CallingConventions m_callingConvention; + private RuntimeParameterInfo[] m_parameters; + private String m_name; + private MethodAttributes m_attributes; + private CallingConventions m_callingConvention; // // ctors // - private RTDynamicMethod() {} + private RTDynamicMethod() { } - internal RTDynamicMethod(DynamicMethod owner, String name, MethodAttributes attributes, CallingConventions callingConvention) { + internal RTDynamicMethod(DynamicMethod owner, String name, MethodAttributes attributes, CallingConventions callingConvention) + { m_owner = owner; m_name = name; m_attributes = attributes; m_callingConvention = callingConvention; } - + // // MethodInfo api // - public override String ToString() { + public override String ToString() + { return ReturnType.FormatTypeName() + " " + FormatNameAndSig(); } - public override String Name { + public override String Name + { get { return m_name; } } - public override Type DeclaringType { + public override Type DeclaringType + { get { return null; } } - public override Type ReflectedType { + public override Type ReflectedType + { get { return null; } } - public override Module Module { + public override Module Module + { get { return m_owner.m_module; } } - public override RuntimeMethodHandle MethodHandle { - get { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod")); } + public override RuntimeMethodHandle MethodHandle + { + get { throw new InvalidOperationException(SR.InvalidOperation_NotAllowedInDynamicMethod); } } - public override MethodAttributes Attributes { + public override MethodAttributes Attributes + { get { return m_attributes; } - } + } - public override CallingConventions CallingConvention { + public override CallingConventions CallingConvention + { get { return m_callingConvention; } } - - public override MethodInfo GetBaseDefinition() { + + public override MethodInfo GetBaseDefinition() + { return this; } - + [Pure] - public override ParameterInfo[] GetParameters() { + public override ParameterInfo[] GetParameters() + { ParameterInfo[] privateParameters = LoadParameters(); ParameterInfo[] parameters = new ParameterInfo[privateParameters.Length]; Array.Copy(privateParameters, 0, parameters, 0, privateParameters.Length); return parameters; } - - public override MethodImplAttributes GetMethodImplementationFlags() { + + public override MethodImplAttributes GetMethodImplementationFlags() + { return MethodImplAttributes.IL | MethodImplAttributes.NoInlining; } - public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) { + public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) + { // We want the creator of the DynamicMethod to control who has access to the // DynamicMethod (just like we do for delegates). However, a user can get to // the corresponding RTDynamicMethod using Exception.TargetSite, StackFrame.GetMethod, etc. // If we allowed use of RTDynamicMethod, the creator of the DynamicMethod would // not be able to bound access to the DynamicMethod. Hence, we do not allow // direct use of RTDynamicMethod. - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), "this"); + throw new ArgumentException(SR.Argument_MustBeRuntimeMethodInfo, "this"); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { + public override Object[] GetCustomAttributes(Type attributeType, bool inherit) + { if (attributeType == null) throw new ArgumentNullException(nameof(attributeType)); Contract.EndContractBlock(); - if (attributeType.IsAssignableFrom(typeof(MethodImplAttribute))) + if (attributeType.IsAssignableFrom(typeof(MethodImplAttribute))) return new Object[] { new MethodImplAttribute(GetMethodImplementationFlags()) }; else - return EmptyArray<Object>.Value; + return Array.Empty<Object>(); } - public override Object[] GetCustomAttributes(bool inherit) { + public override Object[] GetCustomAttributes(bool inherit) + { // support for MethodImplAttribute PCA return new Object[] { new MethodImplAttribute(GetMethodImplementationFlags()) }; } - - public override bool IsDefined(Type attributeType, bool inherit) { + + public override bool IsDefined(Type attributeType, bool inherit) + { if (attributeType == null) throw new ArgumentNullException(nameof(attributeType)); Contract.EndContractBlock(); - if (attributeType.IsAssignableFrom(typeof(MethodImplAttribute))) + if (attributeType.IsAssignableFrom(typeof(MethodImplAttribute))) return true; else return false; @@ -751,11 +727,13 @@ namespace System.Reflection.Emit } } - public override ParameterInfo ReturnParameter { - get { return null; } + public override ParameterInfo ReturnParameter + { + get { return null; } } - public override ICustomAttributeProvider ReturnTypeCustomAttributes { + public override ICustomAttributeProvider ReturnTypeCustomAttributes + { get { return GetEmptyCAHolder(); } } @@ -763,45 +741,49 @@ namespace System.Reflection.Emit // private implementation // - internal ParameterInfo[] LoadParameters() { - if (m_parameters == null) { + internal RuntimeParameterInfo[] LoadParameters() + { + if (m_parameters == null) + { Type[] parameterTypes = m_owner.m_parameterTypes; - ParameterInfo[] parameters = new ParameterInfo[parameterTypes.Length]; - for (int i = 0; i < parameterTypes.Length; i++) + RuntimeParameterInfo[] parameters = new RuntimeParameterInfo[parameterTypes.Length]; + for (int i = 0; i < parameterTypes.Length; i++) parameters[i] = new RuntimeParameterInfo(this, null, parameterTypes[i], i); - if (m_parameters == null) + if (m_parameters == null) // should we interlockexchange? m_parameters = parameters; } return m_parameters; } - + // private implementation of CA for the return type - private ICustomAttributeProvider GetEmptyCAHolder() { + private ICustomAttributeProvider GetEmptyCAHolder() + { return new EmptyCAHolder(); } /////////////////////////////////////////////////// // EmptyCAHolder - private class EmptyCAHolder : ICustomAttributeProvider { - internal EmptyCAHolder() {} + private class EmptyCAHolder : ICustomAttributeProvider + { + internal EmptyCAHolder() { } - Object[] ICustomAttributeProvider.GetCustomAttributes(Type attributeType, bool inherit) { - return EmptyArray<Object>.Value; + Object[] ICustomAttributeProvider.GetCustomAttributes(Type attributeType, bool inherit) + { + return Array.Empty<Object>(); } - Object[] ICustomAttributeProvider.GetCustomAttributes(bool inherit) { - return EmptyArray<Object>.Value; + Object[] ICustomAttributeProvider.GetCustomAttributes(bool inherit) + { + return Array.Empty<Object>(); } - bool ICustomAttributeProvider.IsDefined (Type attributeType, bool inherit) { + bool ICustomAttributeProvider.IsDefined(Type attributeType, bool inherit) + { return false; } } - } - } - } diff --git a/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs index 96564d537b..55aa5c5a8f 100644 --- a/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs @@ -12,8 +12,9 @@ ** ** ===========================================================*/ -namespace System.Reflection.Emit { - + +namespace System.Reflection.Emit +{ using System; using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; @@ -23,21 +24,22 @@ namespace System.Reflection.Emit { sealed public class EnumBuilder : TypeInfo { - public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo){ - if(typeInfo==null) return false; + public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo) + { + if (typeInfo == null) return false; return IsAssignableFrom(typeInfo.AsType()); } // Define literal for enum public FieldBuilder DefineLiteral(String literalName, Object literalValue) - { - BCLDebug.Log("DYNIL","## DYNIL LOGGING: EnumBuilder.DefineLiteral( " + literalName + " )"); + { + BCLDebug.Log("DYNIL", "## DYNIL LOGGING: EnumBuilder.DefineLiteral( " + literalName + " )"); // Define the underlying field for the enum. It will be a non-static, private field with special name bit set. FieldBuilder fieldBuilder = m_typeBuilder.DefineField( - literalName, - this, + literalName, + this, FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal); fieldBuilder.SetConstant(literalValue); return fieldBuilder; @@ -50,143 +52,156 @@ namespace System.Reflection.Emit { } // CreateType cause EnumBuilder to be baked. - public Type CreateType() + public Type CreateType() { - BCLDebug.Log("DYNIL","## DYNIL LOGGING: EnumBuilder.CreateType() "); + BCLDebug.Log("DYNIL", "## DYNIL LOGGING: EnumBuilder.CreateType() "); return m_typeBuilder.CreateType(); } - + // Get the internal metadata token for this class. - public TypeToken TypeToken { - get {return m_typeBuilder.TypeToken; } + public TypeToken TypeToken + { + get { return m_typeBuilder.TypeToken; } } - + // return the underlying field for the enum - public FieldBuilder UnderlyingField { - get {return m_underlyingField; } + public FieldBuilder UnderlyingField + { + get { return m_underlyingField; } } - public override String Name { + public override String Name + { get { return m_typeBuilder.Name; } } - + /**************************************************** * * abstract methods defined in the base class * */ - public override Guid GUID { - get { + public override Guid GUID + { + get + { return m_typeBuilder.GUID; } } public override Object InvokeMember( - String name, + String name, BindingFlags invokeAttr, - Binder binder, - Object target, - Object[] args, - ParameterModifier[] modifiers, + Binder binder, + Object target, + Object[] args, + ParameterModifier[] modifiers, CultureInfo culture, - String[] namedParameters) + String[] namedParameters) { return m_typeBuilder.InvokeMember(name, invokeAttr, binder, target, args, modifiers, culture, namedParameters); } - - public override Module Module { - get {return m_typeBuilder.Module;} + + public override Module Module + { + get { return m_typeBuilder.Module; } } - - public override Assembly Assembly { - get {return m_typeBuilder.Assembly;} + + public override Assembly Assembly + { + get { return m_typeBuilder.Assembly; } } - public override RuntimeTypeHandle TypeHandle { - get {return m_typeBuilder.TypeHandle;} + public override RuntimeTypeHandle TypeHandle + { + get { return m_typeBuilder.TypeHandle; } } - - public override String FullName { - get { return m_typeBuilder.FullName;} + + public override String FullName + { + get { return m_typeBuilder.FullName; } } - - public override String AssemblyQualifiedName { - get { + + public override String AssemblyQualifiedName + { + get + { return m_typeBuilder.AssemblyQualifiedName; } } - - public override String Namespace { - get { return m_typeBuilder.Namespace;} + + public override String Namespace + { + get { return m_typeBuilder.Namespace; } } - - public override Type BaseType { - get{return m_typeBuilder.BaseType;} + + public override Type BaseType + { + get { return m_typeBuilder.BaseType; } } - - protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr,Binder binder, - CallingConventions callConvention, Type[] types,ParameterModifier[] modifiers) + + protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, + CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { return m_typeBuilder.GetConstructor(bindingAttr, binder, callConvention, types, modifiers); } - + public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr) { return m_typeBuilder.GetConstructors(bindingAttr); } - - protected override MethodInfo GetMethodImpl(String name,BindingFlags bindingAttr,Binder binder, - CallingConventions callConvention, Type[] types,ParameterModifier[] modifiers) + + protected override MethodInfo GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, + CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { if (types == null) return m_typeBuilder.GetMethod(name, bindingAttr); else return m_typeBuilder.GetMethod(name, bindingAttr, binder, callConvention, types, modifiers); } - + public override MethodInfo[] GetMethods(BindingFlags bindingAttr) { return m_typeBuilder.GetMethods(bindingAttr); } - + public override FieldInfo GetField(String name, BindingFlags bindingAttr) { return m_typeBuilder.GetField(name, bindingAttr); } - + public override FieldInfo[] GetFields(BindingFlags bindingAttr) { return m_typeBuilder.GetFields(bindingAttr); } - + public override Type GetInterface(String name, bool ignoreCase) { return m_typeBuilder.GetInterface(name, ignoreCase); } - + public override Type[] GetInterfaces() { return m_typeBuilder.GetInterfaces(); } - + public override EventInfo GetEvent(String name, BindingFlags bindingAttr) { return m_typeBuilder.GetEvent(name, bindingAttr); } - + public override EventInfo[] GetEvents() { return m_typeBuilder.GetEvents(); } - - protected override PropertyInfo GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, + + protected override PropertyInfo GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } - + public override PropertyInfo[] GetProperties(BindingFlags bindingAttr) { return m_typeBuilder.GetProperties(bindingAttr); @@ -199,14 +214,14 @@ namespace System.Reflection.Emit { public override Type GetNestedType(String name, BindingFlags bindingAttr) { - return m_typeBuilder.GetNestedType(name,bindingAttr); + return m_typeBuilder.GetNestedType(name, bindingAttr); } - - public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr) + + public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr) { return m_typeBuilder.GetMember(name, type, bindingAttr); } - + public override MemberInfo[] GetMembers(BindingFlags bindingAttr) { return m_typeBuilder.GetMembers(bindingAttr); @@ -221,12 +236,14 @@ namespace System.Reflection.Emit { { return m_typeBuilder.GetEvents(bindingAttr); } - + protected override TypeAttributes GetAttributeFlagsImpl() { return m_typeBuilder.Attributes; } - + + public override bool IsSZArray => false; + protected override bool IsArrayImpl() { return false; @@ -236,7 +253,7 @@ namespace System.Reflection.Emit { return false; } - protected override bool IsValueTypeImpl() + protected override bool IsValueTypeImpl() { return true; } @@ -250,7 +267,7 @@ namespace System.Reflection.Emit { { return false; } - + protected override bool IsCOMObjectImpl() { return false; @@ -290,7 +307,7 @@ namespace System.Reflection.Emit { return GetEnumUnderlyingType(); } } - + //ICustomAttributeProvider public override Object[] GetCustomAttributes(bool inherit) { @@ -303,64 +320,66 @@ namespace System.Reflection.Emit { return m_typeBuilder.GetCustomAttributes(attributeType, inherit); } - // Use this function if client decides to form the custom attribute blob themselves + // Use this function if client decides to form the custom attribute blob themselves public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) { - m_typeBuilder.SetCustomAttribute(con, binaryAttribute); + m_typeBuilder.SetCustomAttribute(con, binaryAttribute); } - // Use this function if client wishes to build CustomAttribute using CustomAttributeBuilder + // Use this function if client wishes to build CustomAttribute using CustomAttributeBuilder public void SetCustomAttribute(CustomAttributeBuilder customBuilder) { m_typeBuilder.SetCustomAttribute(customBuilder); } // Return the class that declared this Field. - public override Type DeclaringType { - get {return m_typeBuilder.DeclaringType;} + public override Type DeclaringType + { + get { return m_typeBuilder.DeclaringType; } } // Return the class that was used to obtain this field. - - public override Type ReflectedType { - get {return m_typeBuilder.ReflectedType;} + + public override Type ReflectedType + { + get { return m_typeBuilder.ReflectedType; } } - // Returns true if one or more instance of attributeType is defined on this member. - public override bool IsDefined (Type attributeType, bool inherit) + // Returns true if one or more instance of attributeType is defined on this member. + public override bool IsDefined(Type attributeType, bool inherit) { return m_typeBuilder.IsDefined(attributeType, inherit); } - + /***************************************************** * * private/protected functions * */ - + //******************************* // Make a private constructor so these cannot be constructed externally. //******************************* - private EnumBuilder() {} - - public override Type MakePointerType() - { - return SymbolType.FormCompoundType("*", this, 0); + private EnumBuilder() { } + + public override Type MakePointerType() + { + return SymbolType.FormCompoundType("*", this, 0); } - public override Type MakeByRefType() + public override Type MakeByRefType() { return SymbolType.FormCompoundType("&", this, 0); } - public override Type MakeArrayType() + public override Type MakeArrayType() { return SymbolType.FormCompoundType("[]", this, 0); } - public override Type MakeArrayType(int rank) + public override Type MakeArrayType(int rank) { if (rank <= 0) throw new IndexOutOfRangeException(); @@ -370,9 +389,9 @@ namespace System.Reflection.Emit { { szrank = "*"; } - else + else { - for(int i = 1; i < rank; i++) + for (int i = 1; i < rank; i++) szrank += ","; } @@ -380,18 +399,18 @@ namespace System.Reflection.Emit { return SymbolType.FormCompoundType(s, this, 0); } - + // Constructs a EnumBuilder. // EnumBuilder can only be a top-level (not nested) enum type. internal EnumBuilder( - String name, // name of type - Type underlyingType, // underlying type for an Enum + String name, // name of type + Type underlyingType, // underlying type for an Enum TypeAttributes visibility, // any bits on TypeAttributes.VisibilityMask) - ModuleBuilder module) // module containing this type + ModuleBuilder module) // module containing this type { // Client should not set any bits other than the visibility bits. if ((visibility & ~TypeAttributes.VisibilityMask) != 0) - throw new ArgumentException(Environment.GetResourceString("Argument_ShouldOnlySetVisibilityFlags"), nameof(name)); + throw new ArgumentException(SR.Argument_ShouldOnlySetVisibilityFlags, nameof(name)); m_typeBuilder = new TypeBuilder(name, visibility | TypeAttributes.Sealed, typeof(System.Enum), null, module, PackingSize.Unspecified, TypeBuilder.UnspecifiedTypeSize, null); // Define the underlying field for the enum. It will be a non-static, private field with special name bit set. @@ -403,7 +422,7 @@ namespace System.Reflection.Emit { * private data members * */ - internal TypeBuilder m_typeBuilder; - private FieldBuilder m_underlyingField; + internal TypeBuilder m_typeBuilder; + private FieldBuilder m_underlyingField; } } diff --git a/src/mscorlib/src/System/Reflection/Emit/EventBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/EventBuilder.cs index 34c76b93d1..ef60d05172 100644 --- a/src/mscorlib/src/System/Reflection/Emit/EventBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/EventBuilder.cs @@ -12,40 +12,40 @@ ** ** ===========================================================*/ -namespace System.Reflection.Emit { - - using System; - using System.Reflection; - using System.Runtime.InteropServices; - using System.Diagnostics.Contracts; - + +using System; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Diagnostics.Contracts; + +namespace System.Reflection.Emit +{ // // A EventBuilder is always associated with a TypeBuilder. The TypeBuilder.DefineEvent // method will return a new EventBuilder to a client. // public sealed class EventBuilder - { - + { // Make a private constructor so these cannot be constructed externally. - private EventBuilder() {} - + private EventBuilder() { } + // Constructs a EventBuilder. // internal EventBuilder( - ModuleBuilder mod, // the module containing this EventBuilder - String name, // Event name + ModuleBuilder mod, // the module containing this EventBuilder + String name, // Event name EventAttributes attr, // event attribute such as Public, Private, and Protected defined above - //int eventType, // event type - TypeBuilder type, // containing type - EventToken evToken) - { + //int eventType, // event type + TypeBuilder type, // containing type + EventToken evToken) + { m_name = name; m_module = mod; m_attributes = attr; m_evToken = evToken; m_type = type; } - + // Return the Token for this event within the TypeBuilder that the // event is defined within. public EventToken GetEventToken() @@ -73,22 +73,22 @@ namespace System.Reflection.Emit { { SetMethodSemantics(mdBuilder, MethodSemanticsAttributes.AddOn); } - + public void SetRemoveOnMethod(MethodBuilder mdBuilder) { SetMethodSemantics(mdBuilder, MethodSemanticsAttributes.RemoveOn); } - + public void SetRaiseMethod(MethodBuilder mdBuilder) { SetMethodSemantics(mdBuilder, MethodSemanticsAttributes.Fire); } - + public void AddOtherMethod(MethodBuilder mdBuilder) { SetMethodSemantics(mdBuilder, MethodSemanticsAttributes.Other); } - + // Use this function if client decides to form the custom attribute blob themselves public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) @@ -121,10 +121,10 @@ namespace System.Reflection.Emit { } // These are package private so that TypeBuilder can access them. - private String m_name; // The name of the event - private EventToken m_evToken; // The token of this event - private ModuleBuilder m_module; - private EventAttributes m_attributes; - private TypeBuilder m_type; + private String m_name; // The name of the event + private EventToken m_evToken; // The token of this event + private ModuleBuilder m_module; + private EventAttributes m_attributes; + private TypeBuilder m_type; } } diff --git a/src/mscorlib/src/System/Reflection/Emit/EventToken.cs b/src/mscorlib/src/System/Reflection/Emit/EventToken.cs index 8ffdce9732..18ec630b5f 100644 --- a/src/mscorlib/src/System/Reflection/Emit/EventToken.cs +++ b/src/mscorlib/src/System/Reflection/Emit/EventToken.cs @@ -12,30 +12,34 @@ ** ** ===========================================================*/ -namespace System.Reflection.Emit { - - using System; - using System.Reflection; + +using System; +using System.Reflection; + +namespace System.Reflection.Emit +{ [Serializable] public struct EventToken { public static readonly EventToken Empty = new EventToken(); - + internal int m_event; - internal EventToken(int str) { - m_event=str; + internal EventToken(int str) + { + m_event = str; } - - public int Token { + + public int Token + { get { return m_event; } } - + public override int GetHashCode() { return m_event; } - + public override bool Equals(Object obj) { if (obj is EventToken) @@ -43,25 +47,20 @@ namespace System.Reflection.Emit { else return false; } - + public bool Equals(EventToken obj) { return obj.m_event == m_event; } - + public static bool operator ==(EventToken a, EventToken b) { return a.Equals(b); } - + public static bool operator !=(EventToken a, EventToken b) { return !(a == b); } - } - - - - } diff --git a/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs index 5953b67173..d0e9d3483c 100644 --- a/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs @@ -4,14 +4,14 @@ // -namespace System.Reflection.Emit +namespace System.Reflection.Emit { using System.Runtime.InteropServices; using System; using CultureInfo = System.Globalization.CultureInfo; using System.Reflection; using System.Diagnostics.Contracts; - + public sealed class FieldBuilder : FieldInfo { #region Private Data Members @@ -24,36 +24,36 @@ namespace System.Reflection.Emit #endregion #region Constructor - internal FieldBuilder(TypeBuilder typeBuilder, String fieldName, Type type, + internal FieldBuilder(TypeBuilder typeBuilder, String fieldName, Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers, FieldAttributes attributes) { if (fieldName == null) throw new ArgumentNullException(nameof(fieldName)); if (fieldName.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(fieldName)); + throw new ArgumentException(SR.Argument_EmptyName, nameof(fieldName)); if (fieldName[0] == '\0') - throw new ArgumentException(Environment.GetResourceString("Argument_IllegalName"), nameof(fieldName)); + throw new ArgumentException(SR.Argument_IllegalName, nameof(fieldName)); if (type == null) throw new ArgumentNullException(nameof(type)); if (type == typeof(void)) - throw new ArgumentException(Environment.GetResourceString("Argument_BadFieldType")); + throw new ArgumentException(SR.Argument_BadFieldType); Contract.EndContractBlock(); m_fieldName = fieldName; m_typeBuilder = typeBuilder; m_fieldType = type; m_Attributes = attributes & ~FieldAttributes.ReservedMask; - + SignatureHelper sigHelp = SignatureHelper.GetFieldSigHelper(m_typeBuilder.Module); sigHelp.AddArgument(type, requiredCustomModifiers, optionalCustomModifiers); int sigLength; byte[] signature = sigHelp.InternalGetSignature(out sigLength); - + m_fieldTok = TypeBuilder.DefineField(m_typeBuilder.GetModuleBuilder().GetNativeHandle(), typeBuilder.TypeToken.Token, fieldName, signature, sigLength, m_Attributes); @@ -74,20 +74,20 @@ namespace System.Reflection.Emit { get { return m_fieldTok; } } - + public override Module Module { get { return m_typeBuilder.Module; } } - public override String Name + public override String Name { - get {return m_fieldName; } + get { return m_fieldName; } } - public override Type DeclaringType + public override Type DeclaringType { - get + get { if (m_typeBuilder.m_isHiddenGlobalType == true) return null; @@ -95,10 +95,10 @@ namespace System.Reflection.Emit return m_typeBuilder; } } - - public override Type ReflectedType + + public override Type ReflectedType { - get + get { if (m_typeBuilder.m_isHiddenGlobalType == true) return null; @@ -110,35 +110,35 @@ namespace System.Reflection.Emit #endregion #region FieldInfo Overrides - public override Type FieldType + public override Type FieldType { get { return m_fieldType; } } public override Object GetValue(Object obj) - { + { // NOTE!! If this is implemented, make sure that this throws // a NotSupportedException for Save-only dynamic assemblies. // Otherwise, it could cause the .cctor to be executed. - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } - public override void SetValue(Object obj,Object val,BindingFlags invokeAttr,Binder binder,CultureInfo culture) - { + public override void SetValue(Object obj, Object val, BindingFlags invokeAttr, Binder binder, CultureInfo culture) + { // NOTE!! If this is implemented, make sure that this throws // a NotSupportedException for Save-only dynamic assemblies. // Otherwise, it could cause the .cctor to be executed. - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } - public override RuntimeFieldHandle FieldHandle + public override RuntimeFieldHandle FieldHandle { - get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); } + get { throw new NotSupportedException(SR.NotSupported_DynamicModule); } } - public override FieldAttributes Attributes + public override FieldAttributes Attributes { get { return m_Attributes; } } @@ -148,44 +148,41 @@ namespace System.Reflection.Emit #region ICustomAttributeProvider Implementation public override Object[] GetCustomAttributes(bool inherit) { - - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } - + public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { - - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } public override bool IsDefined(Type attributeType, bool inherit) { - - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } #endregion #region Public Members - public FieldToken GetToken() + public FieldToken GetToken() { return m_tkField; } - public void SetOffset(int iOffset) + public void SetOffset(int iOffset) { - m_typeBuilder.ThrowIfCreated(); - + m_typeBuilder.ThrowIfCreated(); + TypeBuilder.SetFieldLayoutOffset(m_typeBuilder.GetModuleBuilder().GetNativeHandle(), GetToken().Token, iOffset); } - public void SetConstant(Object defaultValue) + public void SetConstant(Object defaultValue) { - m_typeBuilder.ThrowIfCreated(); - + m_typeBuilder.ThrowIfCreated(); + TypeBuilder.SetConstantValue(m_typeBuilder.GetModuleBuilder(), GetToken().Token, m_fieldType, defaultValue); } - + public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) { diff --git a/src/mscorlib/src/System/Reflection/Emit/FieldToken.cs b/src/mscorlib/src/System/Reflection/Emit/FieldToken.cs index add428f96e..6c5d778d8f 100644 --- a/src/mscorlib/src/System/Reflection/Emit/FieldToken.cs +++ b/src/mscorlib/src/System/Reflection/Emit/FieldToken.cs @@ -12,11 +12,12 @@ ** ** ===========================================================*/ -namespace System.Reflection.Emit { - - using System; - using System.Reflection; +using System; +using System.Reflection; + +namespace System.Reflection.Emit +{ // The FieldToken class is an opaque representation of the Token returned // by the Metadata to represent the field. FieldTokens are generated by // Module.GetFieldToken(). There are no meaningful accessors on this class, @@ -28,7 +29,7 @@ namespace System.Reflection.Emit { internal int m_fieldTok; internal Object m_class; - + // Creates an empty FieldToken. A publicly visible constructor so that // it can be created on the stack. //public FieldToken() { @@ -38,23 +39,25 @@ namespace System.Reflection.Emit { //} // The actual constructor. Sets the field, attributes and class // variables - - internal FieldToken (int field, Type fieldClass) { - m_fieldTok=field; + + internal FieldToken(int field, Type fieldClass) + { + m_fieldTok = field; m_class = fieldClass; } - - public int Token { + + public int Token + { get { return m_fieldTok; } } - - + + // Generates the hash code for this field. public override int GetHashCode() { return (m_fieldTok); } - + // Returns true if obj is an instance of FieldToken and is // equal to this instance. public override bool Equals(Object obj) @@ -69,16 +72,15 @@ namespace System.Reflection.Emit { { return obj.m_fieldTok == m_fieldTok && obj.m_class == m_class; } - + public static bool operator ==(FieldToken a, FieldToken b) { return a.Equals(b); } - + public static bool operator !=(FieldToken a, FieldToken b) { return !(a == b); } - } } diff --git a/src/mscorlib/src/System/Reflection/Emit/FlowControl.cs b/src/mscorlib/src/System/Reflection/Emit/FlowControl.cs index 9e528b2551..fb8564652f 100644 --- a/src/mscorlib/src/System/Reflection/Emit/FlowControl.cs +++ b/src/mscorlib/src/System/Reflection/Emit/FlowControl.cs @@ -11,23 +11,23 @@ ** THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT BY HAND! ** See clrsrcincopcodegen.pl for more information.** ============================================================*/ -namespace System.Reflection.Emit { using System; -[Serializable] -public enum FlowControl +namespace System.Reflection.Emit { - - Branch = 0, - Break = 1, - Call = 2, - Cond_Branch = 3, - Meta = 4, - Next = 5, - [Obsolete("This API has been deprecated. http://go.microsoft.com/fwlink/?linkid=14202")] - Phi = 6, - Return = 7, - Throw = 8, -} + [Serializable] + public enum FlowControl + { + Branch = 0, + Break = 1, + Call = 2, + Cond_Branch = 3, + Meta = 4, + Next = 5, + [Obsolete("This API has been deprecated. http://go.microsoft.com/fwlink/?linkid=14202")] + Phi = 6, + Return = 7, + Throw = 8, + } } diff --git a/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs index 894f57d49c..dd5ffa92a9 100644 --- a/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs @@ -4,19 +4,20 @@ // +using System; +using System.Reflection; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Diagnostics.Contracts; + namespace System.Reflection.Emit { - using System; - using System.Reflection; - using System.Collections; - using System.Collections.Generic; - using System.Globalization; - using System.Diagnostics.Contracts; - - public sealed class GenericTypeParameterBuilder: TypeInfo + public sealed class GenericTypeParameterBuilder : TypeInfo { - public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo){ - if(typeInfo==null) return false; + public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo) + { + if (typeInfo == null) return false; return IsAssignableFrom(typeInfo.AsType()); } @@ -32,14 +33,14 @@ namespace System.Reflection.Emit #endregion #region Object Overrides - public override String ToString() - { + public override String ToString() + { return m_type.Name; } - public override bool Equals(object o) - { + public override bool Equals(object o) + { GenericTypeParameterBuilder g = o as GenericTypeParameterBuilder; - + if (g == null) return false; @@ -62,22 +63,22 @@ namespace System.Reflection.Emit #region Type Overrides - public override Type MakePointerType() - { - return SymbolType.FormCompoundType("*", this, 0); + public override Type MakePointerType() + { + return SymbolType.FormCompoundType("*", this, 0); } - public override Type MakeByRefType() + public override Type MakeByRefType() { return SymbolType.FormCompoundType("&", this, 0); } - public override Type MakeArrayType() + public override Type MakeArrayType() { return SymbolType.FormCompoundType("[]", this, 0); } - public override Type MakeArrayType(int rank) + public override Type MakeArrayType(int rank) { if (rank <= 0) throw new IndexOutOfRangeException(); @@ -88,9 +89,9 @@ namespace System.Reflection.Emit { szrank = "*"; } - else + else { - for(int i = 1; i < rank; i++) + for (int i = 1; i < rank; i++) szrank += ","; } @@ -113,7 +114,7 @@ namespace System.Reflection.Emit public override String AssemblyQualifiedName { get { return null; } } - public override Type BaseType { get { return m_type.BaseType; } } + public override Type BaseType { get { return m_type.BaseType; } } protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); } @@ -153,6 +154,8 @@ namespace System.Reflection.Emit protected override TypeAttributes GetAttributeFlagsImpl() { return TypeAttributes.Public; } + public override bool IsSZArray => false; + protected override bool IsArrayImpl() { return false; } protected override bool IsByRefImpl() { return false; } @@ -189,7 +192,7 @@ namespace System.Reflection.Emit public override Type GetGenericTypeDefinition() { throw new InvalidOperationException(); } - public override Type MakeGenericType(params Type[] typeArguments) { throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericTypeDefinition")); } + public override Type MakeGenericType(params Type[] typeArguments) { throw new InvalidOperationException(SR.Arg_NotGenericTypeDefinition); } protected override bool IsValueTypeImpl() { return false; } @@ -209,7 +212,7 @@ namespace System.Reflection.Emit #region Public Members public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) - { + { m_type.SetGenParamCustomAttribute(con, binaryAttribute); } diff --git a/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs b/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs index 2cee63ff2e..4021410a33 100644 --- a/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs +++ b/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs @@ -4,16 +4,16 @@ // -namespace System.Reflection.Emit +using System; +using System.Diagnostics.SymbolStore; +using System.Runtime.InteropServices; +using System.Reflection; +using System.Globalization; +using System.Diagnostics; +using System.Diagnostics.Contracts; + +namespace System.Reflection.Emit { - using System; - using System.Diagnostics.SymbolStore; - using System.Runtime.InteropServices; - using System.Reflection; - using System.Globalization; - using System.Diagnostics; - using System.Diagnostics.Contracts; - public class ILGenerator { #region Const Members @@ -28,18 +28,18 @@ namespace System.Reflection.Emit { return EnlargeArray(incoming, incoming.Length * 2); } - + internal static T[] EnlargeArray<T>(T[] incoming, int requiredSize) { Contract.Requires(incoming != null); Contract.Ensures(Contract.Result<T[]>() != null); Contract.Ensures(Contract.Result<T[]>().Length == requiredSize); - + T[] temp = new T[requiredSize]; Array.Copy(incoming, 0, temp, 0, incoming.Length); return temp; } - + private static byte[] EnlargeArray(byte[] incoming) { return EnlargeArray(incoming, incoming.Length * 2); @@ -50,7 +50,7 @@ namespace System.Reflection.Emit Contract.Requires(incoming != null); Contract.Ensures(Contract.Result<byte[]>() != null); Contract.Ensures(Contract.Result<byte[]>().Length == requiredSize); - + byte[] temp = new byte[requiredSize]; Buffer.BlockCopy(incoming, 0, temp, 0, incoming.Length); return temp; @@ -58,35 +58,35 @@ namespace System.Reflection.Emit #endregion #region Internal Data Members - private int m_length; - private byte[] m_ILStream; + private int m_length; + private byte[] m_ILStream; + + private int[] m_labelList; + private int m_labelCount; - private int[] m_labelList; - private int m_labelCount; + private __FixupData[] m_fixupData; - private __FixupData[] m_fixupData; - - private int m_fixupCount; + private int m_fixupCount; - private int[] m_RelocFixupList; - private int m_RelocFixupCount; + private int[] m_RelocFixupList; + private int m_RelocFixupCount; - private int m_exceptionCount; - private int m_currExcStackCount; - private __ExceptionInfo[] m_exceptions; //This is the list of all of the exceptions in this ILStream. - private __ExceptionInfo[] m_currExcStack; //This is the stack of exceptions which we're currently in. + private int m_exceptionCount; + private int m_currExcStackCount; + private __ExceptionInfo[] m_exceptions; //This is the list of all of the exceptions in this ILStream. + private __ExceptionInfo[] m_currExcStack; //This is the stack of exceptions which we're currently in. - internal ScopeTree m_ScopeTree; // this variable tracks all debugging scope information - internal LineNumberInfo m_LineNumberInfo; // this variable tracks all line number information + internal ScopeTree m_ScopeTree; // this variable tracks all debugging scope information + internal LineNumberInfo m_LineNumberInfo; // this variable tracks all line number information - internal MethodInfo m_methodBuilder; - internal int m_localCount; - internal SignatureHelper m_localSignature; + internal MethodInfo m_methodBuilder; + internal int m_localCount; + internal SignatureHelper m_localSignature; - private int m_maxStackSize = 0; // Maximum stack size not counting the exceptions. + private int m_maxStackSize = 0; // Maximum stack size not counting the exceptions. - private int m_maxMidStack = 0; // Maximum stack size for a given basic block. - private int m_maxMidStackCur = 0; // Running count of the maximum stack size for the current basic block. + private int m_maxMidStack = 0; // Maximum stack size for a given basic block. + private int m_maxMidStackCur = 0; // Running count of the maximum stack size for the current basic block. internal int CurrExcStackCount { @@ -128,9 +128,9 @@ namespace System.Reflection.Emit m_fixupData = null; - m_exceptions = null; + m_exceptions = null; m_exceptionCount = 0; - m_currExcStack = null; + m_currExcStack = null; m_currExcStackCount = 0; m_RelocFixupList = null; @@ -144,7 +144,7 @@ namespace System.Reflection.Emit // initialize local signature m_localCount = 0; MethodBuilder mb = m_methodBuilder as MethodBuilder; - if (mb == null) + if (mb == null) m_localSignature = SignatureHelper.GetLocalVarSigHelper(null); else m_localSignature = SignatureHelper.GetLocalVarSigHelper(mb.GetTypeBuilder().Module); @@ -173,7 +173,6 @@ namespace System.Reflection.Emit m_ILStream[m_length++] = (byte)opcode.Value; UpdateStackSize(opcode, opcode.StackChange()); - } internal void UpdateStackSize(OpCode opcode, int stackchange) @@ -211,13 +210,13 @@ namespace System.Reflection.Emit return ((ModuleBuilder)m_methodBuilder.Module).GetMethodTokenInternal(method, optionalParameterTypes, useMethodDef); } - internal virtual SignatureHelper GetMemberRefSignature(CallingConventions call, Type returnType, + internal virtual SignatureHelper GetMemberRefSignature(CallingConventions call, Type returnType, Type[] parameterTypes, Type[] optionalParameterTypes) { return GetMemberRefSignature(call, returnType, parameterTypes, optionalParameterTypes, 0); } - private SignatureHelper GetMemberRefSignature(CallingConventions call, Type returnType, + private SignatureHelper GetMemberRefSignature(CallingConventions call, Type returnType, Type[] parameterTypes, Type[] optionalParameterTypes, int cGenericParameters) { return ((ModuleBuilder)m_methodBuilder.Module).GetMemberRefSignature(call, returnType, parameterTypes, optionalParameterTypes, cGenericParameters); @@ -234,7 +233,7 @@ namespace System.Reflection.Emit if (m_currExcStackCount != 0) { - throw new ArgumentException(Environment.GetResourceString("Argument_UnclosedExceptionBlock")); + throw new ArgumentException(SR.Argument_UnclosedExceptionBlock); } if (m_length == 0) return null; @@ -251,7 +250,7 @@ namespace System.Reflection.Emit //Do the fixups. //This involves iterating over all of the labels and //replacing them with their proper values. - for (int i =0; i < m_fixupCount; i++) + for (int i = 0; i < m_fixupCount; i++) { updateAddr = GetLabelPos(m_fixupData[i].m_fixupLabel) - (m_fixupData[i].m_fixupPos + m_fixupData[i].m_fixupInstSize); @@ -259,11 +258,10 @@ namespace System.Reflection.Emit //Throw an exception if they're trying to store a jump in a single byte instruction that doesn't fit. if (m_fixupData[i].m_fixupInstSize == 1) { - //Verify that our one-byte arg will fit into a Signed Byte. if (updateAddr < SByte.MinValue || updateAddr > SByte.MaxValue) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_IllegalOneByteBranch",m_fixupData[i].m_fixupPos, updateAddr)); + throw new NotSupportedException(SR.Format(SR.NotSupported_IllegalOneByteBranch, m_fixupData[i].m_fixupPos, updateAddr)); } //Place the one-byte arg @@ -287,17 +285,17 @@ namespace System.Reflection.Emit internal __ExceptionInfo[] GetExceptions() { - __ExceptionInfo []temp; + __ExceptionInfo[] temp; if (m_currExcStackCount != 0) { - throw new NotSupportedException(Environment.GetResourceString(ResId.Argument_UnclosedExceptionBlock)); + throw new NotSupportedException(SR.GetResourceString(ResId.Argument_UnclosedExceptionBlock)); } - + if (m_exceptionCount == 0) { return null; } - + temp = new __ExceptionInfo[m_exceptionCount]; Array.Copy(m_exceptions, 0, temp, 0, m_exceptionCount); SortExceptions(temp); @@ -325,14 +323,14 @@ namespace System.Reflection.Emit m_length = PutInteger4InArray(value, m_length, m_ILStream); } - private static int PutInteger4InArray(int value, int startPos, byte []array) + private static int PutInteger4InArray(int value, int startPos, byte[] array) { // Puts an Int32 onto the stream. This is an internal routine, so it does not do any error checking. array[startPos++] = (byte)value; - array[startPos++] = (byte)(value >>8); - array[startPos++] = (byte)(value >>16); - array[startPos++] = (byte)(value >>24); + array[startPos++] = (byte)(value >> 8); + array[startPos++] = (byte)(value >> 16); + array[startPos++] = (byte)(value >> 24); return startPos; } @@ -342,12 +340,12 @@ namespace System.Reflection.Emit // Verifies that the label exists and that it has been given a value. int index = lbl.GetLabelValue(); - + if (index < 0 || index >= m_labelCount) - throw new ArgumentException(Environment.GetResourceString("Argument_BadLabel")); + throw new ArgumentException(SR.Argument_BadLabel); if (m_labelList[index] < 0) - throw new ArgumentException(Environment.GetResourceString("Argument_BadLabelContent")); + throw new ArgumentException(SR.Argument_BadLabelContent); return m_labelList[index]; } @@ -378,7 +376,7 @@ namespace System.Reflection.Emit return m_maxStackSize; } - private static void SortExceptions(__ExceptionInfo []exceptions) + private static void SortExceptions(__ExceptionInfo[] exceptions) { // In order to call exceptions properly we have to sort them in ascending order by their end position. // Just a cheap insertion sort. We don't expect many exceptions (<10), where InsertionSort beats QuickSort. @@ -421,40 +419,42 @@ namespace System.Reflection.Emit { EnsureCapacity(3); InternalEmit(opcode); - } - public virtual void Emit(OpCode opcode, byte arg) + public virtual void Emit(OpCode opcode, byte arg) { EnsureCapacity(4); InternalEmit(opcode); - m_ILStream[m_length++]=arg; + m_ILStream[m_length++] = arg; } [CLSCompliant(false)] - public void Emit(OpCode opcode, sbyte arg) + public void Emit(OpCode opcode, sbyte arg) { // Puts opcode onto the stream of instructions followed by arg EnsureCapacity(4); InternalEmit(opcode); - if (arg<0) { - m_ILStream[m_length++]=(byte)(256+arg); - } else { - m_ILStream[m_length++]=(byte) arg; + if (arg < 0) + { + m_ILStream[m_length++] = (byte)(256 + arg); + } + else + { + m_ILStream[m_length++] = (byte)arg; } } - public virtual void Emit(OpCode opcode, short arg) + public virtual void Emit(OpCode opcode, short arg) { // Puts opcode onto the stream of instructions followed by arg EnsureCapacity(5); InternalEmit(opcode); - m_ILStream[m_length++]=(byte) arg; - m_ILStream[m_length++]=(byte) (arg>>8); + m_ILStream[m_length++] = (byte)arg; + m_ILStream[m_length++] = (byte)(arg >> 8); } - public virtual void Emit(OpCode opcode, int arg) + public virtual void Emit(OpCode opcode, int arg) { // Puts opcode onto the stream of instructions followed by arg EnsureCapacity(7); @@ -488,26 +488,26 @@ namespace System.Reflection.Emit UpdateStackSize(opcode, stackchange); RecordTokenFixup(); - PutInteger4(tk); + PutInteger4(tk); } } - public virtual void EmitCalli(OpCode opcode, CallingConventions callingConvention, + public virtual void EmitCalli(OpCode opcode, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type[] optionalParameterTypes) { int stackchange = 0; - SignatureHelper sig; + SignatureHelper sig; if (optionalParameterTypes != null) { if ((callingConvention & CallingConventions.VarArgs) == 0) { // Client should not supply optional parameter in default calling convention - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAVarArgCallingConvention")); + throw new InvalidOperationException(SR.InvalidOperation_NotAVarArgCallingConvention); } } - ModuleBuilder modBuilder = (ModuleBuilder) m_methodBuilder.Module; + ModuleBuilder modBuilder = (ModuleBuilder)m_methodBuilder.Module; sig = GetMemberRefSignature(callingConvention, returnType, parameterTypes, @@ -542,7 +542,7 @@ namespace System.Reflection.Emit throw new ArgumentNullException(nameof(methodInfo)); if (!(opcode.Equals(OpCodes.Call) || opcode.Equals(OpCodes.Callvirt) || opcode.Equals(OpCodes.Newobj))) - throw new ArgumentException(Environment.GetResourceString("Argument_NotMethodCallOpcode"), nameof(opcode)); + throw new ArgumentException(SR.Argument_NotMethodCallOpcode, nameof(opcode)); Contract.EndContractBlock(); @@ -657,11 +657,11 @@ namespace System.Reflection.Emit // patched if necessary when persisting the module to a PE. int tempVal = 0; - ModuleBuilder modBuilder = (ModuleBuilder) m_methodBuilder.Module; + ModuleBuilder modBuilder = (ModuleBuilder)m_methodBuilder.Module; if (opcode == OpCodes.Ldtoken && cls != null && cls.IsGenericTypeDefinition) { // This gets the token for the generic type definition if cls is one. - tempVal = modBuilder.GetTypeToken( cls ).Token; + tempVal = modBuilder.GetTypeToken(cls).Token; } else { @@ -676,44 +676,47 @@ namespace System.Reflection.Emit PutInteger4(tempVal); } - public virtual void Emit(OpCode opcode, long arg) { + public virtual void Emit(OpCode opcode, long arg) + { EnsureCapacity(11); InternalEmit(opcode); - m_ILStream[m_length++] = (byte) arg; - m_ILStream[m_length++] = (byte) (arg>>8); - m_ILStream[m_length++] = (byte) (arg>>16); - m_ILStream[m_length++] = (byte) (arg>>24); - m_ILStream[m_length++] = (byte) (arg>>32); - m_ILStream[m_length++] = (byte) (arg>>40); - m_ILStream[m_length++] = (byte) (arg>>48); - m_ILStream[m_length++] = (byte) (arg>>56); + m_ILStream[m_length++] = (byte)arg; + m_ILStream[m_length++] = (byte)(arg >> 8); + m_ILStream[m_length++] = (byte)(arg >> 16); + m_ILStream[m_length++] = (byte)(arg >> 24); + m_ILStream[m_length++] = (byte)(arg >> 32); + m_ILStream[m_length++] = (byte)(arg >> 40); + m_ILStream[m_length++] = (byte)(arg >> 48); + m_ILStream[m_length++] = (byte)(arg >> 56); } - unsafe public virtual void Emit(OpCode opcode, float arg) { + unsafe public virtual void Emit(OpCode opcode, float arg) + { EnsureCapacity(7); InternalEmit(opcode); uint tempVal = *(uint*)&arg; - m_ILStream[m_length++] = (byte) tempVal; - m_ILStream[m_length++] = (byte) (tempVal>>8); - m_ILStream[m_length++] = (byte) (tempVal>>16); - m_ILStream[m_length++] = (byte) (tempVal>>24); + m_ILStream[m_length++] = (byte)tempVal; + m_ILStream[m_length++] = (byte)(tempVal >> 8); + m_ILStream[m_length++] = (byte)(tempVal >> 16); + m_ILStream[m_length++] = (byte)(tempVal >> 24); } - unsafe public virtual void Emit(OpCode opcode, double arg) { + unsafe public virtual void Emit(OpCode opcode, double arg) + { EnsureCapacity(11); InternalEmit(opcode); - ulong tempVal = *(ulong*)&arg; - m_ILStream[m_length++] = (byte) tempVal; - m_ILStream[m_length++] = (byte) (tempVal>>8); - m_ILStream[m_length++] = (byte) (tempVal>>16); - m_ILStream[m_length++] = (byte) (tempVal>>24); - m_ILStream[m_length++] = (byte) (tempVal>>32); - m_ILStream[m_length++] = (byte) (tempVal>>40); - m_ILStream[m_length++] = (byte) (tempVal>>48); - m_ILStream[m_length++] = (byte) (tempVal>>56); + ulong tempVal = *(ulong*)&arg; + m_ILStream[m_length++] = (byte)tempVal; + m_ILStream[m_length++] = (byte)(tempVal >> 8); + m_ILStream[m_length++] = (byte)(tempVal >> 16); + m_ILStream[m_length++] = (byte)(tempVal >> 24); + m_ILStream[m_length++] = (byte)(tempVal >> 32); + m_ILStream[m_length++] = (byte)(tempVal >> 40); + m_ILStream[m_length++] = (byte)(tempVal >> 48); + m_ILStream[m_length++] = (byte)(tempVal >> 56); } - public virtual void Emit(OpCode opcode, Label label) + public virtual void Emit(OpCode opcode, Label label) { // Puts opcode onto the stream and leaves space to include label // when fixups are done. Labels are created using ILGenerator.DefineLabel and @@ -724,18 +727,21 @@ namespace System.Reflection.Emit // opcode must represent a branch instruction (although we don't explicitly // verify this). Since branches are relative instructions, label will be replaced with the // correct offset to branch during the fixup process. - + int tempVal = label.GetLabelValue(); EnsureCapacity(7); - + InternalEmit(opcode); - if (OpCodes.TakesSingleByteArgument(opcode)) { + if (OpCodes.TakesSingleByteArgument(opcode)) + { AddFixup(label, m_length, 1); m_length++; - } else { + } + else + { AddFixup(label, m_length, 4); - m_length+=4; + m_length += 4; } } @@ -753,32 +759,33 @@ namespace System.Reflection.Emit int count = labels.Length; - EnsureCapacity( count * 4 + 7 ); + EnsureCapacity(count * 4 + 7); InternalEmit(opcode); PutInteger4(count); - for ( remaining = count * 4, i = 0; remaining > 0; remaining -= 4, i++ ) { - AddFixup( labels[i], m_length, remaining ); + for (remaining = count * 4, i = 0; remaining > 0; remaining -= 4, i++) + { + AddFixup(labels[i], m_length, remaining); m_length += 4; } } public virtual void Emit(OpCode opcode, FieldInfo field) { - ModuleBuilder modBuilder = (ModuleBuilder) m_methodBuilder.Module; - int tempVal = modBuilder.GetFieldToken( field ).Token; + ModuleBuilder modBuilder = (ModuleBuilder)m_methodBuilder.Module; + int tempVal = modBuilder.GetFieldToken(field).Token; EnsureCapacity(7); InternalEmit(opcode); RecordTokenFixup(); PutInteger4(tempVal); } - public virtual void Emit(OpCode opcode, String str) + public virtual void Emit(OpCode opcode, String str) { // Puts the opcode onto the IL stream followed by the metadata token // represented by str. The location of str is recorded for future // fixups if the module is persisted to a PE. - ModuleBuilder modBuilder = (ModuleBuilder) m_methodBuilder.Module; + ModuleBuilder modBuilder = (ModuleBuilder)m_methodBuilder.Module; int tempVal = modBuilder.GetStringConstant(str).Token; EnsureCapacity(7); InternalEmit(opcode); @@ -797,12 +804,12 @@ namespace System.Reflection.Emit int tempVal = local.GetLocalIndex(); if (local.GetMethodBuilder() != m_methodBuilder) { - throw new ArgumentException(Environment.GetResourceString("Argument_UnmatchedMethodForLocal"), nameof(local)); + throw new ArgumentException(SR.Argument_UnmatchedMethodForLocal, nameof(local)); } // If the instruction is a ldloc, ldloca a stloc, morph it to the optimal form. if (opcode.Equals(OpCodes.Ldloc)) { - switch(tempVal) + switch (tempVal) { case 0: opcode = OpCodes.Ldloc_0; @@ -824,7 +831,7 @@ namespace System.Reflection.Emit } else if (opcode.Equals(OpCodes.Stloc)) { - switch(tempVal) + switch (tempVal) { case 0: opcode = OpCodes.Stloc_0; @@ -852,28 +859,28 @@ namespace System.Reflection.Emit EnsureCapacity(7); InternalEmit(opcode); - + if (opcode.OperandType == OperandType.InlineNone) return; else if (!OpCodes.TakesSingleByteArgument(opcode)) { - m_ILStream[m_length++]=(byte) tempVal; - m_ILStream[m_length++]=(byte) (tempVal>>8); + m_ILStream[m_length++] = (byte)tempVal; + m_ILStream[m_length++] = (byte)(tempVal >> 8); } else { //Handle stloc_1, ldloc_1 if (tempVal > Byte.MaxValue) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadInstructionOrIndexOutOfBound")); + throw new InvalidOperationException(SR.InvalidOperation_BadInstructionOrIndexOutOfBound); } - m_ILStream[m_length++]=(byte)tempVal; + m_ILStream[m_length++] = (byte)tempVal; } } #endregion #region Exceptions - public virtual Label BeginExceptionBlock() + public virtual Label BeginExceptionBlock() { // Begin an Exception block. Creating an Exception block records some information, // but does not actually emit any IL onto the stream. Exceptions should be created and @@ -898,11 +905,13 @@ namespace System.Reflection.Emit m_currExcStack = new __ExceptionInfo[DefaultExceptionArraySize]; } - if (m_exceptionCount>=m_exceptions.Length) { - m_exceptions=EnlargeArray(m_exceptions); + if (m_exceptionCount >= m_exceptions.Length) + { + m_exceptions = EnlargeArray(m_exceptions); } - if (m_currExcStackCount>=m_currExcStack.Length) { + if (m_currExcStackCount >= m_currExcStack.Length) + { m_currExcStack = EnlargeArray(m_currExcStack); } @@ -917,14 +926,16 @@ namespace System.Reflection.Emit return endLabel; } - public virtual void EndExceptionBlock() { - if (m_currExcStackCount==0) { - throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock")); + public virtual void EndExceptionBlock() + { + if (m_currExcStackCount == 0) + { + throw new NotSupportedException(SR.Argument_NotInExceptionBlock); } - // Pop the current exception block - __ExceptionInfo current = m_currExcStack[m_currExcStackCount-1]; - m_currExcStack[m_currExcStackCount-1] = null; + // Pop the current exception block + __ExceptionInfo current = m_currExcStack[m_currExcStackCount - 1]; + m_currExcStack[m_currExcStackCount - 1] = null; m_currExcStackCount--; Label endLabel = current.GetEndLabel(); @@ -933,36 +944,40 @@ namespace System.Reflection.Emit if (state == __ExceptionInfo.State_Filter || state == __ExceptionInfo.State_Try) { - - - throw new InvalidOperationException(Environment.GetResourceString("Argument_BadExceptionCodeGen")); + throw new InvalidOperationException(SR.Argument_BadExceptionCodeGen); } - if (state == __ExceptionInfo.State_Catch) { + if (state == __ExceptionInfo.State_Catch) + { this.Emit(OpCodes.Leave, endLabel); - } else if (state == __ExceptionInfo.State_Finally || state == __ExceptionInfo.State_Fault) { + } + else if (state == __ExceptionInfo.State_Finally || state == __ExceptionInfo.State_Fault) + { this.Emit(OpCodes.Endfinally); } //Check if we've alredy set this label. //The only reason why we might have set this is if we have a finally block. - if (m_labelList[endLabel.GetLabelValue()]==-1) { + if (m_labelList[endLabel.GetLabelValue()] == -1) + { MarkLabel(endLabel); - } else { + } + else + { MarkLabel(current.GetFinallyEndLabel()); } current.Done(m_length); } - public virtual void BeginExceptFilterBlock() + public virtual void BeginExceptFilterBlock() { // Begins an exception filter block. Emits a branch instruction to the end of the current exception block. if (m_currExcStackCount == 0) - throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock")); + throw new NotSupportedException(SR.Argument_NotInExceptionBlock); - __ExceptionInfo current = m_currExcStack[m_currExcStackCount-1]; + __ExceptionInfo current = m_currExcStack[m_currExcStackCount - 1]; Label endLabel = current.GetEndLabel(); this.Emit(OpCodes.Leave, endLabel); @@ -970,30 +985,35 @@ namespace System.Reflection.Emit current.MarkFilterAddr(m_length); } - public virtual void BeginCatchBlock(Type exceptionType) + public virtual void BeginCatchBlock(Type exceptionType) { // Begins a catch block. Emits a branch instruction to the end of the current exception block. - if (m_currExcStackCount==0) { - throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock")); + if (m_currExcStackCount == 0) + { + throw new NotSupportedException(SR.Argument_NotInExceptionBlock); } - __ExceptionInfo current = m_currExcStack[m_currExcStackCount-1]; + __ExceptionInfo current = m_currExcStack[m_currExcStackCount - 1]; - if (current.GetCurrentState() == __ExceptionInfo.State_Filter) { - if (exceptionType != null) { - throw new ArgumentException(Environment.GetResourceString("Argument_ShouldNotSpecifyExceptionType")); + if (current.GetCurrentState() == __ExceptionInfo.State_Filter) + { + if (exceptionType != null) + { + throw new ArgumentException(SR.Argument_ShouldNotSpecifyExceptionType); } this.Emit(OpCodes.Endfilter); - } else { + } + else + { // execute this branch if previous clause is Catch or Fault - if (exceptionType==null) { + if (exceptionType == null) + { throw new ArgumentNullException(nameof(exceptionType)); } Label endLabel = current.GetEndLabel(); this.Emit(OpCodes.Leave, endLabel); - } current.MarkCatchAddr(m_length, exceptionType); @@ -1001,10 +1021,11 @@ namespace System.Reflection.Emit public virtual void BeginFaultBlock() { - if (m_currExcStackCount==0) { - throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock")); + if (m_currExcStackCount == 0) + { + throw new NotSupportedException(SR.Argument_NotInExceptionBlock); } - __ExceptionInfo current = m_currExcStack[m_currExcStackCount-1]; + __ExceptionInfo current = m_currExcStack[m_currExcStackCount - 1]; // emit the leave for the clause before this one. Label endLabel = current.GetEndLabel(); @@ -1013,28 +1034,29 @@ namespace System.Reflection.Emit current.MarkFaultAddr(m_length); } - public virtual void BeginFinallyBlock() + public virtual void BeginFinallyBlock() { - if (m_currExcStackCount==0) { - throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock")); + if (m_currExcStackCount == 0) + { + throw new NotSupportedException(SR.Argument_NotInExceptionBlock); } - __ExceptionInfo current = m_currExcStack[m_currExcStackCount-1]; - int state = current.GetCurrentState(); - Label endLabel = current.GetEndLabel(); - int catchEndAddr = 0; + __ExceptionInfo current = m_currExcStack[m_currExcStackCount - 1]; + int state = current.GetCurrentState(); + Label endLabel = current.GetEndLabel(); + int catchEndAddr = 0; if (state != __ExceptionInfo.State_Try) { // generate leave for any preceeding catch clause - this.Emit(OpCodes.Leave, endLabel); + this.Emit(OpCodes.Leave, endLabel); catchEndAddr = m_length; } - + MarkLabel(endLabel); Label finallyEndLabel = this.DefineLabel(); current.SetFinallyEndLabel(finallyEndLabel); - + // generate leave for try clause this.Emit(OpCodes.Leave, finallyEndLabel); if (catchEndAddr == 0) @@ -1045,25 +1067,27 @@ namespace System.Reflection.Emit #endregion #region Labels - public virtual Label DefineLabel() + public virtual Label DefineLabel() { // Declares a new Label. This is just a token and does not yet represent any particular location // within the stream. In order to set the position of the label within the stream, you must call // Mark Label. // Delay init the lable array in case we dont use it - if (m_labelList == null){ + if (m_labelList == null) + { m_labelList = new int[DefaultLabelArraySize]; } - if (m_labelCount>=m_labelList.Length) { + if (m_labelCount >= m_labelList.Length) + { m_labelList = EnlargeArray(m_labelList); } - m_labelList[m_labelCount]=-1; + m_labelList[m_labelCount] = -1; return new Label(m_labelCount++); } - public virtual void MarkLabel(Label loc) + public virtual void MarkLabel(Label loc) { // Defines a label by setting the position where that label is found within the stream. // Does not allow a label to be defined more than once. @@ -1071,15 +1095,17 @@ namespace System.Reflection.Emit int labelIndex = loc.GetLabelValue(); //This should never happen. - if (labelIndex<0 || labelIndex>=m_labelList.Length) { - throw new ArgumentException (Environment.GetResourceString("Argument_InvalidLabel")); + if (labelIndex < 0 || labelIndex >= m_labelList.Length) + { + throw new ArgumentException(SR.Argument_InvalidLabel); } - if (m_labelList[labelIndex]!=-1) { - throw new ArgumentException (Environment.GetResourceString("Argument_RedefinedLabel")); + if (m_labelList[labelIndex] != -1) + { + throw new ArgumentException(SR.Argument_RedefinedLabel); } - m_labelList[labelIndex]=m_length; + m_labelList[labelIndex] = m_length; } #endregion @@ -1089,17 +1115,20 @@ namespace System.Reflection.Emit { // Emits the il to throw an exception - if (excType==null) { + if (excType == null) + { throw new ArgumentNullException(nameof(excType)); } - if (!excType.IsSubclassOf(typeof(Exception)) && excType!=typeof(Exception)) { - throw new ArgumentException(Environment.GetResourceString("Argument_NotExceptionType")); + if (!excType.IsSubclassOf(typeof(Exception)) && excType != typeof(Exception)) + { + throw new ArgumentException(SR.Argument_NotExceptionType); } Contract.EndContractBlock(); ConstructorInfo con = excType.GetConstructor(Type.EmptyTypes); - if (con==null) { - throw new ArgumentException(Environment.GetResourceString("Argument_MissingDefaultConstructor")); + if (con == null) + { + throw new ArgumentException(SR.Argument_MissingDefaultConstructor); } this.Emit(OpCodes.Newobj, con); this.Emit(OpCodes.Throw); @@ -1108,7 +1137,7 @@ namespace System.Reflection.Emit private static Type GetConsoleType() { return Type.GetType( - "System.Console, System.Console, Version=4.0.0.0, Culture=neutral, PublicKeyToken=" + AssemblyRef.MicrosoftPublicKeyToken, + "System.Console, System.Console, Version=4.0.0.0, Culture=neutral, PublicKeyToken=" + AssemblyRef.MicrosoftPublicKeyToken, throwOnError: true); } @@ -1123,17 +1152,17 @@ namespace System.Reflection.Emit Emit(OpCodes.Call, mi); } - public virtual void EmitWriteLine(LocalBuilder localBuilder) + public virtual void EmitWriteLine(LocalBuilder localBuilder) { // Emits the IL necessary to call WriteLine with lcl. It is // an error to call EmitWriteLine with a lcl which is not of // one of the types for which Console.WriteLine implements overloads. (e.g. // we do *not* call ToString on the locals. - Object cls; - if (m_methodBuilder==null) + Object cls; + if (m_methodBuilder == null) { - throw new ArgumentException(Environment.GetResourceString("InvalidOperation_BadILGeneratorUsage")); + throw new ArgumentException(SR.InvalidOperation_BadILGeneratorUsage); } MethodInfo prop = GetConsoleType().GetMethod("get_Out"); @@ -1141,13 +1170,15 @@ namespace System.Reflection.Emit Emit(OpCodes.Ldloc, localBuilder); Type[] parameterTypes = new Type[1]; cls = localBuilder.LocalType; - if (cls is TypeBuilder || cls is EnumBuilder) { - throw new ArgumentException(Environment.GetResourceString("NotSupported_OutputStreamUsingTypeBuilder")); + if (cls is TypeBuilder || cls is EnumBuilder) + { + throw new ArgumentException(SR.NotSupported_OutputStreamUsingTypeBuilder); } parameterTypes[0] = (Type)cls; MethodInfo mi = prop.ReturnType.GetMethod("WriteLine", parameterTypes); - if (mi==null) { - throw new ArgumentException(Environment.GetResourceString("Argument_EmitWriteLineType"), nameof(localBuilder)); + if (mi == null) + { + throw new ArgumentException(SR.Argument_EmitWriteLineType, nameof(localBuilder)); } Emit(OpCodes.Callvirt, mi); @@ -1167,25 +1198,30 @@ namespace System.Reflection.Emit throw new ArgumentNullException(nameof(fld)); } Contract.EndContractBlock(); - + MethodInfo prop = GetConsoleType().GetMethod("get_Out"); Emit(OpCodes.Call, prop); - if ((fld.Attributes & FieldAttributes.Static)!=0) { + if ((fld.Attributes & FieldAttributes.Static) != 0) + { Emit(OpCodes.Ldsfld, fld); - } else { + } + else + { Emit(OpCodes.Ldarg, (short)0); //Load the this ref. Emit(OpCodes.Ldfld, fld); } Type[] parameterTypes = new Type[1]; cls = fld.FieldType; - if (cls is TypeBuilder || cls is EnumBuilder) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_OutputStreamUsingTypeBuilder")); + if (cls is TypeBuilder || cls is EnumBuilder) + { + throw new NotSupportedException(SR.NotSupported_OutputStreamUsingTypeBuilder); } parameterTypes[0] = (Type)cls; MethodInfo mi = prop.ReturnType.GetMethod("WriteLine", parameterTypes); - if (mi==null) { - throw new ArgumentException(Environment.GetResourceString("Argument_EmitWriteLineType"), nameof(fld)); + if (mi == null) + { + throw new ArgumentException(SR.Argument_EmitWriteLineType, nameof(fld)); } Emit(OpCodes.Callvirt, mi); } @@ -1203,24 +1239,26 @@ namespace System.Reflection.Emit // Declare a local of type "local". The current active lexical scope // will be the scope that local will live. - LocalBuilder localBuilder; + LocalBuilder localBuilder; MethodBuilder methodBuilder = m_methodBuilder as MethodBuilder; - if (methodBuilder == null) + if (methodBuilder == null) throw new NotSupportedException(); if (methodBuilder.IsTypeCreated()) { // cannot change method after its containing type has been created - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_TypeHasBeenCreated")); + throw new InvalidOperationException(SR.InvalidOperation_TypeHasBeenCreated); } - if (localType==null) { + if (localType == null) + { throw new ArgumentNullException(nameof(localType)); } - if (methodBuilder.m_bIsBaked) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_MethodBaked")); + if (methodBuilder.m_bIsBaked) + { + throw new InvalidOperationException(SR.InvalidOperation_MethodBaked); } // add the localType to local signature @@ -1240,12 +1278,12 @@ namespace System.Reflection.Emit throw new ArgumentNullException(nameof(usingNamespace)); if (usingNamespace.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(usingNamespace)); + throw new ArgumentException(SR.Argument_EmptyName, nameof(usingNamespace)); Contract.EndContractBlock(); int index; MethodBuilder methodBuilder = m_methodBuilder as MethodBuilder; - if (methodBuilder == null) + if (methodBuilder == null) throw new NotSupportedException(); index = methodBuilder.GetILGenerator().m_ScopeTree.GetCurrentActiveScopeIndex(); @@ -1301,43 +1339,44 @@ namespace System.Reflection.Emit { internal Label m_fixupLabel; internal int m_fixupPos; - + internal int m_fixupInstSize; } - internal sealed class __ExceptionInfo { - - internal const int None = 0x0000; //COR_ILEXCEPTION_CLAUSE_NONE - internal const int Filter = 0x0001; //COR_ILEXCEPTION_CLAUSE_FILTER - internal const int Finally = 0x0002; //COR_ILEXCEPTION_CLAUSE_FINALLY - internal const int Fault = 0x0004; //COR_ILEXCEPTION_CLAUSE_FAULT - internal const int PreserveStack = 0x0004; //COR_ILEXCEPTION_CLAUSE_PRESERVESTACK + internal sealed class __ExceptionInfo + { + internal const int None = 0x0000; //COR_ILEXCEPTION_CLAUSE_NONE + internal const int Filter = 0x0001; //COR_ILEXCEPTION_CLAUSE_FILTER + internal const int Finally = 0x0002; //COR_ILEXCEPTION_CLAUSE_FINALLY + internal const int Fault = 0x0004; //COR_ILEXCEPTION_CLAUSE_FAULT + internal const int PreserveStack = 0x0004; //COR_ILEXCEPTION_CLAUSE_PRESERVESTACK internal const int State_Try = 0; - internal const int State_Filter =1; + internal const int State_Filter = 1; internal const int State_Catch = 2; internal const int State_Finally = 3; internal const int State_Fault = 4; internal const int State_Done = 5; internal int m_startAddr; - internal int []m_filterAddr; - internal int []m_catchAddr; - internal int []m_catchEndAddr; - internal int []m_type; - internal Type []m_catchClass; + internal int[] m_filterAddr; + internal int[] m_catchAddr; + internal int[] m_catchEndAddr; + internal int[] m_type; + internal Type[] m_catchClass; internal Label m_endLabel; internal Label m_finallyEndLabel; internal int m_endAddr; internal int m_endFinally; internal int m_currentCatch; - int m_currentState; + private int m_currentState; //This will never get called. The values exist merely to keep the //compiler happy. - private __ExceptionInfo() { + private __ExceptionInfo() + { m_startAddr = 0; m_filterAddr = null; m_catchAddr = null; @@ -1349,68 +1388,70 @@ namespace System.Reflection.Emit m_currentState = State_Try; } - internal __ExceptionInfo(int startAddr, Label endLabel) { - m_startAddr=startAddr; - m_endAddr=-1; - m_filterAddr=new int[4]; - m_catchAddr=new int[4]; - m_catchEndAddr=new int[4]; - m_catchClass=new Type[4]; - m_currentCatch=0; - m_endLabel=endLabel; - m_type=new int[4]; - m_endFinally=-1; + internal __ExceptionInfo(int startAddr, Label endLabel) + { + m_startAddr = startAddr; + m_endAddr = -1; + m_filterAddr = new int[4]; + m_catchAddr = new int[4]; + m_catchEndAddr = new int[4]; + m_catchClass = new Type[4]; + m_currentCatch = 0; + m_endLabel = endLabel; + m_type = new int[4]; + m_endFinally = -1; m_currentState = State_Try; } private void MarkHelper( - int catchorfilterAddr, // the starting address of a clause - int catchEndAddr, // the end address of a previous catch clause. Only use when finally is following a catch - Type catchClass, // catch exception type - int type) // kind of clause - { - if (m_currentCatch>=m_catchAddr.Length) { - m_filterAddr=ILGenerator.EnlargeArray(m_filterAddr); - m_catchAddr=ILGenerator.EnlargeArray(m_catchAddr); - m_catchEndAddr=ILGenerator.EnlargeArray(m_catchEndAddr); - m_catchClass=ILGenerator.EnlargeArray(m_catchClass); + int catchorfilterAddr, // the starting address of a clause + int catchEndAddr, // the end address of a previous catch clause. Only use when finally is following a catch + Type catchClass, // catch exception type + int type) // kind of clause + { + if (m_currentCatch >= m_catchAddr.Length) + { + m_filterAddr = ILGenerator.EnlargeArray(m_filterAddr); + m_catchAddr = ILGenerator.EnlargeArray(m_catchAddr); + m_catchEndAddr = ILGenerator.EnlargeArray(m_catchEndAddr); + m_catchClass = ILGenerator.EnlargeArray(m_catchClass); m_type = ILGenerator.EnlargeArray(m_type); } if (type == Filter) { - m_type[m_currentCatch]=type; + m_type[m_currentCatch] = type; m_filterAddr[m_currentCatch] = catchorfilterAddr; m_catchAddr[m_currentCatch] = -1; if (m_currentCatch > 0) { - Debug.Assert(m_catchEndAddr[m_currentCatch-1] == -1,"m_catchEndAddr[m_currentCatch-1] == -1"); - m_catchEndAddr[m_currentCatch-1] = catchorfilterAddr; + Debug.Assert(m_catchEndAddr[m_currentCatch - 1] == -1, "m_catchEndAddr[m_currentCatch-1] == -1"); + m_catchEndAddr[m_currentCatch - 1] = catchorfilterAddr; } } else { // catch or Fault clause - m_catchClass[m_currentCatch]=catchClass; + m_catchClass[m_currentCatch] = catchClass; if (m_type[m_currentCatch] != Filter) { - m_type[m_currentCatch]=type; + m_type[m_currentCatch] = type; } - m_catchAddr[m_currentCatch]=catchorfilterAddr; + m_catchAddr[m_currentCatch] = catchorfilterAddr; if (m_currentCatch > 0) { - if (m_type[m_currentCatch] != Filter) - { - Debug.Assert(m_catchEndAddr[m_currentCatch-1] == -1,"m_catchEndAddr[m_currentCatch-1] == -1"); - m_catchEndAddr[m_currentCatch-1] = catchEndAddr; - } + if (m_type[m_currentCatch] != Filter) + { + Debug.Assert(m_catchEndAddr[m_currentCatch - 1] == -1, "m_catchEndAddr[m_currentCatch-1] == -1"); + m_catchEndAddr[m_currentCatch - 1] = catchEndAddr; + } } - m_catchEndAddr[m_currentCatch]=-1; + m_catchEndAddr[m_currentCatch] = -1; m_currentCatch++; } - if (m_endAddr==-1) + if (m_endAddr == -1) { - m_endAddr=catchorfilterAddr; + m_endAddr = catchorfilterAddr; } } @@ -1426,74 +1467,92 @@ namespace System.Reflection.Emit MarkHelper(faultAddr, faultAddr, null, Fault); } - internal void MarkCatchAddr(int catchAddr, Type catchException) { + internal void MarkCatchAddr(int catchAddr, Type catchException) + { m_currentState = State_Catch; MarkHelper(catchAddr, catchAddr, catchException, None); } - internal void MarkFinallyAddr(int finallyAddr, int endCatchAddr) { - if (m_endFinally!=-1) { - throw new ArgumentException(Environment.GetResourceString("Argument_TooManyFinallyClause")); - } else { + internal void MarkFinallyAddr(int finallyAddr, int endCatchAddr) + { + if (m_endFinally != -1) + { + throw new ArgumentException(SR.Argument_TooManyFinallyClause); + } + else + { m_currentState = State_Finally; - m_endFinally=finallyAddr; + m_endFinally = finallyAddr; } MarkHelper(finallyAddr, endCatchAddr, null, Finally); } - internal void Done(int endAddr) { - Debug.Assert(m_currentCatch > 0,"m_currentCatch > 0"); - Debug.Assert(m_catchAddr[m_currentCatch-1] > 0,"m_catchAddr[m_currentCatch-1] > 0"); - Debug.Assert(m_catchEndAddr[m_currentCatch-1] == -1,"m_catchEndAddr[m_currentCatch-1] == -1"); - m_catchEndAddr[m_currentCatch-1] = endAddr; + internal void Done(int endAddr) + { + Debug.Assert(m_currentCatch > 0, "m_currentCatch > 0"); + Debug.Assert(m_catchAddr[m_currentCatch - 1] > 0, "m_catchAddr[m_currentCatch-1] > 0"); + Debug.Assert(m_catchEndAddr[m_currentCatch - 1] == -1, "m_catchEndAddr[m_currentCatch-1] == -1"); + m_catchEndAddr[m_currentCatch - 1] = endAddr; m_currentState = State_Done; } - internal int GetStartAddress() { + internal int GetStartAddress() + { return m_startAddr; } - internal int GetEndAddress() { + internal int GetEndAddress() + { return m_endAddr; } - internal int GetFinallyEndAddress() { + internal int GetFinallyEndAddress() + { return m_endFinally; } - internal Label GetEndLabel() { + internal Label GetEndLabel() + { return m_endLabel; } - internal int [] GetFilterAddresses() { + internal int[] GetFilterAddresses() + { return m_filterAddr; } - internal int [] GetCatchAddresses() { + internal int[] GetCatchAddresses() + { return m_catchAddr; } - internal int [] GetCatchEndAddresses() { + internal int[] GetCatchEndAddresses() + { return m_catchEndAddr; } - internal Type [] GetCatchClass() { + internal Type[] GetCatchClass() + { return m_catchClass; } - internal int GetNumberOfCatches() { + internal int GetNumberOfCatches() + { return m_currentCatch; } - internal int[] GetExceptionTypes() { + internal int[] GetExceptionTypes() + { return m_type; } - internal void SetFinallyEndLabel(Label lbl) { - m_finallyEndLabel=lbl; + internal void SetFinallyEndLabel(Label lbl) + { + m_finallyEndLabel = lbl; } - internal Label GetFinallyEndLabel() { + internal Label GetFinallyEndLabel() + { return m_finallyEndLabel; } @@ -1505,15 +1564,16 @@ namespace System.Reflection.Emit // of an exception. This is somewhat of a mis-nomer. This gives a // random result for cases where the two exceptions being compared do // not having a nesting relation. - internal bool IsInner(__ExceptionInfo exc) { + internal bool IsInner(__ExceptionInfo exc) + { Contract.Requires(exc != null); - Debug.Assert(m_currentCatch > 0,"m_currentCatch > 0"); - Debug.Assert(exc.m_currentCatch > 0,"exc.m_currentCatch > 0"); + Debug.Assert(m_currentCatch > 0, "m_currentCatch > 0"); + Debug.Assert(exc.m_currentCatch > 0, "exc.m_currentCatch > 0"); int exclast = exc.m_currentCatch - 1; int last = m_currentCatch - 1; - if (exc.m_catchEndAddr[exclast] < m_catchEndAddr[last]) + if (exc.m_catchEndAddr[exclast] < m_catchEndAddr[last]) return true; else if (exc.m_catchEndAddr[exclast] == m_catchEndAddr[last]) { @@ -1530,7 +1590,8 @@ namespace System.Reflection.Emit // 2 indicates in a catch block // 3 indicates in a finally block // 4 indicates Done - internal int GetCurrentState() { + internal int GetCurrentState() + { return m_currentState; } } @@ -1545,10 +1606,10 @@ namespace System.Reflection.Emit * ***************************/ [Serializable] - enum ScopeAction + internal enum ScopeAction { - Open = 0x0, - Close = 0x1, + Open = 0x0, + Close = 0x1, } internal sealed class ScopeTree @@ -1569,8 +1630,8 @@ namespace System.Reflection.Emit ***************************/ internal int GetCurrentActiveScopeIndex() { - int cClose = 0; - int i = m_iCount - 1; + int cClose = 0; + int i = m_iCount - 1; if (m_iCount == 0) { @@ -1590,13 +1651,13 @@ namespace System.Reflection.Emit } internal void AddLocalSymInfoToCurrentScope( - String strName, - byte[] signature, - int slot, - int startOffset, - int endOffset) + String strName, + byte[] signature, + int slot, + int startOffset, + int endOffset) { - int i = GetCurrentActiveScopeIndex(); + int i = GetCurrentActiveScopeIndex(); if (m_localSymInfos[i] == null) { m_localSymInfos[i] = new LocalSymInfo(); @@ -1605,9 +1666,9 @@ namespace System.Reflection.Emit } internal void AddUsingNamespaceToCurrentScope( - String strNamespace) + String strNamespace) { - int i = GetCurrentActiveScopeIndex(); + int i = GetCurrentActiveScopeIndex(); if (m_localSymInfos[i] == null) { m_localSymInfos[i] = new LocalSymInfo(); @@ -1617,16 +1678,16 @@ namespace System.Reflection.Emit internal void AddScopeInfo(ScopeAction sa, int iOffset) { - if (sa == ScopeAction.Close && m_iOpenScopeCount <=0) + if (sa == ScopeAction.Close && m_iOpenScopeCount <= 0) { - throw new ArgumentException(Environment.GetResourceString("Argument_UnmatchingSymScope")); + throw new ArgumentException(SR.Argument_UnmatchingSymScope); } Contract.EndContractBlock(); // make sure that arrays are large enough to hold addition info - EnsureCapacity(); - - + EnsureCapacity(); + + m_ScopeActions[m_iCount] = sa; m_iOffsets[m_iCount] = iOffset; m_localSymInfos[m_iCount] = null; @@ -1637,7 +1698,6 @@ namespace System.Reflection.Emit } else m_iOpenScopeCount--; - } /************************** @@ -1675,7 +1735,7 @@ namespace System.Reflection.Emit internal void EmitScopeTree(ISymbolWriter symWriter) { - int i; + int i; for (i = 0; i < m_iCount; i++) { if (m_ScopeActions[i] == ScopeAction.Open) @@ -1693,11 +1753,11 @@ namespace System.Reflection.Emit } } - internal int[] m_iOffsets; // array of offsets - internal ScopeAction[] m_ScopeActions; // array of scope actions - internal int m_iCount; // how many entries in the arrays are occupied - internal int m_iOpenScopeCount; // keep track how many scopes are open - internal const int InitialSize = 16; + internal int[] m_iOffsets; // array of offsets + internal ScopeAction[] m_ScopeActions; // array of scope actions + internal int m_iCount; // how many entries in the arrays are occupied + internal int m_iOpenScopeCount; // keep track how many scopes are open + internal const int InitialSize = 16; internal LocalSymInfo[] m_localSymInfos; // keep track debugging local information } @@ -1718,32 +1778,32 @@ namespace System.Reflection.Emit internal void AddLineNumberInfo( ISymbolDocumentWriter document, - int iOffset, - int iStartLine, - int iStartColumn, - int iEndLine, - int iEndColumn) - { - int i; - + int iOffset, + int iStartLine, + int iStartColumn, + int iEndLine, + int iEndColumn) + { + int i; + // make sure that arrays are large enough to hold addition info i = FindDocument(document); - + Debug.Assert(i < m_DocumentCount, "Bad document look up!"); m_Documents[i].AddLineNumberInfo(document, iOffset, iStartLine, iStartColumn, iEndLine, iEndColumn); } - + // Find a REDocument representing document. If we cannot find one, we will add a new entry into // the REDocument array. private int FindDocument(ISymbolDocumentWriter document) { - int i; - + int i; + // This is an optimization. The chance that the previous line is coming from the same // document is very high. if (m_iLastFound < m_DocumentCount && m_Documents[m_iLastFound].m_document == document) return m_iLastFound; - + for (i = 0; i < m_DocumentCount; i++) { if (m_Documents[i].m_document == document) @@ -1752,7 +1812,7 @@ namespace System.Reflection.Emit return m_iLastFound; } } - + // cannot find an existing document so add one to the array EnsureCapacity(); m_iLastFound = m_DocumentCount; @@ -1776,7 +1836,7 @@ namespace System.Reflection.Emit else if (m_DocumentCount == m_Documents.Length) { // the arrays are full. Enlarge the arrays - REDocument[] temp = new REDocument [m_DocumentCount * 2]; + REDocument[] temp = new REDocument[m_DocumentCount * 2]; Array.Copy(m_Documents, 0, temp, 0, m_DocumentCount); m_Documents = temp; } @@ -1788,10 +1848,10 @@ namespace System.Reflection.Emit m_Documents[i].EmitLineNumberInfo(symWriter); } - private int m_DocumentCount; // how many documents that we have right now + private int m_DocumentCount; // how many documents that we have right now private REDocument[] m_Documents; // array of documents - private const int InitialSize = 16; - private int m_iLastFound; + private const int InitialSize = 16; + private int m_iLastFound; } @@ -1811,17 +1871,17 @@ namespace System.Reflection.Emit internal void AddLineNumberInfo( ISymbolDocumentWriter document, - int iOffset, - int iStartLine, - int iStartColumn, - int iEndLine, - int iEndColumn) + int iOffset, + int iStartLine, + int iStartColumn, + int iEndLine, + int iEndColumn) { Debug.Assert(document == m_document, "Bad document look up!"); - + // make sure that arrays are large enough to hold addition info EnsureCapacity(); - + m_iOffsets[m_iLineNumberCount] = iOffset; m_iLines[m_iLineNumberCount] = iStartLine; m_iColumns[m_iLineNumberCount] = iStartColumn; @@ -1847,27 +1907,27 @@ namespace System.Reflection.Emit m_iEndColumns = new int[InitialSize]; } else if (m_iLineNumberCount == m_iOffsets.Length) - { + { // the arrays are full. Enlarge the arrays // It would probably be simpler to just use Lists here int newSize = checked(m_iLineNumberCount * 2); - int[] temp = new int [newSize]; + int[] temp = new int[newSize]; Array.Copy(m_iOffsets, 0, temp, 0, m_iLineNumberCount); m_iOffsets = temp; - temp = new int [newSize]; + temp = new int[newSize]; Array.Copy(m_iLines, 0, temp, 0, m_iLineNumberCount); m_iLines = temp; - temp = new int [newSize]; + temp = new int[newSize]; Array.Copy(m_iColumns, 0, temp, 0, m_iLineNumberCount); m_iColumns = temp; - temp = new int [newSize]; + temp = new int[newSize]; Array.Copy(m_iEndLines, 0, temp, 0, m_iLineNumberCount); m_iEndLines = temp; - temp = new int [newSize]; + temp = new int[newSize]; Array.Copy(m_iEndColumns, 0, temp, 0, m_iLineNumberCount); m_iEndColumns = temp; } @@ -1875,40 +1935,40 @@ namespace System.Reflection.Emit internal void EmitLineNumberInfo(ISymbolWriter symWriter) { - int[] iOffsetsTemp; - int[] iLinesTemp; - int[] iColumnsTemp; - int[] iEndLinesTemp; - int[] iEndColumnsTemp; + int[] iOffsetsTemp; + int[] iLinesTemp; + int[] iColumnsTemp; + int[] iEndLinesTemp; + int[] iEndColumnsTemp; if (m_iLineNumberCount == 0) return; // reduce the array size to be exact - iOffsetsTemp = new int [m_iLineNumberCount]; + iOffsetsTemp = new int[m_iLineNumberCount]; Array.Copy(m_iOffsets, 0, iOffsetsTemp, 0, m_iLineNumberCount); - iLinesTemp = new int [m_iLineNumberCount]; + iLinesTemp = new int[m_iLineNumberCount]; Array.Copy(m_iLines, 0, iLinesTemp, 0, m_iLineNumberCount); - iColumnsTemp = new int [m_iLineNumberCount]; + iColumnsTemp = new int[m_iLineNumberCount]; Array.Copy(m_iColumns, 0, iColumnsTemp, 0, m_iLineNumberCount); - iEndLinesTemp = new int [m_iLineNumberCount]; + iEndLinesTemp = new int[m_iLineNumberCount]; Array.Copy(m_iEndLines, 0, iEndLinesTemp, 0, m_iLineNumberCount); - iEndColumnsTemp = new int [m_iLineNumberCount]; + iEndColumnsTemp = new int[m_iLineNumberCount]; Array.Copy(m_iEndColumns, 0, iEndColumnsTemp, 0, m_iLineNumberCount); - symWriter.DefineSequencePoints(m_document, iOffsetsTemp, iLinesTemp, iColumnsTemp, iEndLinesTemp, iEndColumnsTemp); + symWriter.DefineSequencePoints(m_document, iOffsetsTemp, iLinesTemp, iColumnsTemp, iEndLinesTemp, iEndColumnsTemp); } - private int[] m_iOffsets; // array of offsets - private int[] m_iLines; // array of offsets - private int[] m_iColumns; // array of offsets - private int[] m_iEndLines; // array of offsets - private int[] m_iEndColumns; // array of offsets + private int[] m_iOffsets; // array of offsets + private int[] m_iLines; // array of offsets + private int[] m_iColumns; // array of offsets + private int[] m_iEndLines; // array of offsets + private int[] m_iEndColumns; // array of offsets internal ISymbolDocumentWriter m_document; // The ISymbolDocumentWriter that this REDocument is tracking. - private int m_iLineNumberCount; // how many entries in the arrays are occupied - private const int InitialSize = 16; + private int m_iLineNumberCount; // how many entries in the arrays are occupied + private const int InitialSize = 16; } // end of REDocument } diff --git a/src/mscorlib/src/System/Reflection/Emit/ISymWrapperCore.cs b/src/mscorlib/src/System/Reflection/Emit/ISymWrapperCore.cs index e6f4622f0e..cda651c9ce 100644 --- a/src/mscorlib/src/System/Reflection/Emit/ISymWrapperCore.cs +++ b/src/mscorlib/src/System/Reflection/Emit/ISymWrapperCore.cs @@ -2,14 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System; +using System.Security; +using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; +using System.Diagnostics.SymbolStore; + namespace System.Reflection.Emit { - using System; - using System.Security; - using System.Runtime.InteropServices; - using System.Runtime.CompilerServices; - using System.Diagnostics.SymbolStore; - //----------------------------------------------------------------------------------- // On Telesto, we don't ship the ISymWrapper.dll assembly. However, ReflectionEmit // relies on that assembly to write out managed PDBs. @@ -31,7 +31,7 @@ namespace System.Reflection.Emit // SymWrapperCore is never instantiated and is used as an encapsulation class. // It is our "ISymWrapper.dll" assembly within an assembly. //------------------------------------------------------------------------------ - class SymWrapperCore + internal class SymWrapperCore { //------------------------------------------------------------------------------ // Block instantiation @@ -49,7 +49,6 @@ namespace System.Reflection.Emit //------------------------------------------------------------------------------ private unsafe class SymDocumentWriter : ISymbolDocumentWriter { - //------------------------------------------------------------------------------ // Ctor //------------------------------------------------------------------------------ @@ -57,10 +56,10 @@ namespace System.Reflection.Emit { m_pDocumentWriterSafeHandle = pDocumentWriterSafeHandle; // The handle is actually a pointer to a native ISymUnmanagedDocumentWriter. - m_pDocWriter = (ISymUnmanagedDocumentWriter *)m_pDocumentWriterSafeHandle.DangerousGetHandle(); + m_pDocWriter = (ISymUnmanagedDocumentWriter*)m_pDocumentWriterSafeHandle.DangerousGetHandle(); m_vtable = (ISymUnmanagedDocumentWriterVTable)(Marshal.PtrToStructure(m_pDocWriter->m_unmanagedVTable, typeof(ISymUnmanagedDocumentWriterVTable))); } - + //------------------------------------------------------------------------------ // Returns the underlying ISymUnmanagedDocumentWriter* (as a safehandle.) //------------------------------------------------------------------------------ @@ -68,7 +67,7 @@ namespace System.Reflection.Emit { return m_pDocumentWriterSafeHandle; } - + //========================================================================================= // Public interface methods start here. (Well actually, they're all NotSupported @@ -82,11 +81,11 @@ namespace System.Reflection.Emit { throw new NotSupportedException(); // Intentionally not supported to match desktop CLR } - + //------------------------------------------------------------------------------ // SetCheckSum() wrapper //------------------------------------------------------------------------------ - void ISymbolDocumentWriter.SetCheckSum(Guid algorithmId, byte [] checkSum) + void ISymbolDocumentWriter.SetCheckSum(Guid algorithmId, byte[] checkSum) { int hr = m_vtable.SetCheckSum(m_pDocWriter, algorithmId, (uint)checkSum.Length, checkSum); if (hr < 0) @@ -94,8 +93,8 @@ namespace System.Reflection.Emit throw Marshal.GetExceptionForHR(hr); } } - - private delegate int DSetCheckSum(ISymUnmanagedDocumentWriter * pThis, Guid algorithmId, uint checkSumSize, [In] byte[] checkSum); + + private delegate int DSetCheckSum(ISymUnmanagedDocumentWriter* pThis, Guid algorithmId, uint checkSumSize, [In] byte[] checkSum); //------------------------------------------------------------------------------ // This layout must match the unmanaged ISymUnmanagedDocumentWriter* COM vtable @@ -105,14 +104,14 @@ namespace System.Reflection.Emit [StructLayout(LayoutKind.Sequential)] private struct ISymUnmanagedDocumentWriterVTable { - internal IntPtr QueryInterface; - internal IntPtr AddRef; - internal IntPtr Release; + internal IntPtr QueryInterface; + internal IntPtr AddRef; + internal IntPtr Release; - internal IntPtr SetSource; - internal DSetCheckSum SetCheckSum; + internal IntPtr SetSource; + internal DSetCheckSum SetCheckSum; } - + //------------------------------------------------------------------------------ // This layout must match the (start) of the unmanaged ISymUnmanagedDocumentWriter // COM object. @@ -128,15 +127,13 @@ namespace System.Reflection.Emit //------------------------------------------------------------------------------ private PunkSafeHandle m_pDocumentWriterSafeHandle; - private ISymUnmanagedDocumentWriter * m_pDocWriter; + private ISymUnmanagedDocumentWriter* m_pDocWriter; //------------------------------------------------------------------------------ // Stores the "managed vtable" (actually a structure full of delegates that // P/Invoke to the corresponding unmanaged COM methods.) //------------------------------------------------------------------------------ private ISymUnmanagedDocumentWriterVTable m_vtable; - - } // class SymDocumentWriter @@ -146,8 +143,6 @@ namespace System.Reflection.Emit //------------------------------------------------------------------------------ internal unsafe class SymWriter : ISymbolWriter { - - //------------------------------------------------------------------------------ // Creates a SymWriter. The SymWriter is a managed wrapper around the unmanaged // symbol writer provided by the runtime (ildbsymlib or diasymreader.dll). @@ -166,7 +161,7 @@ namespace System.Reflection.Emit private SymWriter() { } - + //------------------------------------------------------------------------------ // DefineDocument() wrapper //------------------------------------------------------------------------------ @@ -188,7 +183,7 @@ namespace System.Reflection.Emit } return new SymDocumentWriter(psymUnmanagedDocumentWriter); } - + //------------------------------------------------------------------------------ // OpenMethod() wrapper //------------------------------------------------------------------------------ @@ -200,7 +195,7 @@ namespace System.Reflection.Emit throw Marshal.GetExceptionForHR(hr); } } - + //------------------------------------------------------------------------------ // CloseMethod() wrapper //------------------------------------------------------------------------------ @@ -212,7 +207,7 @@ namespace System.Reflection.Emit throw Marshal.GetExceptionForHR(hr); } } - + //------------------------------------------------------------------------------ // DefineSequencePoints() wrapper //------------------------------------------------------------------------------ @@ -248,11 +243,11 @@ namespace System.Reflection.Emit { return; } - if ( (offsets != null && offsets.Length != spCount) || - (lines != null && lines.Length != spCount) || + if ((offsets != null && offsets.Length != spCount) || + (lines != null && lines.Length != spCount) || (columns != null && columns.Length != spCount) || (endLines != null && endLines.Length != spCount) || - (endColumns != null && endColumns.Length != spCount) ) + (endColumns != null && endColumns.Length != spCount)) { throw new ArgumentException(); } @@ -269,9 +264,8 @@ namespace System.Reflection.Emit { throw Marshal.GetExceptionForHR(hr); } - } - + //------------------------------------------------------------------------------ // OpenScope() wrapper //------------------------------------------------------------------------------ @@ -285,7 +279,7 @@ namespace System.Reflection.Emit } return ret; } - + //------------------------------------------------------------------------------ // CloseScope() wrapper //------------------------------------------------------------------------------ @@ -297,7 +291,7 @@ namespace System.Reflection.Emit throw Marshal.GetExceptionForHR(hr); } } - + //------------------------------------------------------------------------------ // DefineLocalVariable() wrapper //------------------------------------------------------------------------------ @@ -339,7 +333,7 @@ namespace System.Reflection.Emit throw Marshal.GetExceptionForHR(hr); } } - + //------------------------------------------------------------------------------ // UsingNamespace() wrapper //------------------------------------------------------------------------------ @@ -364,65 +358,65 @@ namespace System.Reflection.Emit internal void InternalSetUnderlyingWriter(IntPtr ppUnderlyingWriter) { m_pWriter = *((ISymUnmanagedWriter**)ppUnderlyingWriter); - m_vtable = (ISymUnmanagedWriterVTable) (Marshal.PtrToStructure(m_pWriter->m_unmanagedVTable, typeof(ISymUnmanagedWriterVTable))); + m_vtable = (ISymUnmanagedWriterVTable)(Marshal.PtrToStructure(m_pWriter->m_unmanagedVTable, typeof(ISymUnmanagedWriterVTable))); } //------------------------------------------------------------------------------ // Define delegates for the unmanaged COM methods we invoke. //------------------------------------------------------------------------------ - private delegate int DInitialize(ISymUnmanagedWriter* pthis, - IntPtr emitter, //IUnknown* + private delegate int DInitialize(ISymUnmanagedWriter* pthis, + IntPtr emitter, //IUnknown* [MarshalAs(UnmanagedType.LPWStr)] String filename, //WCHAR* - IntPtr pIStream, //IStream* - [MarshalAs(UnmanagedType.Bool)] bool fFullBuild + IntPtr pIStream, //IStream* + [MarshalAs(UnmanagedType.Bool)] bool fFullBuild ); - private delegate int DDefineDocument(ISymUnmanagedWriter* pthis, + private delegate int DDefineDocument(ISymUnmanagedWriter* pthis, [MarshalAs(UnmanagedType.LPWStr)] String url, - [In] ref Guid language, - [In] ref Guid languageVender, - [In] ref Guid documentType, - [Out] out PunkSafeHandle ppsymUnmanagedDocumentWriter + [In] ref Guid language, + [In] ref Guid languageVender, + [In] ref Guid documentType, + [Out] out PunkSafeHandle ppsymUnmanagedDocumentWriter ); - + private delegate int DSetUserEntryPoint(ISymUnmanagedWriter* pthis, int entryMethod); private delegate int DOpenMethod(ISymUnmanagedWriter* pthis, int entryMethod); private delegate int DCloseMethod(ISymUnmanagedWriter* pthis); private delegate int DDefineSequencePoints(ISymUnmanagedWriter* pthis, - PunkSafeHandle document, - int spCount, - [In] int[] offsets, - [In] int[] lines, - [In] int[] columns, - [In] int[] endLines, - [In] int[] endColumns); + PunkSafeHandle document, + int spCount, + [In] int[] offsets, + [In] int[] lines, + [In] int[] columns, + [In] int[] endLines, + [In] int[] endColumns); private delegate int DOpenScope(ISymUnmanagedWriter* pthis, int startOffset, [Out] out int pretval); private delegate int DCloseScope(ISymUnmanagedWriter* pthis, int endOffset); private delegate int DSetScopeRange(ISymUnmanagedWriter* pthis, int scopeID, int startOffset, int endOffset); - private delegate int DDefineLocalVariable(ISymUnmanagedWriter* pthis, + private delegate int DDefineLocalVariable(ISymUnmanagedWriter* pthis, [MarshalAs(UnmanagedType.LPWStr)] String name, - int attributes, - int cSig, - [In] byte[] signature, - int addrKind, - int addr1, - int addr2, - int addr3, - int startOffset, - int endOffset + int attributes, + int cSig, + [In] byte[] signature, + int addrKind, + int addr1, + int addr2, + int addr3, + int startOffset, + int endOffset ); private delegate int DClose(ISymUnmanagedWriter* pthis); - private delegate int DSetSymAttribute(ISymUnmanagedWriter* pthis, - int parent, + private delegate int DSetSymAttribute(ISymUnmanagedWriter* pthis, + int parent, [MarshalAs(UnmanagedType.LPWStr)] String name, - int cData, - [In] byte[] data + int cData, + [In] byte[] data ); @@ -440,38 +434,37 @@ namespace System.Reflection.Emit [StructLayout(LayoutKind.Sequential)] private struct ISymUnmanagedWriterVTable { - internal IntPtr QueryInterface; - internal IntPtr AddRef; - internal IntPtr Release; + internal IntPtr QueryInterface; + internal IntPtr AddRef; + internal IntPtr Release; - internal DDefineDocument DefineDocument; - internal DSetUserEntryPoint SetUserEntryPoint; + internal DDefineDocument DefineDocument; + internal DSetUserEntryPoint SetUserEntryPoint; - internal DOpenMethod OpenMethod; - internal DCloseMethod CloseMethod; + internal DOpenMethod OpenMethod; + internal DCloseMethod CloseMethod; - internal DOpenScope OpenScope; - internal DCloseScope CloseScope; + internal DOpenScope OpenScope; + internal DCloseScope CloseScope; - internal DSetScopeRange SetScopeRange; + internal DSetScopeRange SetScopeRange; - internal DDefineLocalVariable DefineLocalVariable; - internal IntPtr DefineParameter; - internal IntPtr DefineField; - internal IntPtr DefineGlobalVariable; + internal DDefineLocalVariable DefineLocalVariable; + internal IntPtr DefineParameter; + internal IntPtr DefineField; + internal IntPtr DefineGlobalVariable; - internal DClose Close; - internal DSetSymAttribute SetSymAttribute; + internal DClose Close; + internal DSetSymAttribute SetSymAttribute; - internal DOpenNamespace OpenNamespace; - internal DCloseNamespace CloseNamespace; - internal DUsingNamespace UsingNamespace; + internal DOpenNamespace OpenNamespace; + internal DCloseNamespace CloseNamespace; + internal DUsingNamespace UsingNamespace; - internal IntPtr SetMethodSourceRange; - internal DInitialize Initialize; - internal IntPtr GetDebugInfo; + internal IntPtr SetMethodSourceRange; + internal DInitialize Initialize; + internal IntPtr GetDebugInfo; internal DDefineSequencePoints DefineSequencePoints; - } //------------------------------------------------------------------------------ @@ -490,19 +483,14 @@ namespace System.Reflection.Emit // As with the real ISymWrapper.dll, ISymWrapper performs *no* Release (or AddRef) on this pointer. // Managing lifetime is up to the caller (coreclr.dll). //------------------------------------------------------------------------------ - private ISymUnmanagedWriter *m_pWriter; + private ISymUnmanagedWriter* m_pWriter; //------------------------------------------------------------------------------ // Stores the "managed vtable" (actually a structure full of delegates that // P/Invoke to the corresponding unmanaged COM methods.) //------------------------------------------------------------------------------ private ISymUnmanagedWriterVTable m_vtable; - } // class SymWriter - - - - } //class SymWrapperCore @@ -518,7 +506,7 @@ namespace System.Reflection.Emit // // Had to make this a non-nested class since FCall's don't like to bind to nested classes. //-------------------------------------------------------------------------------------- - sealed class PunkSafeHandle : SafeHandle + internal sealed class PunkSafeHandle : SafeHandle { internal PunkSafeHandle() : base((IntPtr)0, true) diff --git a/src/mscorlib/src/System/Reflection/Emit/Label.cs b/src/mscorlib/src/System/Reflection/Emit/Label.cs index c7b987ff10..f6315a67d2 100644 --- a/src/mscorlib/src/System/Reflection/Emit/Label.cs +++ b/src/mscorlib/src/System/Reflection/Emit/Label.cs @@ -13,11 +13,13 @@ ** ** ===========================================================*/ -namespace System.Reflection.Emit { - using System; - using System.Reflection; - using System.Runtime.InteropServices; +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +namespace System.Reflection.Emit +{ // The Label class is an opaque representation of a label used by the // ILGenerator class. The token is used to mark where labels occur in the IL // stream and then the necessary offsets are put back in the code when the ILGenerator @@ -25,27 +27,29 @@ namespace System.Reflection.Emit { // Labels are created by using ILGenerator.CreateLabel and their position is set // by using ILGenerator.MarkLabel. [Serializable] - public struct Label { - + public struct Label + { internal int m_label; - + //public Label() { // m_label=0; //} - - internal Label (int label) { - m_label=label; + + internal Label(int label) + { + m_label = label; } - - internal int GetLabelValue() { + + internal int GetLabelValue() + { return m_label; } - + public override int GetHashCode() { return m_label; } - + public override bool Equals(Object obj) { if (obj is Label) @@ -53,17 +57,17 @@ namespace System.Reflection.Emit { else return false; } - + public bool Equals(Label obj) { return obj.m_label == m_label; } - + public static bool operator ==(Label a, Label b) { return a.Equals(b); } - + public static bool operator !=(Label a, Label b) { return !(a == b); diff --git a/src/mscorlib/src/System/Reflection/Emit/LocalBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/LocalBuilder.cs index fe4c33160a..c04c3c8434 100644 --- a/src/mscorlib/src/System/Reflection/Emit/LocalBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/LocalBuilder.cs @@ -6,10 +6,10 @@ using System; using System.Reflection; using System.Runtime.InteropServices; -namespace System.Reflection.Emit +namespace System.Reflection.Emit { public sealed class LocalBuilder : LocalVariableInfo - { + { #region Private Data Members private int m_localIndex; private Type m_localType; @@ -19,9 +19,9 @@ namespace System.Reflection.Emit #region Constructor private LocalBuilder() { } - internal LocalBuilder(int localIndex, Type localType, MethodInfo methodBuilder) + internal LocalBuilder(int localIndex, Type localType, MethodInfo methodBuilder) : this(localIndex, localType, methodBuilder, false) { } - internal LocalBuilder(int localIndex, Type localType, MethodInfo methodBuilder, bool isPinned) + internal LocalBuilder(int localIndex, Type localType, MethodInfo methodBuilder, bool isPinned) { m_isPinned = isPinned; m_localIndex = localIndex; @@ -31,11 +31,11 @@ namespace System.Reflection.Emit #endregion #region Internal Members - internal int GetLocalIndex() + internal int GetLocalIndex() { return m_localIndex; } - internal MethodInfo GetMethodBuilder() + internal MethodInfo GetMethodBuilder() { return m_methodBuilder; } @@ -43,13 +43,13 @@ namespace System.Reflection.Emit #region LocalVariableInfo Override public override bool IsPinned { get { return m_isPinned; } } - public override Type LocalType + public override Type LocalType { - get - { - return m_localType; + get + { + return m_localType; } - } + } public override int LocalIndex { get { return m_localIndex; } } #endregion @@ -57,7 +57,7 @@ namespace System.Reflection.Emit public void SetLocalSymInfo(String name) { SetLocalSymInfo(name, 0, 0); - } + } public void SetLocalSymInfo(String name, int startOffset, int endOffset) { @@ -69,27 +69,27 @@ namespace System.Reflection.Emit int index; MethodBuilder methodBuilder = m_methodBuilder as MethodBuilder; - if (methodBuilder == null) + if (methodBuilder == null) // it's a light code gen entity throw new NotSupportedException(); - dynMod = (ModuleBuilder) methodBuilder.Module; + dynMod = (ModuleBuilder)methodBuilder.Module; if (methodBuilder.IsTypeCreated()) { // cannot change method after its containing type has been created - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_TypeHasBeenCreated")); + throw new InvalidOperationException(SR.InvalidOperation_TypeHasBeenCreated); } - + // set the name and range of offset for the local if (dynMod.GetSymWriter() == null) { // cannot set local name if not debug module - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotADebugModule")); + throw new InvalidOperationException(SR.InvalidOperation_NotADebugModule); } - + sigHelp = SignatureHelper.GetFieldSigHelper(dynMod); sigHelp.AddArgument(m_localType); signature = sigHelp.InternalGetSignature(out sigLength); - + // The symbol store doesn't want the calling convention on the // front of the signature, but InternalGetSignature returns // the callinging convention. So we strip it off. This is a @@ -97,7 +97,7 @@ namespace System.Reflection.Emit // yet another array of bytes... mungedSig = new byte[sigLength - 1]; Buffer.BlockCopy(signature, 1, mungedSig, 0, sigLength - 1); - + index = methodBuilder.GetILGenerator().m_ScopeTree.GetCurrentActiveScopeIndex(); if (index == -1) { @@ -105,7 +105,7 @@ namespace System.Reflection.Emit methodBuilder.m_localSymInfo.AddLocalSymInfo( name, mungedSig, - m_localIndex, + m_localIndex, startOffset, endOffset); } @@ -114,7 +114,7 @@ namespace System.Reflection.Emit methodBuilder.GetILGenerator().m_ScopeTree.AddLocalSymInfoToCurrentScope( name, mungedSig, - m_localIndex, + m_localIndex, startOffset, endOffset); } diff --git a/src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs index 17c8ce074d..530a5ee092 100644 --- a/src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs @@ -4,7 +4,7 @@ // -namespace System.Reflection.Emit +namespace System.Reflection.Emit { using System.Text; using System; @@ -35,7 +35,7 @@ namespace System.Reflection.Emit private byte[] m_ubBody; // The IL for the method private ExceptionHandler[] m_exceptions; // Exception handlers or null if there are none. private const int DefaultMaxStack = 16; - private int m_maxStack = DefaultMaxStack; + private int m_maxStack = DefaultMaxStack; // Flags internal bool m_bIsBaked; @@ -69,7 +69,7 @@ namespace System.Reflection.Emit Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers, ModuleBuilder mod, TypeBuilder type, bool bIsGlobalMethod) { - Init(name, attributes, callingConvention, + Init(name, attributes, callingConvention, returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers, mod, type, bIsGlobalMethod); @@ -77,17 +77,17 @@ namespace System.Reflection.Emit private void Init(String name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, - Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers, + Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers, ModuleBuilder mod, TypeBuilder type, bool bIsGlobalMethod) { if (name == null) throw new ArgumentNullException(nameof(name)); if (name.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(name)); + throw new ArgumentException(SR.Argument_EmptyName, nameof(name)); if (name[0] == '\0') - throw new ArgumentException(Environment.GetResourceString("Argument_IllegalName"), nameof(name)); + throw new ArgumentException(SR.Argument_IllegalName, nameof(name)); if (mod == null) throw new ArgumentNullException(nameof(mod)); @@ -95,7 +95,7 @@ namespace System.Reflection.Emit if (parameterTypes != null) { - foreach(Type t in parameterTypes) + foreach (Type t in parameterTypes) { if (t == null) throw new ArgumentNullException(nameof(parameterTypes)); @@ -124,7 +124,7 @@ namespace System.Reflection.Emit else if ((attributes & MethodAttributes.Virtual) != 0) { // A method can't be both static and virtual - throw new ArgumentException(Environment.GetResourceString("Arg_NoStaticVirtual")); + throw new ArgumentException(SR.Arg_NoStaticVirtual); } if ((attributes & MethodAttributes.SpecialName) != MethodAttributes.SpecialName) @@ -132,10 +132,10 @@ namespace System.Reflection.Emit if ((type.Attributes & TypeAttributes.Interface) == TypeAttributes.Interface) { // methods on interface have to be abstract + virtual except special name methods such as type initializer - if ((attributes & (MethodAttributes.Abstract | MethodAttributes.Virtual)) != - (MethodAttributes.Abstract | MethodAttributes.Virtual) && + if ((attributes & (MethodAttributes.Abstract | MethodAttributes.Virtual)) != + (MethodAttributes.Abstract | MethodAttributes.Virtual) && (attributes & MethodAttributes.Static) == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_BadAttributeOnInterfaceMethod")); + throw new ArgumentException(SR.Argument_BadAttributeOnInterfaceMethod); } } @@ -156,9 +156,9 @@ namespace System.Reflection.Emit m_parameterTypeRequiredCustomModifiers = parameterTypeRequiredCustomModifiers; m_parameterTypeOptionalCustomModifiers = parameterTypeOptionalCustomModifiers; -// m_signature = SignatureHelper.GetMethodSigHelper(mod, callingConvention, -// returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, -// parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers); + // m_signature = SignatureHelper.GetMethodSigHelper(mod, callingConvention, + // returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, + // parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers); m_iAttributes = attributes; m_bIsGlobalMethod = bIsGlobalMethod; @@ -179,9 +179,9 @@ namespace System.Reflection.Emit internal void CheckContext(params Type[][] typess) { - m_module.CheckContext(typess); + m_module.CheckContext(typess); } - + internal void CheckContext(params Type[] types) { m_module.CheckContext(types); @@ -197,22 +197,22 @@ namespace System.Reflection.Emit } Contract.EndContractBlock(); - __ExceptionInfo[] excp; - int counter=0; - int[] filterAddrs; - int[] catchAddrs; - int[] catchEndAddrs; - Type[] catchClass; - int[] type; - int numCatch; - int start, end; - ModuleBuilder dynMod = (ModuleBuilder) m_module; + __ExceptionInfo[] excp; + int counter = 0; + int[] filterAddrs; + int[] catchAddrs; + int[] catchEndAddrs; + Type[] catchClass; + int[] type; + int numCatch; + int start, end; + ModuleBuilder dynMod = (ModuleBuilder)m_module; m_containingType.ThrowIfCreated(); if (m_bIsBaked) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_MethodHasBody")); + throw new InvalidOperationException(SR.InvalidOperation_MethodHasBody); } if (il.m_methodBuilder != this && il.m_methodBuilder != null) @@ -221,15 +221,15 @@ namespace System.Reflection.Emit // through MethodBuilder::GetILGenerator. // - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadILGeneratorUsage")); + throw new InvalidOperationException(SR.InvalidOperation_BadILGeneratorUsage); } - + ThrowIfShouldNotHaveBody(); if (il.m_ScopeTree.m_iOpenScopeCount != 0) { // There are still unclosed local scope - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_OpenLocalVariableScope")); + throw new InvalidOperationException(SR.InvalidOperation_OpenLocalVariableScope); } @@ -276,20 +276,18 @@ namespace System.Reflection.Emit break; } } - } } - m_bIsBaked=true; + m_bIsBaked = true; if (dynMod.GetSymWriter() != null) { - // set the debugging information such as scope and line number // if it is in a debug module // - SymbolToken tk = new SymbolToken(MetadataTokenInternal); + SymbolToken tk = new SymbolToken(MetadataTokenInternal); ISymbolWriter symWriter = dynMod.GetSymWriter(); // call OpenMethod to make this method the current method @@ -299,16 +297,16 @@ namespace System.Reflection.Emit // the top-levelsmethod scope // symWriter.OpenScope(0); - + if (m_symCustomAttrs != null) { - foreach(SymCustomAttr symCustomAttr in m_symCustomAttrs) + foreach (SymCustomAttr symCustomAttr in m_symCustomAttrs) dynMod.GetSymWriter().SetSymAttribute( - new SymbolToken (MetadataTokenInternal), - symCustomAttr.m_name, + new SymbolToken(MetadataTokenInternal), + symCustomAttr.m_name, symCustomAttr.m_data); } - + if (m_localSymInfo != null) m_localSymInfo.EmitLocalSymInfo(symWriter); il.m_ScopeTree.EmitScopeTree(symWriter); @@ -330,14 +328,14 @@ namespace System.Reflection.Emit m_ubBody = null; m_localSymInfo = null; m_mdMethodFixups = null; - m_localSignature = null; + m_localSignature = null; m_exceptions = null; } internal override Type[] GetParameterTypes() { if (m_parameterTypes == null) - m_parameterTypes = EmptyArray<Type>.Value; + m_parameterTypes = Array.Empty<Type>(); return m_parameterTypes; } @@ -347,11 +345,11 @@ namespace System.Reflection.Emit MethodInfo mi = null; ConstructorInfo ci = null; - if ( (mi = method as MethodInfo) != null ) + if ((mi = method as MethodInfo) != null) { return mi.ReturnType; } - else if ( (ci = method as ConstructorInfo) != null) + else if ((ci = method as ConstructorInfo) != null) { return ci.GetReturnType(); } @@ -377,9 +375,9 @@ namespace System.Reflection.Emit internal SignatureHelper GetMethodSignature() { if (m_parameterTypes == null) - m_parameterTypes = EmptyArray<Type>.Value; + m_parameterTypes = Array.Empty<Type>(); - m_signature = SignatureHelper.GetMethodSigHelper (m_module, m_callingConvention, m_inst != null ? m_inst.Length : 0, + m_signature = SignatureHelper.GetMethodSigHelper(m_module, m_callingConvention, m_inst != null ? m_inst.Length : 0, m_returnType == null ? typeof(void) : m_returnType, m_returnTypeRequiredCustomModifiers, m_returnTypeOptionalCustomModifiers, m_parameterTypes, m_parameterTypeRequiredCustomModifiers, m_parameterTypeOptionalCustomModifiers); @@ -394,7 +392,7 @@ namespace System.Reflection.Emit signatureLength = m_localSignature.Length; return m_localSignature; } - + if (m_ilGenerator != null) { if (m_ilGenerator.m_localCount != 0) @@ -432,28 +430,28 @@ namespace System.Reflection.Emit internal int CalculateNumberOfExceptions(__ExceptionInfo[] excp) { - int num=0; + int num = 0; - if (excp==null) + if (excp == null) { return 0; } - for (int i=0; i<excp.Length; i++) + for (int i = 0; i < excp.Length; i++) { - num+=excp[i].GetNumberOfCatches(); + num += excp[i].GetNumberOfCatches(); } return num; } internal bool IsTypeCreated() - { - return (m_containingType != null && m_containingType.IsCreated()); + { + return (m_containingType != null && m_containingType.IsCreated()); } internal TypeBuilder GetTypeBuilder() - { + { return m_containingType; } @@ -464,20 +462,25 @@ namespace System.Reflection.Emit #endregion #region Object Overrides - public override bool Equals(Object obj) { - if (!(obj is MethodBuilder)) { + public override bool Equals(Object obj) + { + if (!(obj is MethodBuilder)) + { return false; } - if (!(this.m_strName.Equals(((MethodBuilder)obj).m_strName))) { + if (!(this.m_strName.Equals(((MethodBuilder)obj).m_strName))) + { return false; } - if (m_iAttributes!=(((MethodBuilder)obj).m_iAttributes)) { + if (m_iAttributes != (((MethodBuilder)obj).m_iAttributes)) + { return false; } SignatureHelper thatSig = ((MethodBuilder)obj).GetMethodSignature(); - if (thatSig.Equals(GetMethodSignature())) { + if (thatSig.Equals(GetMethodSignature())) + { return true; } return false; @@ -503,15 +506,15 @@ namespace System.Reflection.Emit #region MemberInfo Overrides public override String Name { - get - { - return m_strName; + get + { + return m_strName; } } internal int MetadataTokenInternal { - get + get { return GetToken().Token; } @@ -519,7 +522,7 @@ namespace System.Reflection.Emit public override Module Module { - get + get { return m_containingType.Module; } @@ -535,9 +538,9 @@ namespace System.Reflection.Emit } } - public override ICustomAttributeProvider ReturnTypeCustomAttributes + public override ICustomAttributeProvider ReturnTypeCustomAttributes { - get + get { return null; } @@ -556,7 +559,7 @@ namespace System.Reflection.Emit #region MethodBase Overrides public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } public override MethodImplAttributes GetMethodImplementationFlags() @@ -571,12 +574,12 @@ namespace System.Reflection.Emit public override CallingConventions CallingConvention { - get {return m_callingConvention;} + get { return m_callingConvention; } } public override RuntimeMethodHandle MethodHandle { - get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); } + get { throw new NotSupportedException(SR.NotSupported_DynamicModule); } } public override bool IsSecurityCritical @@ -613,7 +616,7 @@ namespace System.Reflection.Emit public override ParameterInfo[] GetParameters() { if (!m_bIsBaked || m_containingType == null || m_containingType.BakedRuntimeType == null) - throw new NotSupportedException(Environment.GetResourceString("InvalidOperation_TypeNotCreated")); + throw new NotSupportedException(SR.InvalidOperation_TypeNotCreated); MethodInfo rmi = m_containingType.GetMethod(m_strName, m_parameterTypes); @@ -625,7 +628,7 @@ namespace System.Reflection.Emit get { if (!m_bIsBaked || m_containingType == null || m_containingType.BakedRuntimeType == null) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_TypeNotCreated")); + throw new InvalidOperationException(SR.InvalidOperation_TypeNotCreated); MethodInfo rmi = m_containingType.GetMethod(m_strName, m_parameterTypes); @@ -637,20 +640,17 @@ namespace System.Reflection.Emit #region ICustomAttributeProvider Implementation public override Object[] GetCustomAttributes(bool inherit) { - - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { - - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } public override bool IsDefined(Type attributeType, bool inherit) { - - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } #endregion @@ -663,43 +663,43 @@ namespace System.Reflection.Emit public override MethodInfo GetGenericMethodDefinition() { if (!IsGenericMethod) throw new InvalidOperationException(); return this; } public override bool IsGenericMethod { get { return m_inst != null; } } - + public override Type[] GetGenericArguments() { return m_inst; } - public override MethodInfo MakeGenericMethod(params Type[] typeArguments) + public override MethodInfo MakeGenericMethod(params Type[] typeArguments) { - return MethodBuilderInstantiation.MakeGenericMethod(this, typeArguments); + return MethodBuilderInstantiation.MakeGenericMethod(this, typeArguments); } - - - public GenericTypeParameterBuilder[] DefineGenericParameters (params string[] names) + + + public GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names) { if (names == null) throw new ArgumentNullException(nameof(names)); if (names.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Arg_EmptyArray"), nameof(names)); + throw new ArgumentException(SR.Arg_EmptyArray, nameof(names)); Contract.EndContractBlock(); if (m_inst != null) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_GenericParametersAlreadySet")); + throw new InvalidOperationException(SR.InvalidOperation_GenericParametersAlreadySet); - for (int i = 0; i < names.Length; i ++) + for (int i = 0; i < names.Length; i++) if (names[i] == null) throw new ArgumentNullException(nameof(names)); if (m_tkMethod.Token != 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_MethodBuilderBaked")); + throw new InvalidOperationException(SR.InvalidOperation_MethodBuilderBaked); m_bIsGenMethDef = true; m_inst = new GenericTypeParameterBuilder[names.Length]; - for (int i = 0; i < names.Length; i ++) + for (int i = 0; i < names.Length; i++) m_inst[i] = new GenericTypeParameterBuilder(new TypeBuilder(names[i], i, this)); return m_inst; } - - internal void ThrowIfGeneric () { if (IsGenericMethod && !IsGenericMethodDefinition) throw new InvalidOperationException (); } + + internal void ThrowIfGeneric() { if (IsGenericMethod && !IsGenericMethodDefinition) throw new InvalidOperationException(); } #endregion #region Public Members @@ -773,22 +773,22 @@ namespace System.Reflection.Emit return m_tkMethod; } - public void SetParameters (params Type[] parameterTypes) + public void SetParameters(params Type[] parameterTypes) { CheckContext(parameterTypes); - - SetSignature (null, null, null, parameterTypes, null, null); + + SetSignature(null, null, null, parameterTypes, null, null); } - public void SetReturnType (Type returnType) + public void SetReturnType(Type returnType) { CheckContext(returnType); - - SetSignature (returnType, null, null, null, null, null); + + SetSignature(returnType, null, null, null, null, null); } public void SetSignature( - Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, + Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers) { // We should throw InvalidOperation_MethodBuilderBaked here if the method signature has been baked. @@ -800,7 +800,7 @@ namespace System.Reflection.Emit CheckContext(returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes); CheckContext(parameterTypeRequiredCustomModifiers); CheckContext(parameterTypeOptionalCustomModifiers); - + ThrowIfGeneric(); if (returnType != null) @@ -811,7 +811,7 @@ namespace System.Reflection.Emit if (parameterTypes != null) { m_parameterTypes = new Type[parameterTypes.Length]; - Array.Copy (parameterTypes, 0, m_parameterTypes, 0, parameterTypes.Length); + Array.Copy(parameterTypes, 0, m_parameterTypes, 0, parameterTypes.Length); } m_returnTypeRequiredCustomModifiers = returnTypeRequiredCustomModifiers; @@ -820,18 +820,18 @@ namespace System.Reflection.Emit m_parameterTypeOptionalCustomModifiers = parameterTypeOptionalCustomModifiers; } - + public ParameterBuilder DefineParameter(int position, ParameterAttributes attributes, String strParamName) { if (position < 0) - throw new ArgumentOutOfRangeException(Environment.GetResourceString("ArgumentOutOfRange_ParamSequence")); + throw new ArgumentOutOfRangeException(SR.ArgumentOutOfRange_ParamSequence); Contract.EndContractBlock(); ThrowIfGeneric(); - m_containingType.ThrowIfCreated (); + m_containingType.ThrowIfCreated(); if (position > 0 && (m_parameterTypes == null || position > m_parameterTypes.Length)) - throw new ArgumentOutOfRangeException(Environment.GetResourceString("ArgumentOutOfRange_ParamSequence")); + throw new ArgumentOutOfRangeException(SR.ArgumentOutOfRange_ParamSequence); attributes = attributes & ~ParameterAttributes.ReservedMask; return new ParameterBuilder(this, position, attributes, strParamName); @@ -844,11 +844,11 @@ namespace System.Reflection.Emit public byte[] m_data; } - public void SetImplementationFlags(MethodImplAttributes attributes) + public void SetImplementationFlags(MethodImplAttributes attributes) { - ThrowIfGeneric (); + ThrowIfGeneric(); - m_containingType.ThrowIfCreated (); + m_containingType.ThrowIfCreated(); m_dwMethodImplFlags = attributes; @@ -857,7 +857,8 @@ namespace System.Reflection.Emit TypeBuilder.SetMethodImpl(m_module.GetNativeHandle(), MetadataTokenInternal, attributes); } - public ILGenerator GetILGenerator() { + public ILGenerator GetILGenerator() + { Contract.Ensures(Contract.Result<ILGenerator>() != null); ThrowIfGeneric(); @@ -868,18 +869,20 @@ namespace System.Reflection.Emit return m_ilGenerator; } - public ILGenerator GetILGenerator(int size) { + public ILGenerator GetILGenerator(int size) + { Contract.Ensures(Contract.Result<ILGenerator>() != null); - ThrowIfGeneric (); + ThrowIfGeneric(); ThrowIfShouldNotHaveBody(); - + if (m_ilGenerator == null) m_ilGenerator = new ILGenerator(this, size); return m_ilGenerator; } - private void ThrowIfShouldNotHaveBody() { + private void ThrowIfShouldNotHaveBody() + { if ((m_dwMethodImplFlags & MethodImplAttributes.CodeTypeMask) != MethodImplAttributes.IL || (m_dwMethodImplFlags & MethodImplAttributes.Unmanaged) != 0 || (m_iAttributes & MethodAttributes.PinvokeImpl) != 0 || @@ -887,16 +890,16 @@ namespace System.Reflection.Emit { // cannot attach method body if methodimpl is marked not marked as managed IL // - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ShouldNotHaveMethodBody")); + throw new InvalidOperationException(SR.InvalidOperation_ShouldNotHaveMethodBody); } } - - public bool InitLocals - { + + public bool InitLocals + { // Property is set to true if user wishes to have zero initialized stack frame for this method. Default to false. - get { ThrowIfGeneric (); return m_fInitLocals; } - set { ThrowIfGeneric (); m_fInitLocals = value; } + get { ThrowIfGeneric(); return m_fInitLocals; } + set { ThrowIfGeneric(); m_fInitLocals = value; } } public Module GetModule() @@ -904,12 +907,12 @@ namespace System.Reflection.Emit return GetModuleBuilder(); } - public String Signature - { - get - { - return GetMethodSignature().ToString(); - } + public String Signature + { + get + { + return GetMethodSignature().ToString(); + } } @@ -941,7 +944,7 @@ namespace System.Reflection.Emit ThrowIfGeneric(); customBuilder.CreateCustomAttribute((ModuleBuilder)m_module, MetadataTokenInternal); - + if (IsKnownCA(customBuilder.m_con)) ParseCA(customBuilder.m_con, customBuilder.m_blob); } @@ -959,7 +962,7 @@ namespace System.Reflection.Emit private void ParseCA(ConstructorInfo con, byte[] blob) { Type caType = con.DeclaringType; - if (caType == typeof(System.Runtime.CompilerServices.MethodImplAttribute)) + if (caType == typeof(System.Runtime.CompilerServices.MethodImplAttribute)) { // dig through the blob looking for the MethodImplAttributes flag // that must be in the MethodCodeType field @@ -968,11 +971,11 @@ namespace System.Reflection.Emit // allows this method to have no body when any kind of MethodImplAttribute is present m_canBeRuntimeImpl = true; } - else if (caType == typeof(DllImportAttribute)) { + else if (caType == typeof(DllImportAttribute)) + { m_canBeRuntimeImpl = true; m_isDllImport = true; } - } internal bool m_canBeRuntimeImpl = false; @@ -987,15 +990,15 @@ namespace System.Reflection.Emit // and namespace information with a given active lexical scope. #region Internal Data Members - internal String[] m_strName; - internal byte[][] m_ubSignature; - internal int[] m_iLocalSlot; - internal int[] m_iStartOffset; - internal int[] m_iEndOffset; - internal int m_iLocalSymCount; // how many entries in the arrays are occupied - internal String[] m_namespace; - internal int m_iNameSpaceCount; - internal const int InitialSize = 16; + internal String[] m_strName; + internal byte[][] m_ubSignature; + internal int[] m_iLocalSlot; + internal int[] m_iStartOffset; + internal int[] m_iEndOffset; + internal int m_iLocalSymCount; // how many entries in the arrays are occupied + internal String[] m_namespace; + internal int m_iNameSpaceCount; + internal const int InitialSize = 16; #endregion #region Constructor @@ -1016,7 +1019,7 @@ namespace System.Reflection.Emit } else if (m_iNameSpaceCount == m_namespace.Length) { - String [] strTemp = new String [checked(m_iNameSpaceCount * 2)]; + String[] strTemp = new String[checked(m_iNameSpaceCount * 2)]; Array.Copy(m_namespace, 0, strTemp, 0, m_iNameSpaceCount); m_namespace = strTemp; } @@ -1038,33 +1041,32 @@ namespace System.Reflection.Emit // the arrays are full. Enlarge the arrays // why aren't we just using lists here? int newSize = checked(m_iLocalSymCount * 2); - int[] temp = new int [newSize]; + int[] temp = new int[newSize]; Array.Copy(m_iLocalSlot, 0, temp, 0, m_iLocalSymCount); m_iLocalSlot = temp; - temp = new int [newSize]; + temp = new int[newSize]; Array.Copy(m_iStartOffset, 0, temp, 0, m_iLocalSymCount); m_iStartOffset = temp; - temp = new int [newSize]; + temp = new int[newSize]; Array.Copy(m_iEndOffset, 0, temp, 0, m_iLocalSymCount); m_iEndOffset = temp; - String [] strTemp = new String [newSize]; + String[] strTemp = new String[newSize]; Array.Copy(m_strName, 0, strTemp, 0, m_iLocalSymCount); m_strName = strTemp; byte[][] ubTemp = new byte[newSize][]; Array.Copy(m_ubSignature, 0, ubTemp, 0, m_iLocalSymCount); m_ubSignature = ubTemp; - } } #endregion #region Internal Members - internal void AddLocalSymInfo(String strName,byte[] signature,int slot,int startOffset,int endOffset) + internal void AddLocalSymInfo(String strName, byte[] signature, int slot, int startOffset, int endOffset) { // make sure that arrays are large enough to hold addition info EnsureCapacity(); @@ -1073,7 +1075,7 @@ namespace System.Reflection.Emit m_iLocalSlot[m_iLocalSymCount] = slot; m_strName[m_iLocalSymCount] = strName; m_ubSignature[m_iLocalSymCount] = signature; - checked {m_iLocalSymCount++; } + checked { m_iLocalSymCount++; } } internal void AddUsingNamespace(String strNamespace) @@ -1085,13 +1087,13 @@ namespace System.Reflection.Emit internal virtual void EmitLocalSymInfo(ISymbolWriter symWriter) { - int i; + int i; - for (i = 0; i < m_iLocalSymCount; i ++) + for (i = 0; i < m_iLocalSymCount; i++) { symWriter.DefineLocalVariable( m_strName[i], - FieldAttributes.PrivateScope, + FieldAttributes.PrivateScope, m_ubSignature[i], SymAddressKind.ILOffset, m_iLocalSlot[i], @@ -1100,7 +1102,7 @@ namespace System.Reflection.Emit m_iStartOffset[i], m_iEndOffset[i]); } - for (i = 0; i < m_iNameSpaceCount; i ++) + for (i = 0; i < m_iNameSpaceCount; i++) { symWriter.UsingNamespace(m_namespace[i]); } @@ -1124,7 +1126,7 @@ namespace System.Reflection.Emit internal readonly int m_handlerEndOffset; internal readonly ExceptionHandlingClauseOptions m_kind; -#region Constructors + #region Constructors internal ExceptionHandler(int tryStartOffset, int tryEndOffset, int filterOffset, int handlerStartOffset, int handlerEndOffset, int kind, int exceptionTypeToken) @@ -1160,7 +1162,7 @@ namespace System.Reflection.Emit return false; } } - + #endregion #region Equality @@ -1187,7 +1189,7 @@ namespace System.Reflection.Emit other.m_kind == m_kind; } - public static bool operator ==(ExceptionHandler left, ExceptionHandler right) + public static bool operator ==(ExceptionHandler left, ExceptionHandler right) { return left.Equals(right); } @@ -1196,7 +1198,7 @@ namespace System.Reflection.Emit { return !left.Equals(right); } - + #endregion } } diff --git a/src/mscorlib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs b/src/mscorlib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs index 57ad1665c0..2d0a9b41dd 100644 --- a/src/mscorlib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs +++ b/src/mscorlib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs @@ -4,14 +4,14 @@ // +using System; +using System.Reflection; +using System.Collections; +using System.Globalization; +using System.Diagnostics.Contracts; + namespace System.Reflection.Emit { - using System; - using System.Reflection; - using System.Collections; - using System.Globalization; - using System.Diagnostics.Contracts; - internal sealed class MethodBuilderInstantiation : MethodInfo { #region Static Members @@ -38,18 +38,18 @@ namespace System.Reflection.Emit m_inst = inst; } #endregion - + internal override Type[] GetParameterTypes() { return m_method.GetParameterTypes(); } #region MemberBase - public override MemberTypes MemberType { get { return m_method.MemberType; } } + public override MemberTypes MemberType { get { return m_method.MemberType; } } public override String Name { get { return m_method.Name; } } - public override Type DeclaringType { get { return m_method.DeclaringType; } } + public override Type DeclaringType { get { return m_method.DeclaringType; } } public override Type ReflectedType { get { return m_method.ReflectedType; } } - public override Object[] GetCustomAttributes(bool inherit) { return m_method.GetCustomAttributes(inherit); } + public override Object[] GetCustomAttributes(bool inherit) { return m_method.GetCustomAttributes(inherit); } public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { return m_method.GetCustomAttributes(attributeType, inherit); } public override bool IsDefined(Type attributeType, bool inherit) { return m_method.IsDefined(attributeType, inherit); } public override Module Module { get { return m_method.Module; } } @@ -57,9 +57,9 @@ namespace System.Reflection.Emit #region MethodBase Members [Pure] - public override ParameterInfo[] GetParameters() { throw new NotSupportedException(); } + public override ParameterInfo[] GetParameters() { throw new NotSupportedException(); } public override MethodImplAttributes GetMethodImplementationFlags() { return m_method.GetMethodImplementationFlags(); } - public override RuntimeMethodHandle MethodHandle { get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); } } + public override RuntimeMethodHandle MethodHandle { get { throw new NotSupportedException(SR.NotSupported_DynamicModule); } } public override MethodAttributes Attributes { get { return m_method.Attributes; } } public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) { @@ -88,11 +88,11 @@ namespace System.Reflection.Emit public override MethodInfo MakeGenericMethod(params Type[] arguments) { - throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericMethodDefinition")); + throw new InvalidOperationException(SR.Arg_NotGenericMethodDefinition); } public override bool IsGenericMethod { get { return true; } } - + #endregion #region Public Abstract\Virtual Members diff --git a/src/mscorlib/src/System/Reflection/Emit/MethodToken.cs b/src/mscorlib/src/System/Reflection/Emit/MethodToken.cs index 76b7279f30..0905ac922a 100644 --- a/src/mscorlib/src/System/Reflection/Emit/MethodToken.cs +++ b/src/mscorlib/src/System/Reflection/Emit/MethodToken.cs @@ -12,25 +12,28 @@ ** ** ===========================================================*/ -namespace System.Reflection.Emit { - - using System; - using System.Reflection; +using System; +using System.Reflection; + +namespace System.Reflection.Emit +{ [Serializable] public struct MethodToken { public static readonly MethodToken Empty = new MethodToken(); internal int m_method; - - internal MethodToken(int str) { - m_method=str; + + internal MethodToken(int str) + { + m_method = str; } - - public int Token { + + public int Token + { get { return m_method; } } - + public override int GetHashCode() { return m_method; @@ -43,21 +46,20 @@ namespace System.Reflection.Emit { else return false; } - + public bool Equals(MethodToken obj) { return obj.m_method == m_method; } - + public static bool operator ==(MethodToken a, MethodToken b) { return a.Equals(b); } - + public static bool operator !=(MethodToken a, MethodToken b) { return !(a == b); } - } } diff --git a/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs index 30e6382550..d92d8220b8 100644 --- a/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs @@ -4,7 +4,7 @@ // -namespace System.Reflection.Emit +namespace System.Reflection.Emit { using System.Runtime.InteropServices; using System; @@ -120,7 +120,7 @@ namespace System.Reflection.Emit object.ReferenceEquals(foundType.DeclaringType, enclosingType)) { // Cannot have two types with the same name - throw new ArgumentException(Environment.GetResourceString("Argument_DuplicateTypeName")); + throw new ArgumentException(SR.Argument_DuplicateTypeName); } } @@ -135,10 +135,9 @@ namespace System.Reflection.Emit // convert the format string to byte array and then call FormCompoundType return SymbolType.FormCompoundType(strFormat, baseType, 0); - } - - + + internal void CheckContext(params Type[][] typess) { ContainingAssemblyBuilder.CheckContext(typess); @@ -179,14 +178,6 @@ namespace System.Reflection.Emit { Debug.Assert(method != null); -#if FEATURE_APPX - if (ContainingAssemblyBuilder.ProfileAPICheck) - { - if ((method.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", method.FullName)); - } -#endif - return GetMemberRefOfMethodInfo(GetNativeHandle(), tr, method); } @@ -194,14 +185,6 @@ namespace System.Reflection.Emit { Debug.Assert(method != null); -#if FEATURE_APPX - if (ContainingAssemblyBuilder.ProfileAPICheck) - { - if ((method.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", method.FullName)); - } -#endif - return GetMemberRefOfMethodInfo(GetNativeHandle(), tr, method); } @@ -213,15 +196,6 @@ namespace System.Reflection.Emit { Debug.Assert(runtimeField != null); -#if FEATURE_APPX - if (ContainingAssemblyBuilder.ProfileAPICheck) - { - RtFieldInfo rtField = runtimeField as RtFieldInfo; - if (rtField != null && (rtField.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtField.FullName)); - } -#endif - return GetMemberRefOfFieldInfo(GetNativeHandle(), tkType, declaringType, runtimeField.MetadataToken); } @@ -286,17 +260,6 @@ namespace System.Reflection.Emit Debug.Assert(!type.IsByRef, "Must not be ByRef."); Debug.Assert(!type.IsGenericType || type.IsGenericTypeDefinition, "Must not have generic arguments."); -#if FEATURE_APPX - if (ContainingAssemblyBuilder.ProfileAPICheck) - { - RuntimeType rtType = type as RuntimeType; - if (rtType != null && (rtType.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0) - { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtType.FullName)); - } - } -#endif - return GetTypeRef(GetNativeHandle(), typeName, GetRuntimeModuleFromModule(refedModule).GetNativeHandle(), strRefedModuleFileName, tkResolution); } @@ -315,7 +278,7 @@ namespace System.Reflection.Emit ConstructorOnTypeBuilderInstantiation conOnTypeBuilderInst = null; RuntimeConstructorInfo rtCon = null; - if ( (conBuilder = con as ConstructorBuilder) != null ) + if ((conBuilder = con as ConstructorBuilder) != null) { if (usingRef == false && conBuilder.Module.Equals(this)) return conBuilder.GetToken(); @@ -324,14 +287,14 @@ namespace System.Reflection.Emit tr = GetTypeTokenInternal(con.ReflectedType).Token; mr = GetMemberRef(con.ReflectedType.Module, tr, conBuilder.GetToken().Token); } - else if ( (conOnTypeBuilderInst = con as ConstructorOnTypeBuilderInstantiation) != null ) + else if ((conOnTypeBuilderInst = con as ConstructorOnTypeBuilderInstantiation) != null) { if (usingRef == true) throw new InvalidOperationException(); tr = GetTypeTokenInternal(con.DeclaringType).Token; mr = GetMemberRef(con.DeclaringType.Module, tr, conOnTypeBuilderInst.MetadataTokenInternal); } - else if ( (rtCon = con as RuntimeConstructorInfo) != null && con.ReflectedType.IsArray == false) + else if ((rtCon = con as RuntimeConstructorInfo) != null && con.ReflectedType.IsArray == false) { // constructor is not a dynamic field // We need to get the TypeRef tokens @@ -345,7 +308,7 @@ namespace System.Reflection.Emit // go through the slower code path, i.e. retrieve parameters and form signature helper. ParameterInfo[] parameters = con.GetParameters(); if (parameters == null) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidConstructorInfo")); + throw new ArgumentException(SR.Argument_InvalidConstructorInfo); Type[] parameterTypes = new Type[parameters.Length]; Type[][] requiredCustomModifiers = new Type[parameters.Length][]; @@ -354,7 +317,7 @@ namespace System.Reflection.Emit for (int i = 0; i < parameters.Length; i++) { if (parameters[i] == null) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidConstructorInfo")); + throw new ArgumentException(SR.Argument_InvalidConstructorInfo); parameterTypes[i] = parameters[i].ParameterType; requiredCustomModifiers[i] = parameters[i].GetRequiredCustomModifiers(); @@ -369,8 +332,8 @@ namespace System.Reflection.Emit mr = GetMemberRefFromSignature(tr, con.Name, sigBytes, length); } - - return new MethodToken( mr ); + + return new MethodToken(mr); } internal void Init(String strModuleName, String strFileName, int tkFile) @@ -395,7 +358,7 @@ namespace System.Reflection.Emit #endregion #region Module Overrides - + // m_internalModuleBuilder is null iff this is a "internal" ModuleBuilder internal InternalModuleBuilder InternalModule { @@ -405,7 +368,7 @@ namespace System.Reflection.Emit } } - internal override ModuleHandle GetModuleHandle() + protected override ModuleHandle GetModuleHandleImpl() { return new ModuleHandle(GetNativeHandle()); } @@ -446,7 +409,7 @@ namespace System.Reflection.Emit if ((method.CallingConvention & CallingConventions.VarArgs) == 0) { // Client should not supply optional parameter in default calling convention - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAVarArgCallingConvention")); + throw new InvalidOperationException(SR.InvalidOperation_NotAVarArgCallingConvention); } } @@ -532,7 +495,7 @@ namespace System.Reflection.Emit } internal SignatureHelper GetMemberRefSignature(CallingConventions call, Type returnType, - Type[] parameterTypes, IEnumerable<Type> optionalParameterTypes, int cGenericParameters) + Type[] parameterTypes, IEnumerable<Type> optionalParameterTypes, int cGenericParameters) { SignatureHelper sig = SignatureHelper.GetMethodSigHelper(this, call, returnType, cGenericParameters); @@ -544,7 +507,8 @@ namespace System.Reflection.Emit } } - if (optionalParameterTypes != null) { + if (optionalParameterTypes != null) + { int i = 0; foreach (Type type in optionalParameterTypes) { @@ -599,7 +563,7 @@ namespace System.Reflection.Emit public override Type[] GetTypes() { - lock(SyncRoot) + lock (SyncRoot) { return GetTypesNoLock(); } @@ -620,7 +584,7 @@ namespace System.Reflection.Emit tmpTypeBldr = enumBldr.m_typeBuilder; else tmpTypeBldr = (TypeBuilder)builder; - + // We should not return TypeBuilders. // Otherwise anyone can emit code in it. if (tmpTypeBldr.IsCreated()) @@ -636,15 +600,15 @@ namespace System.Reflection.Emit { return GetType(className, false, false); } - + public override Type GetType(String className, bool ignoreCase) { return GetType(className, false, ignoreCase); } - + public override Type GetType(String className, bool throwOnError, bool ignoreCase) { - lock(SyncRoot) + lock (SyncRoot) { return GetTypeNoLock(className, throwOnError, ignoreCase); } @@ -658,7 +622,7 @@ namespace System.Reflection.Emit // This API first delegate to the Module.GetType implementation. If succeeded, great! // If not, we have to look up the current module to find the TypeBuilder to represent the base // type and form the Type object for "foo[,]". - + // Module.GetType() will verify className. Type baseType = InternalModule.GetType(className, throwOnError, ignoreCase); if (baseType != null) @@ -674,7 +638,7 @@ namespace System.Reflection.Emit while (startIndex <= className.Length) { // Are there any possible special characters left? - int i = className.IndexOfAny(new char[]{'[', '*', '&'}, startIndex); + int i = className.IndexOfAny(new char[] { '[', '*', '&' }, startIndex); if (i == -1) { // No, type name is simple. @@ -709,7 +673,7 @@ namespace System.Reflection.Emit parameters = null; } - baseName = baseName.Replace(@"\\",@"\").Replace(@"\[",@"[").Replace(@"\*",@"*").Replace(@"\&",@"&"); + baseName = baseName.Replace(@"\\", @"\").Replace(@"\[", @"[").Replace(@"\*", @"*").Replace(@"\&", @"&"); if (parameters != null) { @@ -742,9 +706,9 @@ namespace System.Reflection.Emit return null; } - if (parameters == null) + if (parameters == null) return baseType; - + return GetType(parameters, baseType); } @@ -885,7 +849,7 @@ namespace System.Reflection.Emit { Contract.Ensures(Contract.Result<TypeBuilder>() != null); - lock(SyncRoot) + lock (SyncRoot) { return DefineTypeNoLock(name, TypeAttributes.NotPublic, null, null, PackingSize.Unspecified, TypeBuilder.UnspecifiedTypeSize); } @@ -895,7 +859,7 @@ namespace System.Reflection.Emit { Contract.Ensures(Contract.Result<TypeBuilder>() != null); - lock(SyncRoot) + lock (SyncRoot) { return DefineTypeNoLock(name, attr, null, null, PackingSize.Unspecified, TypeBuilder.UnspecifiedTypeSize); } @@ -905,7 +869,7 @@ namespace System.Reflection.Emit { Contract.Ensures(Contract.Result<TypeBuilder>() != null); - lock(SyncRoot) + lock (SyncRoot) { // Why do we only call CheckContext here? Why don't we call it in the other overloads? CheckContext(parent); @@ -918,7 +882,7 @@ namespace System.Reflection.Emit { Contract.Ensures(Contract.Result<TypeBuilder>() != null); - lock(SyncRoot) + lock (SyncRoot) { return DefineTypeNoLock(name, attr, parent, null, PackingSize.Unspecified, typesize); } @@ -938,7 +902,7 @@ namespace System.Reflection.Emit { Contract.Ensures(Contract.Result<TypeBuilder>() != null); - lock(SyncRoot) + lock (SyncRoot) { return DefineTypeNoLock(name, attr, parent, interfaces, PackingSize.Unspecified, TypeBuilder.UnspecifiedTypeSize); } @@ -955,7 +919,7 @@ namespace System.Reflection.Emit { Contract.Ensures(Contract.Result<TypeBuilder>() != null); - lock(SyncRoot) + lock (SyncRoot) { return DefineTypeNoLock(name, attr, parent, packsize); } @@ -979,7 +943,7 @@ namespace System.Reflection.Emit Contract.Ensures(Contract.Result<EnumBuilder>() != null); CheckContext(underlyingType); - lock(SyncRoot) + lock (SyncRoot) { EnumBuilder enumBuilder = DefineEnumNoLock(name, visibility, underlyingType); @@ -1006,7 +970,7 @@ namespace System.Reflection.Emit return new EnumBuilder(name, underlyingType, visibility, this); } - + #endregion #region Define Resource @@ -1021,7 +985,7 @@ namespace System.Reflection.Emit return DefineGlobalMethod(name, attributes, CallingConventions.Standard, returnType, parameterTypes); } - public MethodBuilder DefineGlobalMethod(String name, MethodAttributes attributes, CallingConventions callingConvention, + public MethodBuilder DefineGlobalMethod(String name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) { Contract.Ensures(Contract.Result<MethodBuilder>() != null); @@ -1029,33 +993,33 @@ namespace System.Reflection.Emit return DefineGlobalMethod(name, attributes, callingConvention, returnType, null, null, parameterTypes, null, null); } - public MethodBuilder DefineGlobalMethod(String name, MethodAttributes attributes, CallingConventions callingConvention, + public MethodBuilder DefineGlobalMethod(String name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { - lock(SyncRoot) + lock (SyncRoot) { - return DefineGlobalMethodNoLock(name, attributes, callingConvention, returnType, + return DefineGlobalMethodNoLock(name, attributes, callingConvention, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers, parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers); } } - private MethodBuilder DefineGlobalMethodNoLock(String name, MethodAttributes attributes, CallingConventions callingConvention, + private MethodBuilder DefineGlobalMethodNoLock(String name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { if (m_moduleData.m_fGlobalBeenCreated == true) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_GlobalsHaveBeenCreated")); - + throw new InvalidOperationException(SR.InvalidOperation_GlobalsHaveBeenCreated); + if (name == null) throw new ArgumentNullException(nameof(name)); if (name.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(name)); - + throw new ArgumentException(SR.Argument_EmptyName, nameof(name)); + if ((attributes & MethodAttributes.Static) == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_GlobalFunctionHasToBeStatic")); + throw new ArgumentException(SR.Argument_GlobalFunctionHasToBeStatic); Contract.Ensures(Contract.Result<MethodBuilder>() != null); Contract.EndContractBlock(); @@ -1066,14 +1030,14 @@ namespace System.Reflection.Emit m_moduleData.m_fHasGlobal = true; - return m_moduleData.m_globalTypeBuilder.DefineMethod(name, attributes, callingConvention, - returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers, + return m_moduleData.m_globalTypeBuilder.DefineMethod(name, attributes, callingConvention, + returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers, parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers); } - + public void CreateGlobalFunctions() { - lock(SyncRoot) + lock (SyncRoot) { CreateGlobalFunctionsNoLock(); } @@ -1084,12 +1048,12 @@ namespace System.Reflection.Emit if (m_moduleData.m_fGlobalBeenCreated) { // cannot create globals twice - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotADebugModule")); + throw new InvalidOperationException(SR.InvalidOperation_NotADebugModule); } m_moduleData.m_globalTypeBuilder.CreateType(); m_moduleData.m_fGlobalBeenCreated = true; } - + #endregion #region Define Data @@ -1101,7 +1065,7 @@ namespace System.Reflection.Emit // will be the signature for the Field. Contract.Ensures(Contract.Result<FieldBuilder>() != null); - lock(SyncRoot) + lock (SyncRoot) { return DefineInitializedDataNoLock(name, data, attributes); } @@ -1114,20 +1078,20 @@ namespace System.Reflection.Emit // will be the signature for the Field. if (m_moduleData.m_fGlobalBeenCreated == true) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_GlobalsHaveBeenCreated")); + throw new InvalidOperationException(SR.InvalidOperation_GlobalsHaveBeenCreated); } Contract.Ensures(Contract.Result<FieldBuilder>() != null); Contract.EndContractBlock(); - + m_moduleData.m_fHasGlobal = true; return m_moduleData.m_globalTypeBuilder.DefineInitializedData(name, data, attributes); } - + public FieldBuilder DefineUninitializedData(String name, int size, FieldAttributes attributes) { Contract.Ensures(Contract.Result<FieldBuilder>() != null); - lock(SyncRoot) + lock (SyncRoot) { return DefineUninitializedDataNoLock(name, size, attributes); } @@ -1141,15 +1105,15 @@ namespace System.Reflection.Emit if (m_moduleData.m_fGlobalBeenCreated == true) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_GlobalsHaveBeenCreated")); + throw new InvalidOperationException(SR.InvalidOperation_GlobalsHaveBeenCreated); } Contract.Ensures(Contract.Result<FieldBuilder>() != null); Contract.EndContractBlock(); - + m_moduleData.m_fHasGlobal = true; return m_moduleData.m_globalTypeBuilder.DefineUninitializedData(name, size, attributes); } - + #endregion #region GetToken @@ -1164,14 +1128,14 @@ namespace System.Reflection.Emit private TypeToken GetTypeTokenInternal(Type type, bool getGenericDefinition) { - lock(SyncRoot) + lock (SyncRoot) { return GetTypeTokenWorkerNoLock(type, getGenericDefinition); } } public TypeToken GetTypeToken(Type type) - { + { return GetTypeTokenInternal(type, true); } @@ -1182,7 +1146,7 @@ namespace System.Reflection.Emit Contract.EndContractBlock(); CheckContext(type); - + // Return a token for the class relative to the Module. Tokens // are used to indentify objects when the objects are used in IL // instructions. Tokens are always relative to the Module. For example, @@ -1194,7 +1158,7 @@ namespace System.Reflection.Emit // We should also be aware of multiple dynamic modules and multiple implementation of Type!!! if (type.IsByRef) - throw new ArgumentException(Environment.GetResourceString("Argument_CannotGetTypeTokenForByRef")); + throw new ArgumentException(SR.Argument_CannotGetTypeTokenForByRef); if ((type.IsGenericType && (!type.IsGenericTypeDefinition || !getGenericDefinition)) || type.IsGenericParameter || @@ -1231,10 +1195,10 @@ namespace System.Reflection.Emit { return new TypeToken(paramBuilder.MetadataTokenInternal); } - + return new TypeToken(GetTypeRefNested(type, this, String.Empty)); } - + // After this point, the referenced module is not the same as the referencing // module. // @@ -1258,21 +1222,21 @@ namespace System.Reflection.Emit return new TypeToken(GetTypeRefNested(type, refedModule, strRefedModuleFileName)); } - + public TypeToken GetTypeToken(String name) { // Return a token for the class relative to the Module. // Module.GetType() verifies name - + // Unfortunately, we will need to load the Type and then call GetTypeToken in // order to correctly track the assembly reference information. - + return GetTypeToken(InternalModule.GetType(name, false, true)); } public MethodToken GetMethodToken(MethodInfo method) { - lock(SyncRoot) + lock (SyncRoot) { return GetMethodTokenNoLock(method, true); } @@ -1280,7 +1244,7 @@ namespace System.Reflection.Emit internal MethodToken GetMethodTokenInternal(MethodInfo method) { - lock(SyncRoot) + lock (SyncRoot) { return GetMethodTokenNoLock(method, false); } @@ -1300,18 +1264,18 @@ namespace System.Reflection.Emit int tr; int mr = 0; - + SymbolMethod symMethod = null; MethodBuilder methBuilder = null; - if ( (methBuilder = method as MethodBuilder) != null ) + if ((methBuilder = method as MethodBuilder) != null) { int methodToken = methBuilder.MetadataTokenInternal; if (method.Module.Equals(this)) return new MethodToken(methodToken); if (method.DeclaringType == null) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotImportGlobalFromDifferentModule")); + throw new InvalidOperationException(SR.InvalidOperation_CannotImportGlobalFromDifferentModule); // method is defined in a different module tr = getGenericTypeDefinition ? GetTypeToken(method.DeclaringType).Token : GetTypeTokenInternal(method.DeclaringType).Token; @@ -1335,7 +1299,7 @@ namespace System.Reflection.Emit // We need to get the TypeRef tokens if (declaringType == null) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotImportGlobalFromDifferentModule")); + throw new InvalidOperationException(SR.InvalidOperation_CannotImportGlobalFromDifferentModule); RuntimeMethodInfo rtMeth = null; @@ -1343,15 +1307,15 @@ namespace System.Reflection.Emit { // use reflection to build signature to work around the E_T_VAR problem in EEClass ParameterInfo[] paramInfo = method.GetParameters(); - + Type[] tt = new Type[paramInfo.Length]; - + for (int i = 0; i < paramInfo.Length; i++) tt[i] = paramInfo[i].ParameterType; return GetArrayMethodToken(declaringType, method.Name, method.CallingConvention, method.ReturnType, tt); } - else if ( (rtMeth = method as RuntimeMethodInfo) != null ) + else if ((rtMeth = method as RuntimeMethodInfo) != null) { tr = getGenericTypeDefinition ? GetTypeToken(method.DeclaringType).Token : GetTypeTokenInternal(method.DeclaringType).Token; mr = GetMemberRefOfMethodInfo(tr, rtMeth); @@ -1372,25 +1336,25 @@ namespace System.Reflection.Emit requiredCustomModifiers[i] = parameters[i].GetRequiredCustomModifiers(); optionalCustomModifiers[i] = parameters[i].GetOptionalCustomModifiers(); } - + tr = getGenericTypeDefinition ? GetTypeToken(method.DeclaringType).Token : GetTypeTokenInternal(method.DeclaringType).Token; SignatureHelper sigHelp; - try + try { sigHelp = SignatureHelper.GetMethodSigHelper( - this, method.CallingConvention, method.ReturnType, - method.ReturnParameter.GetRequiredCustomModifiers(), method.ReturnParameter.GetOptionalCustomModifiers(), + this, method.CallingConvention, method.ReturnType, + method.ReturnParameter.GetRequiredCustomModifiers(), method.ReturnParameter.GetOptionalCustomModifiers(), parameterTypes, requiredCustomModifiers, optionalCustomModifiers); - } - catch(NotImplementedException) + } + catch (NotImplementedException) { // Legacy code deriving from MethodInfo may not have implemented ReturnParameter. sigHelp = SignatureHelper.GetMethodSigHelper(this, method.ReturnType, parameterTypes); } - int length; + int length; byte[] sigBytes = sigHelp.InternalGetSignature(out length); mr = GetMemberRefFromSignature(tr, method.Name, sigBytes, length); } @@ -1464,17 +1428,17 @@ namespace System.Reflection.Emit return tk; } - - public MethodToken GetArrayMethodToken(Type arrayClass, String methodName, CallingConventions callingConvention, + + public MethodToken GetArrayMethodToken(Type arrayClass, String methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) { - lock(SyncRoot) + lock (SyncRoot) { return GetArrayMethodTokenNoLock(arrayClass, methodName, callingConvention, returnType, parameterTypes); } } - private MethodToken GetArrayMethodTokenNoLock(Type arrayClass, String methodName, CallingConventions callingConvention, + private MethodToken GetArrayMethodTokenNoLock(Type arrayClass, String methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) { if (arrayClass == null) @@ -1484,10 +1448,10 @@ namespace System.Reflection.Emit throw new ArgumentNullException(nameof(methodName)); if (methodName.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(methodName)); + throw new ArgumentException(SR.Argument_EmptyName, nameof(methodName)); if (arrayClass.IsArray == false) - throw new ArgumentException(Environment.GetResourceString("Argument_HasToBeArrayClass")); + throw new ArgumentException(SR.Argument_HasToBeArrayClass); Contract.EndContractBlock(); CheckContext(returnType, arrayClass); @@ -1509,7 +1473,7 @@ namespace System.Reflection.Emit typeSpec.Token, methodName, sigBytes, length)); } - public MethodInfo GetArrayMethod(Type arrayClass, String methodName, CallingConventions callingConvention, + public MethodInfo GetArrayMethod(Type arrayClass, String methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) { CheckContext(returnType, arrayClass); @@ -1531,23 +1495,24 @@ namespace System.Reflection.Emit return InternalGetConstructorToken(con, false); } - public FieldToken GetFieldToken(FieldInfo field) + public FieldToken GetFieldToken(FieldInfo field) { - lock(SyncRoot) + lock (SyncRoot) { return GetFieldTokenNoLock(field); } } - private FieldToken GetFieldTokenNoLock(FieldInfo field) + private FieldToken GetFieldTokenNoLock(FieldInfo field) { - if (field == null) { + if (field == null) + { throw new ArgumentNullException(nameof(field)); } Contract.EndContractBlock(); - int tr; - int mr = 0; + int tr; + int mr = 0; FieldBuilder fdBuilder = null; RuntimeFieldInfo rtField = null; @@ -1572,22 +1537,22 @@ namespace System.Reflection.Emit // field is defined in a different module if (field.DeclaringType == null) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotImportGlobalFromDifferentModule")); + throw new InvalidOperationException(SR.InvalidOperation_CannotImportGlobalFromDifferentModule); } tr = GetTypeTokenInternal(field.DeclaringType).Token; mr = GetMemberRef(field.ReflectedType.Module, tr, fdBuilder.GetToken().Token); } } - else if ( (rtField = field as RuntimeFieldInfo) != null) + else if ((rtField = field as RuntimeFieldInfo) != null) { // FieldInfo is not an dynamic field - + // We need to get the TypeRef tokens if (field.DeclaringType == null) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotImportGlobalFromDifferentModule")); + throw new InvalidOperationException(SR.InvalidOperation_CannotImportGlobalFromDifferentModule); } - + if (field.DeclaringType != null && field.DeclaringType.IsGenericType) { int length; @@ -1597,11 +1562,11 @@ namespace System.Reflection.Emit } else { - tr = GetTypeTokenInternal(field.DeclaringType).Token; + tr = GetTypeTokenInternal(field.DeclaringType).Token; mr = GetMemberRefOfFieldInfo(tr, field.DeclaringType.GetTypeHandleInternal(), rtField); } } - else if ( (fOnTB = field as FieldOnTypeBuilderInstantiation) != null) + else if ((fOnTB = field as FieldOnTypeBuilderInstantiation) != null) { FieldInfo fb = fOnTB.FieldInfo; int length; @@ -1623,11 +1588,11 @@ namespace System.Reflection.Emit mr = GetMemberRefFromSignature(tr, field.Name, sigBytes, length); } - + return new FieldToken(mr, field.GetType()); } - - public StringToken GetStringConstant(String str) + + public StringToken GetStringConstant(String str) { if (str == null) { @@ -1639,7 +1604,7 @@ namespace System.Reflection.Emit // value has already been defined, the existing token will be returned. return new StringToken(GetStringConstant(GetNativeHandle(), str, str.Length)); } - + public SignatureToken GetSignatureToken(SignatureHelper sigHelper) { // Define signature token given a signature helper. This will define a metadata @@ -1653,11 +1618,11 @@ namespace System.Reflection.Emit int sigLength; byte[] sigBytes; - + // get the signature in byte form sigBytes = sigHelper.InternalGetSignature(out sigLength); return new SignatureToken(TypeBuilder.GetTokenFromSig(GetNativeHandle(), sigBytes, sigLength), this); - } + } public SignatureToken GetSignatureToken(byte[] sigBytes, int sigLength) { if (sigBytes == null) @@ -1669,7 +1634,7 @@ namespace System.Reflection.Emit return new SignatureToken(TypeBuilder.GetTokenFromSig(GetNativeHandle(), localSigBytes, sigLength), this); } - + #endregion #region Other @@ -1681,7 +1646,7 @@ namespace System.Reflection.Emit if (binaryAttribute == null) throw new ArgumentNullException(nameof(binaryAttribute)); Contract.EndContractBlock(); - + TypeBuilder.DefineCustomAttribute( this, 1, // This is hard coding the module token to 1 @@ -1742,7 +1707,7 @@ namespace System.Reflection.Emit throw new ArgumentNullException(nameof(url)); Contract.EndContractBlock(); - lock(SyncRoot) + lock (SyncRoot) { return DefineDocumentNoLock(url, language, languageVendor, documentType); } @@ -1753,12 +1718,12 @@ namespace System.Reflection.Emit if (m_iSymWriter == null) { // Cannot DefineDocument when it is not a debug module - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotADebugModule")); + throw new InvalidOperationException(SR.InvalidOperation_NotADebugModule); } return m_iSymWriter.DefineDocument(url, language, languageVendor, documentType); } - + [Pure] public bool IsTransient() { diff --git a/src/mscorlib/src/System/Reflection/Emit/ModuleBuilderData.cs b/src/mscorlib/src/System/Reflection/Emit/ModuleBuilderData.cs index 4b6f8b4efe..4f1b8eb713 100644 --- a/src/mscorlib/src/System/Reflection/Emit/ModuleBuilderData.cs +++ b/src/mscorlib/src/System/Reflection/Emit/ModuleBuilderData.cs @@ -6,16 +6,16 @@ //////////////////////////////////////////////////////////////////////////////// // +using System; +using System.Diagnostics; +using System.Diagnostics.Contracts; +using System.Globalization; +using System.IO; +using System.Reflection; +using System.Runtime.Versioning; + namespace System.Reflection.Emit { - using System; - using System.Diagnostics; - using System.Diagnostics.Contracts; - using System.Globalization; - using System.IO; - using System.Reflection; - using System.Runtime.Versioning; - // This is a package private class. This class hold all of the managed // data member for ModuleBuilder. Note that what ever data members added to // this class cannot be accessed from the EE. @@ -46,25 +46,25 @@ namespace System.Reflection.Emit if (strExtension == null || strExtension == String.Empty) { // This is required by our loader. It cannot load module file that does not have file extension. - throw new ArgumentException(Environment.GetResourceString("Argument_NoModuleFileExtension", strFileName)); + throw new ArgumentException(SR.Format(SR.Argument_NoModuleFileExtension, strFileName)); } m_strFileName = strFileName; } } - internal String m_strModuleName; // scope name (can be different from file name) - internal String m_strFileName; - internal bool m_fGlobalBeenCreated; - internal bool m_fHasGlobal; + internal String m_strModuleName; // scope name (can be different from file name) + internal String m_strFileName; + internal bool m_fGlobalBeenCreated; + internal bool m_fHasGlobal; [NonSerialized] - internal TypeBuilder m_globalTypeBuilder; + internal TypeBuilder m_globalTypeBuilder; [NonSerialized] internal ModuleBuilder m_module; - private int m_tkFile; - internal bool m_isSaved; + private int m_tkFile; + internal bool m_isSaved; internal const String MULTI_BYTE_VALUE_CLASS = "$ArrayType$"; - internal String m_strResourceFileName; - internal byte[] m_resourceBytes; + internal String m_strResourceFileName; + internal byte[] m_resourceBytes; } // class ModuleBuilderData } diff --git a/src/mscorlib/src/System/Reflection/Emit/OpCodes.cs b/src/mscorlib/src/System/Reflection/Emit/OpCodes.cs index 324fad9ceb..99915492c1 100644 --- a/src/mscorlib/src/System/Reflection/Emit/OpCodes.cs +++ b/src/mscorlib/src/System/Reflection/Emit/OpCodes.cs @@ -10,2540 +10,2543 @@ ** ** ============================================================*/ -namespace System.Reflection.Emit { using System; -// -// Internal enums for opcode values. Note that the value names are used to construct -// publicly visible ilasm-compatible opcode names, so their exact form is important! -// -internal enum OpCodeValues { - Nop = 0x00, - Break = 0x01, - Ldarg_0 = 0x02, - Ldarg_1 = 0x03, - Ldarg_2 = 0x04, - Ldarg_3 = 0x05, - Ldloc_0 = 0x06, - Ldloc_1 = 0x07, - Ldloc_2 = 0x08, - Ldloc_3 = 0x09, - Stloc_0 = 0x0a, - Stloc_1 = 0x0b, - Stloc_2 = 0x0c, - Stloc_3 = 0x0d, - Ldarg_S = 0x0e, - Ldarga_S = 0x0f, - Starg_S = 0x10, - Ldloc_S = 0x11, - Ldloca_S = 0x12, - Stloc_S = 0x13, - Ldnull = 0x14, - Ldc_I4_M1 = 0x15, - Ldc_I4_0 = 0x16, - Ldc_I4_1 = 0x17, - Ldc_I4_2 = 0x18, - Ldc_I4_3 = 0x19, - Ldc_I4_4 = 0x1a, - Ldc_I4_5 = 0x1b, - Ldc_I4_6 = 0x1c, - Ldc_I4_7 = 0x1d, - Ldc_I4_8 = 0x1e, - Ldc_I4_S = 0x1f, - Ldc_I4 = 0x20, - Ldc_I8 = 0x21, - Ldc_R4 = 0x22, - Ldc_R8 = 0x23, - Dup = 0x25, - Pop = 0x26, - Jmp = 0x27, - Call = 0x28, - Calli = 0x29, - Ret = 0x2a, - Br_S = 0x2b, - Brfalse_S = 0x2c, - Brtrue_S = 0x2d, - Beq_S = 0x2e, - Bge_S = 0x2f, - Bgt_S = 0x30, - Ble_S = 0x31, - Blt_S = 0x32, - Bne_Un_S = 0x33, - Bge_Un_S = 0x34, - Bgt_Un_S = 0x35, - Ble_Un_S = 0x36, - Blt_Un_S = 0x37, - Br = 0x38, - Brfalse = 0x39, - Brtrue = 0x3a, - Beq = 0x3b, - Bge = 0x3c, - Bgt = 0x3d, - Ble = 0x3e, - Blt = 0x3f, - Bne_Un = 0x40, - Bge_Un = 0x41, - Bgt_Un = 0x42, - Ble_Un = 0x43, - Blt_Un = 0x44, - Switch = 0x45, - Ldind_I1 = 0x46, - Ldind_U1 = 0x47, - Ldind_I2 = 0x48, - Ldind_U2 = 0x49, - Ldind_I4 = 0x4a, - Ldind_U4 = 0x4b, - Ldind_I8 = 0x4c, - Ldind_I = 0x4d, - Ldind_R4 = 0x4e, - Ldind_R8 = 0x4f, - Ldind_Ref = 0x50, - Stind_Ref = 0x51, - Stind_I1 = 0x52, - Stind_I2 = 0x53, - Stind_I4 = 0x54, - Stind_I8 = 0x55, - Stind_R4 = 0x56, - Stind_R8 = 0x57, - Add = 0x58, - Sub = 0x59, - Mul = 0x5a, - Div = 0x5b, - Div_Un = 0x5c, - Rem = 0x5d, - Rem_Un = 0x5e, - And = 0x5f, - Or = 0x60, - Xor = 0x61, - Shl = 0x62, - Shr = 0x63, - Shr_Un = 0x64, - Neg = 0x65, - Not = 0x66, - Conv_I1 = 0x67, - Conv_I2 = 0x68, - Conv_I4 = 0x69, - Conv_I8 = 0x6a, - Conv_R4 = 0x6b, - Conv_R8 = 0x6c, - Conv_U4 = 0x6d, - Conv_U8 = 0x6e, - Callvirt = 0x6f, - Cpobj = 0x70, - Ldobj = 0x71, - Ldstr = 0x72, - Newobj = 0x73, - Castclass = 0x74, - Isinst = 0x75, - Conv_R_Un = 0x76, - Unbox = 0x79, - Throw = 0x7a, - Ldfld = 0x7b, - Ldflda = 0x7c, - Stfld = 0x7d, - Ldsfld = 0x7e, - Ldsflda = 0x7f, - Stsfld = 0x80, - Stobj = 0x81, - Conv_Ovf_I1_Un = 0x82, - Conv_Ovf_I2_Un = 0x83, - Conv_Ovf_I4_Un = 0x84, - Conv_Ovf_I8_Un = 0x85, - Conv_Ovf_U1_Un = 0x86, - Conv_Ovf_U2_Un = 0x87, - Conv_Ovf_U4_Un = 0x88, - Conv_Ovf_U8_Un = 0x89, - Conv_Ovf_I_Un = 0x8a, - Conv_Ovf_U_Un = 0x8b, - Box = 0x8c, - Newarr = 0x8d, - Ldlen = 0x8e, - Ldelema = 0x8f, - Ldelem_I1 = 0x90, - Ldelem_U1 = 0x91, - Ldelem_I2 = 0x92, - Ldelem_U2 = 0x93, - Ldelem_I4 = 0x94, - Ldelem_U4 = 0x95, - Ldelem_I8 = 0x96, - Ldelem_I = 0x97, - Ldelem_R4 = 0x98, - Ldelem_R8 = 0x99, - Ldelem_Ref = 0x9a, - Stelem_I = 0x9b, - Stelem_I1 = 0x9c, - Stelem_I2 = 0x9d, - Stelem_I4 = 0x9e, - Stelem_I8 = 0x9f, - Stelem_R4 = 0xa0, - Stelem_R8 = 0xa1, - Stelem_Ref = 0xa2, - Ldelem = 0xa3, - Stelem = 0xa4, - Unbox_Any = 0xa5, - Conv_Ovf_I1 = 0xb3, - Conv_Ovf_U1 = 0xb4, - Conv_Ovf_I2 = 0xb5, - Conv_Ovf_U2 = 0xb6, - Conv_Ovf_I4 = 0xb7, - Conv_Ovf_U4 = 0xb8, - Conv_Ovf_I8 = 0xb9, - Conv_Ovf_U8 = 0xba, - Refanyval = 0xc2, - Ckfinite = 0xc3, - Mkrefany = 0xc6, - Ldtoken = 0xd0, - Conv_U2 = 0xd1, - Conv_U1 = 0xd2, - Conv_I = 0xd3, - Conv_Ovf_I = 0xd4, - Conv_Ovf_U = 0xd5, - Add_Ovf = 0xd6, - Add_Ovf_Un = 0xd7, - Mul_Ovf = 0xd8, - Mul_Ovf_Un = 0xd9, - Sub_Ovf = 0xda, - Sub_Ovf_Un = 0xdb, - Endfinally = 0xdc, - Leave = 0xdd, - Leave_S = 0xde, - Stind_I = 0xdf, - Conv_U = 0xe0, - Prefix7 = 0xf8, - Prefix6 = 0xf9, - Prefix5 = 0xfa, - Prefix4 = 0xfb, - Prefix3 = 0xfc, - Prefix2 = 0xfd, - Prefix1 = 0xfe, - Prefixref = 0xff, - Arglist = 0xfe00, - Ceq = 0xfe01, - Cgt = 0xfe02, - Cgt_Un = 0xfe03, - Clt = 0xfe04, - Clt_Un = 0xfe05, - Ldftn = 0xfe06, - Ldvirtftn = 0xfe07, - Ldarg = 0xfe09, - Ldarga = 0xfe0a, - Starg = 0xfe0b, - Ldloc = 0xfe0c, - Ldloca = 0xfe0d, - Stloc = 0xfe0e, - Localloc = 0xfe0f, - Endfilter = 0xfe11, - Unaligned_ = 0xfe12, - Volatile_ = 0xfe13, - Tail_ = 0xfe14, - Initobj = 0xfe15, - Constrained_ = 0xfe16, - Cpblk = 0xfe17, - Initblk = 0xfe18, - Rethrow = 0xfe1a, - Sizeof = 0xfe1c, - Refanytype = 0xfe1d, - Readonly_ = 0xfe1e, - - // If you add more opcodes here, modify OpCode.Name to handle them correctly -}; - -public class OpCodes { - -/// <summary> -/// <para> -/// The IL instruction opcodes supported by the -/// runtime. The IL Instruction Specification describes each -/// Opcode. -/// </para> -/// </summary> -/// <seealso topic='IL Instruction Set Specification'/> - - private OpCodes() { - } - - public static readonly OpCode Nop = new OpCode(OpCodeValues.Nop, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Break = new OpCode(OpCodeValues.Break, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Break << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldarg_0 = new OpCode(OpCodeValues.Ldarg_0, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldarg_1 = new OpCode(OpCodeValues.Ldarg_1, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldarg_2 = new OpCode(OpCodeValues.Ldarg_2, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldarg_3 = new OpCode(OpCodeValues.Ldarg_3, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldloc_0 = new OpCode(OpCodeValues.Ldloc_0, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldloc_1 = new OpCode(OpCodeValues.Ldloc_1, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldloc_2 = new OpCode(OpCodeValues.Ldloc_2, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldloc_3 = new OpCode(OpCodeValues.Ldloc_3, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stloc_0 = new OpCode(OpCodeValues.Stloc_0, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stloc_1 = new OpCode(OpCodeValues.Stloc_1, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stloc_2 = new OpCode(OpCodeValues.Stloc_2, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stloc_3 = new OpCode(OpCodeValues.Stloc_3, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldarg_S = new OpCode(OpCodeValues.Ldarg_S, - ((int)OperandType.ShortInlineVar) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldarga_S = new OpCode(OpCodeValues.Ldarga_S, - ((int)OperandType.ShortInlineVar) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Starg_S = new OpCode(OpCodeValues.Starg_S, - ((int)OperandType.ShortInlineVar) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldloc_S = new OpCode(OpCodeValues.Ldloc_S, - ((int)OperandType.ShortInlineVar) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldloca_S = new OpCode(OpCodeValues.Ldloca_S, - ((int)OperandType.ShortInlineVar) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stloc_S = new OpCode(OpCodeValues.Stloc_S, - ((int)OperandType.ShortInlineVar) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldnull = new OpCode(OpCodeValues.Ldnull, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldc_I4_M1 = new OpCode(OpCodeValues.Ldc_I4_M1, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldc_I4_0 = new OpCode(OpCodeValues.Ldc_I4_0, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldc_I4_1 = new OpCode(OpCodeValues.Ldc_I4_1, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldc_I4_2 = new OpCode(OpCodeValues.Ldc_I4_2, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldc_I4_3 = new OpCode(OpCodeValues.Ldc_I4_3, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldc_I4_4 = new OpCode(OpCodeValues.Ldc_I4_4, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldc_I4_5 = new OpCode(OpCodeValues.Ldc_I4_5, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldc_I4_6 = new OpCode(OpCodeValues.Ldc_I4_6, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldc_I4_7 = new OpCode(OpCodeValues.Ldc_I4_7, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldc_I4_8 = new OpCode(OpCodeValues.Ldc_I4_8, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldc_I4_S = new OpCode(OpCodeValues.Ldc_I4_S, - ((int)OperandType.ShortInlineI) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldc_I4 = new OpCode(OpCodeValues.Ldc_I4, - ((int)OperandType.InlineI) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldc_I8 = new OpCode(OpCodeValues.Ldc_I8, - ((int)OperandType.InlineI8) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldc_R4 = new OpCode(OpCodeValues.Ldc_R4, - ((int)OperandType.ShortInlineR) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushr4 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldc_R8 = new OpCode(OpCodeValues.Ldc_R8, - ((int)OperandType.InlineR) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Dup = new OpCode(OpCodeValues.Dup, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1_push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Pop = new OpCode(OpCodeValues.Pop, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Jmp = new OpCode(OpCodeValues.Jmp, - ((int)OperandType.InlineMethod) | - ((int)FlowControl.Call << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - OpCode.EndsUncondJmpBlkFlag | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Call = new OpCode(OpCodeValues.Call, - ((int)OperandType.InlineMethod) | - ((int)FlowControl.Call << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Varpop << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Varpush << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Calli = new OpCode(OpCodeValues.Calli, - ((int)OperandType.InlineSig) | - ((int)FlowControl.Call << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Varpop << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Varpush << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ret = new OpCode(OpCodeValues.Ret, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Return << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Varpop << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - OpCode.EndsUncondJmpBlkFlag | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Br_S = new OpCode(OpCodeValues.Br_S, - ((int)OperandType.ShortInlineBrTarget) | - ((int)FlowControl.Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - OpCode.EndsUncondJmpBlkFlag | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Brfalse_S = new OpCode(OpCodeValues.Brfalse_S, - ((int)OperandType.ShortInlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Brtrue_S = new OpCode(OpCodeValues.Brtrue_S, - ((int)OperandType.ShortInlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Beq_S = new OpCode(OpCodeValues.Beq_S, - ((int)OperandType.ShortInlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Bge_S = new OpCode(OpCodeValues.Bge_S, - ((int)OperandType.ShortInlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Bgt_S = new OpCode(OpCodeValues.Bgt_S, - ((int)OperandType.ShortInlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ble_S = new OpCode(OpCodeValues.Ble_S, - ((int)OperandType.ShortInlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Blt_S = new OpCode(OpCodeValues.Blt_S, - ((int)OperandType.ShortInlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Bne_Un_S = new OpCode(OpCodeValues.Bne_Un_S, - ((int)OperandType.ShortInlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Bge_Un_S = new OpCode(OpCodeValues.Bge_Un_S, - ((int)OperandType.ShortInlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Bgt_Un_S = new OpCode(OpCodeValues.Bgt_Un_S, - ((int)OperandType.ShortInlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ble_Un_S = new OpCode(OpCodeValues.Ble_Un_S, - ((int)OperandType.ShortInlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Blt_Un_S = new OpCode(OpCodeValues.Blt_Un_S, - ((int)OperandType.ShortInlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Br = new OpCode(OpCodeValues.Br, - ((int)OperandType.InlineBrTarget) | - ((int)FlowControl.Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - OpCode.EndsUncondJmpBlkFlag | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Brfalse = new OpCode(OpCodeValues.Brfalse, - ((int)OperandType.InlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Brtrue = new OpCode(OpCodeValues.Brtrue, - ((int)OperandType.InlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Beq = new OpCode(OpCodeValues.Beq, - ((int)OperandType.InlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Bge = new OpCode(OpCodeValues.Bge, - ((int)OperandType.InlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Bgt = new OpCode(OpCodeValues.Bgt, - ((int)OperandType.InlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ble = new OpCode(OpCodeValues.Ble, - ((int)OperandType.InlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Blt = new OpCode(OpCodeValues.Blt, - ((int)OperandType.InlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Bne_Un = new OpCode(OpCodeValues.Bne_Un, - ((int)OperandType.InlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Bge_Un = new OpCode(OpCodeValues.Bge_Un, - ((int)OperandType.InlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Bgt_Un = new OpCode(OpCodeValues.Bgt_Un, - ((int)OperandType.InlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ble_Un = new OpCode(OpCodeValues.Ble_Un, - ((int)OperandType.InlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Blt_Un = new OpCode(OpCodeValues.Blt_Un, - ((int)OperandType.InlineBrTarget) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Switch = new OpCode(OpCodeValues.Switch, - ((int)OperandType.InlineSwitch) | - ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldind_I1 = new OpCode(OpCodeValues.Ldind_I1, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldind_U1 = new OpCode(OpCodeValues.Ldind_U1, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldind_I2 = new OpCode(OpCodeValues.Ldind_I2, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldind_U2 = new OpCode(OpCodeValues.Ldind_U2, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldind_I4 = new OpCode(OpCodeValues.Ldind_I4, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldind_U4 = new OpCode(OpCodeValues.Ldind_U4, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldind_I8 = new OpCode(OpCodeValues.Ldind_I8, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldind_I = new OpCode(OpCodeValues.Ldind_I, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldind_R4 = new OpCode(OpCodeValues.Ldind_R4, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushr4 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldind_R8 = new OpCode(OpCodeValues.Ldind_R8, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldind_Ref = new OpCode(OpCodeValues.Ldind_Ref, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stind_Ref = new OpCode(OpCodeValues.Stind_Ref, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stind_I1 = new OpCode(OpCodeValues.Stind_I1, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stind_I2 = new OpCode(OpCodeValues.Stind_I2, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stind_I4 = new OpCode(OpCodeValues.Stind_I4, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stind_I8 = new OpCode(OpCodeValues.Stind_I8, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi_popi8 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stind_R4 = new OpCode(OpCodeValues.Stind_R4, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi_popr4 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stind_R8 = new OpCode(OpCodeValues.Stind_R8, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi_popr8 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Add = new OpCode(OpCodeValues.Add, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Sub = new OpCode(OpCodeValues.Sub, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Mul = new OpCode(OpCodeValues.Mul, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Div = new OpCode(OpCodeValues.Div, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Div_Un = new OpCode(OpCodeValues.Div_Un, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Rem = new OpCode(OpCodeValues.Rem, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Rem_Un = new OpCode(OpCodeValues.Rem_Un, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode And = new OpCode(OpCodeValues.And, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Or = new OpCode(OpCodeValues.Or, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Xor = new OpCode(OpCodeValues.Xor, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Shl = new OpCode(OpCodeValues.Shl, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Shr = new OpCode(OpCodeValues.Shr, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Shr_Un = new OpCode(OpCodeValues.Shr_Un, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Neg = new OpCode(OpCodeValues.Neg, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Not = new OpCode(OpCodeValues.Not, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_I1 = new OpCode(OpCodeValues.Conv_I1, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_I2 = new OpCode(OpCodeValues.Conv_I2, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_I4 = new OpCode(OpCodeValues.Conv_I4, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_I8 = new OpCode(OpCodeValues.Conv_I8, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_R4 = new OpCode(OpCodeValues.Conv_R4, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushr4 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_R8 = new OpCode(OpCodeValues.Conv_R8, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_U4 = new OpCode(OpCodeValues.Conv_U4, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_U8 = new OpCode(OpCodeValues.Conv_U8, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Callvirt = new OpCode(OpCodeValues.Callvirt, - ((int)OperandType.InlineMethod) | - ((int)FlowControl.Call << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Varpop << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Varpush << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Cpobj = new OpCode(OpCodeValues.Cpobj, - ((int)OperandType.InlineType) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldobj = new OpCode(OpCodeValues.Ldobj, - ((int)OperandType.InlineType) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldstr = new OpCode(OpCodeValues.Ldstr, - ((int)OperandType.InlineString) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Newobj = new OpCode(OpCodeValues.Newobj, - ((int)OperandType.InlineMethod) | - ((int)FlowControl.Call << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Varpop << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Castclass = new OpCode(OpCodeValues.Castclass, - ((int)OperandType.InlineType) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Isinst = new OpCode(OpCodeValues.Isinst, - ((int)OperandType.InlineType) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_R_Un = new OpCode(OpCodeValues.Conv_R_Un, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Unbox = new OpCode(OpCodeValues.Unbox, - ((int)OperandType.InlineType) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Throw = new OpCode(OpCodeValues.Throw, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Throw << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - OpCode.EndsUncondJmpBlkFlag | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldfld = new OpCode(OpCodeValues.Ldfld, - ((int)OperandType.InlineField) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldflda = new OpCode(OpCodeValues.Ldflda, - ((int)OperandType.InlineField) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stfld = new OpCode(OpCodeValues.Stfld, - ((int)OperandType.InlineField) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldsfld = new OpCode(OpCodeValues.Ldsfld, - ((int)OperandType.InlineField) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldsflda = new OpCode(OpCodeValues.Ldsflda, - ((int)OperandType.InlineField) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stsfld = new OpCode(OpCodeValues.Stsfld, - ((int)OperandType.InlineField) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stobj = new OpCode(OpCodeValues.Stobj, - ((int)OperandType.InlineType) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_Ovf_I1_Un = new OpCode(OpCodeValues.Conv_Ovf_I1_Un, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_Ovf_I2_Un = new OpCode(OpCodeValues.Conv_Ovf_I2_Un, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_Ovf_I4_Un = new OpCode(OpCodeValues.Conv_Ovf_I4_Un, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_Ovf_I8_Un = new OpCode(OpCodeValues.Conv_Ovf_I8_Un, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_Ovf_U1_Un = new OpCode(OpCodeValues.Conv_Ovf_U1_Un, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_Ovf_U2_Un = new OpCode(OpCodeValues.Conv_Ovf_U2_Un, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_Ovf_U4_Un = new OpCode(OpCodeValues.Conv_Ovf_U4_Un, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_Ovf_U8_Un = new OpCode(OpCodeValues.Conv_Ovf_U8_Un, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_Ovf_I_Un = new OpCode(OpCodeValues.Conv_Ovf_I_Un, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_Ovf_U_Un = new OpCode(OpCodeValues.Conv_Ovf_U_Un, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Box = new OpCode(OpCodeValues.Box, - ((int)OperandType.InlineType) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Newarr = new OpCode(OpCodeValues.Newarr, - ((int)OperandType.InlineType) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldlen = new OpCode(OpCodeValues.Ldlen, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldelema = new OpCode(OpCodeValues.Ldelema, - ((int)OperandType.InlineType) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldelem_I1 = new OpCode(OpCodeValues.Ldelem_I1, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldelem_U1 = new OpCode(OpCodeValues.Ldelem_U1, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldelem_I2 = new OpCode(OpCodeValues.Ldelem_I2, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldelem_U2 = new OpCode(OpCodeValues.Ldelem_U2, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldelem_I4 = new OpCode(OpCodeValues.Ldelem_I4, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldelem_U4 = new OpCode(OpCodeValues.Ldelem_U4, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldelem_I8 = new OpCode(OpCodeValues.Ldelem_I8, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldelem_I = new OpCode(OpCodeValues.Ldelem_I, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldelem_R4 = new OpCode(OpCodeValues.Ldelem_R4, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushr4 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldelem_R8 = new OpCode(OpCodeValues.Ldelem_R8, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldelem_Ref = new OpCode(OpCodeValues.Ldelem_Ref, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stelem_I = new OpCode(OpCodeValues.Stelem_I, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref_popi_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-3 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stelem_I1 = new OpCode(OpCodeValues.Stelem_I1, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref_popi_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-3 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stelem_I2 = new OpCode(OpCodeValues.Stelem_I2, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref_popi_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-3 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stelem_I4 = new OpCode(OpCodeValues.Stelem_I4, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref_popi_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-3 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stelem_I8 = new OpCode(OpCodeValues.Stelem_I8, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref_popi_popi8 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-3 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stelem_R4 = new OpCode(OpCodeValues.Stelem_R4, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref_popi_popr4 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-3 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stelem_R8 = new OpCode(OpCodeValues.Stelem_R8, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref_popi_popr8 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-3 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stelem_Ref = new OpCode(OpCodeValues.Stelem_Ref, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref_popi_popref << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-3 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldelem = new OpCode(OpCodeValues.Ldelem, - ((int)OperandType.InlineType) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stelem = new OpCode(OpCodeValues.Stelem, - ((int)OperandType.InlineType) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref_popi_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Unbox_Any = new OpCode(OpCodeValues.Unbox_Any, - ((int)OperandType.InlineType) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_Ovf_I1 = new OpCode(OpCodeValues.Conv_Ovf_I1, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_Ovf_U1 = new OpCode(OpCodeValues.Conv_Ovf_U1, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_Ovf_I2 = new OpCode(OpCodeValues.Conv_Ovf_I2, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_Ovf_U2 = new OpCode(OpCodeValues.Conv_Ovf_U2, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_Ovf_I4 = new OpCode(OpCodeValues.Conv_Ovf_I4, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_Ovf_U4 = new OpCode(OpCodeValues.Conv_Ovf_U4, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_Ovf_I8 = new OpCode(OpCodeValues.Conv_Ovf_I8, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_Ovf_U8 = new OpCode(OpCodeValues.Conv_Ovf_U8, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Refanyval = new OpCode(OpCodeValues.Refanyval, - ((int)OperandType.InlineType) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ckfinite = new OpCode(OpCodeValues.Ckfinite, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Mkrefany = new OpCode(OpCodeValues.Mkrefany, - ((int)OperandType.InlineType) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldtoken = new OpCode(OpCodeValues.Ldtoken, - ((int)OperandType.InlineTok) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_U2 = new OpCode(OpCodeValues.Conv_U2, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_U1 = new OpCode(OpCodeValues.Conv_U1, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_I = new OpCode(OpCodeValues.Conv_I, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_Ovf_I = new OpCode(OpCodeValues.Conv_Ovf_I, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_Ovf_U = new OpCode(OpCodeValues.Conv_Ovf_U, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Add_Ovf = new OpCode(OpCodeValues.Add_Ovf, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Add_Ovf_Un = new OpCode(OpCodeValues.Add_Ovf_Un, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Mul_Ovf = new OpCode(OpCodeValues.Mul_Ovf, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Mul_Ovf_Un = new OpCode(OpCodeValues.Mul_Ovf_Un, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Sub_Ovf = new OpCode(OpCodeValues.Sub_Ovf, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Sub_Ovf_Un = new OpCode(OpCodeValues.Sub_Ovf_Un, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Endfinally = new OpCode(OpCodeValues.Endfinally, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Return << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - OpCode.EndsUncondJmpBlkFlag | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Leave = new OpCode(OpCodeValues.Leave, - ((int)OperandType.InlineBrTarget) | - ((int)FlowControl.Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - OpCode.EndsUncondJmpBlkFlag | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Leave_S = new OpCode(OpCodeValues.Leave_S, - ((int)OperandType.ShortInlineBrTarget) | - ((int)FlowControl.Branch << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - OpCode.EndsUncondJmpBlkFlag | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stind_I = new OpCode(OpCodeValues.Stind_I, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (-2 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Conv_U = new OpCode(OpCodeValues.Conv_U, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Prefix7 = new OpCode(OpCodeValues.Prefix7, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Meta << OpCode.FlowControlShift) | - ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Prefix6 = new OpCode(OpCodeValues.Prefix6, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Meta << OpCode.FlowControlShift) | - ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Prefix5 = new OpCode(OpCodeValues.Prefix5, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Meta << OpCode.FlowControlShift) | - ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Prefix4 = new OpCode(OpCodeValues.Prefix4, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Meta << OpCode.FlowControlShift) | - ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Prefix3 = new OpCode(OpCodeValues.Prefix3, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Meta << OpCode.FlowControlShift) | - ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Prefix2 = new OpCode(OpCodeValues.Prefix2, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Meta << OpCode.FlowControlShift) | - ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Prefix1 = new OpCode(OpCodeValues.Prefix1, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Meta << OpCode.FlowControlShift) | - ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Prefixref = new OpCode(OpCodeValues.Prefixref, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Meta << OpCode.FlowControlShift) | - ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (1 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Arglist = new OpCode(OpCodeValues.Arglist, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ceq = new OpCode(OpCodeValues.Ceq, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Cgt = new OpCode(OpCodeValues.Cgt, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Cgt_Un = new OpCode(OpCodeValues.Cgt_Un, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Clt = new OpCode(OpCodeValues.Clt, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Clt_Un = new OpCode(OpCodeValues.Clt_Un, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldftn = new OpCode(OpCodeValues.Ldftn, - ((int)OperandType.InlineMethod) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldvirtftn = new OpCode(OpCodeValues.Ldvirtftn, - ((int)OperandType.InlineMethod) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldarg = new OpCode(OpCodeValues.Ldarg, - ((int)OperandType.InlineVar) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldarga = new OpCode(OpCodeValues.Ldarga, - ((int)OperandType.InlineVar) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Starg = new OpCode(OpCodeValues.Starg, - ((int)OperandType.InlineVar) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldloc = new OpCode(OpCodeValues.Ldloc, - ((int)OperandType.InlineVar) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Ldloca = new OpCode(OpCodeValues.Ldloca, - ((int)OperandType.InlineVar) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Stloc = new OpCode(OpCodeValues.Stloc, - ((int)OperandType.InlineVar) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Localloc = new OpCode(OpCodeValues.Localloc, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Endfilter = new OpCode(OpCodeValues.Endfilter, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Return << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - OpCode.EndsUncondJmpBlkFlag | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Unaligned = new OpCode(OpCodeValues.Unaligned_, - ((int)OperandType.ShortInlineI) | - ((int)FlowControl.Meta << OpCode.FlowControlShift) | - ((int)OpCodeType.Prefix << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Volatile = new OpCode(OpCodeValues.Volatile_, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Meta << OpCode.FlowControlShift) | - ((int)OpCodeType.Prefix << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Tailcall = new OpCode(OpCodeValues.Tail_, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Meta << OpCode.FlowControlShift) | - ((int)OpCodeType.Prefix << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Initobj = new OpCode(OpCodeValues.Initobj, - ((int)OperandType.InlineType) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (-1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Constrained = new OpCode(OpCodeValues.Constrained_, - ((int)OperandType.InlineType) | - ((int)FlowControl.Meta << OpCode.FlowControlShift) | - ((int)OpCodeType.Prefix << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Cpblk = new OpCode(OpCodeValues.Cpblk, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi_popi_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (-3 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Initblk = new OpCode(OpCodeValues.Initblk, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Popi_popi_popi << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (-3 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Rethrow = new OpCode(OpCodeValues.Rethrow, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Throw << OpCode.FlowControlShift) | - ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - OpCode.EndsUncondJmpBlkFlag | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Sizeof = new OpCode(OpCodeValues.Sizeof, - ((int)OperandType.InlineType) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (1 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Refanytype = new OpCode(OpCodeValues.Refanytype, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Next << OpCode.FlowControlShift) | - ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - public static readonly OpCode Readonly = new OpCode(OpCodeValues.Readonly_, - ((int)OperandType.InlineNone) | - ((int)FlowControl.Meta << OpCode.FlowControlShift) | - ((int)OpCodeType.Prefix << OpCode.OpCodeTypeShift) | - ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | - ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | - (2 << OpCode.SizeShift) | - (0 << OpCode.StackChangeShift) - ); - - - public static bool TakesSingleByteArgument(OpCode inst) +namespace System.Reflection.Emit +{ + // + // Internal enums for opcode values. Note that the value names are used to construct + // publicly visible ilasm-compatible opcode names, so their exact form is important! + // + internal enum OpCodeValues + { + Nop = 0x00, + Break = 0x01, + Ldarg_0 = 0x02, + Ldarg_1 = 0x03, + Ldarg_2 = 0x04, + Ldarg_3 = 0x05, + Ldloc_0 = 0x06, + Ldloc_1 = 0x07, + Ldloc_2 = 0x08, + Ldloc_3 = 0x09, + Stloc_0 = 0x0a, + Stloc_1 = 0x0b, + Stloc_2 = 0x0c, + Stloc_3 = 0x0d, + Ldarg_S = 0x0e, + Ldarga_S = 0x0f, + Starg_S = 0x10, + Ldloc_S = 0x11, + Ldloca_S = 0x12, + Stloc_S = 0x13, + Ldnull = 0x14, + Ldc_I4_M1 = 0x15, + Ldc_I4_0 = 0x16, + Ldc_I4_1 = 0x17, + Ldc_I4_2 = 0x18, + Ldc_I4_3 = 0x19, + Ldc_I4_4 = 0x1a, + Ldc_I4_5 = 0x1b, + Ldc_I4_6 = 0x1c, + Ldc_I4_7 = 0x1d, + Ldc_I4_8 = 0x1e, + Ldc_I4_S = 0x1f, + Ldc_I4 = 0x20, + Ldc_I8 = 0x21, + Ldc_R4 = 0x22, + Ldc_R8 = 0x23, + Dup = 0x25, + Pop = 0x26, + Jmp = 0x27, + Call = 0x28, + Calli = 0x29, + Ret = 0x2a, + Br_S = 0x2b, + Brfalse_S = 0x2c, + Brtrue_S = 0x2d, + Beq_S = 0x2e, + Bge_S = 0x2f, + Bgt_S = 0x30, + Ble_S = 0x31, + Blt_S = 0x32, + Bne_Un_S = 0x33, + Bge_Un_S = 0x34, + Bgt_Un_S = 0x35, + Ble_Un_S = 0x36, + Blt_Un_S = 0x37, + Br = 0x38, + Brfalse = 0x39, + Brtrue = 0x3a, + Beq = 0x3b, + Bge = 0x3c, + Bgt = 0x3d, + Ble = 0x3e, + Blt = 0x3f, + Bne_Un = 0x40, + Bge_Un = 0x41, + Bgt_Un = 0x42, + Ble_Un = 0x43, + Blt_Un = 0x44, + Switch = 0x45, + Ldind_I1 = 0x46, + Ldind_U1 = 0x47, + Ldind_I2 = 0x48, + Ldind_U2 = 0x49, + Ldind_I4 = 0x4a, + Ldind_U4 = 0x4b, + Ldind_I8 = 0x4c, + Ldind_I = 0x4d, + Ldind_R4 = 0x4e, + Ldind_R8 = 0x4f, + Ldind_Ref = 0x50, + Stind_Ref = 0x51, + Stind_I1 = 0x52, + Stind_I2 = 0x53, + Stind_I4 = 0x54, + Stind_I8 = 0x55, + Stind_R4 = 0x56, + Stind_R8 = 0x57, + Add = 0x58, + Sub = 0x59, + Mul = 0x5a, + Div = 0x5b, + Div_Un = 0x5c, + Rem = 0x5d, + Rem_Un = 0x5e, + And = 0x5f, + Or = 0x60, + Xor = 0x61, + Shl = 0x62, + Shr = 0x63, + Shr_Un = 0x64, + Neg = 0x65, + Not = 0x66, + Conv_I1 = 0x67, + Conv_I2 = 0x68, + Conv_I4 = 0x69, + Conv_I8 = 0x6a, + Conv_R4 = 0x6b, + Conv_R8 = 0x6c, + Conv_U4 = 0x6d, + Conv_U8 = 0x6e, + Callvirt = 0x6f, + Cpobj = 0x70, + Ldobj = 0x71, + Ldstr = 0x72, + Newobj = 0x73, + Castclass = 0x74, + Isinst = 0x75, + Conv_R_Un = 0x76, + Unbox = 0x79, + Throw = 0x7a, + Ldfld = 0x7b, + Ldflda = 0x7c, + Stfld = 0x7d, + Ldsfld = 0x7e, + Ldsflda = 0x7f, + Stsfld = 0x80, + Stobj = 0x81, + Conv_Ovf_I1_Un = 0x82, + Conv_Ovf_I2_Un = 0x83, + Conv_Ovf_I4_Un = 0x84, + Conv_Ovf_I8_Un = 0x85, + Conv_Ovf_U1_Un = 0x86, + Conv_Ovf_U2_Un = 0x87, + Conv_Ovf_U4_Un = 0x88, + Conv_Ovf_U8_Un = 0x89, + Conv_Ovf_I_Un = 0x8a, + Conv_Ovf_U_Un = 0x8b, + Box = 0x8c, + Newarr = 0x8d, + Ldlen = 0x8e, + Ldelema = 0x8f, + Ldelem_I1 = 0x90, + Ldelem_U1 = 0x91, + Ldelem_I2 = 0x92, + Ldelem_U2 = 0x93, + Ldelem_I4 = 0x94, + Ldelem_U4 = 0x95, + Ldelem_I8 = 0x96, + Ldelem_I = 0x97, + Ldelem_R4 = 0x98, + Ldelem_R8 = 0x99, + Ldelem_Ref = 0x9a, + Stelem_I = 0x9b, + Stelem_I1 = 0x9c, + Stelem_I2 = 0x9d, + Stelem_I4 = 0x9e, + Stelem_I8 = 0x9f, + Stelem_R4 = 0xa0, + Stelem_R8 = 0xa1, + Stelem_Ref = 0xa2, + Ldelem = 0xa3, + Stelem = 0xa4, + Unbox_Any = 0xa5, + Conv_Ovf_I1 = 0xb3, + Conv_Ovf_U1 = 0xb4, + Conv_Ovf_I2 = 0xb5, + Conv_Ovf_U2 = 0xb6, + Conv_Ovf_I4 = 0xb7, + Conv_Ovf_U4 = 0xb8, + Conv_Ovf_I8 = 0xb9, + Conv_Ovf_U8 = 0xba, + Refanyval = 0xc2, + Ckfinite = 0xc3, + Mkrefany = 0xc6, + Ldtoken = 0xd0, + Conv_U2 = 0xd1, + Conv_U1 = 0xd2, + Conv_I = 0xd3, + Conv_Ovf_I = 0xd4, + Conv_Ovf_U = 0xd5, + Add_Ovf = 0xd6, + Add_Ovf_Un = 0xd7, + Mul_Ovf = 0xd8, + Mul_Ovf_Un = 0xd9, + Sub_Ovf = 0xda, + Sub_Ovf_Un = 0xdb, + Endfinally = 0xdc, + Leave = 0xdd, + Leave_S = 0xde, + Stind_I = 0xdf, + Conv_U = 0xe0, + Prefix7 = 0xf8, + Prefix6 = 0xf9, + Prefix5 = 0xfa, + Prefix4 = 0xfb, + Prefix3 = 0xfc, + Prefix2 = 0xfd, + Prefix1 = 0xfe, + Prefixref = 0xff, + Arglist = 0xfe00, + Ceq = 0xfe01, + Cgt = 0xfe02, + Cgt_Un = 0xfe03, + Clt = 0xfe04, + Clt_Un = 0xfe05, + Ldftn = 0xfe06, + Ldvirtftn = 0xfe07, + Ldarg = 0xfe09, + Ldarga = 0xfe0a, + Starg = 0xfe0b, + Ldloc = 0xfe0c, + Ldloca = 0xfe0d, + Stloc = 0xfe0e, + Localloc = 0xfe0f, + Endfilter = 0xfe11, + Unaligned_ = 0xfe12, + Volatile_ = 0xfe13, + Tail_ = 0xfe14, + Initobj = 0xfe15, + Constrained_ = 0xfe16, + Cpblk = 0xfe17, + Initblk = 0xfe18, + Rethrow = 0xfe1a, + Sizeof = 0xfe1c, + Refanytype = 0xfe1d, + Readonly_ = 0xfe1e, + + // If you add more opcodes here, modify OpCode.Name to handle them correctly + }; + + public class OpCodes { - switch (inst.OperandType) + /// <summary> + /// <para> + /// The IL instruction opcodes supported by the + /// runtime. The IL Instruction Specification describes each + /// Opcode. + /// </para> + /// </summary> + /// <seealso topic='IL Instruction Set Specification'/> + + private OpCodes() { - case OperandType.ShortInlineBrTarget : - case OperandType.ShortInlineI : - case OperandType.ShortInlineVar : - return true; - }; - return false; + } + + public static readonly OpCode Nop = new OpCode(OpCodeValues.Nop, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Break = new OpCode(OpCodeValues.Break, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Break << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldarg_0 = new OpCode(OpCodeValues.Ldarg_0, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldarg_1 = new OpCode(OpCodeValues.Ldarg_1, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldarg_2 = new OpCode(OpCodeValues.Ldarg_2, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldarg_3 = new OpCode(OpCodeValues.Ldarg_3, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldloc_0 = new OpCode(OpCodeValues.Ldloc_0, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldloc_1 = new OpCode(OpCodeValues.Ldloc_1, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldloc_2 = new OpCode(OpCodeValues.Ldloc_2, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldloc_3 = new OpCode(OpCodeValues.Ldloc_3, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stloc_0 = new OpCode(OpCodeValues.Stloc_0, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stloc_1 = new OpCode(OpCodeValues.Stloc_1, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stloc_2 = new OpCode(OpCodeValues.Stloc_2, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stloc_3 = new OpCode(OpCodeValues.Stloc_3, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldarg_S = new OpCode(OpCodeValues.Ldarg_S, + ((int)OperandType.ShortInlineVar) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldarga_S = new OpCode(OpCodeValues.Ldarga_S, + ((int)OperandType.ShortInlineVar) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Starg_S = new OpCode(OpCodeValues.Starg_S, + ((int)OperandType.ShortInlineVar) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldloc_S = new OpCode(OpCodeValues.Ldloc_S, + ((int)OperandType.ShortInlineVar) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldloca_S = new OpCode(OpCodeValues.Ldloca_S, + ((int)OperandType.ShortInlineVar) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stloc_S = new OpCode(OpCodeValues.Stloc_S, + ((int)OperandType.ShortInlineVar) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldnull = new OpCode(OpCodeValues.Ldnull, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldc_I4_M1 = new OpCode(OpCodeValues.Ldc_I4_M1, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldc_I4_0 = new OpCode(OpCodeValues.Ldc_I4_0, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldc_I4_1 = new OpCode(OpCodeValues.Ldc_I4_1, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldc_I4_2 = new OpCode(OpCodeValues.Ldc_I4_2, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldc_I4_3 = new OpCode(OpCodeValues.Ldc_I4_3, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldc_I4_4 = new OpCode(OpCodeValues.Ldc_I4_4, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldc_I4_5 = new OpCode(OpCodeValues.Ldc_I4_5, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldc_I4_6 = new OpCode(OpCodeValues.Ldc_I4_6, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldc_I4_7 = new OpCode(OpCodeValues.Ldc_I4_7, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldc_I4_8 = new OpCode(OpCodeValues.Ldc_I4_8, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldc_I4_S = new OpCode(OpCodeValues.Ldc_I4_S, + ((int)OperandType.ShortInlineI) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldc_I4 = new OpCode(OpCodeValues.Ldc_I4, + ((int)OperandType.InlineI) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldc_I8 = new OpCode(OpCodeValues.Ldc_I8, + ((int)OperandType.InlineI8) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldc_R4 = new OpCode(OpCodeValues.Ldc_R4, + ((int)OperandType.ShortInlineR) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushr4 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldc_R8 = new OpCode(OpCodeValues.Ldc_R8, + ((int)OperandType.InlineR) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Dup = new OpCode(OpCodeValues.Dup, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1_push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Pop = new OpCode(OpCodeValues.Pop, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Jmp = new OpCode(OpCodeValues.Jmp, + ((int)OperandType.InlineMethod) | + ((int)FlowControl.Call << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + OpCode.EndsUncondJmpBlkFlag | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Call = new OpCode(OpCodeValues.Call, + ((int)OperandType.InlineMethod) | + ((int)FlowControl.Call << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Varpop << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Varpush << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Calli = new OpCode(OpCodeValues.Calli, + ((int)OperandType.InlineSig) | + ((int)FlowControl.Call << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Varpop << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Varpush << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ret = new OpCode(OpCodeValues.Ret, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Return << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Varpop << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + OpCode.EndsUncondJmpBlkFlag | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Br_S = new OpCode(OpCodeValues.Br_S, + ((int)OperandType.ShortInlineBrTarget) | + ((int)FlowControl.Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + OpCode.EndsUncondJmpBlkFlag | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Brfalse_S = new OpCode(OpCodeValues.Brfalse_S, + ((int)OperandType.ShortInlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Brtrue_S = new OpCode(OpCodeValues.Brtrue_S, + ((int)OperandType.ShortInlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Beq_S = new OpCode(OpCodeValues.Beq_S, + ((int)OperandType.ShortInlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Bge_S = new OpCode(OpCodeValues.Bge_S, + ((int)OperandType.ShortInlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Bgt_S = new OpCode(OpCodeValues.Bgt_S, + ((int)OperandType.ShortInlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ble_S = new OpCode(OpCodeValues.Ble_S, + ((int)OperandType.ShortInlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Blt_S = new OpCode(OpCodeValues.Blt_S, + ((int)OperandType.ShortInlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Bne_Un_S = new OpCode(OpCodeValues.Bne_Un_S, + ((int)OperandType.ShortInlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Bge_Un_S = new OpCode(OpCodeValues.Bge_Un_S, + ((int)OperandType.ShortInlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Bgt_Un_S = new OpCode(OpCodeValues.Bgt_Un_S, + ((int)OperandType.ShortInlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ble_Un_S = new OpCode(OpCodeValues.Ble_Un_S, + ((int)OperandType.ShortInlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Blt_Un_S = new OpCode(OpCodeValues.Blt_Un_S, + ((int)OperandType.ShortInlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Br = new OpCode(OpCodeValues.Br, + ((int)OperandType.InlineBrTarget) | + ((int)FlowControl.Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + OpCode.EndsUncondJmpBlkFlag | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Brfalse = new OpCode(OpCodeValues.Brfalse, + ((int)OperandType.InlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Brtrue = new OpCode(OpCodeValues.Brtrue, + ((int)OperandType.InlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Beq = new OpCode(OpCodeValues.Beq, + ((int)OperandType.InlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Bge = new OpCode(OpCodeValues.Bge, + ((int)OperandType.InlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Bgt = new OpCode(OpCodeValues.Bgt, + ((int)OperandType.InlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ble = new OpCode(OpCodeValues.Ble, + ((int)OperandType.InlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Blt = new OpCode(OpCodeValues.Blt, + ((int)OperandType.InlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Bne_Un = new OpCode(OpCodeValues.Bne_Un, + ((int)OperandType.InlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Bge_Un = new OpCode(OpCodeValues.Bge_Un, + ((int)OperandType.InlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Bgt_Un = new OpCode(OpCodeValues.Bgt_Un, + ((int)OperandType.InlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ble_Un = new OpCode(OpCodeValues.Ble_Un, + ((int)OperandType.InlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Blt_Un = new OpCode(OpCodeValues.Blt_Un, + ((int)OperandType.InlineBrTarget) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Macro << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Switch = new OpCode(OpCodeValues.Switch, + ((int)OperandType.InlineSwitch) | + ((int)FlowControl.Cond_Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldind_I1 = new OpCode(OpCodeValues.Ldind_I1, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldind_U1 = new OpCode(OpCodeValues.Ldind_U1, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldind_I2 = new OpCode(OpCodeValues.Ldind_I2, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldind_U2 = new OpCode(OpCodeValues.Ldind_U2, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldind_I4 = new OpCode(OpCodeValues.Ldind_I4, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldind_U4 = new OpCode(OpCodeValues.Ldind_U4, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldind_I8 = new OpCode(OpCodeValues.Ldind_I8, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldind_I = new OpCode(OpCodeValues.Ldind_I, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldind_R4 = new OpCode(OpCodeValues.Ldind_R4, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushr4 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldind_R8 = new OpCode(OpCodeValues.Ldind_R8, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldind_Ref = new OpCode(OpCodeValues.Ldind_Ref, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stind_Ref = new OpCode(OpCodeValues.Stind_Ref, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stind_I1 = new OpCode(OpCodeValues.Stind_I1, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stind_I2 = new OpCode(OpCodeValues.Stind_I2, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stind_I4 = new OpCode(OpCodeValues.Stind_I4, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stind_I8 = new OpCode(OpCodeValues.Stind_I8, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi_popi8 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stind_R4 = new OpCode(OpCodeValues.Stind_R4, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi_popr4 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stind_R8 = new OpCode(OpCodeValues.Stind_R8, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi_popr8 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Add = new OpCode(OpCodeValues.Add, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Sub = new OpCode(OpCodeValues.Sub, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Mul = new OpCode(OpCodeValues.Mul, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Div = new OpCode(OpCodeValues.Div, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Div_Un = new OpCode(OpCodeValues.Div_Un, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Rem = new OpCode(OpCodeValues.Rem, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Rem_Un = new OpCode(OpCodeValues.Rem_Un, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode And = new OpCode(OpCodeValues.And, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Or = new OpCode(OpCodeValues.Or, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Xor = new OpCode(OpCodeValues.Xor, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Shl = new OpCode(OpCodeValues.Shl, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Shr = new OpCode(OpCodeValues.Shr, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Shr_Un = new OpCode(OpCodeValues.Shr_Un, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Neg = new OpCode(OpCodeValues.Neg, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Not = new OpCode(OpCodeValues.Not, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_I1 = new OpCode(OpCodeValues.Conv_I1, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_I2 = new OpCode(OpCodeValues.Conv_I2, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_I4 = new OpCode(OpCodeValues.Conv_I4, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_I8 = new OpCode(OpCodeValues.Conv_I8, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_R4 = new OpCode(OpCodeValues.Conv_R4, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushr4 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_R8 = new OpCode(OpCodeValues.Conv_R8, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_U4 = new OpCode(OpCodeValues.Conv_U4, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_U8 = new OpCode(OpCodeValues.Conv_U8, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Callvirt = new OpCode(OpCodeValues.Callvirt, + ((int)OperandType.InlineMethod) | + ((int)FlowControl.Call << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Varpop << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Varpush << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Cpobj = new OpCode(OpCodeValues.Cpobj, + ((int)OperandType.InlineType) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldobj = new OpCode(OpCodeValues.Ldobj, + ((int)OperandType.InlineType) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldstr = new OpCode(OpCodeValues.Ldstr, + ((int)OperandType.InlineString) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Newobj = new OpCode(OpCodeValues.Newobj, + ((int)OperandType.InlineMethod) | + ((int)FlowControl.Call << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Varpop << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Castclass = new OpCode(OpCodeValues.Castclass, + ((int)OperandType.InlineType) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Isinst = new OpCode(OpCodeValues.Isinst, + ((int)OperandType.InlineType) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_R_Un = new OpCode(OpCodeValues.Conv_R_Un, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Unbox = new OpCode(OpCodeValues.Unbox, + ((int)OperandType.InlineType) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Throw = new OpCode(OpCodeValues.Throw, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Throw << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + OpCode.EndsUncondJmpBlkFlag | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldfld = new OpCode(OpCodeValues.Ldfld, + ((int)OperandType.InlineField) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldflda = new OpCode(OpCodeValues.Ldflda, + ((int)OperandType.InlineField) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stfld = new OpCode(OpCodeValues.Stfld, + ((int)OperandType.InlineField) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldsfld = new OpCode(OpCodeValues.Ldsfld, + ((int)OperandType.InlineField) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldsflda = new OpCode(OpCodeValues.Ldsflda, + ((int)OperandType.InlineField) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stsfld = new OpCode(OpCodeValues.Stsfld, + ((int)OperandType.InlineField) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stobj = new OpCode(OpCodeValues.Stobj, + ((int)OperandType.InlineType) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_Ovf_I1_Un = new OpCode(OpCodeValues.Conv_Ovf_I1_Un, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_Ovf_I2_Un = new OpCode(OpCodeValues.Conv_Ovf_I2_Un, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_Ovf_I4_Un = new OpCode(OpCodeValues.Conv_Ovf_I4_Un, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_Ovf_I8_Un = new OpCode(OpCodeValues.Conv_Ovf_I8_Un, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_Ovf_U1_Un = new OpCode(OpCodeValues.Conv_Ovf_U1_Un, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_Ovf_U2_Un = new OpCode(OpCodeValues.Conv_Ovf_U2_Un, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_Ovf_U4_Un = new OpCode(OpCodeValues.Conv_Ovf_U4_Un, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_Ovf_U8_Un = new OpCode(OpCodeValues.Conv_Ovf_U8_Un, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_Ovf_I_Un = new OpCode(OpCodeValues.Conv_Ovf_I_Un, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_Ovf_U_Un = new OpCode(OpCodeValues.Conv_Ovf_U_Un, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Box = new OpCode(OpCodeValues.Box, + ((int)OperandType.InlineType) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Newarr = new OpCode(OpCodeValues.Newarr, + ((int)OperandType.InlineType) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldlen = new OpCode(OpCodeValues.Ldlen, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldelema = new OpCode(OpCodeValues.Ldelema, + ((int)OperandType.InlineType) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldelem_I1 = new OpCode(OpCodeValues.Ldelem_I1, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldelem_U1 = new OpCode(OpCodeValues.Ldelem_U1, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldelem_I2 = new OpCode(OpCodeValues.Ldelem_I2, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldelem_U2 = new OpCode(OpCodeValues.Ldelem_U2, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldelem_I4 = new OpCode(OpCodeValues.Ldelem_I4, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldelem_U4 = new OpCode(OpCodeValues.Ldelem_U4, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldelem_I8 = new OpCode(OpCodeValues.Ldelem_I8, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldelem_I = new OpCode(OpCodeValues.Ldelem_I, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldelem_R4 = new OpCode(OpCodeValues.Ldelem_R4, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushr4 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldelem_R8 = new OpCode(OpCodeValues.Ldelem_R8, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldelem_Ref = new OpCode(OpCodeValues.Ldelem_Ref, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushref << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stelem_I = new OpCode(OpCodeValues.Stelem_I, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref_popi_popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-3 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stelem_I1 = new OpCode(OpCodeValues.Stelem_I1, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref_popi_popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-3 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stelem_I2 = new OpCode(OpCodeValues.Stelem_I2, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref_popi_popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-3 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stelem_I4 = new OpCode(OpCodeValues.Stelem_I4, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref_popi_popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-3 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stelem_I8 = new OpCode(OpCodeValues.Stelem_I8, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref_popi_popi8 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-3 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stelem_R4 = new OpCode(OpCodeValues.Stelem_R4, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref_popi_popr4 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-3 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stelem_R8 = new OpCode(OpCodeValues.Stelem_R8, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref_popi_popr8 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-3 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stelem_Ref = new OpCode(OpCodeValues.Stelem_Ref, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref_popi_popref << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-3 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldelem = new OpCode(OpCodeValues.Ldelem, + ((int)OperandType.InlineType) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref_popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stelem = new OpCode(OpCodeValues.Stelem, + ((int)OperandType.InlineType) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref_popi_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Unbox_Any = new OpCode(OpCodeValues.Unbox_Any, + ((int)OperandType.InlineType) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Objmodel << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popref << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_Ovf_I1 = new OpCode(OpCodeValues.Conv_Ovf_I1, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_Ovf_U1 = new OpCode(OpCodeValues.Conv_Ovf_U1, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_Ovf_I2 = new OpCode(OpCodeValues.Conv_Ovf_I2, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_Ovf_U2 = new OpCode(OpCodeValues.Conv_Ovf_U2, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_Ovf_I4 = new OpCode(OpCodeValues.Conv_Ovf_I4, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_Ovf_U4 = new OpCode(OpCodeValues.Conv_Ovf_U4, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_Ovf_I8 = new OpCode(OpCodeValues.Conv_Ovf_I8, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_Ovf_U8 = new OpCode(OpCodeValues.Conv_Ovf_U8, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi8 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Refanyval = new OpCode(OpCodeValues.Refanyval, + ((int)OperandType.InlineType) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ckfinite = new OpCode(OpCodeValues.Ckfinite, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushr8 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Mkrefany = new OpCode(OpCodeValues.Mkrefany, + ((int)OperandType.InlineType) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Ldtoken = new OpCode(OpCodeValues.Ldtoken, + ((int)OperandType.InlineTok) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_U2 = new OpCode(OpCodeValues.Conv_U2, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_U1 = new OpCode(OpCodeValues.Conv_U1, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_I = new OpCode(OpCodeValues.Conv_I, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_Ovf_I = new OpCode(OpCodeValues.Conv_Ovf_I, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_Ovf_U = new OpCode(OpCodeValues.Conv_Ovf_U, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Add_Ovf = new OpCode(OpCodeValues.Add_Ovf, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Add_Ovf_Un = new OpCode(OpCodeValues.Add_Ovf_Un, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Mul_Ovf = new OpCode(OpCodeValues.Mul_Ovf, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Mul_Ovf_Un = new OpCode(OpCodeValues.Mul_Ovf_Un, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Sub_Ovf = new OpCode(OpCodeValues.Sub_Ovf, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Sub_Ovf_Un = new OpCode(OpCodeValues.Sub_Ovf_Un, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1_pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push1 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-1 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Endfinally = new OpCode(OpCodeValues.Endfinally, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Return << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + OpCode.EndsUncondJmpBlkFlag | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Leave = new OpCode(OpCodeValues.Leave, + ((int)OperandType.InlineBrTarget) | + ((int)FlowControl.Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + OpCode.EndsUncondJmpBlkFlag | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Leave_S = new OpCode(OpCodeValues.Leave_S, + ((int)OperandType.ShortInlineBrTarget) | + ((int)FlowControl.Branch << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop0 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + OpCode.EndsUncondJmpBlkFlag | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Stind_I = new OpCode(OpCodeValues.Stind_I, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Popi_popi << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Push0 << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (-2 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Conv_U = new OpCode(OpCodeValues.Conv_U, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Next << OpCode.FlowControlShift) | + ((int)OpCodeType.Primitive << OpCode.OpCodeTypeShift) | + ((int)StackBehaviour.Pop1 << OpCode.StackBehaviourPopShift) | + ((int)StackBehaviour.Pushi << OpCode.StackBehaviourPushShift) | + (1 << OpCode.SizeShift) | + (0 << OpCode.StackChangeShift) + ); + + public static readonly OpCode Prefix7 = new OpCode(OpCodeValues.Prefix7, + ((int)OperandType.InlineNone) | + ((int)FlowControl.Meta << OpCode.FlowControlShift) | + ((int)OpCodeType.Nternal << OpCode.OpCodeTypeShift) | + ((int |