From a56e30c8d33048216567753d9d3fefc2152af8ac Mon Sep 17 00:00:00 2001 From: Jiyoung Yun Date: Thu, 13 Apr 2017 14:17:19 +0900 Subject: Imported Upstream version 2.0.0.11353 --- .../src/System/Reflection/Emit/AQNBuilder.cs | 18 +- .../src/System/Reflection/Emit/AssemblyBuilder.cs | 155 +- .../Reflection/Emit/AssemblyBuilderAccess.cs | 5 +- .../System/Reflection/Emit/AssemblyBuilderData.cs | 126 +- .../System/Reflection/Emit/ConstructorBuilder.cs | 92 +- .../Reflection/Emit/CustomAttributeBuilder.cs | 88 +- .../System/Reflection/Emit/DynamicILGenerator.cs | 126 +- .../src/System/Reflection/Emit/DynamicMethod.cs | 484 +- .../src/System/Reflection/Emit/EnumBuilder.cs | 223 +- .../src/System/Reflection/Emit/EventBuilder.cs | 54 +- .../src/System/Reflection/Emit/EventToken.cs | 37 +- .../src/System/Reflection/Emit/FieldBuilder.cs | 77 +- .../src/System/Reflection/Emit/FieldToken.cs | 34 +- .../src/System/Reflection/Emit/FlowControl.cs | 30 +- .../Reflection/Emit/GenericTypeParameterBuilder.cs | 55 +- .../src/System/Reflection/Emit/ILGenerator.cs | 774 +-- .../src/System/Reflection/Emit/ISymWrapperCore.cs | 188 +- src/mscorlib/src/System/Reflection/Emit/Label.cs | 38 +- .../src/System/Reflection/Emit/LocalBuilder.cs | 44 +- .../src/System/Reflection/Emit/MethodBuilder.cs | 304 +- .../Reflection/Emit/MethodBuilderInstantiation.cs | 28 +- .../src/System/Reflection/Emit/MethodToken.cs | 30 +- .../src/System/Reflection/Emit/ModuleBuilder.cs | 267 +- .../System/Reflection/Emit/ModuleBuilderData.cs | 36 +- src/mscorlib/src/System/Reflection/Emit/OpCodes.cs | 5063 ++++++++++---------- src/mscorlib/src/System/Reflection/Emit/Opcode.cs | 271 +- .../src/System/Reflection/Emit/OpcodeType.cs | 24 +- .../src/System/Reflection/Emit/OperandType.cs | 48 +- .../src/System/Reflection/Emit/PEFileKinds.cs | 10 +- .../src/System/Reflection/Emit/ParameterBuilder.cs | 93 +- .../src/System/Reflection/Emit/ParameterToken.cs | 36 +- .../src/System/Reflection/Emit/PropertyBuilder.cs | 130 +- .../src/System/Reflection/Emit/PropertyToken.cs | 34 +- .../src/System/Reflection/Emit/SignatureHelper.cs | 308 +- .../src/System/Reflection/Emit/SignatureToken.cs | 36 +- .../src/System/Reflection/Emit/StackBehaviour.cs | 68 +- .../src/System/Reflection/Emit/StringToken.cs | 46 +- .../src/System/Reflection/Emit/SymbolMethod.cs | 66 +- .../src/System/Reflection/Emit/SymbolType.cs | 269 +- .../src/System/Reflection/Emit/TypeBuilder.cs | 614 +-- .../Reflection/Emit/TypeBuilderInstantiation.cs | 60 +- .../src/System/Reflection/Emit/TypeToken.cs | 40 +- .../Emit/XXXOnTypeBuilderInstantiation.cs | 56 +- 43 files changed, 5260 insertions(+), 5325 deletions(-) (limited to 'src/mscorlib/src/System/Reflection/Emit') 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 nestings = new List(); 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() != 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() != 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() != 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 m_moduleBuilderList; - internal List m_resWriterList; - internal String m_strAssemblyName; - internal AssemblyBuilderAccess m_access; + + internal List m_moduleBuilderList; + internal List 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.Value); + CustomAttributeBuilder transparencyAttribute = new CustomAttributeBuilder(transparencyCtor, Array.Empty()); List assemblyAttributes = new List(); 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(); } - + // 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.Value; + return Array.Empty(); } - 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.Value; + Object[] ICustomAttributeProvider.GetCustomAttributes(Type attributeType, bool inherit) + { + return Array.Empty(); } - Object[] ICustomAttributeProvider.GetCustomAttributes(bool inherit) { - return EmptyArray.Value; + Object[] ICustomAttributeProvider.GetCustomAttributes(bool inherit) + { + return Array.Empty(); } - 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[] incoming, int requiredSize) { Contract.Requires(incoming != null); Contract.Ensures(Contract.Result() != null); Contract.Ensures(Contract.Result().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() != null); Contract.Ensures(Contract.Result().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.Value; + m_parameterTypes = Array.Empty(); 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.Value; + m_parameterTypes = Array.Empty(); - 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 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() != 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() != 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 optionalParameterTypes, int cGenericParameters) + Type[] parameterTypes, IEnumerable 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() != 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() != 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() != 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() != 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() != 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() != null); - lock(SyncRoot) + lock (SyncRoot) { return DefineTypeNoLock(name, attr, parent, packsize); } @@ -979,7 +943,7 @@ namespace System.Reflection.Emit Contract.Ensures(Contract.Result() != 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() != 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() != 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() != 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() != 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() != 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() != 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 { - -/// -/// -/// The IL instruction opcodes supported by the -/// runtime. The IL Instruction Specification describes each -/// Opcode. -/// -/// -/// - - 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) + /// + /// + /// The IL instruction opcodes supported by the + /// runtime. The IL Instruction Specification describes each + /// Opcode. + /// + /// + /// + + 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)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) + { + switch (inst.OperandType) + { + case OperandType.ShortInlineBrTarget: + case OperandType.ShortInlineI: + case OperandType.ShortInlineVar: + return true; + }; + return false; + } } } -} diff --git a/src/mscorlib/src/System/Reflection/Emit/Opcode.cs b/src/mscorlib/src/System/Reflection/Emit/Opcode.cs index 74a9de16b6..37768be9d7 100644 --- a/src/mscorlib/src/System/Reflection/Emit/Opcode.cs +++ b/src/mscorlib/src/System/Reflection/Emit/Opcode.cs @@ -2,191 +2,196 @@ // 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.Emit { using System; using System.Threading; using System.Diagnostics.Contracts; -public struct OpCode +namespace System.Reflection.Emit { - // - // Use packed bitfield for flags to avoid code bloat - // - - internal const int OperandTypeMask = 0x1F; // 000000000000000000000000000XXXXX - - internal const int FlowControlShift = 5; // 00000000000000000000000XXXX00000 - internal const int FlowControlMask = 0x0F; + public struct OpCode + { + // + // Use packed bitfield for flags to avoid code bloat + // - internal const int OpCodeTypeShift = 9; // 00000000000000000000XXX000000000 - internal const int OpCodeTypeMask = 0x07; + internal const int OperandTypeMask = 0x1F; // 000000000000000000000000000XXXXX - internal const int StackBehaviourPopShift = 12; // 000000000000000XXXXX000000000000 - internal const int StackBehaviourPushShift = 17; // 0000000000XXXXX00000000000000000 - internal const int StackBehaviourMask = 0x1F; + internal const int FlowControlShift = 5; // 00000000000000000000000XXXX00000 + internal const int FlowControlMask = 0x0F; - internal const int SizeShift = 22; // 00000000XX0000000000000000000000 - internal const int SizeMask = 0x03; + internal const int OpCodeTypeShift = 9; // 00000000000000000000XXX000000000 + internal const int OpCodeTypeMask = 0x07; - internal const int EndsUncondJmpBlkFlag = 0x01000000; // 0000000X000000000000000000000000 + internal const int StackBehaviourPopShift = 12; // 000000000000000XXXXX000000000000 + internal const int StackBehaviourPushShift = 17; // 0000000000XXXXX00000000000000000 + internal const int StackBehaviourMask = 0x1F; - // unused // 0000XXX0000000000000000000000000 + internal const int SizeShift = 22; // 00000000XX0000000000000000000000 + internal const int SizeMask = 0x03; - internal const int StackChangeShift = 28; // XXXX0000000000000000000000000000 + internal const int EndsUncondJmpBlkFlag = 0x01000000; // 0000000X000000000000000000000000 - private OpCodeValues m_value; - private int m_flags; + // unused // 0000XXX0000000000000000000000000 - internal OpCode(OpCodeValues value, int flags) - { - m_value = value; - m_flags = flags; - } + internal const int StackChangeShift = 28; // XXXX0000000000000000000000000000 - internal bool EndsUncondJmpBlk() - { - return (m_flags & EndsUncondJmpBlkFlag) != 0; - } - - internal int StackChange() - { - return (m_flags >> StackChangeShift); - } + private OpCodeValues m_value; + private int m_flags; - public OperandType OperandType - { - get + internal OpCode(OpCodeValues value, int flags) { - return (OperandType)(m_flags & OperandTypeMask); + m_value = value; + m_flags = flags; } - } - public FlowControl FlowControl - { - get + internal bool EndsUncondJmpBlk() { - return (FlowControl)((m_flags >> FlowControlShift) & FlowControlMask); + return (m_flags & EndsUncondJmpBlkFlag) != 0; } - } - public OpCodeType OpCodeType - { - get + internal int StackChange() { - return (OpCodeType)((m_flags >> OpCodeTypeShift) & OpCodeTypeMask); + return (m_flags >> StackChangeShift); } - } - public StackBehaviour StackBehaviourPop - { - get + public OperandType OperandType { - return (StackBehaviour)((m_flags >> StackBehaviourPopShift) & StackBehaviourMask); + get + { + return (OperandType)(m_flags & OperandTypeMask); + } } - } - public StackBehaviour StackBehaviourPush - { - get + public FlowControl FlowControl { - return (StackBehaviour)((m_flags >> StackBehaviourPushShift) & StackBehaviourMask); + get + { + return (FlowControl)((m_flags >> FlowControlShift) & FlowControlMask); + } } - } - public int Size - { - get + public OpCodeType OpCodeType { - return (m_flags >> SizeShift) & SizeMask; + get + { + return (OpCodeType)((m_flags >> OpCodeTypeShift) & OpCodeTypeMask); + } } - } - public short Value - { - get + public StackBehaviour StackBehaviourPop { - return (short)m_value; + get + { + return (StackBehaviour)((m_flags >> StackBehaviourPopShift) & StackBehaviourMask); + } } - } - private static volatile string[] g_nameCache; + public StackBehaviour StackBehaviourPush + { + get + { + return (StackBehaviour)((m_flags >> StackBehaviourPushShift) & StackBehaviourMask); + } + } - public String Name - { - get + public int Size { - if (Size == 0) - return null; + get + { + return (m_flags >> SizeShift) & SizeMask; + } + } - // Create and cache the opcode names lazily. They should be rarely used (only for logging, etc.) - // Note that we do not any locks here because of we always get the same names. The last one wins. - string[] nameCache = g_nameCache; - if (nameCache == null) { - nameCache = new String[0x11f]; - g_nameCache = nameCache; + public short Value + { + get + { + return (short)m_value; } + } - OpCodeValues opCodeValue = (OpCodeValues)(ushort)Value; + private static volatile string[] g_nameCache; - int idx = (int)opCodeValue; - if (idx > 0xFF) { - if (idx >= 0xfe00 && idx <= 0xfe1e) { - // Transform two byte opcode value to lower range that's suitable - // for array index - idx = 0x100 + (idx - 0xfe00); - } - else { - // Unknown opcode + public String Name + { + get + { + if (Size == 0) return null; + + // Create and cache the opcode names lazily. They should be rarely used (only for logging, etc.) + // Note that we do not any locks here because of we always get the same names. The last one wins. + string[] nameCache = g_nameCache; + if (nameCache == null) + { + nameCache = new String[0x11f]; + g_nameCache = nameCache; } - } - String name = Volatile.Read(ref nameCache[idx]); - if (name != null) - return name; + OpCodeValues opCodeValue = (OpCodeValues)(ushort)Value; + + int idx = (int)opCodeValue; + if (idx > 0xFF) + { + if (idx >= 0xfe00 && idx <= 0xfe1e) + { + // Transform two byte opcode value to lower range that's suitable + // for array index + idx = 0x100 + (idx - 0xfe00); + } + else + { + // Unknown opcode + return null; + } + } - // Create ilasm style name from the enum value name. - name = Enum.GetName(typeof(OpCodeValues), opCodeValue).ToLowerInvariant().Replace("_", "."); - Volatile.Write(ref nameCache[idx], name); - return name; + String name = Volatile.Read(ref nameCache[idx]); + if (name != null) + return name; + + // Create ilasm style name from the enum value name. + name = Enum.GetName(typeof(OpCodeValues), opCodeValue).ToLowerInvariant().Replace("_", "."); + Volatile.Write(ref nameCache[idx], name); + return name; + } } - } - [Pure] - public override bool Equals(Object obj) - { - if (obj is OpCode) - return Equals((OpCode)obj); - else - return false; - } + [Pure] + public override bool Equals(Object obj) + { + if (obj is OpCode) + return Equals((OpCode)obj); + else + return false; + } - [Pure] - public bool Equals(OpCode obj) - { - return obj.Value == Value; - } + [Pure] + public bool Equals(OpCode obj) + { + return obj.Value == Value; + } - [Pure] - public static bool operator ==(OpCode a, OpCode b) - { - return a.Equals(b); - } + [Pure] + public static bool operator ==(OpCode a, OpCode b) + { + return a.Equals(b); + } - [Pure] - public static bool operator !=(OpCode a, OpCode b) - { - return !(a == b); - } + [Pure] + public static bool operator !=(OpCode a, OpCode b) + { + return !(a == b); + } - public override int GetHashCode() - { - return Value; - } + public override int GetHashCode() + { + return Value; + } - public override String ToString() - { - return Name; + public override String ToString() + { + return Name; + } } } -} diff --git a/src/mscorlib/src/System/Reflection/Emit/OpcodeType.cs b/src/mscorlib/src/System/Reflection/Emit/OpcodeType.cs index 87dea058e5..2363d607fc 100644 --- a/src/mscorlib/src/System/Reflection/Emit/OpcodeType.cs +++ b/src/mscorlib/src/System/Reflection/Emit/OpcodeType.cs @@ -12,20 +12,20 @@ ** THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT BY HAND! ** See opcodegen.pl for more information.** ============================================================*/ -namespace System.Reflection.Emit { using System; -[Serializable] -public enum OpCodeType +namespace System.Reflection.Emit { - - [Obsolete("This API has been deprecated. http://go.microsoft.com/fwlink/?linkid=14202")] - Annotation = 0, - Macro = 1, - Nternal = 2, - Objmodel = 3, - Prefix = 4, - Primitive = 5, -} + [Serializable] + public enum OpCodeType + { + [Obsolete("This API has been deprecated. http://go.microsoft.com/fwlink/?linkid=14202")] + Annotation = 0, + Macro = 1, + Nternal = 2, + Objmodel = 3, + Prefix = 4, + Primitive = 5, + } } diff --git a/src/mscorlib/src/System/Reflection/Emit/OperandType.cs b/src/mscorlib/src/System/Reflection/Emit/OperandType.cs index e972e8603d..033539b999 100644 --- a/src/mscorlib/src/System/Reflection/Emit/OperandType.cs +++ b/src/mscorlib/src/System/Reflection/Emit/OperandType.cs @@ -12,32 +12,32 @@ ** THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT BY HAND! ** See opcodegen.pl for more information.** ============================================================*/ -namespace System.Reflection.Emit { using System; -[Serializable] -public enum OperandType +namespace System.Reflection.Emit { - - InlineBrTarget = 0, - InlineField = 1, - InlineI = 2, - InlineI8 = 3, - InlineMethod = 4, - InlineNone = 5, - [Obsolete("This API has been deprecated. http://go.microsoft.com/fwlink/?linkid=14202")] - InlinePhi = 6, - InlineR = 7, - InlineSig = 9, - InlineString = 10, - InlineSwitch = 11, - InlineTok = 12, - InlineType = 13, - InlineVar = 14, - ShortInlineBrTarget = 15, - ShortInlineI = 16, - ShortInlineR = 17, - ShortInlineVar = 18, -} + [Serializable] + public enum OperandType + { + InlineBrTarget = 0, + InlineField = 1, + InlineI = 2, + InlineI8 = 3, + InlineMethod = 4, + InlineNone = 5, + [Obsolete("This API has been deprecated. http://go.microsoft.com/fwlink/?linkid=14202")] + InlinePhi = 6, + InlineR = 7, + InlineSig = 9, + InlineString = 10, + InlineSwitch = 11, + InlineTok = 12, + InlineType = 13, + InlineVar = 14, + ShortInlineBrTarget = 15, + ShortInlineI = 16, + ShortInlineR = 17, + ShortInlineVar = 18, + } } diff --git a/src/mscorlib/src/System/Reflection/Emit/PEFileKinds.cs b/src/mscorlib/src/System/Reflection/Emit/PEFileKinds.cs index 531ff41dd7..f9246fce6d 100644 --- a/src/mscorlib/src/System/Reflection/Emit/PEFileKinds.cs +++ b/src/mscorlib/src/System/Reflection/Emit/PEFileKinds.cs @@ -2,14 +2,16 @@ // 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.Emit { - - using System; + +using System; + +namespace System.Reflection.Emit +{ // This Enum matchs the CorFieldAttr defined in CorHdr.h [Serializable] public enum PEFileKinds { - Dll = 0x0001, + Dll = 0x0001, ConsoleApplication = 0x0002, WindowApplication = 0x0003, } diff --git a/src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs index 1b3babf595..636825956a 100644 --- a/src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/ParameterBuilder.cs @@ -12,17 +12,18 @@ ** ** ===========================================================*/ -namespace System.Reflection.Emit { - using System.Runtime.InteropServices; - using System; - using System.Reflection; - using System.Diagnostics.Contracts; +using System.Runtime.InteropServices; +using System; +using System.Reflection; +using System.Diagnostics.Contracts; + +namespace System.Reflection.Emit +{ public class ParameterBuilder { - // Set the default value of the parameter - public virtual void SetConstant(Object defaultValue) + public virtual void SetConstant(Object defaultValue) { TypeBuilder.SetConstantValue( m_methodBuilder.GetModuleBuilder(), @@ -30,7 +31,7 @@ namespace System.Reflection.Emit { m_iPosition == 0 ? m_methodBuilder.ReturnType : m_methodBuilder.m_parameterTypes[m_iPosition - 1], defaultValue); } - + // Use this function if client decides to form the custom attribute blob themselves public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) @@ -44,7 +45,7 @@ namespace System.Reflection.Emit { TypeBuilder.DefineCustomAttribute( m_methodBuilder.GetModuleBuilder(), m_pdToken.Token, - ((ModuleBuilder )m_methodBuilder.GetModule()).GetConstructorToken(con).Token, + ((ModuleBuilder)m_methodBuilder.GetModule()).GetConstructorToken(con).Token, binaryAttribute, false, false); } @@ -57,65 +58,71 @@ namespace System.Reflection.Emit { throw new ArgumentNullException(nameof(customBuilder)); } Contract.EndContractBlock(); - customBuilder.CreateCustomAttribute((ModuleBuilder) (m_methodBuilder .GetModule()), m_pdToken.Token); + customBuilder.CreateCustomAttribute((ModuleBuilder)(m_methodBuilder.GetModule()), m_pdToken.Token); } - + //******************************* // Make a private constructor so these cannot be constructed externally. //******************************* - private ParameterBuilder() {} + private ParameterBuilder() { } internal ParameterBuilder( - MethodBuilder methodBuilder, - int sequence, - ParameterAttributes attributes, - String strParamName) // can be NULL string + MethodBuilder methodBuilder, + int sequence, + ParameterAttributes attributes, + String strParamName) // can be NULL string { m_iPosition = sequence; m_strParamName = strParamName; m_methodBuilder = methodBuilder; m_strParamName = strParamName; m_attributes = attributes; - m_pdToken = new ParameterToken( TypeBuilder.SetParamInfo( + m_pdToken = new ParameterToken(TypeBuilder.SetParamInfo( m_methodBuilder.GetModuleBuilder().GetNativeHandle(), - m_methodBuilder.GetToken().Token, - sequence, - attributes, + m_methodBuilder.GetToken().Token, + sequence, + attributes, strParamName)); } - + public virtual ParameterToken GetToken() { return m_pdToken; - } - - public virtual String Name { - get {return m_strParamName;} } - - public virtual int Position { - get {return m_iPosition;} + + public virtual String Name + { + get { return m_strParamName; } + } + + public virtual int Position + { + get { return m_iPosition; } } - - public virtual int Attributes { - get {return (int) m_attributes;} + + public virtual int Attributes + { + get { return (int)m_attributes; } } - - public bool IsIn { - get {return ((m_attributes & ParameterAttributes.In) != 0);} + + public bool IsIn + { + get { return ((m_attributes & ParameterAttributes.In) != 0); } } - public bool IsOut { - get {return ((m_attributes & ParameterAttributes.Out) != 0);} + public bool IsOut + { + get { return ((m_attributes & ParameterAttributes.Out) != 0); } } - public bool IsOptional { - get {return ((m_attributes & ParameterAttributes.Optional) != 0);} + public bool IsOptional + { + get { return ((m_attributes & ParameterAttributes.Optional) != 0); } } - - private String m_strParamName; - private int m_iPosition; + + private String m_strParamName; + private int m_iPosition; private ParameterAttributes m_attributes; - private MethodBuilder m_methodBuilder; - private ParameterToken m_pdToken; + private MethodBuilder m_methodBuilder; + private ParameterToken m_pdToken; } } diff --git a/src/mscorlib/src/System/Reflection/Emit/ParameterToken.cs b/src/mscorlib/src/System/Reflection/Emit/ParameterToken.cs index a4a32a51fb..42f85af464 100644 --- a/src/mscorlib/src/System/Reflection/Emit/ParameterToken.cs +++ b/src/mscorlib/src/System/Reflection/Emit/ParameterToken.cs @@ -12,33 +12,36 @@ ** ** ===========================================================*/ -namespace System.Reflection.Emit { - - using System; - using System.Reflection; +using System; +using System.Reflection; + +namespace System.Reflection.Emit +{ // The ParameterToken class is an opaque representation of the Token returned // by the Metadata to represent the parameter. [Serializable] - public struct ParameterToken { - + public struct ParameterToken + { public static readonly ParameterToken Empty = new ParameterToken(); internal int m_tkParameter; - - - internal ParameterToken(int tkParam) { + + + internal ParameterToken(int tkParam) + { m_tkParameter = tkParam; } - - public int Token { + + public int Token + { get { return m_tkParameter; } } - + public override int GetHashCode() { return m_tkParameter; } - + public override bool Equals(Object obj) { if (obj is ParameterToken) @@ -46,21 +49,20 @@ namespace System.Reflection.Emit { else return false; } - + public bool Equals(ParameterToken obj) { return obj.m_tkParameter == m_tkParameter; } - + public static bool operator ==(ParameterToken a, ParameterToken b) { return a.Equals(b); } - + public static bool operator !=(ParameterToken a, ParameterToken b) { return !(a == b); } - } } diff --git a/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs index 7c4ed9dc0f..6dbcba251f 100644 --- a/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs @@ -12,8 +12,9 @@ ** ** ===========================================================*/ -namespace System.Reflection.Emit { - + +namespace System.Reflection.Emit +{ using System; using System.Reflection; using CultureInfo = System.Globalization.CultureInfo; @@ -25,30 +26,29 @@ namespace System.Reflection.Emit { // method will return a new PropertyBuilder to a client. // public sealed class PropertyBuilder : PropertyInfo - { - + { // Make a private constructor so these cannot be constructed externally. - private PropertyBuilder() {} - + private PropertyBuilder() { } + // Constructs a PropertyBuilder. // internal PropertyBuilder( - ModuleBuilder mod, // the module containing this PropertyBuilder - String name, // property name - SignatureHelper sig, // property signature descriptor info - PropertyAttributes attr, // property attribute such as DefaultProperty, Bindable, DisplayBind, etc - Type returnType, // return type of the property. - PropertyToken prToken, // the metadata token for this property - TypeBuilder containingType) // the containing type + ModuleBuilder mod, // the module containing this PropertyBuilder + String name, // property name + SignatureHelper sig, // property signature descriptor info + PropertyAttributes attr, // property attribute such as DefaultProperty, Bindable, DisplayBind, etc + Type returnType, // return type of the property. + PropertyToken prToken, // the metadata token for this property + TypeBuilder containingType) // the containing type { 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)); Contract.EndContractBlock(); - + m_name = name; m_moduleBuilder = mod; m_signature = sig; @@ -58,32 +58,32 @@ namespace System.Reflection.Emit { m_tkProperty = prToken.Token; m_containingType = containingType; } - + //************************************************ // Set the default value of the Property //************************************************ - public void SetConstant(Object defaultValue) + public void SetConstant(Object defaultValue) { m_containingType.ThrowIfCreated(); - + TypeBuilder.SetConstantValue( m_moduleBuilder, m_prToken.Token, m_returnType, defaultValue); } - + // Return the Token for this property within the TypeBuilder that the // property is defined within. public PropertyToken PropertyToken { - get {return m_prToken;} + get { return m_prToken; } } - + public override Module Module { - get + get { return m_containingType.Module; } @@ -102,25 +102,25 @@ namespace System.Reflection.Emit { m_prToken.Token, semantics, mdBuilder.GetToken().Token); - } + } public void SetGetMethod(MethodBuilder mdBuilder) { SetMethodSemantics(mdBuilder, MethodSemanticsAttributes.Getter); m_getMethod = mdBuilder; } - + public void SetSetMethod(MethodBuilder mdBuilder) { SetMethodSemantics(mdBuilder, MethodSemanticsAttributes.Setter); - m_setMethod = mdBuilder; + m_setMethod = mdBuilder; } 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) @@ -129,7 +129,7 @@ namespace System.Reflection.Emit { throw new ArgumentNullException(nameof(con)); if (binaryAttribute == null) throw new ArgumentNullException(nameof(binaryAttribute)); - + m_containingType.ThrowIfCreated(); TypeBuilder.DefineCustomAttribute( m_moduleBuilder, @@ -151,29 +151,29 @@ namespace System.Reflection.Emit { } // Not supported functions in dynamic module. - public override Object GetValue(Object obj,Object[] index) + public override Object GetValue(Object obj, Object[] index) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } - public override Object GetValue(Object obj,BindingFlags invokeAttr,Binder binder,Object[] index,CultureInfo culture) + public override Object GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } - public override void SetValue(Object obj,Object value,Object[] index) + public override void SetValue(Object obj, Object value, Object[] index) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } - public override void SetValue(Object obj,Object value,BindingFlags invokeAttr,Binder binder,Object[] index,CultureInfo culture) + public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } public override MethodInfo[] GetAccessors(bool nonPublic) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } public override MethodInfo GetGetMethod(bool nonPublic) @@ -198,61 +198,69 @@ namespace System.Reflection.Emit { public override ParameterInfo[] GetIndexParameters() { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } - public override Type PropertyType { + public override Type PropertyType + { get { return m_returnType; } } - public override PropertyAttributes Attributes { - get { return m_attributes;} + public override PropertyAttributes Attributes + { + get { return m_attributes; } } - public override bool CanRead { - get { if (m_getMethod != null) return true; else return false; } } + public override bool CanRead + { + get { if (m_getMethod != null) return true; else return false; } + } - public override bool CanWrite { + public override bool CanWrite + { get { if (m_setMethod != null) return true; else return false; } } 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) + public override bool IsDefined(Type attributeType, bool inherit) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } - public override String Name { + public override String Name + { get { return m_name; } } - public override Type DeclaringType { + public override Type DeclaringType + { get { return m_containingType; } } - public override Type ReflectedType { + public override Type ReflectedType + { get { return m_containingType; } } // These are package private so that TypeBuilder can access them. - private String m_name; // The name of the property - private PropertyToken m_prToken; // The token of this property - private int m_tkProperty; - private ModuleBuilder m_moduleBuilder; - private SignatureHelper m_signature; - private PropertyAttributes m_attributes; // property's attribute flags - private Type m_returnType; // property's return type - private MethodInfo m_getMethod; - private MethodInfo m_setMethod; - private TypeBuilder m_containingType; + private String m_name; // The name of the property + private PropertyToken m_prToken; // The token of this property + private int m_tkProperty; + private ModuleBuilder m_moduleBuilder; + private SignatureHelper m_signature; + private PropertyAttributes m_attributes; // property's attribute flags + private Type m_returnType; // property's return type + private MethodInfo m_getMethod; + private MethodInfo m_setMethod; + private TypeBuilder m_containingType; } } diff --git a/src/mscorlib/src/System/Reflection/Emit/PropertyToken.cs b/src/mscorlib/src/System/Reflection/Emit/PropertyToken.cs index 72ab983bb9..b450b198d2 100644 --- a/src/mscorlib/src/System/Reflection/Emit/PropertyToken.cs +++ b/src/mscorlib/src/System/Reflection/Emit/PropertyToken.cs @@ -12,26 +12,29 @@ ** ** ===========================================================*/ -namespace System.Reflection.Emit { - - using System; - using System.Reflection; +using System; +using System.Reflection; + +namespace System.Reflection.Emit +{ [Serializable] - public struct PropertyToken { - + public struct PropertyToken + { public static readonly PropertyToken Empty = new PropertyToken(); internal int m_property; - internal PropertyToken(int str) { - m_property=str; + internal PropertyToken(int str) + { + m_property = str; } - - public int Token { + + public int Token + { get { return m_property; } } - + // Satisfy value class requirements public override int GetHashCode() { @@ -46,23 +49,20 @@ namespace System.Reflection.Emit { else return false; } - + public bool Equals(PropertyToken obj) { return obj.m_property == m_property; } - + public static bool operator ==(PropertyToken a, PropertyToken b) { return a.Equals(b); } - + public static bool operator !=(PropertyToken a, PropertyToken b) { return !(a == b); } - } - - } diff --git a/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs b/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs index b43abcb51c..fd1a8e70fe 100644 --- a/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs +++ b/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs @@ -4,23 +4,23 @@ // -namespace System.Reflection.Emit +using System.Text; +using System; +using System.Diagnostics; +using System.Diagnostics.Contracts; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Versioning; + +namespace System.Reflection.Emit { - using System.Text; - using System; - using System.Diagnostics; - using System.Diagnostics.Contracts; - using System.Reflection; - using System.Runtime.CompilerServices; - using System.Runtime.InteropServices; - using System.Runtime.Versioning; - public sealed class SignatureHelper { #region Consts Fields private const int NO_SIZE_IN_SIG = -1; #endregion - + #region Static Members public static SignatureHelper GetMethodSigHelper(Module mod, Type returnType, Type[] parameterTypes) { @@ -31,7 +31,7 @@ namespace System.Reflection.Emit { return GetMethodSigHelper(mod, callingConvention, cGenericParam, returnType, null, null, null, null, null); } - + public static SignatureHelper GetMethodSigHelper(Module mod, CallingConventions callingConvention, Type returnType) { return GetMethodSigHelper(mod, callingConvention, returnType, null, null, null, null, null); @@ -41,17 +41,17 @@ namespace System.Reflection.Emit { SignatureHelper sigHelp = new SignatureHelper(scope, MdSigCallingConvention.GenericInst); sigHelp.AddData(inst.Length); - foreach(Type t in inst) + foreach (Type t in inst) sigHelp.AddArgument(t); return sigHelp; } - + internal static SignatureHelper GetMethodSigHelper( Module scope, CallingConventions callingConvention, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { - return GetMethodSigHelper(scope, callingConvention, 0, returnType, requiredReturnTypeCustomModifiers, + return GetMethodSigHelper(scope, callingConvention, 0, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers, parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers); } @@ -62,11 +62,11 @@ namespace System.Reflection.Emit { SignatureHelper sigHelp; MdSigCallingConvention intCall; - + if (returnType == null) { returnType = typeof(void); - } + } intCall = MdSigCallingConvention.Default; @@ -81,8 +81,8 @@ namespace System.Reflection.Emit if ((callingConvention & CallingConventions.HasThis) == CallingConventions.HasThis) intCall |= MdSigCallingConvention.HasThis; - sigHelp = new SignatureHelper(scope, intCall, cGenericParam, returnType, - requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers); + sigHelp = new SignatureHelper(scope, intCall, cGenericParam, returnType, + requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers); sigHelp.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers); return sigHelp; @@ -92,7 +92,7 @@ namespace System.Reflection.Emit { SignatureHelper sigHelp; MdSigCallingConvention intCall; - + if (returnType == null) returnType = typeof(void); @@ -114,19 +114,19 @@ namespace System.Reflection.Emit } else { - throw new ArgumentException(Environment.GetResourceString("Argument_UnknownUnmanagedCallConv"), nameof(unmanagedCallConv)); + throw new ArgumentException(SR.Argument_UnknownUnmanagedCallConv, nameof(unmanagedCallConv)); } - + sigHelp = new SignatureHelper(mod, intCall, returnType, null, null); - + return sigHelp; } public static SignatureHelper GetLocalVarSigHelper() - { + { return GetLocalVarSigHelper(null); } - + public static SignatureHelper GetMethodSigHelper(CallingConventions callingConvention, Type returnType) { return GetMethodSigHelper(null, callingConvention, returnType); @@ -141,47 +141,47 @@ namespace System.Reflection.Emit { return new SignatureHelper(mod, MdSigCallingConvention.LocalSig); } - + public static SignatureHelper GetFieldSigHelper(Module mod) { return new SignatureHelper(mod, MdSigCallingConvention.Field); } - + public static SignatureHelper GetPropertySigHelper(Module mod, Type returnType, Type[] parameterTypes) { return GetPropertySigHelper(mod, returnType, null, null, parameterTypes, null, null); } - public static SignatureHelper GetPropertySigHelper(Module mod, - Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, + public static SignatureHelper GetPropertySigHelper(Module mod, + Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { - return GetPropertySigHelper(mod, (CallingConventions)0, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers, + return GetPropertySigHelper(mod, (CallingConventions)0, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers, parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers); } public static SignatureHelper GetPropertySigHelper(Module mod, CallingConventions callingConvention, - Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, + Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { SignatureHelper sigHelp; - + if (returnType == null) { returnType = typeof(void); - } + } MdSigCallingConvention intCall = MdSigCallingConvention.Property; if ((callingConvention & CallingConventions.HasThis) == CallingConventions.HasThis) intCall |= MdSigCallingConvention.HasThis; - sigHelp = new SignatureHelper(mod, intCall, + sigHelp = new SignatureHelper(mod, intCall, returnType, requiredReturnTypeCustomModifiers, optionalReturnTypeCustomModifiers); sigHelp.AddArguments(parameterTypes, requiredParameterTypeCustomModifiers, optionalParameterTypeCustomModifiers); return sigHelp; } - + internal static SignatureHelper GetTypeSigToken(Module module, Type type) { if (module == null) @@ -216,13 +216,13 @@ namespace System.Reflection.Emit // Use this constructor to instantiate a any signatures that will require a return type. Init(mod, callingConvention, cGenericParameters); - if (callingConvention == MdSigCallingConvention.Field) - throw new ArgumentException(Environment.GetResourceString("Argument_BadFieldSig")); + if (callingConvention == MdSigCallingConvention.Field) + throw new ArgumentException(SR.Argument_BadFieldSig); - AddOneArgTypeHelper(returnType, requiredCustomModifiers, optionalCustomModifiers); + AddOneArgTypeHelper(returnType, requiredCustomModifiers, optionalCustomModifiers); } - private SignatureHelper(Module mod, MdSigCallingConvention callingConvention, + private SignatureHelper(Module mod, MdSigCallingConvention callingConvention, Type returnType, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) : this(mod, callingConvention, 0, returnType, requiredCustomModifiers, optionalCustomModifiers) { @@ -244,31 +244,31 @@ namespace System.Reflection.Emit m_sigDone = false; m_sizeLoc = NO_SIZE_IN_SIG; - if (m_module == null && mod != null) - throw new ArgumentException(Environment.GetResourceString("NotSupported_MustBeModuleBuilder")); + if (m_module == null && mod != null) + throw new ArgumentException(SR.NotSupported_MustBeModuleBuilder); } private void Init(Module mod, MdSigCallingConvention callingConvention) { Init(mod, callingConvention, 0); } - + private void Init(Module mod, MdSigCallingConvention callingConvention, int cGenericParam) - { + { Init(mod); AddData((byte)callingConvention); if (callingConvention == MdSigCallingConvention.Field || - callingConvention == MdSigCallingConvention.GenericInst) + callingConvention == MdSigCallingConvention.GenericInst) { m_sizeLoc = NO_SIZE_IN_SIG; - } - else + } + else { if (cGenericParam > 0) AddData(cGenericParam); - + m_sizeLoc = m_currSig++; } } @@ -302,10 +302,10 @@ namespace System.Reflection.Emit throw new ArgumentNullException(nameof(optionalCustomModifiers)); if (t.HasElementType) - throw new ArgumentException(Environment.GetResourceString("Argument_ArraysInvalid"), nameof(optionalCustomModifiers)); + throw new ArgumentException(SR.Argument_ArraysInvalid, nameof(optionalCustomModifiers)); if (t.ContainsGenericParameters) - throw new ArgumentException(Environment.GetResourceString("Argument_GenericsInvalid"), nameof(optionalCustomModifiers)); + throw new ArgumentException(SR.Argument_GenericsInvalid, nameof(optionalCustomModifiers)); AddElementType(CorElementType.CModOpt); @@ -325,10 +325,10 @@ namespace System.Reflection.Emit throw new ArgumentNullException(nameof(requiredCustomModifiers)); if (t.HasElementType) - throw new ArgumentException(Environment.GetResourceString("Argument_ArraysInvalid"), nameof(requiredCustomModifiers)); + throw new ArgumentException(SR.Argument_ArraysInvalid, nameof(requiredCustomModifiers)); if (t.ContainsGenericParameters) - throw new ArgumentException(Environment.GetResourceString("Argument_GenericsInvalid"), nameof(requiredCustomModifiers)); + throw new ArgumentException(SR.Argument_GenericsInvalid, nameof(requiredCustomModifiers)); AddElementType(CorElementType.CModReqd); @@ -425,7 +425,7 @@ namespace System.Reflection.Emit } else if (clsArgument.IsArray) { - if (clsArgument.IsSzArray) + if (clsArgument.IsSZArray) { AddElementType(CorElementType.SzArray); @@ -482,7 +482,7 @@ namespace System.Reflection.Emit } } } - + private void AddData(int data) { // A managed representation of CorSigCompressData; @@ -491,80 +491,79 @@ namespace System.Reflection.Emit { m_signature = ExpandArray(m_signature); } - + if (data <= 0x7F) { m_signature[m_currSig++] = (byte)(data & 0xFF); - } + } else if (data <= 0x3FFF) { - m_signature[m_currSig++] = (byte)((data >>8) | 0x80); + m_signature[m_currSig++] = (byte)((data >> 8) | 0x80); m_signature[m_currSig++] = (byte)(data & 0xFF); - } + } else if (data <= 0x1FFFFFFF) { - m_signature[m_currSig++] = (byte)((data >>24) | 0xC0); - m_signature[m_currSig++] = (byte)((data >>16) & 0xFF); - m_signature[m_currSig++] = (byte)((data >>8) & 0xFF); + m_signature[m_currSig++] = (byte)((data >> 24) | 0xC0); + m_signature[m_currSig++] = (byte)((data >> 16) & 0xFF); + m_signature[m_currSig++] = (byte)((data >> 8) & 0xFF); m_signature[m_currSig++] = (byte)((data) & 0xFF); - } + } else { - throw new ArgumentException(Environment.GetResourceString("Argument_LargeInteger")); - } - + throw new ArgumentException(SR.Argument_LargeInteger); + } } - + private void AddElementType(CorElementType cvt) { // Adds an element to the signature. A managed represenation of CorSigCompressElement - if (m_currSig + 1 > m_signature.Length) + if (m_currSig + 1 > m_signature.Length) m_signature = ExpandArray(m_signature); m_signature[m_currSig++] = (byte)cvt; } - - private void AddToken(int token) + + private void AddToken(int token) { // A managed represenation of CompressToken // Pulls the token appart to get a rid, adds some appropriate bits // to the token and then adds this to the signature. - int rid = (token & 0x00FFFFFF); //This is RidFromToken; + int rid = (token & 0x00FFFFFF); //This is RidFromToken; MetadataTokenType type = (MetadataTokenType)(token & unchecked((int)0xFF000000)); //This is TypeFromToken; - - if (rid > 0x3FFFFFF) + + if (rid > 0x3FFFFFF) { // token is too big to be compressed - throw new ArgumentException(Environment.GetResourceString("Argument_LargeInteger")); + throw new ArgumentException(SR.Argument_LargeInteger); } - - rid = (rid << 2); - + + rid = (rid << 2); + // TypeDef is encoded with low bits 00 // TypeRef is encoded with low bits 01 // TypeSpec is encoded with low bits 10 - if (type == MetadataTokenType.TypeRef) - { + if (type == MetadataTokenType.TypeRef) + { //if type is mdtTypeRef - rid|=0x1; - } - else if (type == MetadataTokenType.TypeSpec) - { + rid |= 0x1; + } + else if (type == MetadataTokenType.TypeSpec) + { //if type is mdtTypeSpec - rid|=0x2; + rid |= 0x2; } - + AddData(rid); } - + private void InternalAddTypeToken(TypeToken clsToken, CorElementType CorType) { // Add a type token into signature. CorType will be either CorElementType.Class or CorElementType.ValueType AddElementType(CorType); AddToken(clsToken.Token); } - + private unsafe void InternalAddRuntimeType(Type type) { // Add a runtime type into the signature. @@ -580,11 +579,11 @@ namespace System.Reflection.Emit if (m_currSig + sizeof(void*) > m_signature.Length) m_signature = ExpandArray(m_signature); - byte *phandle = (byte*)&handle; + byte* phandle = (byte*)&handle; for (int i = 0; i < sizeof(void*); i++) m_signature[m_currSig++] = phandle[i]; } - + private byte[] ExpandArray(byte[] inArray) { // Expand the signature buffer size @@ -595,25 +594,25 @@ namespace System.Reflection.Emit { // Expand the signature buffer size - if (requiredLength < inArray.Length) - requiredLength = inArray.Length*2; + if (requiredLength < inArray.Length) + requiredLength = inArray.Length * 2; byte[] outArray = new byte[requiredLength]; Buffer.BlockCopy(inArray, 0, outArray, 0, inArray.Length); return outArray; } - + private void IncrementArgCounts() { - if (m_sizeLoc == NO_SIZE_IN_SIG) - { + if (m_sizeLoc == NO_SIZE_IN_SIG) + { //We don't have a size if this is a field. return; } m_argCount++; } - + private void SetNumberOfSignatureElements(bool forceCopy) { // For most signatures, this will set the number of elements in a byte which we have reserved for it. @@ -628,18 +627,18 @@ namespace System.Reflection.Emit byte[] temp; int newSigSize; int currSigHolder = m_currSig; - - if (m_sizeLoc == NO_SIZE_IN_SIG) + + if (m_sizeLoc == NO_SIZE_IN_SIG) return; - + //If we have fewer than 128 arguments and we haven't been told to copy the //array, we can just set the appropriate bit and return. - if (m_argCount < 0x80 && !forceCopy) + if (m_argCount < 0x80 && !forceCopy) { m_signature[m_sizeLoc] = (byte)m_argCount; return; - } - + } + //We need to have more bytes for the size. Figure out how many bytes here. //Since we need to copy anyway, we're just going to take the cost of doing a //new allocation. @@ -655,45 +654,45 @@ namespace System.Reflection.Emit { newSigSize = 4; } - + //Allocate the new array. temp = new byte[m_currSig + newSigSize - 1]; - + //Copy the calling convention. The calling convention is always just one byte //so we just copy that byte. Then copy the rest of the array, shifting everything //to make room for the new number of elements. temp[0] = m_signature[0]; Buffer.BlockCopy(m_signature, m_sizeLoc + 1, temp, m_sizeLoc + newSigSize, currSigHolder - (m_sizeLoc + 1)); m_signature = temp; - + //Use the AddData method to add the number of elements appropriately compressed. m_currSig = m_sizeLoc; AddData(m_argCount); m_currSig = currSigHolder + (newSigSize - 1); } - + #endregion #region Internal Members internal int ArgumentCount - { - get - { - return m_argCount; - } + { + get + { + return m_argCount; + } } internal static bool IsSimpleType(CorElementType type) { - if (type <= CorElementType.String) + if (type <= CorElementType.String) return true; - if (type == CorElementType.TypedByRef || type == CorElementType.I || type == CorElementType.U || type == CorElementType.Object) + if (type == CorElementType.TypedByRef || type == CorElementType.I || type == CorElementType.U || type == CorElementType.Object) return true; return false; } - + internal byte[] InternalGetSignature(out int length) { // An internal method to return the signature. Does not trim the @@ -703,7 +702,7 @@ namespace System.Reflection.Emit // // param length : an out param indicating the length of the array. // return : A reference to the internal ubyte array. - + if (!m_sigDone) { m_sigDone = true; @@ -713,20 +712,20 @@ namespace System.Reflection.Emit // array. Bummer, eh? SetNumberOfSignatureElements(false); } - + length = m_currSig; return m_signature; } - - - - + + + + internal byte[] InternalGetSignatureArray() { - int argCount = m_argCount; + int argCount = m_argCount; int currSigLength = m_currSig; int newSigSize = currSigLength; - + //Allocate the new array. if (argCount < 0x7F) newSigSize += 1; @@ -745,26 +744,26 @@ namespace System.Reflection.Emit temp[sigCopyIndex++] = (byte)(argCount & 0xFF); else if (argCount <= 0x3FFF) { - temp[sigCopyIndex++] = (byte)((argCount >>8) | 0x80); + temp[sigCopyIndex++] = (byte)((argCount >> 8) | 0x80); temp[sigCopyIndex++] = (byte)(argCount & 0xFF); - } + } else if (argCount <= 0x1FFFFFFF) { - temp[sigCopyIndex++] = (byte)((argCount >>24) | 0xC0); - temp[sigCopyIndex++] = (byte)((argCount >>16) & 0xFF); - temp[sigCopyIndex++] = (byte)((argCount >>8) & 0xFF); + temp[sigCopyIndex++] = (byte)((argCount >> 24) | 0xC0); + temp[sigCopyIndex++] = (byte)((argCount >> 16) & 0xFF); + temp[sigCopyIndex++] = (byte)((argCount >> 8) & 0xFF); temp[sigCopyIndex++] = (byte)((argCount) & 0xFF); - } + } else - throw new ArgumentException(Environment.GetResourceString("Argument_LargeInteger")); + throw new ArgumentException(SR.Argument_LargeInteger); // copy the sig part of the sig Buffer.BlockCopy(m_signature, 2, temp, sigCopyIndex, currSigLength - 2); // mark the end of sig temp[newSigSize - 1] = (byte)CorElementType.End; - + return temp; } - + #endregion #region Public Methods @@ -781,21 +780,21 @@ namespace System.Reflection.Emit IncrementArgCounts(); AddOneArgTypeHelper(argument, pinned); } - + public void AddArguments(Type[] arguments, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers) { if (requiredCustomModifiers != null && (arguments == null || requiredCustomModifiers.Length != arguments.Length)) - throw new ArgumentException(Environment.GetResourceString("Argument_MismatchedArrays", nameof(requiredCustomModifiers), nameof(arguments))); + throw new ArgumentException(SR.Format(SR.Argument_MismatchedArrays, nameof(requiredCustomModifiers), nameof(arguments))); if (optionalCustomModifiers != null && (arguments == null || optionalCustomModifiers.Length != arguments.Length)) - throw new ArgumentException(Environment.GetResourceString("Argument_MismatchedArrays", nameof(optionalCustomModifiers), nameof(arguments))); + throw new ArgumentException(SR.Format(SR.Argument_MismatchedArrays, nameof(optionalCustomModifiers), nameof(arguments))); if (arguments != null) { - for (int i =0; i < arguments.Length; i++) + for (int i = 0; i < arguments.Length; i++) { - AddArgument(arguments[i], - requiredCustomModifiers == null ? null : requiredCustomModifiers[i], + AddArgument(arguments[i], + requiredCustomModifiers == null ? null : requiredCustomModifiers[i], optionalCustomModifiers == null ? null : optionalCustomModifiers[i]); } } @@ -804,13 +803,13 @@ namespace System.Reflection.Emit public void AddArgument(Type argument, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) { if (m_sigDone) - throw new ArgumentException(Environment.GetResourceString("Argument_SigIsFinalized")); - + throw new ArgumentException(SR.Argument_SigIsFinalized); + if (argument == null) throw new ArgumentNullException(nameof(argument)); IncrementArgCounts(); - + // Add an argument to the signature. Takes a Type and determines whether it // is one of the primitive types of which we have special knowledge or a more // general class. In the former case, we only add the appropriate short cut encoding, @@ -825,26 +824,26 @@ namespace System.Reflection.Emit public override bool Equals(Object obj) { - if (!(obj is SignatureHelper)) + if (!(obj is SignatureHelper)) { return false; } - + SignatureHelper temp = (SignatureHelper)obj; - - if ( !temp.m_module.Equals(m_module) || temp.m_currSig!=m_currSig || temp.m_sizeLoc!=m_sizeLoc || temp.m_sigDone !=m_sigDone ) + + if (!temp.m_module.Equals(m_module) || temp.m_currSig != m_currSig || temp.m_sizeLoc != m_sizeLoc || temp.m_sigDone != m_sigDone) { return false; } - - for (int i=0; i m_currSig) + if (m_signature.Length > m_currSig) { byte[] temp = new byte[m_currSig]; Array.Copy(m_signature, 0, temp, 0, m_currSig); @@ -890,7 +889,7 @@ namespace System.Reflection.Emit return m_signature; } - + public override String ToString() { StringBuilder sb = new StringBuilder(); @@ -906,7 +905,7 @@ namespace System.Reflection.Emit } sb.Append("Signature: " + Environment.NewLine); - for (int i=0; i<=m_currSig; i++) + for (int i = 0; i <= m_currSig; i++) { sb.Append(m_signature[i] + " "); } @@ -914,9 +913,8 @@ namespace System.Reflection.Emit sb.Append(Environment.NewLine); return sb.ToString(); } - - #endregion + #endregion } } diff --git a/src/mscorlib/src/System/Reflection/Emit/SignatureToken.cs b/src/mscorlib/src/System/Reflection/Emit/SignatureToken.cs index 5c908b89c7..e17e0c955e 100644 --- a/src/mscorlib/src/System/Reflection/Emit/SignatureToken.cs +++ b/src/mscorlib/src/System/Reflection/Emit/SignatureToken.cs @@ -13,32 +13,35 @@ ** ** ===========================================================*/ -namespace System.Reflection.Emit { - - using System; - using System.Reflection; - public struct SignatureToken { - +using System; +using System.Reflection; + +namespace System.Reflection.Emit +{ + public struct SignatureToken + { public static readonly SignatureToken Empty = new SignatureToken(); internal int m_signature; internal ModuleBuilder m_moduleBuilder; - - internal SignatureToken(int str, ModuleBuilder mod) { - m_signature=str; + + internal SignatureToken(int str, ModuleBuilder mod) + { + m_signature = str; m_moduleBuilder = mod; } - - public int Token { + + public int Token + { get { return m_signature; } } - + public override int GetHashCode() { return m_signature; } - + public override bool Equals(Object obj) { if (obj is SignatureToken) @@ -46,21 +49,20 @@ namespace System.Reflection.Emit { else return false; } - + public bool Equals(SignatureToken obj) { return obj.m_signature == m_signature; } - + public static bool operator ==(SignatureToken a, SignatureToken b) { return a.Equals(b); } - + public static bool operator !=(SignatureToken a, SignatureToken b) { return !(a == b); } - } } diff --git a/src/mscorlib/src/System/Reflection/Emit/StackBehaviour.cs b/src/mscorlib/src/System/Reflection/Emit/StackBehaviour.cs index 8a447d03fc..afcf2ddf0a 100644 --- a/src/mscorlib/src/System/Reflection/Emit/StackBehaviour.cs +++ b/src/mscorlib/src/System/Reflection/Emit/StackBehaviour.cs @@ -12,42 +12,42 @@ ** THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT BY HAND! ** See clr\src\inc\opcodegen.pl for more information.** ============================================================*/ -namespace System.Reflection.Emit { using System; -[Serializable] -public enum StackBehaviour +namespace System.Reflection.Emit { - - Pop0 = 0, - Pop1 = 1, - Pop1_pop1 = 2, - Popi = 3, - Popi_pop1 = 4, - Popi_popi = 5, - Popi_popi8 = 6, - Popi_popi_popi = 7, - Popi_popr4 = 8, - Popi_popr8 = 9, - Popref = 10, - Popref_pop1 = 11, - Popref_popi = 12, - Popref_popi_popi = 13, - Popref_popi_popi8 = 14, - Popref_popi_popr4 = 15, - Popref_popi_popr8 = 16, - Popref_popi_popref = 17, - Push0 = 18, - Push1 = 19, - Push1_push1 = 20, - Pushi = 21, - Pushi8 = 22, - Pushr4 = 23, - Pushr8 = 24, - Pushref = 25, - Varpop = 26, - Varpush = 27, - Popref_popi_pop1 = 28, -} + [Serializable] + public enum StackBehaviour + { + Pop0 = 0, + Pop1 = 1, + Pop1_pop1 = 2, + Popi = 3, + Popi_pop1 = 4, + Popi_popi = 5, + Popi_popi8 = 6, + Popi_popi_popi = 7, + Popi_popr4 = 8, + Popi_popr8 = 9, + Popref = 10, + Popref_pop1 = 11, + Popref_popi = 12, + Popref_popi_popi = 13, + Popref_popi_popi8 = 14, + Popref_popi_popr4 = 15, + Popref_popi_popr8 = 16, + Popref_popi_popref = 17, + Push0 = 18, + Push1 = 19, + Push1_push1 = 20, + Pushi = 21, + Pushi8 = 22, + Pushr4 = 23, + Pushr8 = 24, + Pushref = 25, + Varpop = 26, + Varpush = 27, + Popref_popi_pop1 = 28, + } } diff --git a/src/mscorlib/src/System/Reflection/Emit/StringToken.cs b/src/mscorlib/src/System/Reflection/Emit/StringToken.cs index 852225697c..1d90816fc6 100644 --- a/src/mscorlib/src/System/Reflection/Emit/StringToken.cs +++ b/src/mscorlib/src/System/Reflection/Emit/StringToken.cs @@ -12,36 +12,39 @@ ** ** ===========================================================*/ -namespace System.Reflection.Emit { - - using System; - using System.Reflection; +using System; +using System.Reflection; + +namespace System.Reflection.Emit +{ [Serializable] - public struct StringToken { - + public struct StringToken + { internal int m_string; - + //public StringToken() { // m_string=0; //} - - internal StringToken(int str) { - m_string=str; + + internal StringToken(int str) + { + m_string = str; } - + // Returns the metadata token for this particular string. // Generated by a call to Module.GetStringConstant(). // - public int Token { + public int Token + { get { return m_string; } } - + public override int GetHashCode() { return m_string; } - + public override bool Equals(Object obj) { if (obj is StringToken) @@ -49,29 +52,20 @@ namespace System.Reflection.Emit { else return false; } - + public bool Equals(StringToken obj) { return obj.m_string == m_string; } - + public static bool operator ==(StringToken a, StringToken b) { return a.Equals(b); } - + public static bool operator !=(StringToken a, StringToken b) { return !(a == b); } - } - - - - - - - - } diff --git a/src/mscorlib/src/System/Reflection/Emit/SymbolMethod.cs b/src/mscorlib/src/System/Reflection/Emit/SymbolMethod.cs index 6b47770608..42713b86db 100644 --- a/src/mscorlib/src/System/Reflection/Emit/SymbolMethod.cs +++ b/src/mscorlib/src/System/Reflection/Emit/SymbolMethod.cs @@ -4,14 +4,14 @@ // -namespace System.Reflection.Emit +namespace System.Reflection.Emit { using System.Runtime.InteropServices; using System; using System.Reflection; using System.Diagnostics.Contracts; using CultureInfo = System.Globalization.CultureInfo; - + internal sealed class SymbolMethod : MethodInfo { #region Private Data Members @@ -26,7 +26,7 @@ namespace System.Reflection.Emit #endregion #region Constructor - internal SymbolMethod(ModuleBuilder mod, MethodToken token, Type arrayClass, String methodName, + internal SymbolMethod(ModuleBuilder mod, MethodToken token, Type arrayClass, String methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) { // This is a kind of MethodInfo to represent methods for array type of unbaked type @@ -47,9 +47,9 @@ namespace System.Reflection.Emit } else { - m_parameterTypes = EmptyArray.Value; + m_parameterTypes = Array.Empty(); } - + m_module = mod; m_containingType = arrayClass; m_name = methodName; @@ -70,28 +70,28 @@ namespace System.Reflection.Emit { return mod.GetArrayMethodToken(m_containingType, m_name, m_callingConvention, m_returnType, m_parameterTypes); } - + #endregion #region MemberInfo Overrides - public override Module Module - { - get { return m_module; } - } + public override Module Module + { + get { return m_module; } + } public override Type ReflectedType { get { return m_containingType as Type; } } - public override String Name + public override String Name { get { return m_name; } } - public override Type DeclaringType + public override Type DeclaringType { - get {return m_containingType;} + get { return m_containingType; } } #endregion @@ -99,27 +99,27 @@ namespace System.Reflection.Emit [Pure] public override ParameterInfo[] GetParameters() { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod")); + throw new NotSupportedException(SR.NotSupported_SymbolMethod); } - + public override MethodImplAttributes GetMethodImplementationFlags() { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod")); + throw new NotSupportedException(SR.NotSupported_SymbolMethod); } - - public override MethodAttributes Attributes + + public override MethodAttributes Attributes { - get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod")); } + get { throw new NotSupportedException(SR.NotSupported_SymbolMethod); } } - - public override CallingConventions CallingConvention + + public override CallingConventions CallingConvention { get { return m_callingConvention; } } - public override RuntimeMethodHandle MethodHandle + public override RuntimeMethodHandle MethodHandle { - get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod")); } + get { throw new NotSupportedException(SR.NotSupported_SymbolMethod); } } #endregion @@ -133,16 +133,16 @@ namespace System.Reflection.Emit } } - public override ICustomAttributeProvider ReturnTypeCustomAttributes + public override ICustomAttributeProvider ReturnTypeCustomAttributes { - get { return null; } + get { return null; } } - + public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod")); + throw new NotSupportedException(SR.NotSupported_SymbolMethod); } - + public override MethodInfo GetBaseDefinition() { return this; @@ -152,19 +152,19 @@ namespace System.Reflection.Emit #region ICustomAttributeProvider Implementation public override Object[] GetCustomAttributes(bool inherit) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod")); + throw new NotSupportedException(SR.NotSupported_SymbolMethod); } - + public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod")); + throw new NotSupportedException(SR.NotSupported_SymbolMethod); } public override bool IsDefined(Type attributeType, bool inherit) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod")); + throw new NotSupportedException(SR.NotSupported_SymbolMethod); } - + #endregion #region Public Members diff --git a/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs b/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs index 205299125b..16848b43dd 100644 --- a/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs +++ b/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs @@ -4,7 +4,7 @@ // -namespace System.Reflection.Emit +namespace System.Reflection.Emit { using System.Runtime.InteropServices; using System; @@ -15,16 +15,17 @@ namespace System.Reflection.Emit [Serializable] internal enum TypeKind { - IsArray = 1, + IsArray = 1, IsPointer = 2, - IsByRef = 3, + IsByRef = 3, } // This is a kind of Type object that will represent the compound expression of a parameter type or field type. internal sealed class SymbolType : 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()); } @@ -52,8 +53,8 @@ namespace System.Reflection.Emit return baseType; } - - + + if (format[curIndex] == '&') { @@ -62,10 +63,10 @@ namespace System.Reflection.Emit symbolType = new SymbolType(TypeKind.IsByRef); symbolType.SetFormat(format, curIndex, 1); curIndex++; - + if (curIndex != format.Length) // ByRef has to be the last char!! - throw new ArgumentException(Environment.GetResourceString("Argument_BadSigFormat")); + throw new ArgumentException(SR.Argument_BadSigFormat); symbolType.SetElementType(baseType); return symbolType; @@ -84,13 +85,13 @@ namespace System.Reflection.Emit // Example: [2..4] - one dimension array with lower bound 2 and size of 3 // Example: [3, 5, 6] - three dimension array with lower bound 3, 5, 6 // Example: [-3, ] [] - one dimensional array of two dimensional array (with lower bound -3 sepcified) - + while (format[curIndex] != ']') { if (format[curIndex] == '*') { symbolType.m_isSzArray = false; - curIndex++; + curIndex++; } // consume, one dimension at a time if ((format[curIndex] >= '0' && format[curIndex] <= '9') || format[curIndex] == '-') @@ -117,10 +118,9 @@ namespace System.Reflection.Emit // set the upper bound to be less than LowerBound to indicate that upper bound it not specified yet! iUpperBound = iLowerBound - 1; - } if (format[curIndex] == '.') - { + { // upper bound is specified // skip over ".." @@ -128,7 +128,7 @@ namespace System.Reflection.Emit if (format[curIndex] != '.') { // bad format!! Throw exception - throw new ArgumentException(Environment.GetResourceString("Argument_BadSigFormat")); + throw new ArgumentException(SR.Argument_BadSigFormat); } curIndex++; @@ -158,7 +158,7 @@ namespace System.Reflection.Emit { // User specified upper bound less than lower bound, this is an error. // Throw error exception. - throw new ArgumentException(Environment.GetResourceString("Argument_BadSigFormat")); + throw new ArgumentException(SR.Argument_BadSigFormat); } } } @@ -176,10 +176,10 @@ namespace System.Reflection.Emit } else if (format[curIndex] != ']') { - throw new ArgumentException(Environment.GetResourceString("Argument_BadSigFormat")); + throw new ArgumentException(SR.Argument_BadSigFormat); } } - + // The last dimension information symbolType.SetBounds(iLowerBound, iUpperBound); @@ -209,21 +209,21 @@ namespace System.Reflection.Emit #endregion #region Data Members - internal TypeKind m_typeKind; - internal Type m_baseType; - internal int m_cRank; // count of dimension + internal TypeKind m_typeKind; + internal Type m_baseType; + internal int m_cRank; // count of dimension // If LowerBound and UpperBound is equal, that means one element. // If UpperBound is less than LowerBound, then the size is not specified. - internal int[] m_iaLowerBound; - internal int[] m_iaUpperBound; // count of dimension - private string m_format; // format string to form the full name. - private bool m_isSzArray = true; + internal int[] m_iaLowerBound; + internal int[] m_iaUpperBound; // count of dimension + private string m_format; // format string to form the full name. + private bool m_isSzArray = true; #endregion #region Constructor internal SymbolType(TypeKind typeKind) { - m_typeKind = typeKind; + m_typeKind = typeKind; m_iaLowerBound = new int[4]; m_iaUpperBound = new int[4]; } @@ -246,15 +246,15 @@ namespace System.Reflection.Emit if (lower != 0 || upper != -1) m_isSzArray = false; - + if (m_iaLowerBound.Length <= m_cRank) { // resize the bound array - int[] iaTemp = new int[m_cRank * 2]; + int[] iaTemp = new int[m_cRank * 2]; Array.Copy(m_iaLowerBound, 0, iaTemp, 0, m_cRank); - m_iaLowerBound = iaTemp; + m_iaLowerBound = iaTemp; Array.Copy(m_iaUpperBound, 0, iaTemp, 0, m_cRank); - m_iaUpperBound = iaTemp; + m_iaUpperBound = iaTemp; } m_iaLowerBound[m_cRank] = lower; @@ -269,36 +269,27 @@ namespace System.Reflection.Emit m_format = format.Substring(curIndex, length); } #endregion - + #region Type Overrides - internal override bool IsSzArray - { - get - { - if (m_cRank > 1) - return false; - - return m_isSzArray; - } - } + public override bool IsSZArray => m_cRank <= 1 && m_isSzArray; - public override Type MakePointerType() - { + public override Type MakePointerType() + { return SymbolType.FormCompoundType(m_format + "*", m_baseType, 0); } - public override Type MakeByRefType() - { + public override Type MakeByRefType() + { return SymbolType.FormCompoundType(m_format + "&", m_baseType, 0); } - - public override Type MakeArrayType() - { + + public override Type MakeArrayType() + { return SymbolType.FormCompoundType(m_format + "[]", m_baseType, 0); } - - public override Type MakeArrayType(int rank) - { + + public override Type MakeArrayType(int rank) + { if (rank <= 0) throw new IndexOutOfRangeException(); Contract.EndContractBlock(); @@ -308,9 +299,9 @@ namespace System.Reflection.Emit { szrank = "*"; } - else + else { - for(int i = 1; i < rank; i++) + for (int i = 1; i < rank; i++) szrank += ","; } @@ -322,55 +313,55 @@ namespace System.Reflection.Emit public override int GetArrayRank() { if (!IsArray) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_SubclassOverride")); + throw new NotSupportedException(SR.NotSupported_SubclassOverride); Contract.EndContractBlock(); return m_cRank; } - - public override Guid GUID + + public override Guid GUID { - get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); } + get { throw new NotSupportedException(SR.NotSupported_NonReflectedType); } } - public override Object InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, + public override Object InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - public override Module Module + public override Module Module { - get + get { Type baseType; - for (baseType = m_baseType; baseType is SymbolType; baseType = ((SymbolType) baseType).m_baseType); + for (baseType = m_baseType; baseType is SymbolType; baseType = ((SymbolType)baseType).m_baseType) ; return baseType.Module; } } - public override Assembly Assembly + public override Assembly Assembly { - get + get { Type baseType; - for (baseType = m_baseType; baseType is SymbolType; baseType = ((SymbolType) baseType).m_baseType); + for (baseType = m_baseType; baseType is SymbolType; baseType = ((SymbolType)baseType).m_baseType) ; return baseType.Assembly; } } - - public override RuntimeTypeHandle TypeHandle + + public override RuntimeTypeHandle TypeHandle { - get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); } + get { throw new NotSupportedException(SR.NotSupported_NonReflectedType); } } - - public override String Name + + public override String Name { - get - { + get + { Type baseType; String sFormat = m_format; @@ -380,140 +371,139 @@ namespace System.Reflection.Emit return baseType.Name + sFormat; } } - - public override String FullName + + public override String FullName { - get - { + get + { return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.FullName); } } - public override String AssemblyQualifiedName + public override String AssemblyQualifiedName { - get - { + get + { return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.AssemblyQualifiedName); } } public override String ToString() - { - return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.ToString); + { + return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.ToString); } - - public override String Namespace + + public override String Namespace { get { return m_baseType.Namespace; } } - - public override Type BaseType + + public override Type BaseType { - get { return typeof(System.Array); } } - - 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) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - + public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - - 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) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - + public override MethodInfo[] GetMethods(BindingFlags bindingAttr) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - + public override FieldInfo GetField(String name, BindingFlags bindingAttr) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - + public override FieldInfo[] GetFields(BindingFlags bindingAttr) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - - public override Type GetInterface(String name,bool ignoreCase) + + public override Type GetInterface(String name, bool ignoreCase) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - + public override Type[] GetInterfaces() { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - - public override EventInfo GetEvent(String name,BindingFlags bindingAttr) + + public override EventInfo GetEvent(String name, BindingFlags bindingAttr) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - + public override EventInfo[] GetEvents() { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - - 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_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - + public override PropertyInfo[] GetProperties(BindingFlags bindingAttr) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } public override Type[] GetNestedTypes(BindingFlags bindingAttr) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - + public override Type GetNestedType(String name, BindingFlags bindingAttr) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr) + public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - + public override MemberInfo[] GetMembers(BindingFlags bindingAttr) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } public override InterfaceMapping GetInterfaceMap(Type interfaceType) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } public override EventInfo[] GetEvents(BindingFlags bindingAttr) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - + protected override TypeAttributes GetAttributeFlagsImpl() { // Return the attribute flags of the base type? Type baseType; - for (baseType = m_baseType; baseType is SymbolType; baseType = ((SymbolType)baseType).m_baseType); + for (baseType = m_baseType; baseType is SymbolType; baseType = ((SymbolType)baseType).m_baseType) ; return baseType.Attributes; } - + protected override bool IsArrayImpl() { return m_typeKind == TypeKind.IsArray; @@ -533,12 +523,12 @@ namespace System.Reflection.Emit { return false; } - - protected override bool IsValueTypeImpl() + + protected override bool IsValueTypeImpl() { return false; } - + protected override bool IsCOMObjectImpl() { return false; @@ -556,31 +546,30 @@ namespace System.Reflection.Emit { return m_baseType; } - + protected override bool HasElementTypeImpl() { return m_baseType != null; } - - public override Type UnderlyingSystemType + + public override Type UnderlyingSystemType { - get { return this; } } - + public override Object[] GetCustomAttributes(bool inherit) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - public override bool IsDefined (Type attributeType, bool inherit) + public override bool IsDefined(Type attributeType, bool inherit) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } #endregion } diff --git a/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs index 88502cb096..a98af2bdcf 100644 --- a/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs @@ -5,7 +5,8 @@ // -namespace System.Reflection.Emit { +namespace System.Reflection.Emit +{ using System; using System.Reflection; using System.Security; @@ -22,21 +23,22 @@ namespace System.Reflection.Emit { [Serializable] public enum PackingSize { - Unspecified = 0, - Size1 = 1, - Size2 = 2, - Size4 = 4, - Size8 = 8, - Size16 = 16, - Size32 = 32, - Size64 = 64, - Size128 = 128, + Unspecified = 0, + Size1 = 1, + Size2 = 2, + Size4 = 4, + Size8 = 8, + Size16 = 16, + Size32 = 32, + Size64 = 64, + Size128 = 128, } public sealed class TypeBuilder : 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()); } @@ -46,7 +48,7 @@ namespace System.Reflection.Emit { private ConstructorInfo m_con; private byte[] m_binaryAttribute; private CustomAttributeBuilder m_customBuilder; - + public CustAttr(ConstructorInfo con, byte[] binaryAttribute) { if (con == null) @@ -83,12 +85,12 @@ namespace System.Reflection.Emit { } } #endregion - + #region Public Static Methods public static MethodInfo GetMethod(Type type, MethodInfo method) { if (!(type is TypeBuilder) && !(type is TypeBuilderInstantiation)) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeTypeBuilder")); + throw new ArgumentException(SR.Argument_MustBeTypeBuilder); // The following checks establishes invariants that more simply put require type to be generic and // method to be a generic method definition declared on the generic type definition of type. @@ -96,15 +98,15 @@ namespace System.Reflection.Emit { // this function followed by MakeGenericMethod on the resulting MethodInfo to finally get G.M. // We could also allow G.M to be created before G.M (BindGenParm followed by this method) // if we wanted to but that just complicates things so these checks are designed to prevent that scenario. - + if (method.IsGenericMethod && !method.IsGenericMethodDefinition) - throw new ArgumentException(Environment.GetResourceString("Argument_NeedGenericMethodDefinition"), nameof(method)); - + throw new ArgumentException(SR.Argument_NeedGenericMethodDefinition, nameof(method)); + if (method.DeclaringType == null || !method.DeclaringType.IsGenericTypeDefinition) - throw new ArgumentException(Environment.GetResourceString("Argument_MethodNeedGenericDeclaringType"), nameof(method)); - + throw new ArgumentException(SR.Argument_MethodNeedGenericDeclaringType, nameof(method)); + if (type.GetGenericTypeDefinition() != method.DeclaringType) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidMethodDeclaringType"), nameof(type)); + throw new ArgumentException(SR.Argument_InvalidMethodDeclaringType, nameof(type)); Contract.EndContractBlock(); // The following converts from Type or TypeBuilder of G to TypeBuilderInstantiation G. These types @@ -112,51 +114,51 @@ namespace System.Reflection.Emit { // G.M() be encoded by a typeSpec whose parent is the typeDef for G and whose instantiation is also G. if (type.IsGenericTypeDefinition) type = type.MakeGenericType(type.GetGenericArguments()); - + if (!(type is TypeBuilderInstantiation)) - throw new ArgumentException(Environment.GetResourceString("Argument_NeedNonGenericType"), nameof(type)); + throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(type)); return MethodOnTypeBuilderInstantiation.GetMethod(method, type as TypeBuilderInstantiation); } public static ConstructorInfo GetConstructor(Type type, ConstructorInfo constructor) - { + { if (!(type is TypeBuilder) && !(type is TypeBuilderInstantiation)) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeTypeBuilder")); + throw new ArgumentException(SR.Argument_MustBeTypeBuilder); if (!constructor.DeclaringType.IsGenericTypeDefinition) - throw new ArgumentException(Environment.GetResourceString("Argument_ConstructorNeedGenericDeclaringType"), nameof(constructor)); + throw new ArgumentException(SR.Argument_ConstructorNeedGenericDeclaringType, nameof(constructor)); Contract.EndContractBlock(); - + if (!(type is TypeBuilderInstantiation)) - throw new ArgumentException(Environment.GetResourceString("Argument_NeedNonGenericType"), nameof(type)); + throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(type)); // TypeBuilder G ==> TypeBuilderInstantiation G if (type is TypeBuilder && type.IsGenericTypeDefinition) type = type.MakeGenericType(type.GetGenericArguments()); if (type.GetGenericTypeDefinition() != constructor.DeclaringType) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidConstructorDeclaringType"), nameof(type)); + throw new ArgumentException(SR.Argument_InvalidConstructorDeclaringType, nameof(type)); return ConstructorOnTypeBuilderInstantiation.GetConstructor(constructor, type as TypeBuilderInstantiation); } public static FieldInfo GetField(Type type, FieldInfo field) { if (!(type is TypeBuilder) && !(type is TypeBuilderInstantiation)) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeTypeBuilder")); + throw new ArgumentException(SR.Argument_MustBeTypeBuilder); if (!field.DeclaringType.IsGenericTypeDefinition) - throw new ArgumentException(Environment.GetResourceString("Argument_FieldNeedGenericDeclaringType"), nameof(field)); + throw new ArgumentException(SR.Argument_FieldNeedGenericDeclaringType, nameof(field)); Contract.EndContractBlock(); - + if (!(type is TypeBuilderInstantiation)) - throw new ArgumentException(Environment.GetResourceString("Argument_NeedNonGenericType"), nameof(type)); + throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(type)); // TypeBuilder G ==> TypeBuilderInstantiation G if (type is TypeBuilder && type.IsGenericTypeDefinition) type = type.MakeGenericType(type.GetGenericArguments()); if (type.GetGenericTypeDefinition() != field.DeclaringType) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFieldDeclaringType"), nameof(type)); + throw new ArgumentException(SR.Argument_InvalidFieldDeclaringType, nameof(type)); return FieldOnTypeBuilderInstantiation.GetField(field, type as TypeBuilderInstantiation); } @@ -168,41 +170,41 @@ namespace System.Reflection.Emit { #region Private Static FCalls [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - [SuppressUnmanagedCodeSecurity] + [SuppressUnmanagedCodeSecurity] private static extern void SetParentType(RuntimeModule module, int tdTypeDef, int tkParent); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - [SuppressUnmanagedCodeSecurity] + [SuppressUnmanagedCodeSecurity] private static extern void AddInterfaceImpl(RuntimeModule module, int tdTypeDef, int tkInterface); #endregion #region Internal Static FCalls [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - [SuppressUnmanagedCodeSecurity] - internal static extern int DefineMethod(RuntimeModule module, int tkParent, String name, byte[] signature, int sigLength, + [SuppressUnmanagedCodeSecurity] + internal static extern int DefineMethod(RuntimeModule module, int tkParent, String name, byte[] signature, int sigLength, MethodAttributes attributes); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - [SuppressUnmanagedCodeSecurity] + [SuppressUnmanagedCodeSecurity] internal static extern int DefineMethodSpec(RuntimeModule module, int tkParent, byte[] signature, int sigLength); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - [SuppressUnmanagedCodeSecurity] - internal static extern int DefineField(RuntimeModule module, int tkParent, String name, byte[] signature, int sigLength, + [SuppressUnmanagedCodeSecurity] + internal static extern int DefineField(RuntimeModule module, int tkParent, String name, byte[] signature, int sigLength, FieldAttributes attributes); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - [SuppressUnmanagedCodeSecurity] - private static extern void SetMethodIL(RuntimeModule module, int tk, bool isInitLocals, + [SuppressUnmanagedCodeSecurity] + private static extern void SetMethodIL(RuntimeModule module, int tk, bool isInitLocals, byte[] body, int bodyLength, - byte[] LocalSig, int sigLength, + byte[] LocalSig, int sigLength, int maxStackSize, - ExceptionHandler[] exceptions, int numExceptions, - int [] tokenFixups, int numTokenFixups); + ExceptionHandler[] exceptions, int numExceptions, + int[] tokenFixups, int numTokenFixups); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - [SuppressUnmanagedCodeSecurity] - private static extern void DefineCustomAttribute(RuntimeModule module, int tkAssociate, int tkConstructor, + [SuppressUnmanagedCodeSecurity] + private static extern void DefineCustomAttribute(RuntimeModule module, int tkAssociate, int tkConstructor, byte[] attr, int attrLength, bool toDisk, bool updateCompilerFlags); internal static void DefineCustomAttribute(ModuleBuilder module, int tkAssociate, int tkConstructor, @@ -216,55 +218,55 @@ namespace System.Reflection.Emit { Buffer.BlockCopy(attr, 0, localAttr, 0, attr.Length); } - DefineCustomAttribute(module.GetNativeHandle(), tkAssociate, tkConstructor, + DefineCustomAttribute(module.GetNativeHandle(), tkAssociate, tkConstructor, localAttr, (localAttr != null) ? localAttr.Length : 0, toDisk, updateCompilerFlags); } [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - [SuppressUnmanagedCodeSecurity] + [SuppressUnmanagedCodeSecurity] internal static extern int DefineProperty(RuntimeModule module, int tkParent, String name, PropertyAttributes attributes, byte[] signature, int sigLength); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - [SuppressUnmanagedCodeSecurity] + [SuppressUnmanagedCodeSecurity] internal static extern int DefineEvent(RuntimeModule module, int tkParent, String name, EventAttributes attributes, int tkEventType); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - [SuppressUnmanagedCodeSecurity] - internal static extern void DefineMethodSemantics(RuntimeModule module, int tkAssociation, + [SuppressUnmanagedCodeSecurity] + internal static extern void DefineMethodSemantics(RuntimeModule module, int tkAssociation, MethodSemanticsAttributes semantics, int tkMethod); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - [SuppressUnmanagedCodeSecurity] + [SuppressUnmanagedCodeSecurity] internal static extern void DefineMethodImpl(RuntimeModule module, int tkType, int tkBody, int tkDecl); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - [SuppressUnmanagedCodeSecurity] + [SuppressUnmanagedCodeSecurity] internal static extern void SetMethodImpl(RuntimeModule module, int tkMethod, MethodImplAttributes MethodImplAttributes); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - [SuppressUnmanagedCodeSecurity] - internal static extern int SetParamInfo(RuntimeModule module, int tkMethod, int iSequence, + [SuppressUnmanagedCodeSecurity] + internal static extern int SetParamInfo(RuntimeModule module, int tkMethod, int iSequence, ParameterAttributes iParamAttributes, String strParamName); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - [SuppressUnmanagedCodeSecurity] + [SuppressUnmanagedCodeSecurity] internal static extern int GetTokenFromSig(RuntimeModule module, byte[] signature, int sigLength); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - [SuppressUnmanagedCodeSecurity] + [SuppressUnmanagedCodeSecurity] internal static extern void SetFieldLayoutOffset(RuntimeModule module, int fdToken, int iOffset); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - [SuppressUnmanagedCodeSecurity] + [SuppressUnmanagedCodeSecurity] internal static extern void SetClassLayout(RuntimeModule module, int tk, PackingSize iPackingSize, int iTypeSize); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - [SuppressUnmanagedCodeSecurity] + [SuppressUnmanagedCodeSecurity] private static extern unsafe void SetConstantValue(RuntimeModule module, int tk, int corType, void* pValue); -#endregion -#region Internal\Private Static Members + #endregion + #region Internal\Private Static Members [Pure] internal static bool IsTypeEqual(Type t1, Type t2) @@ -273,14 +275,14 @@ namespace System.Reflection.Emit { if (t1 == t2) return true; TypeBuilder tb1 = null; - TypeBuilder tb2 = null; - Type runtimeType1 = null; - Type runtimeType2 = null; - + TypeBuilder tb2 = null; + Type runtimeType1 = null; + Type runtimeType2 = null; + // set up the runtimeType and TypeBuilder type corresponding to t1 and t2 if (t1 is TypeBuilder) { - tb1 =(TypeBuilder)t1; + tb1 = (TypeBuilder)t1; // This will be null if it is not baked. runtimeType1 = tb1.m_bakedRuntimeType; } @@ -291,7 +293,7 @@ namespace System.Reflection.Emit { if (t2 is TypeBuilder) { - tb2 =(TypeBuilder)t2; + tb2 = (TypeBuilder)t2; // This will be null if it is not baked. runtimeType2 = tb2.m_bakedRuntimeType; } @@ -299,16 +301,16 @@ namespace System.Reflection.Emit { { runtimeType2 = t2; } - + // If the type builder view is eqaul then it is equal if (tb1 != null && tb2 != null && Object.ReferenceEquals(tb1, tb2)) return true; // if the runtimetype view is eqaul than it is equal - if (runtimeType1 != null && runtimeType2 != null && runtimeType1 == runtimeType2) + if (runtimeType1 != null && runtimeType2 != null && runtimeType1 == runtimeType2) return true; - return false; + return false; } internal static unsafe void SetConstantValue(ModuleBuilder module, int tk, Type destType, Object value) @@ -349,7 +351,7 @@ namespace System.Reflection.Emit { // The constant value supplied should match either the baked enum type or its underlying type // we don't need to compare it with the EnumBuilder itself because you can never have an object of that type if (type != enumBldr.m_typeBuilder.m_bakedRuntimeType && type != underlyingType) - throw new ArgumentException(Environment.GetResourceString("Argument_ConstantDoesntMatch")); + throw new ArgumentException(SR.Argument_ConstantDoesntMatch); } else if ((typeBldr = destType as TypeBuilder) != null) { @@ -358,7 +360,7 @@ namespace System.Reflection.Emit { // The constant value supplied should match either the baked enum type or its underlying type // typeBldr.m_enumUnderlyingType is null if the user hasn't created a "value__" field on the enum if (underlyingType == null || (type != typeBldr.UnderlyingSystemType && type != underlyingType)) - throw new ArgumentException(Environment.GetResourceString("Argument_ConstantDoesntMatch")); + throw new ArgumentException(SR.Argument_ConstantDoesntMatch); } else // must be a runtime Enum Type { @@ -368,7 +370,7 @@ namespace System.Reflection.Emit { // The constant value supplied should match either the enum itself or its underlying type if (type != destType && type != underlyingType) - throw new ArgumentException(Environment.GetResourceString("Argument_ConstantDoesntMatch")); + throw new ArgumentException(SR.Argument_ConstantDoesntMatch); } type = underlyingType; @@ -377,9 +379,9 @@ namespace System.Reflection.Emit { { // Note that it is non CLS compliant if destType != type. But RefEmit never guarantees CLS-Compliance. if (!destType.IsAssignableFrom(type)) - throw new ArgumentException(Environment.GetResourceString("Argument_ConstantDoesntMatch")); + throw new ArgumentException(SR.Argument_ConstantDoesntMatch); } - + CorElementType corType = RuntimeTypeHandle.GetCorElementType((RuntimeType)type); switch (corType) @@ -414,7 +416,7 @@ namespace System.Reflection.Emit { } else { - throw new ArgumentException(Environment.GetResourceString("Argument_ConstantNotSupported", type.ToString())); + throw new ArgumentException(SR.Format(SR.Argument_ConstantNotSupported, type.ToString())); } break; } @@ -425,7 +427,7 @@ namespace System.Reflection.Emit { { // nullable types can hold null value. if (!(destType.IsGenericType && destType.GetGenericTypeDefinition() == typeof(Nullable<>))) - throw new ArgumentException(Environment.GetResourceString("Argument_ConstantNull")); + throw new ArgumentException(SR.Argument_ConstantNull); } SetConstantValue(module.GetNativeHandle(), tk, (int)CorElementType.Class, null); @@ -436,7 +438,7 @@ namespace System.Reflection.Emit { #region Private Data Members private List m_ca; - private TypeToken m_tdType; + private TypeToken m_tdType; private ModuleBuilder m_module; private String m_strName; private String m_strNameSpace; @@ -483,8 +485,8 @@ namespace System.Reflection.Emit { { Contract.Requires(declMeth != null); m_declMeth = declMeth; - m_DeclaringType =m_declMeth.GetTypeBuilder(); - m_module =declMeth.GetModuleBuilder(); + m_DeclaringType = m_declMeth.GetTypeBuilder(); + m_module = declMeth.GetModuleBuilder(); InitAsGenericParam(szName, genParamPos); } @@ -493,7 +495,7 @@ namespace System.Reflection.Emit { { Contract.Requires(declType != null); m_DeclaringType = declType; - m_module =declType.GetModuleBuilder(); + m_module = declType.GetModuleBuilder(); InitAsGenericParam(szName, genParamPos); } @@ -512,7 +514,7 @@ namespace System.Reflection.Emit { Type[] interfaces, ModuleBuilder module, PackingSize iPackingSize, - int iTypeSize, + int iTypeSize, TypeBuilder enclosingType) { Init(name, attr, parent, interfaces, module, iPackingSize, iTypeSize, enclosingType); @@ -525,14 +527,14 @@ namespace System.Reflection.Emit { throw new ArgumentNullException(nameof(fullname)); if (fullname.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(fullname)); + throw new ArgumentException(SR.Argument_EmptyName, nameof(fullname)); if (fullname[0] == '\0') - throw new ArgumentException(Environment.GetResourceString("Argument_IllegalName"), nameof(fullname)); + throw new ArgumentException(SR.Argument_IllegalName, nameof(fullname)); if (fullname.Length > 1023) - throw new ArgumentException(Environment.GetResourceString("Argument_TypeNameTooLong"), nameof(fullname)); + throw new ArgumentException(SR.Argument_TypeNameTooLong, nameof(fullname)); Contract.EndContractBlock(); int i; @@ -547,14 +549,14 @@ namespace System.Reflection.Emit { { // Nested Type should have nested attribute set. // If we are renumbering TypeAttributes' bit, we need to change the logic here. - if (((attr & TypeAttributes.VisibilityMask) == TypeAttributes.Public) ||((attr & TypeAttributes.VisibilityMask) == TypeAttributes.NotPublic)) - throw new ArgumentException(Environment.GetResourceString("Argument_BadNestedTypeFlags"), nameof(attr)); + if (((attr & TypeAttributes.VisibilityMask) == TypeAttributes.Public) || ((attr & TypeAttributes.VisibilityMask) == TypeAttributes.NotPublic)) + throw new ArgumentException(SR.Argument_BadNestedTypeFlags, nameof(attr)); } int[] interfaceTokens = null; if (interfaces != null) { - for(i = 0; i < interfaces.Length; i++) + for (i = 0; i < interfaces.Length; i++) { if (interfaces[i] == null) { @@ -563,7 +565,7 @@ namespace System.Reflection.Emit { } } interfaceTokens = new int[interfaces.Length + 1]; - for(i = 0; i < interfaces.Length; i++) + for (i = 0; i < interfaces.Length; i++) { interfaceTokens[i] = m_module.GetTypeTokenInternal(interfaces[i]).Token; } @@ -609,14 +611,14 @@ namespace System.Reflection.Emit { m_iPackingSize = iPackingSize; m_iTypeSize = iTypeSize; - if ((m_iPackingSize != 0) ||(m_iTypeSize != 0)) + if ((m_iPackingSize != 0) || (m_iTypeSize != 0)) SetClassLayout(GetModuleBuilder().GetNativeHandle(), m_tdType.Token, m_iPackingSize, m_iTypeSize); m_module.AddType(FullName, this); } -#endregion -#region Private Members + #endregion + #region Private Members private FieldBuilder DefineDataHelper(String name, byte[] data, int size, FieldAttributes attributes) { @@ -629,10 +631,10 @@ namespace System.Reflection.Emit { 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 (size <= 0 || size >= 0x003f0000) - throw new ArgumentException(Environment.GetResourceString("Argument_BadSizeForData")); + throw new ArgumentException(SR.Argument_BadSizeForData); Contract.EndContractBlock(); ThrowIfCreated(); @@ -653,7 +655,7 @@ namespace System.Reflection.Emit { valueClassType.CreateType(); } - fdBuilder = DefineField(name, valueClassType,(attributes | FieldAttributes.Static)); + fdBuilder = DefineField(name, valueClassType, (attributes | FieldAttributes.Static)); // now we need to set the RVA fdBuilder.SetData(data, size); @@ -666,54 +668,54 @@ namespace System.Reflection.Emit { if (DeclaringType == null) { // Not a nested class. - if (((attr & TypeAttributes.VisibilityMask) != TypeAttributes.NotPublic) &&((attr & TypeAttributes.VisibilityMask) != TypeAttributes.Public)) + if (((attr & TypeAttributes.VisibilityMask) != TypeAttributes.NotPublic) && ((attr & TypeAttributes.VisibilityMask) != TypeAttributes.Public)) { - throw new ArgumentException(Environment.GetResourceString("Argument_BadTypeAttrNestedVisibilityOnNonNestedType")); + throw new ArgumentException(SR.Argument_BadTypeAttrNestedVisibilityOnNonNestedType); } } else { // Nested class. - if (((attr & TypeAttributes.VisibilityMask) == TypeAttributes.NotPublic) ||((attr & TypeAttributes.VisibilityMask) == TypeAttributes.Public)) + if (((attr & TypeAttributes.VisibilityMask) == TypeAttributes.NotPublic) || ((attr & TypeAttributes.VisibilityMask) == TypeAttributes.Public)) { - throw new ArgumentException(Environment.GetResourceString("Argument_BadTypeAttrNonNestedVisibilityNestedType")); + throw new ArgumentException(SR.Argument_BadTypeAttrNonNestedVisibilityNestedType); } } // Verify that the layout mask is valid. - if (((attr & TypeAttributes.LayoutMask) != TypeAttributes.AutoLayout) &&((attr & TypeAttributes.LayoutMask) != TypeAttributes.SequentialLayout) &&((attr & TypeAttributes.LayoutMask) != TypeAttributes.ExplicitLayout)) + if (((attr & TypeAttributes.LayoutMask) != TypeAttributes.AutoLayout) && ((attr & TypeAttributes.LayoutMask) != TypeAttributes.SequentialLayout) && ((attr & TypeAttributes.LayoutMask) != TypeAttributes.ExplicitLayout)) { - throw new ArgumentException(Environment.GetResourceString("Argument_BadTypeAttrInvalidLayout")); + throw new ArgumentException(SR.Argument_BadTypeAttrInvalidLayout); } // Check if the user attempted to set any reserved bits. if ((attr & TypeAttributes.ReservedMask) != 0) { - throw new ArgumentException(Environment.GetResourceString("Argument_BadTypeAttrReservedBitsSet")); + throw new ArgumentException(SR.Argument_BadTypeAttrReservedBitsSet); } } [Pure] public bool IsCreated() - { + { return m_hasBeenCreated; } - + #endregion #region FCalls [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - [SuppressUnmanagedCodeSecurity] + [SuppressUnmanagedCodeSecurity] private extern static int DefineType(RuntimeModule module, String fullname, int tkParent, TypeAttributes attributes, int tkEnclosingType, int[] interfaceTokens); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - [SuppressUnmanagedCodeSecurity] + [SuppressUnmanagedCodeSecurity] private extern static int DefineGenericParam(RuntimeModule module, String name, int tkParent, GenericParameterAttributes attributes, int position, int[] constraints); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - [SuppressUnmanagedCodeSecurity] + [SuppressUnmanagedCodeSecurity] private static extern void TermCreateClass(RuntimeModule module, int tk, ObjectHandleOnStack type); #endregion @@ -721,7 +723,7 @@ namespace System.Reflection.Emit { internal void ThrowIfCreated() { if (IsCreated()) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_TypeHasBeenCreated")); + throw new InvalidOperationException(SR.InvalidOperation_TypeHasBeenCreated); } internal object SyncRoot @@ -749,12 +751,12 @@ namespace System.Reflection.Emit { { m_genParamAttributes = genericParameterAttributes; } - + internal void SetGenParamCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) { CustAttr ca = new CustAttr(con, binaryAttribute); - lock(SyncRoot) + lock (SyncRoot) { SetGenParamCustomAttributeNoLock(ca); } @@ -764,7 +766,7 @@ namespace System.Reflection.Emit { { CustAttr ca = new CustAttr(customBuilder); - lock(SyncRoot) + lock (SyncRoot) { SetGenParamCustomAttributeNoLock(ca); } @@ -774,7 +776,7 @@ namespace System.Reflection.Emit { { if (m_ca == null) m_ca = new List(); - + m_ca.Add(ca); } #endregion @@ -782,30 +784,30 @@ namespace System.Reflection.Emit { #region Object Overrides public override String ToString() { - return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.ToString); + return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.ToString); } #endregion #region MemberInfo Overrides - public override Type DeclaringType + public override Type DeclaringType { get { return m_DeclaringType; } } - public override Type ReflectedType + public override Type ReflectedType { // Return the class that was used to obtain this field. - + get { return m_DeclaringType; } } - public override String Name + public override String Name { get { return m_strName; } } - public override Module Module + public override Module Module { get { return GetModuleBuilder(); } } @@ -818,12 +820,12 @@ namespace System.Reflection.Emit { #endregion #region Type Overrides - public override Guid GUID + public override Guid GUID { - get + get { if (!IsCreated()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated")); + throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); Contract.EndContractBlock(); return m_bakedRuntimeType.GUID; @@ -834,27 +836,26 @@ namespace System.Reflection.Emit { Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) { if (!IsCreated()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated")); + throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); Contract.EndContractBlock(); return m_bakedRuntimeType.InvokeMember(name, invokeAttr, binder, target, args, modifiers, culture, namedParameters); } - public override Assembly Assembly + public override Assembly Assembly { get { return m_module.Assembly; } } - public override RuntimeTypeHandle TypeHandle + public override RuntimeTypeHandle TypeHandle { - - get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); } + get { throw new NotSupportedException(SR.NotSupported_DynamicModule); } } - public override String FullName + public override String FullName { - get - { + get + { if (m_strFullQualName == null) m_strFullQualName = TypeNameBuilder.ToString(this, TypeNameBuilder.Format.FullName); @@ -862,29 +863,29 @@ namespace System.Reflection.Emit { } } - public override String Namespace + public override String Namespace { get { return m_strNameSpace; } } - public override String AssemblyQualifiedName + public override String AssemblyQualifiedName { - get - { + get + { return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.AssemblyQualifiedName); } } - public override Type BaseType + public override Type BaseType { - get{ return m_typeParent; } + get { return m_typeParent; } } - 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) { if (!IsCreated()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated")); + throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); Contract.EndContractBlock(); return m_bakedRuntimeType.GetConstructor(bindingAttr, binder, callConvention, types, modifiers); @@ -893,17 +894,17 @@ namespace System.Reflection.Emit { public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr) { if (!IsCreated()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated")); + throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); Contract.EndContractBlock(); return m_bakedRuntimeType.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 (!IsCreated()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated")); + throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); Contract.EndContractBlock(); if (types == null) @@ -919,7 +920,7 @@ namespace System.Reflection.Emit { public override MethodInfo[] GetMethods(BindingFlags bindingAttr) { if (!IsCreated()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated")); + throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); Contract.EndContractBlock(); return m_bakedRuntimeType.GetMethods(bindingAttr); @@ -928,7 +929,7 @@ namespace System.Reflection.Emit { public override FieldInfo GetField(String name, BindingFlags bindingAttr) { if (!IsCreated()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated")); + throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); Contract.EndContractBlock(); return m_bakedRuntimeType.GetField(name, bindingAttr); @@ -937,18 +938,18 @@ namespace System.Reflection.Emit { public override FieldInfo[] GetFields(BindingFlags bindingAttr) { if (!IsCreated()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated")); + throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); Contract.EndContractBlock(); return m_bakedRuntimeType.GetFields(bindingAttr); } - public override Type GetInterface(String name,bool ignoreCase) + public override Type GetInterface(String name, bool ignoreCase) { if (!IsCreated()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated")); + throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); Contract.EndContractBlock(); - + return m_bakedRuntimeType.GetInterface(name, ignoreCase); } @@ -961,16 +962,16 @@ namespace System.Reflection.Emit { if (m_typeInterfaces == null) { - return EmptyArray.Value; + return Array.Empty(); } return m_typeInterfaces.ToArray(); } - public override EventInfo GetEvent(String name,BindingFlags bindingAttr) + public override EventInfo GetEvent(String name, BindingFlags bindingAttr) { if (!IsCreated()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated")); + throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); Contract.EndContractBlock(); return m_bakedRuntimeType.GetEvent(name, bindingAttr); @@ -979,7 +980,7 @@ namespace System.Reflection.Emit { public override EventInfo[] GetEvents() { if (!IsCreated()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated")); + throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); Contract.EndContractBlock(); return m_bakedRuntimeType.GetEvents(); @@ -988,13 +989,13 @@ namespace System.Reflection.Emit { 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) { if (!IsCreated()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated")); + throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); Contract.EndContractBlock(); return m_bakedRuntimeType.GetProperties(bindingAttr); @@ -1003,7 +1004,7 @@ namespace System.Reflection.Emit { public override Type[] GetNestedTypes(BindingFlags bindingAttr) { if (!IsCreated()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated")); + throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); Contract.EndContractBlock(); return m_bakedRuntimeType.GetNestedTypes(bindingAttr); @@ -1012,16 +1013,16 @@ namespace System.Reflection.Emit { public override Type GetNestedType(String name, BindingFlags bindingAttr) { if (!IsCreated()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated")); + throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); Contract.EndContractBlock(); - return m_bakedRuntimeType.GetNestedType(name,bindingAttr); + return m_bakedRuntimeType.GetNestedType(name, bindingAttr); } public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr) { if (!IsCreated()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated")); + throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); Contract.EndContractBlock(); return m_bakedRuntimeType.GetMember(name, type, bindingAttr); @@ -1030,7 +1031,7 @@ namespace System.Reflection.Emit { public override InterfaceMapping GetInterfaceMap(Type interfaceType) { if (!IsCreated()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated")); + throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); Contract.EndContractBlock(); return m_bakedRuntimeType.GetInterfaceMap(interfaceType); @@ -1039,7 +1040,7 @@ namespace System.Reflection.Emit { public override EventInfo[] GetEvents(BindingFlags bindingAttr) { if (!IsCreated()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated")); + throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); Contract.EndContractBlock(); return m_bakedRuntimeType.GetEvents(bindingAttr); @@ -1048,66 +1049,68 @@ namespace System.Reflection.Emit { public override MemberInfo[] GetMembers(BindingFlags bindingAttr) { if (!IsCreated()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated")); + throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); Contract.EndContractBlock(); return m_bakedRuntimeType.GetMembers(bindingAttr); } - + public override bool IsAssignableFrom(Type c) { if (TypeBuilder.IsTypeEqual(c, this)) return true; - + Type fromRuntimeType = null; TypeBuilder fromTypeBuilder = c as TypeBuilder; - + if (fromTypeBuilder != null) fromRuntimeType = fromTypeBuilder.m_bakedRuntimeType; else fromRuntimeType = c; - + if (fromRuntimeType != null && fromRuntimeType is RuntimeType) { // fromType is baked. So if this type is not baked, it cannot be assignable to! if (m_bakedRuntimeType == null) return false; - + // since toType is also baked, delegate to the base return m_bakedRuntimeType.IsAssignableFrom(fromRuntimeType); } - + // So if c is not a runtimeType nor TypeBuilder. We don't know how to deal with it. // return false then. if (fromTypeBuilder == null) return false; - + // If fromTypeBuilder is a subclass of this class, then c can be cast to this type. if (fromTypeBuilder.IsSubclassOf(this)) return true; - + if (this.IsInterface == false) return false; - + // now is This type a base type on one of the interface impl? Type[] interfaces = fromTypeBuilder.GetInterfaces(); - for(int i = 0; i < interfaces.Length; i++) + for (int i = 0; i < interfaces.Length; i++) { // unfortunately, IsSubclassOf does not cover the case when they are the same type. if (TypeBuilder.IsTypeEqual(interfaces[i], this)) return true; - + if (interfaces[i].IsSubclassOf(this)) return true; } - return false; - } + return false; + } protected override TypeAttributes GetAttributeFlagsImpl() { return m_iAttr; } + public override bool IsSZArray => false; + protected override bool IsArrayImpl() { return false; @@ -1127,14 +1130,13 @@ namespace System.Reflection.Emit { protected override bool IsCOMObjectImpl() { - return((GetAttributeFlagsImpl() & TypeAttributes.Import) != 0) ? true : false; + return ((GetAttributeFlagsImpl() & TypeAttributes.Import) != 0) ? true : false; } public override Type GetElementType() { - // You will never have to deal with a TypeBuilder if you are just referring to arrays. - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } protected override bool HasElementTypeImpl() @@ -1165,9 +1167,9 @@ namespace System.Reflection.Emit { if (TypeBuilder.IsTypeEqual(p, c)) return false; - p = p.BaseType; - - while(p != null) + p = p.BaseType; + + while (p != null) { if (TypeBuilder.IsTypeEqual(p, c)) return true; @@ -1177,10 +1179,10 @@ namespace System.Reflection.Emit { return false; } - - public override Type UnderlyingSystemType + + public override Type UnderlyingSystemType { - get + get { if (m_bakedRuntimeType != null) return m_bakedRuntimeType; @@ -1188,9 +1190,9 @@ namespace System.Reflection.Emit { if (IsEnum) { if (m_enumUnderlyingType == null) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NoUnderlyingTypeOnEnum")); - - return m_enumUnderlyingType; + throw new InvalidOperationException(SR.InvalidOperation_NoUnderlyingTypeOnEnum); + + return m_enumUnderlyingType; } else { @@ -1199,22 +1201,22 @@ namespace System.Reflection.Emit { } } - 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(); @@ -1225,9 +1227,9 @@ namespace System.Reflection.Emit { { szrank = "*"; } - else + else { - for(int i = 1; i < rank; i++) + for (int i = 1; i < rank; i++) szrank += ","; } @@ -1241,7 +1243,7 @@ namespace System.Reflection.Emit { public override Object[] GetCustomAttributes(bool inherit) { if (!IsCreated()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated")); + throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); Contract.EndContractBlock(); return CustomAttribute.GetCustomAttributes(m_bakedRuntimeType, typeof(object) as RuntimeType, inherit); @@ -1250,7 +1252,7 @@ namespace System.Reflection.Emit { public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { if (!IsCreated()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated")); + throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); if (attributeType == null) throw new ArgumentNullException(nameof(attributeType)); @@ -1259,7 +1261,7 @@ namespace System.Reflection.Emit { RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType; if (attributeRuntimeType == null) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"),nameof(attributeType)); + throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType)); return CustomAttribute.GetCustomAttributes(m_bakedRuntimeType, attributeRuntimeType, inherit); } @@ -1267,7 +1269,7 @@ namespace System.Reflection.Emit { public override bool IsDefined(Type attributeType, bool inherit) { if (!IsCreated()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated")); + throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); if (attributeType == null) throw new ArgumentNullException(nameof(attributeType)); @@ -1276,7 +1278,7 @@ namespace System.Reflection.Emit { RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType; if (attributeRuntimeType == null) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"),nameof(attributeType)); + throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType)); return CustomAttribute.IsDefined(m_bakedRuntimeType, attributeRuntimeType, inherit); } @@ -1284,12 +1286,12 @@ namespace System.Reflection.Emit { #endregion #region Public Member - + #region DefineType public override GenericParameterAttributes GenericParameterAttributes { get { return m_genParamAttributes; } } - internal void SetInterfaces(params Type[] interfaces) - { + internal void SetInterfaces(params Type[] interfaces) + { ThrowIfCreated(); m_typeInterfaces = new List(); @@ -1308,8 +1310,8 @@ namespace System.Reflection.Emit { if (names.Length == 0) throw new ArgumentException(); Contract.EndContractBlock(); - - 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)); @@ -1317,25 +1319,25 @@ namespace System.Reflection.Emit { throw new InvalidOperationException(); 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; } - - public override Type MakeGenericType(params Type[] typeArguments) - { + + public override Type MakeGenericType(params Type[] typeArguments) + { CheckContext(typeArguments); - - return TypeBuilderInstantiation.MakeGenericType(this, typeArguments); + + return TypeBuilderInstantiation.MakeGenericType(this, typeArguments); } - + public override Type[] GetGenericArguments() { return m_inst; } // If a TypeBuilder is generic, it must be a generic type definition // All instantiated generic types are TypeBuilderInstantiation. public override bool IsGenericTypeDefinition { get { return IsGenericType; } } - public override bool IsGenericType { get { return m_inst != null; } } + public override bool IsGenericType { get { return m_inst != null; } } public override bool IsGenericParameter { get { return m_bIsGenParam; } } public override bool IsConstructedGenericType { get { return false; } } @@ -1347,7 +1349,7 @@ namespace System.Reflection.Emit { #region Define Method public void DefineMethodOverride(MethodInfo methodInfoBody, MethodInfo methodInfoDeclaration) { - lock(SyncRoot) + lock (SyncRoot) { DefineMethodOverrideNoLock(methodInfoBody, methodInfoDeclaration); } @@ -1363,13 +1365,13 @@ namespace System.Reflection.Emit { Contract.EndContractBlock(); ThrowIfCreated(); - + if (!object.ReferenceEquals(methodInfoBody.DeclaringType, this)) // Loader restriction: body method has to be from this class - throw new ArgumentException(Environment.GetResourceString("ArgumentException_BadMethodImplBody")); - - MethodToken tkBody; - MethodToken tkDecl; + throw new ArgumentException(SR.ArgumentException_BadMethodImplBody); + + MethodToken tkBody; + MethodToken tkDecl; tkBody = m_module.GetMethodTokenInternal(methodInfoBody); tkDecl = m_module.GetMethodTokenInternal(methodInfoDeclaration); @@ -1405,21 +1407,21 @@ namespace System.Reflection.Emit { return DefineMethod(name, attributes, callingConvention, returnType, null, null, parameterTypes, null, null); } - + public MethodBuilder DefineMethod(String name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers) { Contract.Ensures(Contract.Result() != null); - lock(SyncRoot) + lock (SyncRoot) { - return DefineMethodNoLock(name, attributes, callingConvention, returnType, returnTypeRequiredCustomModifiers, - returnTypeOptionalCustomModifiers, parameterTypes, parameterTypeRequiredCustomModifiers, + return DefineMethodNoLock(name, attributes, callingConvention, returnType, returnTypeRequiredCustomModifiers, + returnTypeOptionalCustomModifiers, parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers); } } - + private MethodBuilder DefineMethodNoLock(String name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers) @@ -1428,7 +1430,7 @@ namespace System.Reflection.Emit { 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.Ensures(Contract.Result() != null); Contract.EndContractBlock(); @@ -1440,10 +1442,10 @@ namespace System.Reflection.Emit { if (parameterTypes != null) { if (parameterTypeOptionalCustomModifiers != null && parameterTypeOptionalCustomModifiers.Length != parameterTypes.Length) - throw new ArgumentException(Environment.GetResourceString("Argument_MismatchedArrays", nameof(parameterTypeOptionalCustomModifiers), nameof(parameterTypes))); + throw new ArgumentException(SR.Format(SR.Argument_MismatchedArrays, nameof(parameterTypeOptionalCustomModifiers), nameof(parameterTypes))); if (parameterTypeRequiredCustomModifiers != null && parameterTypeRequiredCustomModifiers.Length != parameterTypes.Length) - throw new ArgumentException(Environment.GetResourceString("Argument_MismatchedArrays", nameof(parameterTypeRequiredCustomModifiers), nameof(parameterTypes))); + throw new ArgumentException(SR.Format(SR.Argument_MismatchedArrays, nameof(parameterTypeRequiredCustomModifiers), nameof(parameterTypes))); } ThrowIfCreated(); @@ -1451,21 +1453,21 @@ namespace System.Reflection.Emit { if (!m_isHiddenGlobalType) { if (((m_iAttr & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Interface) && - (attributes & MethodAttributes.Abstract) == 0 &&(attributes & MethodAttributes.Static) == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_BadAttributeOnInterfaceMethod")); + (attributes & MethodAttributes.Abstract) == 0 && (attributes & MethodAttributes.Static) == 0) + throw new ArgumentException(SR.Argument_BadAttributeOnInterfaceMethod); } // pass in Method attributes MethodBuilder method = new MethodBuilder( - name, attributes, callingConvention, + name, attributes, callingConvention, returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, - parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers, + parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers, m_module, this, false); if (!m_isHiddenGlobalType) { //If this method is declared to be a constructor, increment our constructor count. - if ((method.Attributes & MethodAttributes.SpecialName) != 0 && method.Name.Equals(ConstructorInfo.ConstructorName)) + if ((method.Attributes & MethodAttributes.SpecialName) != 0 && method.Name.Equals(ConstructorInfo.ConstructorName)) { m_constructorCount++; } @@ -1481,7 +1483,7 @@ namespace System.Reflection.Emit { #region Define Constructor public ConstructorBuilder DefineTypeInitializer() { - lock(SyncRoot) + lock (SyncRoot) { return DefineTypeInitializerNoLock(); } @@ -1504,10 +1506,10 @@ namespace System.Reflection.Emit { { if ((m_iAttr & TypeAttributes.Interface) == TypeAttributes.Interface) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ConstructorNotAllowedOnInterface")); + throw new InvalidOperationException(SR.InvalidOperation_ConstructorNotAllowedOnInterface); } - lock(SyncRoot) + lock (SyncRoot) { return DefineDefaultConstructorNoLock(attributes); } @@ -1533,14 +1535,14 @@ namespace System.Reflection.Emit { genericTypeDefinition = ((TypeBuilder)genericTypeDefinition).m_bakedRuntimeType; if (genericTypeDefinition == null) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); Type inst = genericTypeDefinition.MakeGenericType(m_typeParent.GetGenericArguments()); if (inst is TypeBuilderInstantiation) con = TypeBuilder.GetConstructor(inst, genericTypeDefinition.GetConstructor( BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null)); - else + else con = inst.GetConstructor( BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null); } @@ -1551,7 +1553,7 @@ namespace System.Reflection.Emit { } if (con == null) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NoParentDefaultConstructor")); + throw new NotSupportedException(SR.NotSupported_NoParentDefaultConstructor); // Define the constructor Builder constBuilder = DefineConstructor(attributes, CallingConventions.Standard, null); @@ -1560,7 +1562,7 @@ namespace System.Reflection.Emit { // generate the code to call the parent's default constructor ILGenerator il = constBuilder.GetILGenerator(); il.Emit(OpCodes.Ldarg_0); - il.Emit(OpCodes.Call,con); + il.Emit(OpCodes.Call, con); il.Emit(OpCodes.Ret); constBuilder.m_isDefaultConstructor = true; @@ -1572,21 +1574,21 @@ namespace System.Reflection.Emit { return DefineConstructor(attributes, callingConvention, parameterTypes, null, null); } - public ConstructorBuilder DefineConstructor(MethodAttributes attributes, CallingConventions callingConvention, + public ConstructorBuilder DefineConstructor(MethodAttributes attributes, CallingConventions callingConvention, Type[] parameterTypes, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers) { if ((m_iAttr & TypeAttributes.Interface) == TypeAttributes.Interface && (attributes & MethodAttributes.Static) != MethodAttributes.Static) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ConstructorNotAllowedOnInterface")); + throw new InvalidOperationException(SR.InvalidOperation_ConstructorNotAllowedOnInterface); } - lock(SyncRoot) + lock (SyncRoot) { return DefineConstructorNoLock(attributes, callingConvention, parameterTypes, requiredCustomModifiers, optionalCustomModifiers); } } - private ConstructorBuilder DefineConstructorNoLock(MethodAttributes attributes, CallingConventions callingConvention, + private ConstructorBuilder DefineConstructorNoLock(MethodAttributes attributes, CallingConventions callingConvention, Type[] parameterTypes, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers) { CheckContext(parameterTypes); @@ -1608,8 +1610,8 @@ namespace System.Reflection.Emit { attributes = attributes | MethodAttributes.SpecialName; - ConstructorBuilder constBuilder = - new ConstructorBuilder(name, attributes, callingConvention, + ConstructorBuilder constBuilder = + new ConstructorBuilder(name, attributes, callingConvention, parameterTypes, requiredCustomModifiers, optionalCustomModifiers, m_module, this); m_constructorCount++; @@ -1622,7 +1624,7 @@ namespace System.Reflection.Emit { #region Define Nested Type public TypeBuilder DefineNestedType(String name) { - lock(SyncRoot) + lock (SyncRoot) { return DefineNestedTypeNoLock(name, TypeAttributes.NestedPrivate, null, null, PackingSize.Unspecified, UnspecifiedTypeSize); } @@ -1630,7 +1632,7 @@ namespace System.Reflection.Emit { public TypeBuilder DefineNestedType(String name, TypeAttributes attr, Type parent, Type[] interfaces) { - lock(SyncRoot) + lock (SyncRoot) { // Why do we only call CheckContext here? Why don't we call it in the other overloads? CheckContext(parent); @@ -1642,7 +1644,7 @@ namespace System.Reflection.Emit { public TypeBuilder DefineNestedType(String name, TypeAttributes attr, Type parent) { - lock(SyncRoot) + lock (SyncRoot) { return DefineNestedTypeNoLock(name, attr, parent, null, PackingSize.Unspecified, UnspecifiedTypeSize); } @@ -1650,7 +1652,7 @@ namespace System.Reflection.Emit { public TypeBuilder DefineNestedType(String name, TypeAttributes attr) { - lock(SyncRoot) + lock (SyncRoot) { return DefineNestedTypeNoLock(name, attr, null, null, PackingSize.Unspecified, UnspecifiedTypeSize); } @@ -1658,7 +1660,7 @@ namespace System.Reflection.Emit { public TypeBuilder DefineNestedType(String name, TypeAttributes attr, Type parent, int typeSize) { - lock(SyncRoot) + lock (SyncRoot) { return DefineNestedTypeNoLock(name, attr, parent, null, PackingSize.Unspecified, typeSize); } @@ -1666,7 +1668,7 @@ namespace System.Reflection.Emit { public TypeBuilder DefineNestedType(String name, TypeAttributes attr, Type parent, PackingSize packSize) { - lock(SyncRoot) + lock (SyncRoot) { return DefineNestedTypeNoLock(name, attr, parent, null, packSize, UnspecifiedTypeSize); } @@ -1688,22 +1690,22 @@ namespace System.Reflection.Emit { #endregion #region Define Field - public FieldBuilder DefineField(String fieldName, Type type, FieldAttributes attributes) + public FieldBuilder DefineField(String fieldName, Type type, FieldAttributes attributes) { return DefineField(fieldName, type, null, null, attributes); } - public FieldBuilder DefineField(String fieldName, Type type, Type[] requiredCustomModifiers, - Type[] optionalCustomModifiers, FieldAttributes attributes) + public FieldBuilder DefineField(String fieldName, Type type, Type[] requiredCustomModifiers, + Type[] optionalCustomModifiers, FieldAttributes attributes) { - lock(SyncRoot) + lock (SyncRoot) { return DefineFieldNoLock(fieldName, type, requiredCustomModifiers, optionalCustomModifiers, attributes); } } - private FieldBuilder DefineFieldNoLock(String fieldName, Type type, Type[] requiredCustomModifiers, - Type[] optionalCustomModifiers, FieldAttributes attributes) + private FieldBuilder DefineFieldNoLock(String fieldName, Type type, Type[] requiredCustomModifiers, + Type[] optionalCustomModifiers, FieldAttributes attributes) { ThrowIfCreated(); CheckContext(type); @@ -1715,7 +1717,7 @@ namespace System.Reflection.Emit { { // remember the underlying type for enum type m_enumUnderlyingType = type; - } + } } return new FieldBuilder(this, fieldName, type, requiredCustomModifiers, optionalCustomModifiers, attributes); @@ -1723,7 +1725,7 @@ namespace System.Reflection.Emit { public FieldBuilder DefineInitializedData(String name, byte[] data, FieldAttributes attributes) { - lock(SyncRoot) + lock (SyncRoot) { return DefineInitializedDataNoLock(name, data, attributes); } @@ -1744,7 +1746,7 @@ namespace System.Reflection.Emit { public FieldBuilder DefineUninitializedData(String name, int size, FieldAttributes attributes) { - lock(SyncRoot) + lock (SyncRoot) { return DefineUninitializedDataNoLock(name, size, attributes); } @@ -1763,44 +1765,44 @@ namespace System.Reflection.Emit { #region Define Properties and Events public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes, Type returnType, Type[] parameterTypes) { - return DefineProperty(name, attributes, returnType, null, null, parameterTypes, null, null); + return DefineProperty(name, attributes, returnType, null, null, parameterTypes, null, null); } - public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes, + public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) { - return DefineProperty(name, attributes, callingConvention, returnType, null, null, parameterTypes, null, null); + return DefineProperty(name, attributes, callingConvention, returnType, null, null, parameterTypes, null, null); } - public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes, - Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, + public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes, + Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers) { - return DefineProperty(name, attributes, (CallingConventions)0, returnType, - returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, - parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers); + return DefineProperty(name, attributes, (CallingConventions)0, returnType, + returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, + parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers); } - public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes, CallingConventions callingConvention, - Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, + public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes, CallingConventions callingConvention, + Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers) { - lock(SyncRoot) + lock (SyncRoot) { - return DefinePropertyNoLock(name, attributes, callingConvention, returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, + return DefinePropertyNoLock(name, attributes, callingConvention, returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers); } } private PropertyBuilder DefinePropertyNoLock(String name, PropertyAttributes attributes, CallingConventions callingConvention, - Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, + Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers) { 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(); CheckContext(returnType); @@ -1809,8 +1811,8 @@ namespace System.Reflection.Emit { CheckContext(parameterTypeOptionalCustomModifiers); SignatureHelper sigHelper; - int sigLength; - byte[] sigBytes; + int sigLength; + byte[] sigBytes; ThrowIfCreated(); @@ -1844,7 +1846,7 @@ namespace System.Reflection.Emit { public EventBuilder DefineEvent(String name, EventAttributes attributes, Type eventtype) { - lock(SyncRoot) + lock (SyncRoot) { return DefineEventNoLock(name, attributes, eventtype); } @@ -1855,19 +1857,19 @@ namespace System.Reflection.Emit { 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)); Contract.EndContractBlock(); int tkType; - EventToken evToken; - + EventToken evToken; + CheckContext(eventtype); ThrowIfCreated(); - tkType = m_module.GetTypeTokenInternal( eventtype ).Token; + tkType = m_module.GetTypeTokenInternal(eventtype).Token; // Internal helpers to define property records evToken = new EventToken(DefineEvent( @@ -1909,7 +1911,7 @@ namespace System.Reflection.Emit { internal void CheckContext(params Type[][] typess) { - m_module.CheckContext(typess); + m_module.CheckContext(typess); } internal void CheckContext(params Type[] types) { @@ -1927,7 +1929,7 @@ namespace System.Reflection.Emit { m_typeInterfaces = new List(); int[] interfaceTokens = new int[m_typeInterfaces.Count]; - for(int i = 0; i < m_typeInterfaces.Count; i++) + for (int i = 0; i < m_typeInterfaces.Count; i++) { interfaceTokens[i] = m_module.GetTypeTokenInternal(m_typeInterfaces[i]).Token; } @@ -1976,16 +1978,16 @@ namespace System.Reflection.Emit { // Check for global typebuilder if (((m_tdType.Token & 0x00FFFFFF) != 0) && ((tkParent & 0x00FFFFFF) != 0)) SetParentType(m_module.GetNativeHandle(), m_tdType.Token, tkParent); - + if (m_inst != null) foreach (Type tb in m_inst) if (tb is GenericTypeParameterBuilder) ((GenericTypeParameterBuilder)tb).m_type.CreateType(); } - byte [] body; + byte[] body; MethodAttributes methodAttrs; - + if (!m_isHiddenGlobalType) { // create a public default constructor if this class has no constructor. @@ -1998,7 +2000,7 @@ namespace System.Reflection.Emit { int size = m_listMethods.Count; - for(int i = 0; i < size; i++) + for (int i = 0; i < size; i++) { MethodBuilder meth = m_listMethods[i]; @@ -2009,19 +2011,19 @@ namespace System.Reflection.Emit { methodAttrs = meth.Attributes; // Any of these flags in the implemenation flags is set, we will not attach the IL method body - if (((meth.GetMethodImplementationFlags() &(MethodImplAttributes.CodeTypeMask|MethodImplAttributes.PreserveSig|MethodImplAttributes.Unmanaged)) != MethodImplAttributes.IL) || - ((methodAttrs & MethodAttributes.PinvokeImpl) !=(MethodAttributes) 0)) + if (((meth.GetMethodImplementationFlags() & (MethodImplAttributes.CodeTypeMask | MethodImplAttributes.PreserveSig | MethodImplAttributes.Unmanaged)) != MethodImplAttributes.IL) || + ((methodAttrs & MethodAttributes.PinvokeImpl) != (MethodAttributes)0)) { continue; } int sigLength; byte[] localSig = meth.GetLocalSignature(out sigLength); - + // Check that they haven't declared an abstract method on a non-abstract class - if (((methodAttrs & MethodAttributes.Abstract) != 0) &&((m_iAttr & TypeAttributes.Abstract) == 0)) + if (((methodAttrs & MethodAttributes.Abstract) != 0) && ((m_iAttr & TypeAttributes.Abstract) == 0)) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadTypeAttributesNotAbstract")); + throw new InvalidOperationException(SR.InvalidOperation_BadTypeAttributesNotAbstract); } body = meth.GetBody(); @@ -2036,7 +2038,7 @@ namespace System.Reflection.Emit { //((m_iAttr & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Interface)) if (body != null) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadMethodBody")); + throw new InvalidOperationException(SR.InvalidOperation_BadMethodBody); } else if (body == null || body.Length == 0) { @@ -2051,7 +2053,7 @@ namespace System.Reflection.Emit { if ((body == null || body.Length == 0) && !meth.m_canBeRuntimeImpl) throw new InvalidOperationException( - Environment.GetResourceString("InvalidOperation_BadEmptyMethodBody", meth.Name) ); + SR.Format(SR.InvalidOperation_BadEmptyMethodBody, meth.Name)); } int maxStack = meth.GetMaxStack(); @@ -2059,7 +2061,7 @@ namespace System.Reflection.Emit { ExceptionHandler[] exceptions = meth.GetExceptionHandlers(); int[] tokenFixups = meth.GetTokenFixups(); - SetMethodIL(m_module.GetNativeHandle(), meth.GetToken().Token, meth.InitLocals, + SetMethodIL(m_module.GetNativeHandle(), meth.GetToken().Token, meth.InitLocals, body, (body != null) ? body.Length : 0, localSig, sigLength, maxStack, exceptions, (exceptions != null) ? exceptions.Length : 0, @@ -2086,7 +2088,7 @@ namespace System.Reflection.Emit { // if this type is a nested type, we need to invalidate the cached nested runtime type on the nesting type if (m_DeclaringType != null && m_DeclaringType.m_bakedRuntimeType != null) { - m_DeclaringType.m_bakedRuntimeType.InvalidateCachedNestedType(); + m_DeclaringType.m_bakedRuntimeType.InvalidateCachedNestedType(); } return cls; @@ -2104,8 +2106,8 @@ namespace System.Reflection.Emit { { get { return m_iTypeSize; } } - - public PackingSize PackingSize + + public PackingSize PackingSize { get { return m_iPackingSize; } } @@ -2119,7 +2121,7 @@ namespace System.Reflection.Emit { CheckContext(parent); if (parent.IsInterface) - throw new ArgumentException(Environment.GetResourceString("Argument_CannotSetParentToInterface")); + throw new ArgumentException(SR.Argument_CannotSetParentToInterface); m_typeParent = parent; } @@ -2132,7 +2134,7 @@ namespace System.Reflection.Emit { else { if ((m_iAttr & TypeAttributes.Abstract) == 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadInterfaceNotAbstract")); + throw new InvalidOperationException(SR.InvalidOperation_BadInterfaceNotAbstract); // there is no extends for interface class m_typeParent = null; @@ -2149,7 +2151,7 @@ namespace System.Reflection.Emit { Contract.EndContractBlock(); CheckContext(interfaceType); - + ThrowIfCreated(); TypeToken tkInterface = m_module.GetTypeTokenInternal(interfaceType); @@ -2158,14 +2160,14 @@ namespace System.Reflection.Emit { m_typeInterfaces.Add(interfaceType); } -public TypeToken TypeToken + public TypeToken TypeToken { - get + get { if (IsGenericParameter) ThrowIfCreated(); - return m_tdType; + return m_tdType; } } diff --git a/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs b/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs index da5a56ba28..6d46362f91 100644 --- a/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs +++ b/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs @@ -4,18 +4,19 @@ // +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 TypeBuilderInstantiation : 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()); } @@ -34,9 +35,9 @@ namespace System.Reflection.Emit foreach (Type t in typeArguments) { if (t == null) - throw new ArgumentNullException(nameof(typeArguments)); + throw new ArgumentNullException(nameof(typeArguments)); } - + return new TypeBuilderInstantiation(type, typeArguments); } @@ -77,26 +78,26 @@ namespace System.Reflection.Emit #endregion #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(); Contract.EndContractBlock(); string comma = ""; - for(int i = 1; i < rank; i++) + for (int i = 1; i < rank; i++) comma += ","; string s = String.Format(CultureInfo.InvariantCulture, "[{0}]", comma); @@ -106,14 +107,14 @@ namespace System.Reflection.Emit public override Object InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) { throw new NotSupportedException(); } public override Assembly Assembly { get { return m_type.Assembly; } } public override RuntimeTypeHandle TypeHandle { get { throw new NotSupportedException(); } } - public override String FullName - { - get - { + public override String FullName + { + get + { if (m_strFullQualName == null) - m_strFullQualName = TypeNameBuilder.ToString(this, TypeNameBuilder.Format.FullName); + m_strFullQualName = TypeNameBuilder.ToString(this, TypeNameBuilder.Format.FullName); return m_strFullQualName; - } + } } public override String Namespace { get { return m_type.Namespace; } } public override String AssemblyQualifiedName { get { return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.AssemblyQualifiedName); } } @@ -125,7 +126,7 @@ namespace System.Reflection.Emit for (int i = 0; i < instSubstituted.Length; i++) { Type t = inst[i]; - + if (t is TypeBuilderInstantiation) { instSubstituted[i] = (t as TypeBuilderInstantiation).Substitute(substitutes); @@ -147,7 +148,7 @@ namespace System.Reflection.Emit { // B // D : B,char> - + // D : B,char> // D : B,char> // D : B,char> @@ -159,7 +160,7 @@ namespace System.Reflection.Emit return null; TypeBuilderInstantiation typeBldrBaseAs = typeBldrBase as TypeBuilderInstantiation; - + if (typeBldrBaseAs == null) return typeBldrBase; @@ -167,7 +168,7 @@ namespace System.Reflection.Emit } } protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); } - + public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr) { throw new NotSupportedException(); } protected override MethodInfo GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); } public override MethodInfo[] GetMethods(BindingFlags bindingAttr) { throw new NotSupportedException(); } @@ -187,6 +188,9 @@ namespace System.Reflection.Emit public override EventInfo[] GetEvents(BindingFlags bindingAttr) { throw new NotSupportedException(); } public override MemberInfo[] GetMembers(BindingFlags bindingAttr) { throw new NotSupportedException(); } protected override TypeAttributes GetAttributeFlagsImpl() { return m_type.Attributes; } + + public override bool IsSZArray => false; + protected override bool IsArrayImpl() { return false; } protected override bool IsByRefImpl() { return false; } protected override bool IsPointerImpl() { return false; } @@ -217,7 +221,7 @@ namespace System.Reflection.Emit } public override MethodBase DeclaringMethod { get { return null; } } public override Type GetGenericTypeDefinition() { return m_type; } - public override Type MakeGenericType(params Type[] inst) { throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericTypeDefinition")); } + public override Type MakeGenericType(params Type[] inst) { throw new InvalidOperationException(SR.Arg_NotGenericTypeDefinition); } public override bool IsAssignableFrom(Type c) { throw new NotSupportedException(); } [Pure] diff --git a/src/mscorlib/src/System/Reflection/Emit/TypeToken.cs b/src/mscorlib/src/System/Reflection/Emit/TypeToken.cs index 4fa851c529..4f0c1b3dac 100644 --- a/src/mscorlib/src/System/Reflection/Emit/TypeToken.cs +++ b/src/mscorlib/src/System/Reflection/Emit/TypeToken.cs @@ -12,33 +12,36 @@ ** ** ===========================================================*/ -namespace System.Reflection.Emit { - - using System; - using System.Reflection; - using System.Threading; +using System; +using System.Reflection; +using System.Threading; + +namespace System.Reflection.Emit +{ [Serializable] - public struct TypeToken { - + public struct TypeToken + { public static readonly TypeToken Empty = new TypeToken(); internal int m_class; - - - internal TypeToken(int str) { - m_class=str; + + + internal TypeToken(int str) + { + m_class = str; } - - public int Token { + + public int Token + { get { return m_class; } } - + public override int GetHashCode() { return m_class; } - + public override bool Equals(Object obj) { if (obj is TypeToken) @@ -46,22 +49,21 @@ namespace System.Reflection.Emit { else return false; } - + public bool Equals(TypeToken obj) { return obj.m_class == m_class; } - + public static bool operator ==(TypeToken a, TypeToken b) { return a.Equals(b); } - + public static bool operator !=(TypeToken a, TypeToken b) { return !(a == b); } - } } diff --git a/src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs b/src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs index ca0faf31ca..78238c02b7 100644 --- a/src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs +++ b/src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs @@ -4,16 +4,16 @@ // +using System; +using System.Reflection; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Diagnostics; +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; - using System.Diagnostics.Contracts; - internal sealed class MethodOnTypeBuilderInstantiation : MethodInfo { #region Private Static Members @@ -37,21 +37,21 @@ namespace System.Reflection.Emit m_type = type; } #endregion - + internal override Type[] GetParameterTypes() { return m_method.GetParameterTypes(); } #region MemberInfo Overrides - 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_type; } } public override Type ReflectedType { get { return m_type; } } - 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; } } + public override Module Module { get { return m_method.Module; } } #endregion #region MethodBase Members @@ -65,21 +65,21 @@ namespace System.Reflection.Emit throw new NotSupportedException(); } public override CallingConventions CallingConvention { get { return m_method.CallingConvention; } } - public override Type [] GetGenericArguments() { return m_method.GetGenericArguments(); } + public override Type[] GetGenericArguments() { return m_method.GetGenericArguments(); } public override MethodInfo GetGenericMethodDefinition() { return m_method; } public override bool IsGenericMethodDefinition { get { return m_method.IsGenericMethodDefinition; } } public override bool ContainsGenericParameters { get { return m_method.ContainsGenericParameters; } } public override MethodInfo MakeGenericMethod(params Type[] typeArgs) { if (!IsGenericMethodDefinition) - throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericMethodDefinition")); + throw new InvalidOperationException(SR.Arg_NotGenericMethodDefinition); Contract.EndContractBlock(); return MethodBuilderInstantiation.MakeGenericMethod(this, typeArgs); } public override bool IsGenericMethod { get { return m_method.IsGenericMethod; } } - + #endregion #region Public Abstract\Virtual Members @@ -113,7 +113,7 @@ namespace System.Reflection.Emit m_type = type; } #endregion - + internal override Type[] GetParameterTypes() { return m_ctor.GetParameterTypes(); @@ -129,7 +129,7 @@ namespace System.Reflection.Emit public override String Name { get { return m_ctor.Name; } } public override Type DeclaringType { get { return m_type; } } public override Type ReflectedType { get { return m_type; } } - public override Object[] GetCustomAttributes(bool inherit) { return m_ctor.GetCustomAttributes(inherit); } + public override Object[] GetCustomAttributes(bool inherit) { return m_ctor.GetCustomAttributes(inherit); } public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { return m_ctor.GetCustomAttributes(attributeType, inherit); } public override bool IsDefined(Type attributeType, bool inherit) { return m_ctor.IsDefined(attributeType, inherit); } internal int MetadataTokenInternal @@ -147,7 +147,7 @@ namespace System.Reflection.Emit } } } - public override Module Module { get { return m_ctor.Module; } } + public override Module Module { get { return m_ctor.Module; } } #endregion #region MethodBase Members @@ -195,10 +195,12 @@ namespace System.Reflection.Emit // We're not entirely sure if this cache helps any specific scenarios, so // long-term, one could investigate whether it's needed. In any case, this // method isn't expected to be on any critical paths for performance. - if (type.m_hashtable.Contains(Field)) { + if (type.m_hashtable.Contains(Field)) + { m = type.m_hashtable[Field] as FieldInfo; } - else { + else + { m = new FieldOnTypeBuilderInstantiation(Field, type); type.m_hashtable[Field] = m; } @@ -225,11 +227,11 @@ namespace System.Reflection.Emit internal FieldInfo FieldInfo { get { return m_field; } } #region MemberInfo Overrides - public override MemberTypes MemberType { get { return System.Reflection.MemberTypes.Field; } } + public override MemberTypes MemberType { get { return System.Reflection.MemberTypes.Field; } } public override String Name { get { return m_field.Name; } } public override Type DeclaringType { get { return m_type; } } public override Type ReflectedType { get { return m_type; } } - public override Object[] GetCustomAttributes(bool inherit) { return m_field.GetCustomAttributes(inherit); } + public override Object[] GetCustomAttributes(bool inherit) { return m_field.GetCustomAttributes(inherit); } public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { return m_field.GetCustomAttributes(attributeType, inherit); } public override bool IsDefined(Type attributeType, bool inherit) { return m_field.IsDefined(attributeType, inherit); } internal int MetadataTokenInternal @@ -247,7 +249,7 @@ namespace System.Reflection.Emit } } } - public override Module Module { get { return m_field.Module; } } + public override Module Module { get { return m_field.Module; } } #endregion #region Public Abstract\Virtual Members @@ -260,15 +262,15 @@ namespace System.Reflection.Emit public override Object GetValueDirect(TypedReference obj) { throw new NotImplementedException(); - } - public override RuntimeFieldHandle FieldHandle + } + public override RuntimeFieldHandle FieldHandle { get { throw new NotImplementedException(); } - } + } public override Type FieldType { get { throw new NotImplementedException(); } } public override Object GetValue(Object obj) { throw new InvalidOperationException(); } public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture) { throw new InvalidOperationException(); } - public override FieldAttributes Attributes { get { return m_field.Attributes; } } + public override FieldAttributes Attributes { get { return m_field.Attributes; } } #endregion } } -- cgit v1.2.3