public class ILGenerator
|
BeginCatchBlock | Begins a catch block. |
BeginExceptFilterBlock | Begins an exception block for a filtered exception. |
BeginExceptionBlock | Begins an exception block for a non-filtered exception. |
BeginFaultBlock | Begins an exception fault block in the Microsoft intermediate language (MSIL) stream. |
BeginFinallyBlock | Begins a finally block in the Microsoft intermediate language (MSIL) instruction stream. |
BeginScope | Begins a lexical scope. |
DeclareLocal | Declares a local variable. |
DefineLabel | Declares a new label. |
Emit | Overloaded:Emit(OpCode opcode) Puts the specified instruction onto the stream of instructions. |
Emit | Overloaded:Emit(OpCode opcode, byte arg) Puts the specified instruction and character argument onto the Microsoft intermediate language (MSIL) stream of instructions. |
Emit | Overloaded:Emit(OpCode opcode, ConstructorInfo con) Puts the specified instruction and metadata token for the specified constructor onto the Microsoft intermediate language (MSIL) stream of instructions. |
Emit | Overloaded:Emit(OpCode opcode, double arg) Puts the specified instruction and numerical argument onto the Microsoft intermediate language (MSIL) stream of instructions. |
Emit | Overloaded:Emit(OpCode opcode, FieldInfo field) Puts the specified instruction and metadata token for the specified field onto the Microsoft intermediate language (MSIL) stream of instructions. |
Emit | Overloaded:Emit(OpCode opcode, short arg) Puts the specified instruction and numerical argument onto the Microsoft intermediate language (MSIL) stream of instructions. |
Emit | Overloaded:Emit(OpCode opcode, int arg) Puts the specified instruction and numerical argument onto the Microsoft intermediate language (MSIL) stream of instructions. |
Emit | Overloaded:Emit(OpCode opcode, long arg) Puts the specified instruction and numerical argument onto the Microsoft intermediate language (MSIL) stream of instructions. |
Emit | Overloaded:Emit(OpCode opcode, Label label) Puts the specified instruction onto the Microsoft intermediate language (MSIL) stream and leaves space to include a label when fixes are done. |
Emit | Overloaded:Emit(OpCode opcode, Label[] labels) Puts the specified instruction onto the Microsoft intermediate language (MSIL) stream and leaves space to include a label when fixes are done. |
Emit | Overloaded:Emit(OpCode opcode, LocalBuilder local) Puts the specified instruction onto the Microsoft intermediate language (MSIL) stream followed by the index of the given local variable. |
Emit | Overloaded:Emit(OpCode opcode, MethodInfo meth) Puts the specified instruction onto the Microsoft intermediate language (MSIL) stream followed by the metadata token for the given method. |
Emit | Overloaded:Emit(OpCode opcode, sbyte arg) Puts the specified instruction and character argument onto the Microsoft intermediate language (MSIL) stream of instructions. |
Emit | Overloaded:Emit(OpCode opcode, SignatureHelper signature) Puts the specified instruction and a signature token onto the Microsoft intermediate language (MSIL) stream of instructions. |
Emit | Overloaded:Emit(OpCode opcode, float arg) Puts the specified instruction and numerical argument onto the Microsoft intermediate language (MSIL) stream of instructions. |
Emit | Overloaded:Emit(OpCode opcode, string str) Puts the specified instruction onto the Microsoft intermediate language (MSIL) stream followed by the metadata token for the given string. |
Emit | Overloaded:Emit(OpCode opcode, Type cls) Puts the specified instruction onto the Microsoft intermediate language (MSIL) stream followed by the metadata token for the given type. |
EmitCall | Puts a call or callvirt instruction onto the Microsoft intermediate language (MSIL) stream. |
EmitCalli | Overloaded:EmitCalli(OpCode opcode, CallingConvention unmanagedCallConv, Type returnType, Type[] parameterTypes) Puts a calli instruction using an unmanaged calling convention onto the Microsoft intermediate language (MSIL) stream. |
EmitCalli | Overloaded:EmitCalli(OpCode opcode, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type[] optionalParameterTypes) Puts a calli instruction using a managed calling convention onto the Microsoft intermediate language (MSIL) stream. |
EmitWriteLine | Overloaded:EmitWriteLine(FieldInfo fld) Emits the Microsoft intermediate language (MSIL) necessary to call Console.WriteLine with the given field. |
EmitWriteLine | Overloaded:EmitWriteLine(LocalBuilder localBuilder) Emits the Microsoft intermediate language (MSIL) necessary to call Console.WriteLine with the given local variable. |
EmitWriteLine | Overloaded:EmitWriteLine(string value) Emits the Microsoft intermediate language (MSIL) to call Console.WriteLine with a string. |
EndExceptionBlock | Ends an exception block. |
EndScope | Ends a lexical scope. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
MarkLabel | Marks the Microsoft intermediate language (MSIL) stream's current position with the given label. |
MarkSequencePoint | Marks a sequence point in the Microsoft intermediate language (MSIL) stream. |
ThrowException | Emits an instruction to throw an exception. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
UsingNamespace | Specifies the namespace to be used in evaluating locals and watches for the current active lexical scope. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
public virtual void BeginCatchBlock( |
exceptionType
Exception Type | Condition |
---|---|
ArgumentException | The catch block is within a filtered exception. |
ArgumentNullException | exceptionType is null and the exception filter block has not returned a value that indicates that finally blocks should be run until this catch block is located. |
NotSupportedException | The Microsoft intermediate language (MSIL) being generated is not currently in an exception block. |
public virtual void BeginExceptFilterBlock(); |
Exception Type | Condition |
---|---|
NotSupportedException | The Microsoft intermediate language (MSIL) being generated is not currently in an exception block. |
public virtual Label BeginExceptionBlock(); |
public virtual void BeginFaultBlock(); |
Exception Type | Condition |
---|---|
NotSupportedException | The Microsoft intermediate language (MSIL) being generated is not currently in an exception block. |
public virtual void BeginFinallyBlock(); |
Exception Type | Condition |
---|---|
NotSupportedException | The Microsoft intermediate language (MSIL) being generated is not currently in an exception block. |
public virtual void BeginScope(); |
public LocalBuilder DeclareLocal( |
localType
Exception Type | Condition |
---|---|
ArgumentNullException | localType is null. |
InvalidOperationException | The containing type has been created with TypeBuilder.CreateType. |
public virtual Label DefineLabel(); |
This is just a token and does not yet represent any particular location within the stream.
public virtual void Emit( |
opcode
opcode
arg
public virtual void Emit( |
opcode
con
opcode
arg
opcode
field
opcode
arg
opcode
arg
opcode
arg
opcode
label
opcode
labels
The instruction values are defined in the OpCodes enumeration.
Labels are created using ILGenerator.DefineLabel and their location within the stream is fixed by using ILGenerator.MarkLabel. If a single-byte instruction is used, the label can represent a jump of at most 127 bytes along the stream.instruction must represent a branch instruction. Since branches are relative instructions, label will be replaced with the correct offset to branch during the fixup process.
public virtual void Emit( |
opcode
local
Exception Type | Condition |
---|---|
ArgumentException | local 's parent method does not match the method associated with this ILGenerator. |
ArgumentNullException | local is null. |
InvalidOperationException | instruction is a single-byte instruction and local represents a local with an index of greater than Byte.MaxValue. |
public virtual void Emit( |
opcode
meth
Exception Type | Condition |
---|---|
ArgumentNullException | meth is null. |
opcode
arg
public virtual void Emit( |
opcode
signature
Exception Type | Condition |
---|---|
ArgumentNullException | signature is null. |
opcode
arg
opcode
str
opcode
cls
Exception Type | Condition |
---|---|
ArgumentNullException | cls is null. |
public void EmitCall( |
opcode
methodInfo
optionalParameterTypes
Exception Type | Condition |
---|---|
ArgumentNullException | methodInfo is null. |
InvalidOperationException | The calling convention for the method is not varargs but optional parameter types are supplied. |
public void EmitCalli( |
opcode
unmanagedCallConv
returnType
parameterTypes
public void EmitCalli( |
opcode
callingConvention
returnType
parameterTypes
optionalParameterTypes
public virtual void EmitWriteLine( |
fld
Exception Type | Condition |
---|---|
ArgumentException | There is no TextWriter.WriteLine method for the type of the specified field. |
ArgumentNullException | fld is null. |
NotSupportedException | The type of the field is TypeBuilder or EnumBuilder. |
public virtual void EmitWriteLine( |
localBuilder
Exception Type | Condition |
---|---|
ArgumentException | The type of localBuilder is not supported (TypeBuilder, for example). |
public virtual void EmitWriteLine( |
value
public virtual void EndExceptionBlock(); |
Exception Type | Condition |
---|---|
InvalidOperationException | The end exception block occurs in an unexpected place in the code stream. |
NotSupportedException | The Microsoft intermediate language (MSIL) being generated is not currently in an exception block. |
public virtual void EndScope(); |
~ILGenerator(); |
public virtual int GetHashCode(); |
public Type GetType(); |
public virtual void MarkLabel( |
loc
Exception Type | Condition |
---|---|
ArgumentException | loc represents an invalid index into the label array. -or- An index for loc has already been defined. |
public virtual void MarkSequencePoint( |
document
startLine
startColumn
endLine
endColumn
Exception Type | Condition |
---|---|
ArgumentOutOfRangeException | startLine or endLine is <= 0. |
The symbolic information normally includes at least one Microsoft intermediate language (MSIL) offset for each source line. When the just-in-time (JIT) compiler is about to compile a method, it asks the profiling services for a list of MSIL offsets that should be preserved. These MSIL offsets are called sequence points.
protected object MemberwiseClone(); |
public virtual void ThrowException( |
excType
Exception Type | Condition |
---|---|
ArgumentException | excType is not the Exception class or a derived class of Exception. -or- The type does not have a default constructor. |
ArgumentNullException | excType is null. |
public virtual string ToString(); |
public void UsingNamespace( |
usingNamespace
Exception Type | Condition |
---|---|
ArgumentException | Length of usingNamespace is zero. |
ArgumentNullException | usingNamespace is null. |