modulebuilder.cs
来自「没的 没的 没的 没的 没的 没的 没的 没的 没的 没的 没的 没的 没的 没」· CS 代码 · 共 715 行 · 第 1/2 页
CS
715 行
// Get a method on an array class. [TODO] public MethodInfo GetArrayMethod (Type arrayClass, String methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) { try { StartSync(); // TODO return null; } finally { EndSync(); } } // Get the token for a method on an array class. [TODO] public MethodToken GetArrayMethodToken (Type arrayClass, String methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) { try { StartSync(); // TODO return new MethodToken(0); } finally { EndSync(); } } // Get the token for a constructor within this module. Returns // a member reference if the constructor is in another assembly. public MethodToken GetConstructorToken(ConstructorInfo con) { if(con == null) { throw new ArgumentNullException("con"); } else if(con is ConstructorBuilder) { ConstructorBuilder cb = (con as ConstructorBuilder); if(cb.type.module == this) { return cb.GetToken(); } } else if(con is ClrConstructor) { lock(typeof(AssemblyBuilder)) { return new MethodToken (TypeBuilder.ClrTypeImportMember (privateData, ((ClrConstructor)con).ClrHandle)); } } throw new InvalidOperationException(_("Emit_CannotImportItem")); } // Get the token for a field within this module. Returns // a member reference if the constructor is in another assembly. public FieldToken GetFieldToken(FieldInfo field) { if(field == null) { throw new ArgumentNullException("field"); } else if(field is FieldBuilder) { FieldBuilder fb = (field as FieldBuilder); if(fb.type.module == this) { return fb.GetToken(); } } else if(field is ClrField) { lock(typeof(AssemblyBuilder)) { return new FieldToken (TypeBuilder.ClrTypeImportMember (privateData, ((ClrField)field).ClrHandle)); } } throw new InvalidOperationException(_("Emit_CannotImportItem")); } // Get the token for a method within this module. Returns // a member reference if the constructor is in another assembly. public MethodToken GetMethodToken(MethodInfo method) { if(method == null) { throw new ArgumentNullException("method"); } else if(method is MethodBuilder) { MethodBuilder mb = (method as MethodBuilder); if(mb.type.module == this) { return mb.GetToken(); } } else if(method is ClrMethod) { lock(typeof(AssemblyBuilder)) { return new MethodToken (TypeBuilder.ClrTypeImportMember (privateData, ((ClrMethod)method).ClrHandle)); } } throw new InvalidOperationException(_("Emit_CannotImportItem")); } // Get a token for a signature within this module. [TODO] public SignatureToken GetSignatureToken(SignatureHelper sigHelper) { // TODO return new SignatureToken(0); } [TODO] public SignatureToken GetSignatureToken(byte[] sigBytes, int sigLength) { // TODO return new SignatureToken(0); } // Get a token for a string constant within this module. public StringToken GetStringConstant(String str) { if(str == null) { throw new ArgumentNullException("str"); } lock(typeof(AssemblyBuilder)) { return new StringToken (ClrModuleCreateString(privateData, str)); } } // Get the symbol writer associated with this module. [TODO] public ISymbolWriter GetSymWriter() { // TODO return null; } // Find a type within this module. Returns NULL if not present. [TODO] private Type FindType(String className) { // TODO return null; } // Find a type within this module, while ignoring the case in names. // Returns NULL if not present. [TODO] private Type FindTypeIgnoreCase(String className) { // TODO return null; } // Get a type from within this module. public override Type GetType(String className) { return FindType(className); } public override Type GetType(String className, bool ignoreCase) { if(ignoreCase) { return FindTypeIgnoreCase(className); } else { return FindType(className); } } public override Type GetType(String className, bool throwOnError, bool ignoreCase) { Type type; if(ignoreCase) { type = FindTypeIgnoreCase(className); } else { type = FindType(className); } if(type == null && throwOnError) { throw new TypeLoadException(_("Exception_TypeLoad")); } return type; } // Get all classes that were defined in this module. [TODO] public override Type[] GetTypes() { // TODO return null; } // Get a type token by name. public TypeToken GetTypeToken(String name) { return GetTypeToken(GetType(name, true, false)); } // Get a type token by type. public TypeToken GetTypeToken(Type type) { if(type == null) { throw new ArgumentNullException("type"); } else if(type is TypeBuilder) { TypeBuilder tb = (type as TypeBuilder); if(tb.module == this) { return tb.TypeToken; } } else if(type is EnumBuilder) { EnumBuilder eb = (type as EnumBuilder); if(eb.builder.module == this) { return eb.builder.TypeToken; } } else if(type is ClrType) { if(type.IsByRef) { throw new ArgumentException (_("Emit_CannotImportRefType")); } lock(typeof(AssemblyBuilder)) { return new TypeToken (TypeBuilder.ClrTypeImport (privateData, ((ClrType)type).ClrHandle)); } } throw new InvalidOperationException(_("Emit_CannotImportItem")); } // Determine if this module is transient. public bool IsTransient() { return transient; } // Set a custom attribute on this module. [TODO] public void SetCustomAttribute(CustomAttributeBuilder customBuilder) { try { StartSync(); // TODO } finally { EndSync(); } } [TODO] public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) { try { StartSync(); // TODO } finally { EndSync(); } } // Set a custom attribute that is stored with symbolic information. [TODO] public void SetSymCustomAttribute(String name, byte[] data) { try { StartSync(); // TODO } finally { EndSync(); } } // Set the user entry point for this module. [TODO] public void SetUserEntryPoint(MethodInfo entryPoint) { try { StartSync(); // TODO } finally { EndSync(); } } // Detach this item. void IDetachItem.Detach() { privateData = IntPtr.Zero; } // Create a module within an assembly. [MethodImpl(MethodImplOptions.InternalCall)] extern private static IntPtr ClrModuleCreate(IntPtr assembly, String name); // Create a string token within this module. [MethodImpl(MethodImplOptions.InternalCall)] extern private static int ClrModuleCreateString(IntPtr module, String str); // Write data directly to the ".sdata" section of a module. [MethodImpl(MethodImplOptions.InternalCall)] extern internal static int ClrModuleWriteData(IntPtr module, byte[] data); // Write zero data directly to the ".sdata" section of a module. [MethodImpl(MethodImplOptions.InternalCall)] extern internal static int ClrModuleWriteGap(IntPtr module, int size);}; // class ModuleBuilder#endif // CONFIG_REFLECTION_EMIT}; // namespace System.Reflection.Emit
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?