ILGenerator ILGenerator ILGenerator ILGenerator Class

定义

生成 Microsoft 中间语言 (MSIL) 指令。Generates Microsoft intermediate language (MSIL) instructions.

public ref class ILGenerator : System::Runtime::InteropServices::_ILGenerator
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Runtime.InteropServices.ComVisible(true)]
public class ILGenerator : System.Runtime.InteropServices._ILGenerator
type ILGenerator = class
    interface _ILGenerator
Public Class ILGenerator
Implements _ILGenerator
继承
ILGeneratorILGeneratorILGeneratorILGenerator
属性
实现

注解

ILGenerator 用于在动态程序集中生成方法体的方法和构造函数 (由MethodBuilderConstructorBuilder类) 和独立的动态方法 (由DynamicMethod类)。ILGenerator is used to generate method bodies for methods and constructors in dynamic assemblies (represented by the MethodBuilder and ConstructorBuilder classes) and for standalone dynamic methods (represented by the DynamicMethod class). 若要获取ILGenerator,使用ConstructorBuilder.GetILGeneratorDynamicMethod.GetILGenerator,和MethodBuilder.GetILGenerator方法。To obtain an ILGenerator, use the ConstructorBuilder.GetILGenerator, DynamicMethod.GetILGenerator, and MethodBuilder.GetILGenerator methods.

MSIL 用作实时 (JIT) 编译器的输入。MSIL is used as input to a just-in-time (JIT) compiler.

属性

ILOffset ILOffset ILOffset ILOffset

获取由 ILGenerator 发出的 Microsoft 中间语言 (MSIL) 流中的当前偏移量(以字节为单位)。Gets the current offset, in bytes, in the Microsoft intermediate language (MSIL) stream that is being emitted by the ILGenerator.

方法

BeginCatchBlock(Type) BeginCatchBlock(Type) BeginCatchBlock(Type) BeginCatchBlock(Type)

开始 Catch 块。Begins a catch block.

BeginExceptFilterBlock() BeginExceptFilterBlock() BeginExceptFilterBlock() BeginExceptFilterBlock()

开始已筛选异常的异常块。Begins an exception block for a filtered exception.

BeginExceptionBlock() BeginExceptionBlock() BeginExceptionBlock() BeginExceptionBlock()

开始非筛选异常的异常块。Begins an exception block for a non-filtered exception.

BeginFaultBlock() BeginFaultBlock() BeginFaultBlock() BeginFaultBlock()

在 Microsoft 中间语言 (MSIL) 流中开始一个异常错误块。Begins an exception fault block in the Microsoft intermediate language (MSIL) stream.

BeginFinallyBlock() BeginFinallyBlock() BeginFinallyBlock() BeginFinallyBlock()

在 Microsoft 中间语言 (MSIL) 指令流中开始一个 Finally 块。Begins a finally block in the Microsoft intermediate language (MSIL) instruction stream.

BeginScope() BeginScope() BeginScope() BeginScope()

开始词法范围。Begins a lexical scope.

DeclareLocal(Type) DeclareLocal(Type) DeclareLocal(Type) DeclareLocal(Type)

声明指定类型的局部变量。Declares a local variable of the specified type.

DeclareLocal(Type, Boolean) DeclareLocal(Type, Boolean) DeclareLocal(Type, Boolean) DeclareLocal(Type, Boolean)

声明指定类型的局部变量,还可以选择固定该变量所引用的对象。Declares a local variable of the specified type, optionally pinning the object referred to by the variable.

DefineLabel() DefineLabel() DefineLabel() DefineLabel()

声明新标签。Declares a new label.

Emit(OpCode) Emit(OpCode) Emit(OpCode) Emit(OpCode)

将指定的指令放到指令流上。Puts the specified instruction onto the stream of instructions.

Emit(OpCode, Byte) Emit(OpCode, Byte) Emit(OpCode, Byte) Emit(OpCode, Byte)

将指定的指令和字符参数放到 Microsoft 中间语言 (MSIL) 指令流上。Puts the specified instruction and character argument onto the Microsoft intermediate language (MSIL) stream of instructions.

Emit(OpCode, ConstructorInfo) Emit(OpCode, ConstructorInfo) Emit(OpCode, ConstructorInfo) Emit(OpCode, ConstructorInfo)

将指定构造函数的指定指令和元数据令牌放到 Microsoft 中间语言 (MSIL) 指令流上。Puts the specified instruction and metadata token for the specified constructor onto the Microsoft intermediate language (MSIL) stream of instructions.

Emit(OpCode, Double) Emit(OpCode, Double) Emit(OpCode, Double) Emit(OpCode, Double)

将指定的指令和数值参数放到 Microsoft 中间语言 (MSIL) 指令流上。Puts the specified instruction and numerical argument onto the Microsoft intermediate language (MSIL) stream of instructions.

Emit(OpCode, FieldInfo) Emit(OpCode, FieldInfo) Emit(OpCode, FieldInfo) Emit(OpCode, FieldInfo)

将指定字段的指定指令和元数据令牌放到 Microsoft 中间语言 (MSIL) 指令流上。Puts the specified instruction and metadata token for the specified field onto the Microsoft intermediate language (MSIL) stream of instructions.

Emit(OpCode, Int16) Emit(OpCode, Int16) Emit(OpCode, Int16) Emit(OpCode, Int16)

将指定的指令和数值参数放到 Microsoft 中间语言 (MSIL) 指令流上。Puts the specified instruction and numerical argument onto the Microsoft intermediate language (MSIL) stream of instructions.

Emit(OpCode, Int32) Emit(OpCode, Int32) Emit(OpCode, Int32) Emit(OpCode, Int32)

将指定的指令和数值参数放到 Microsoft 中间语言 (MSIL) 指令流上。Puts the specified instruction and numerical argument onto the Microsoft intermediate language (MSIL) stream of instructions.

Emit(OpCode, Int64) Emit(OpCode, Int64) Emit(OpCode, Int64) Emit(OpCode, Int64)

将指定的指令和数值参数放到 Microsoft 中间语言 (MSIL) 指令流上。Puts the specified instruction and numerical argument onto the Microsoft intermediate language (MSIL) stream of instructions.

Emit(OpCode, Label) Emit(OpCode, Label) Emit(OpCode, Label) Emit(OpCode, Label)

将指定的指令放到 Microsoft 中间语言 (MSIL) 流上,并留出在完成修正时加上标签所需的空白。Puts the specified instruction onto the Microsoft intermediate language (MSIL) stream and leaves space to include a label when fixes are done.

Emit(OpCode, Label[]) Emit(OpCode, Label[]) Emit(OpCode, Label[]) Emit(OpCode, Label[])

将指定的指令放到 Microsoft 中间语言 (MSIL) 流上,并留出在完成修正时加上标签所需的空白。Puts the specified instruction onto the Microsoft intermediate language (MSIL) stream and leaves space to include a label when fixes are done.

Emit(OpCode, LocalBuilder) Emit(OpCode, LocalBuilder) Emit(OpCode, LocalBuilder) Emit(OpCode, LocalBuilder)

将指定的指令放到 Microsoft 中间语言 (MSIL) 流上,后跟给定局部变量的索引。Puts the specified instruction onto the Microsoft intermediate language (MSIL) stream followed by the index of the given local variable.

Emit(OpCode, MethodInfo) Emit(OpCode, MethodInfo) Emit(OpCode, MethodInfo) Emit(OpCode, MethodInfo)

将指定的指令放到 Microsoft 中间语言 (MSIL) 流上,后跟给定方法的元数据令牌。Puts the specified instruction onto the Microsoft intermediate language (MSIL) stream followed by the metadata token for the given method.

Emit(OpCode, SByte) Emit(OpCode, SByte) Emit(OpCode, SByte) Emit(OpCode, SByte)

将指定的指令和字符参数放到 Microsoft 中间语言 (MSIL) 指令流上。Puts the specified instruction and character argument onto the Microsoft intermediate language (MSIL) stream of instructions.

Emit(OpCode, SignatureHelper) Emit(OpCode, SignatureHelper) Emit(OpCode, SignatureHelper) Emit(OpCode, SignatureHelper)

将指定的指令和签名令牌放到 Microsoft 中间语言 (MSIL) 指令流上。Puts the specified instruction and a signature token onto the Microsoft intermediate language (MSIL) stream of instructions.

Emit(OpCode, Single) Emit(OpCode, Single) Emit(OpCode, Single) Emit(OpCode, Single)

将指定的指令和数值参数放到 Microsoft 中间语言 (MSIL) 指令流上。Puts the specified instruction and numerical argument onto the Microsoft intermediate language (MSIL) stream of instructions.

Emit(OpCode, String) Emit(OpCode, String) Emit(OpCode, String) Emit(OpCode, String)

将指定的指令放到 Microsoft 中间语言 (MSIL) 流上,后跟给定字符串的元数据令牌。Puts the specified instruction onto the Microsoft intermediate language (MSIL) stream followed by the metadata token for the given string.

Emit(OpCode, Type) Emit(OpCode, Type) Emit(OpCode, Type) Emit(OpCode, Type)

将指定的指令放到 Microsoft 中间语言 (MSIL) 流上,后跟给定类型的元数据令牌。Puts the specified instruction onto the Microsoft intermediate language (MSIL) stream followed by the metadata token for the given type.

EmitCall(OpCode, MethodInfo, Type[]) EmitCall(OpCode, MethodInfo, Type[]) EmitCall(OpCode, MethodInfo, Type[]) EmitCall(OpCode, MethodInfo, Type[])

callcallvirt 指令置于 Microsoft 中间语言 (MSIL) 流,以调用 varargs 方法。Puts a call or callvirt instruction onto the Microsoft intermediate language (MSIL) stream to call a varargs method.

EmitCalli(OpCode, CallingConvention, Type, Type[]) EmitCalli(OpCode, CallingConvention, Type, Type[]) EmitCalli(OpCode, CallingConvention, Type, Type[]) EmitCalli(OpCode, CallingConvention, Type, Type[])

Calli 指令放到 Microsoft 中间语言 (MSIL) 流,并指定间接调用的非托管调用约定。Puts a Calli instruction onto the Microsoft intermediate language (MSIL) stream, specifying an unmanaged calling convention for the indirect call.

EmitCalli(OpCode, CallingConventions, Type, Type[], Type[]) EmitCalli(OpCode, CallingConventions, Type, Type[], Type[]) EmitCalli(OpCode, CallingConventions, Type, Type[], Type[]) EmitCalli(OpCode, CallingConventions, Type, Type[], Type[])

Calli 指令放到 Microsoft 中间语言 (MSIL) 流,并指定间接调用的托管调用约定。Puts a Calli instruction onto the Microsoft intermediate language (MSIL) stream, specifying a managed calling convention for the indirect call.

EmitWriteLine(FieldInfo) EmitWriteLine(FieldInfo) EmitWriteLine(FieldInfo) EmitWriteLine(FieldInfo)

发出用给定字段调用 WriteLine 所需的 Microsoft 中间语言 (MSIL)。Emits the Microsoft intermediate language (MSIL) necessary to call WriteLine with the given field.

EmitWriteLine(LocalBuilder) EmitWriteLine(LocalBuilder) EmitWriteLine(LocalBuilder) EmitWriteLine(LocalBuilder)

发出使用给定本地变量调用 WriteLine 时必需的 Microsoft 中间语言 (MSIL)。Emits the Microsoft intermediate language (MSIL) necessary to call WriteLine with the given local variable.

EmitWriteLine(String) EmitWriteLine(String) EmitWriteLine(String) EmitWriteLine(String)

发出 Microsoft 中间语言 (MSIL) 以用字符串调用 WriteLineEmits the Microsoft intermediate language (MSIL) to call WriteLine with a string.

EndExceptionBlock() EndExceptionBlock() EndExceptionBlock() EndExceptionBlock()

结束异常块。Ends an exception block.

EndScope() EndScope() EndScope() EndScope()

结束词法范围。Ends a lexical scope.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
MarkLabel(Label) MarkLabel(Label) MarkLabel(Label) MarkLabel(Label)

用给定标签标记 Microsoft 中间语言 (MSIL) 流的当前位置。Marks the Microsoft intermediate language (MSIL) stream's current position with the given label.

MarkSequencePoint(ISymbolDocumentWriter, Int32, Int32, Int32, Int32) MarkSequencePoint(ISymbolDocumentWriter, Int32, Int32, Int32, Int32) MarkSequencePoint(ISymbolDocumentWriter, Int32, Int32, Int32, Int32) MarkSequencePoint(ISymbolDocumentWriter, Int32, Int32, Int32, Int32)

在 Microsoft 中间语言 (MSIL) 流中标记序列点。Marks a sequence point in the Microsoft intermediate language (MSIL) stream.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ThrowException(Type) ThrowException(Type) ThrowException(Type) ThrowException(Type)

发出指令以引发异常。Emits an instruction to throw an exception.

ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)
UsingNamespace(String) UsingNamespace(String) UsingNamespace(String) UsingNamespace(String)

指定用于计算当前活动词法范围的局部变量和监视值的命名空间。Specifies the namespace to be used in evaluating locals and watches for the current active lexical scope.

显式界面实现

_ILGenerator.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _ILGenerator.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _ILGenerator.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _ILGenerator.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。Maps a set of names to a corresponding set of dispatch identifiers.

_ILGenerator.GetTypeInfo(UInt32, UInt32, IntPtr) _ILGenerator.GetTypeInfo(UInt32, UInt32, IntPtr) _ILGenerator.GetTypeInfo(UInt32, UInt32, IntPtr) _ILGenerator.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。Retrieves the type information for an object, which can then be used to get the type information for an interface.

_ILGenerator.GetTypeInfoCount(UInt32) _ILGenerator.GetTypeInfoCount(UInt32) _ILGenerator.GetTypeInfoCount(UInt32) _ILGenerator.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

_ILGenerator.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _ILGenerator.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _ILGenerator.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _ILGenerator.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对某一对象公开的属性和方法的访问。Provides access to properties and methods exposed by an object.

适用于