14 private const int defaultSize = 16;
16 private const int DefaultFixupArraySize = 8;
18 private const int DefaultLabelArraySize = 4;
20 private const int DefaultExceptionArraySize = 2;
24 private byte[] m_ILStream;
26 private int[] m_labelList;
28 private int m_labelCount;
30 private __FixupData[] m_fixupData;
32 private int m_fixupCount;
34 private int[] m_RelocFixupList;
36 private int m_RelocFixupCount;
38 private int m_exceptionCount;
40 private int m_currExcStackCount;
42 private __ExceptionInfo[] m_exceptions;
44 private __ExceptionInfo[] m_currExcStack;
46 internal ScopeTree m_ScopeTree;
48 internal LineNumberInfo m_LineNumberInfo;
52 internal int m_localCount;
56 private int m_maxStackSize;
58 private int m_maxMidStack;
60 private int m_maxMidStackCur;
62 internal int CurrExcStackCount => m_currExcStackCount;
64 internal __ExceptionInfo[] CurrExcStack => m_currExcStack;
70 internal static int[] EnlargeArray(
int[] incoming)
72 int[] array =
new int[incoming.Length * 2];
73 Array.
Copy(incoming, array, incoming.Length);
77 private static byte[] EnlargeArray(
byte[] incoming)
79 byte[] array =
new byte[incoming.Length * 2];
80 Array.
Copy(incoming, array, incoming.Length);
84 private static byte[] EnlargeArray(
byte[] incoming,
int requiredSize)
86 byte[] array =
new byte[requiredSize];
87 Array.
Copy(incoming, array, incoming.Length);
91 private static __FixupData[] EnlargeArray(__FixupData[] incoming)
93 __FixupData[] array =
new __FixupData[incoming.Length * 2];
94 Array.
Copy(incoming, array, incoming.Length);
98 private static __ExceptionInfo[] EnlargeArray(__ExceptionInfo[] incoming)
100 __ExceptionInfo[] array =
new __ExceptionInfo[incoming.Length * 2];
101 Array.Copy(incoming, array, incoming.Length);
105 internal ILGenerator(MethodInfo methodBuilder)
106 : this(methodBuilder, 64)
110 internal ILGenerator(MethodInfo methodBuilder,
int size)
114 m_ILStream =
new byte[16];
118 m_ILStream =
new byte[size];
126 m_exceptionCount = 0;
127 m_currExcStack =
null;
128 m_currExcStackCount = 0;
129 m_RelocFixupList =
null;
130 m_RelocFixupCount = 0;
131 m_ScopeTree =
new ScopeTree();
132 m_LineNumberInfo =
new LineNumberInfo();
133 m_methodBuilder = methodBuilder;
135 MethodBuilder methodBuilder2 = m_methodBuilder as MethodBuilder;
136 if (methodBuilder2 ==
null)
142 m_localSignature = SignatureHelper.
GetLocalVarSigHelper(methodBuilder2.GetTypeBuilder().Module);
146 internal virtual void RecordTokenFixup()
148 if (m_RelocFixupList ==
null)
150 m_RelocFixupList =
new int[8];
152 else if (m_RelocFixupList.Length <= m_RelocFixupCount)
154 m_RelocFixupList = EnlargeArray(m_RelocFixupList);
156 m_RelocFixupList[m_RelocFixupCount++] = m_length;
159 internal void InternalEmit(OpCode opcode)
161 if (opcode.Size != 1)
163 m_ILStream[m_length++] = (byte)(opcode.Value >> 8);
165 m_ILStream[m_length++] = (byte)opcode.Value;
166 UpdateStackSize(opcode, opcode.StackChange());
169 internal void UpdateStackSize(OpCode opcode,
int stackchange)
171 m_maxMidStackCur += stackchange;
172 if (m_maxMidStackCur > m_maxMidStack)
174 m_maxMidStack = m_maxMidStackCur;
176 else if (m_maxMidStackCur < 0)
178 m_maxMidStackCur = 0;
180 if (opcode.EndsUncondJmpBlk())
182 m_maxStackSize += m_maxMidStack;
184 m_maxMidStackCur = 0;
189 private int GetMethodToken(MethodBase method, Type[] optionalParameterTypes,
bool useMethodDef)
191 return ((ModuleBuilder)m_methodBuilder.
Module).GetMethodTokenInternal(method, optionalParameterTypes, useMethodDef);
195 internal virtual SignatureHelper GetMemberRefSignature(
CallingConventions call, Type returnType, Type[] parameterTypes, Type[] optionalParameterTypes)
197 return GetMemberRefSignature(call, returnType, parameterTypes, optionalParameterTypes, 0);
201 private SignatureHelper GetMemberRefSignature(
CallingConventions call, Type returnType, Type[] parameterTypes, Type[] optionalParameterTypes,
int cGenericParameters)
203 return ((ModuleBuilder)m_methodBuilder.
Module).GetMemberRefSignature(call, returnType, parameterTypes, optionalParameterTypes, cGenericParameters);
206 internal byte[] BakeByteArray()
208 if (m_currExcStackCount != 0)
210 throw new ArgumentException(Environment.GetResourceString(
"Argument_UnclosedExceptionBlock"));
216 int length = m_length;
217 byte[] array =
new byte[length];
218 Array.Copy(m_ILStream, array, length);
219 for (
int i = 0; i < m_fixupCount; i++)
221 int num = GetLabelPos(m_fixupData[i].m_fixupLabel) - (m_fixupData[i].m_fixupPos + m_fixupData[i].m_fixupInstSize);
222 if (m_fixupData[i].m_fixupInstSize == 1)
224 if (num < -128 || num > 127)
226 throw new NotSupportedException(Environment.GetResourceString(
"NotSupported_IllegalOneByteBranch", m_fixupData[i].m_fixupPos, num));
230 array[m_fixupData[i].m_fixupPos] = (byte)(256 + num);
234 array[m_fixupData[i].m_fixupPos] = (byte)num;
239 PutInteger4InArray(num, m_fixupData[i].m_fixupPos, array);
245 internal __ExceptionInfo[] GetExceptions()
247 if (m_currExcStackCount != 0)
249 throw new NotSupportedException(Environment.GetResourceString(
"Argument_UnclosedExceptionBlock"));
251 if (m_exceptionCount == 0)
255 __ExceptionInfo[] array =
new __ExceptionInfo[m_exceptionCount];
256 Array.Copy(m_exceptions, array, m_exceptionCount);
257 SortExceptions(array);
261 internal void EnsureCapacity(
int size)
263 if (m_length + size >= m_ILStream.Length)
265 if (m_length + size >= 2 * m_ILStream.Length)
267 m_ILStream = EnlargeArray(m_ILStream, m_length + size);
271 m_ILStream = EnlargeArray(m_ILStream);
276 internal void PutInteger4(
int value)
278 m_length = PutInteger4InArray(value, m_length, m_ILStream);
281 private static int PutInteger4InArray(
int value,
int startPos,
byte[] array)
283 array[startPos++] = (byte)value;
284 array[startPos++] = (byte)(value >> 8);
285 array[startPos++] = (byte)(value >> 16);
286 array[startPos++] = (byte)(value >> 24);
290 private int GetLabelPos(Label lbl)
292 int labelValue = lbl.GetLabelValue();
293 if (labelValue < 0 || labelValue >= m_labelCount)
295 throw new ArgumentException(Environment.GetResourceString(
"Argument_BadLabel"));
297 if (m_labelList[labelValue] < 0)
299 throw new ArgumentException(Environment.GetResourceString(
"Argument_BadLabelContent"));
301 return m_labelList[labelValue];
304 private void AddFixup(Label lbl,
int pos,
int instSize)
306 if (m_fixupData ==
null)
308 m_fixupData =
new __FixupData[8];
310 else if (m_fixupData.Length <= m_fixupCount)
312 m_fixupData = EnlargeArray(m_fixupData);
314 m_fixupData[m_fixupCount].m_fixupPos = pos;
315 m_fixupData[m_fixupCount].m_fixupLabel = lbl;
316 m_fixupData[m_fixupCount].m_fixupInstSize = instSize;
320 internal int GetMaxStackSize()
322 return m_maxStackSize;
325 private static void SortExceptions(__ExceptionInfo[] exceptions)
327 int num = exceptions.Length;
328 for (
int i = 0; i < num; i++)
331 for (
int j = i + 1; j < num; j++)
333 if (exceptions[num2].IsInner(exceptions[j]))
338 __ExceptionInfo _ExceptionInfo = exceptions[i];
339 exceptions[i] = exceptions[num2];
340 exceptions[num2] = _ExceptionInfo;
344 internal int[] GetTokenFixups()
346 if (m_RelocFixupCount == 0)
350 int[] array =
new int[m_RelocFixupCount];
351 Array.Copy(m_RelocFixupList, array, m_RelocFixupCount);
360 InternalEmit(opcode);
369 InternalEmit(opcode);
370 m_ILStream[m_length++] = arg;
376 [CLSCompliant(
false)]
380 InternalEmit(opcode);
383 m_ILStream[m_length++] = (byte)(256 + arg);
387 m_ILStream[m_length++] = (byte)arg;
397 InternalEmit(opcode);
398 m_ILStream[m_length++] = (byte)arg;
399 m_ILStream[m_length++] = (byte)(arg >> 8);
408 InternalEmit(opcode);
419 [SecuritySafeCritical]
433 int methodToken = GetMethodToken(meth,
null, useMethodDef);
435 InternalEmit(opcode);
436 UpdateStackSize(opcode, stackchange);
438 PutInteger4(methodToken);
449 [SecuritySafeCritical]
458 SignatureHelper memberRefSignature = GetMemberRefSignature(callingConvention, returnType, parameterTypes, optionalParameterTypes);
461 if (returnType != typeof(
void))
465 if (parameterTypes !=
null)
467 num -= parameterTypes.Length;
469 if (optionalParameterTypes !=
null)
471 num -= optionalParameterTypes.Length;
493 if (parameterTypes !=
null)
495 num2 = parameterTypes.Length;
498 if (parameterTypes !=
null)
500 for (
int i = 0; i < num2; i++)
505 if (returnType != typeof(
void))
509 if (parameterTypes !=
null)
530 [SecuritySafeCritical]
533 if (methodInfo ==
null)
542 int methodToken = GetMethodToken(methodInfo, optionalParameterTypes, useMethodDef:
false);
544 InternalEmit(opcode);
549 Type[] parameterTypes = methodInfo.GetParameterTypes();
550 if (parameterTypes !=
null)
552 num -= parameterTypes.Length;
558 if (optionalParameterTypes !=
null)
560 num -= optionalParameterTypes.Length;
562 UpdateStackSize(opcode, num);
564 PutInteger4(methodToken);
574 if (signature ==
null)
582 InternalEmit(opcode);
585 num -= signature.ArgumentCount;
587 UpdateStackSize(opcode, num);
598 [SecuritySafeCritical]
607 int methodToken = GetMethodToken(con,
null, useMethodDef:
true);
609 InternalEmit(opcode);
616 Type[] parameterTypes = con.GetParameterTypes();
617 if (parameterTypes !=
null)
619 num -= parameterTypes.Length;
622 UpdateStackSize(opcode, num);
624 PutInteger4(methodToken);
632 [SecuritySafeCritical]
639 InternalEmit(opcode);
650 InternalEmit(opcode);
651 m_ILStream[m_length++] = (byte)arg;
652 m_ILStream[m_length++] = (byte)(arg >> 8);
653 m_ILStream[m_length++] = (byte)(arg >> 16);
654 m_ILStream[m_length++] = (byte)(arg >> 24);
655 m_ILStream[m_length++] = (byte)(arg >> 32);
656 m_ILStream[m_length++] = (byte)(arg >> 40);
657 m_ILStream[m_length++] = (byte)(arg >> 48);
658 m_ILStream[m_length++] = (byte)(arg >> 56);
664 [SecuritySafeCritical]
668 InternalEmit(opcode);
669 uint num = *(uint*)(&arg);
670 m_ILStream[m_length++] = (byte)num;
671 m_ILStream[m_length++] = (byte)(num >> 8);
672 m_ILStream[m_length++] = (byte)(num >> 16);
673 m_ILStream[m_length++] = (byte)(num >> 24);
679 [SecuritySafeCritical]
683 InternalEmit(opcode);
684 ulong num = (ulong)(*(
long*)(&arg));
685 m_ILStream[m_length++] = (byte)num;
686 m_ILStream[m_length++] = (byte)(num >> 8);
687 m_ILStream[m_length++] = (byte)(num >> 16);
688 m_ILStream[m_length++] = (byte)(num >> 24);
689 m_ILStream[m_length++] = (byte)(num >> 32);
690 m_ILStream[m_length++] = (byte)(num >> 40);
691 m_ILStream[m_length++] = (byte)(num >> 48);
692 m_ILStream[m_length++] = (byte)(num >> 56);
700 int labelValue = label.GetLabelValue();
702 InternalEmit(opcode);
705 AddFixup(label, m_length, 1);
710 AddFixup(label, m_length, 4);
726 int num = labels.Length;
727 EnsureCapacity(num * 4 + 7);
728 InternalEmit(opcode);
734 AddFixup(labels[num3], m_length, num2);
749 InternalEmit(opcode);
760 int token = moduleBuilder.GetStringConstant(str).Token;
762 InternalEmit(opcode);
782 int localIndex = local.GetLocalIndex();
783 if (local.GetMethodBuilder() != m_methodBuilder)
804 if (localIndex <= 255)
828 if (localIndex <= 255)
840 InternalEmit(opcode);
847 m_ILStream[m_length++] = (byte)localIndex;
848 m_ILStream[m_length++] = (byte)(localIndex >> 8);
851 if (localIndex > 255)
855 m_ILStream[m_length++] = (byte)localIndex;
862 if (m_exceptions ==
null)
864 m_exceptions =
new __ExceptionInfo[2];
866 if (m_currExcStack ==
null)
868 m_currExcStack =
new __ExceptionInfo[2];
870 if (m_exceptionCount >= m_exceptions.Length)
872 m_exceptions = EnlargeArray(m_exceptions);
874 if (m_currExcStackCount >= m_currExcStack.Length)
876 m_currExcStack = EnlargeArray(m_currExcStack);
879 __ExceptionInfo _ExceptionInfo =
new __ExceptionInfo(m_length, label);
880 m_exceptions[m_exceptionCount++] = _ExceptionInfo;
881 m_currExcStack[m_currExcStackCount++] = _ExceptionInfo;
890 if (m_currExcStackCount == 0)
894 __ExceptionInfo _ExceptionInfo = m_currExcStack[m_currExcStackCount - 1];
895 m_currExcStack[m_currExcStackCount - 1] =
null;
896 m_currExcStackCount--;
897 Label endLabel = _ExceptionInfo.GetEndLabel();
898 switch (_ExceptionInfo.GetCurrentState())
911 if (m_labelList[endLabel.GetLabelValue()] == -1)
917 MarkLabel(_ExceptionInfo.GetFinallyEndLabel());
919 _ExceptionInfo.Done(m_length);
926 if (m_currExcStackCount == 0)
930 __ExceptionInfo _ExceptionInfo = m_currExcStack[m_currExcStackCount - 1];
931 Label endLabel = _ExceptionInfo.GetEndLabel();
933 _ExceptionInfo.MarkFilterAddr(m_length);
944 if (m_currExcStackCount == 0)
948 __ExceptionInfo _ExceptionInfo = m_currExcStack[m_currExcStackCount - 1];
949 if (_ExceptionInfo.GetCurrentState() == 1)
951 if (exceptionType !=
null)
959 if (exceptionType ==
null)
963 Label endLabel = _ExceptionInfo.GetEndLabel();
966 _ExceptionInfo.MarkCatchAddr(m_length, exceptionType);
973 if (m_currExcStackCount == 0)
977 __ExceptionInfo _ExceptionInfo = m_currExcStack[m_currExcStackCount - 1];
978 Label endLabel = _ExceptionInfo.GetEndLabel();
980 _ExceptionInfo.MarkFaultAddr(m_length);
987 if (m_currExcStackCount == 0)
991 __ExceptionInfo _ExceptionInfo = m_currExcStack[m_currExcStackCount - 1];
992 int currentState = _ExceptionInfo.GetCurrentState();
993 Label endLabel = _ExceptionInfo.GetEndLabel();
995 if (currentState != 0)
1002 _ExceptionInfo.SetFinallyEndLabel(label);
1008 _ExceptionInfo.MarkFinallyAddr(m_length, num);
1015 if (m_labelList ==
null)
1017 m_labelList =
new int[4];
1019 if (m_labelCount >= m_labelList.Length)
1021 m_labelList = EnlargeArray(m_labelList);
1023 m_labelList[m_labelCount] = -1;
1024 return new Label(m_labelCount++);
1033 int labelValue = loc.GetLabelValue();
1034 if (labelValue < 0 || labelValue >= m_labelList.Length)
1038 if (m_labelList[labelValue] != -1)
1042 m_labelList[labelValue] = m_length;
1053 if (excType ==
null)
1062 if (constructor ==
null)
1090 if (m_methodBuilder ==
null)
1098 object localType = localBuilder.
LocalType;
1103 array[0] = (
Type)localType;
1105 if (method2 ==
null)
1141 array[0] = (
Type)fieldType;
1143 if (method2 ==
null)
1173 if (methodBuilder ==
null)
1177 if (methodBuilder.IsTypeCreated())
1181 if (localType ==
null)
1185 if (methodBuilder.m_bIsBaked)
1203 if (usingNamespace ==
null)
1207 if (usingNamespace.Length == 0)
1212 if (methodBuilder ==
null)
1216 int currentActiveScopeIndex = methodBuilder.
GetILGenerator().m_ScopeTree.GetCurrentActiveScopeIndex();
1217 if (currentActiveScopeIndex == -1)
1219 methodBuilder.m_localSymInfo.AddUsingNamespace(usingNamespace);
1223 m_ScopeTree.AddUsingNamespaceToCurrentScope(usingNamespace);
1238 if (startLine == 0 || startLine < 0 || endLine == 0 || endLine < 0)
1242 m_LineNumberInfo.AddLineNumberInfo(document, m_length, startLine, startColumn, endLine, endColumn);
1249 m_ScopeTree.AddScopeInfo(ScopeAction.Open, m_length);
1256 m_ScopeTree.AddScopeInfo(ScopeAction.Close, m_length);
1299 void _ILGenerator.
Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid,
short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
1301 throw new NotImplementedException();
void AddArgument(Type clsArgument)
Adds an argument to the signature.
OperandType OperandType
The operand type of an intermediate language (IL) instruction.
static readonly OpCode Throw
Throws the exception object currently on the evaluation stack.
Represents the standard input, output, and error streams for console applications....
virtual bool IsGenericTypeDefinition
Gets a value indicating whether the current T:System.Type represents a generic type definition,...
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
virtual void MarkSequencePoint(ISymbolDocumentWriter document, int startLine, int startColumn, int endLine, int endColumn)
Marks a sequence point in the Microsoft intermediate language (MSIL) stream.
virtual void Emit(OpCode opcode, SignatureHelper signature)
Puts the specified instruction and a signature token onto the Microsoft intermediate language (MSIL) ...
static readonly OpCode Endfinally
Transfers control from the fault or finally clause of an exception block back to the Common Language ...
virtual void MarkLabel(Label loc)
Marks the Microsoft intermediate language (MSIL) stream's current position with the given label.
virtual int ILOffset
Gets the current offset, in bytes, in the Microsoft intermediate language (MSIL) stream that is being...
Describes and represents an enumeration type.
abstract Type FieldType
Gets the type of this field object.
void GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
Maps a set of names to a corresponding set of dispatch identifiers.
static readonly OpCode Ldarg
Loads an argument (referenced by a specified index value) onto the stack.
OperandType
Describes the operand type of Microsoft intermediate language (MSIL) instruction.
Discovers the attributes of a method and provides access to method metadata.
virtual unsafe void Emit(OpCode opcode, float arg)
Puts the specified instruction and numerical argument onto the Microsoft intermediate language (MSIL)...
static readonly OpCode Stloc_3
Pops the current value from the top of the evaluation stack and stores it in a the local variable lis...
virtual void EndScope()
Ends a lexical scope.
Discovers the attributes of a class constructor and provides access to constructor metadata.
static readonly OpCode Ldloc_2
Loads the local variable at index 2 onto the evaluation stack.
Discovers the attributes of a field and provides access to field metadata.
virtual Type ReturnType
Gets the return type of this method.
virtual LocalBuilder DeclareLocal(Type localType, bool pinned)
Declares a local variable of the specified type, optionally pinning the object referred to by the var...
The exception that is thrown when the value of an argument is outside the allowable range of values a...
virtual void Emit(OpCode opcode, MethodInfo meth)
Puts the specified instruction onto the Microsoft intermediate language (MSIL) stream followed by the...
StackBehaviour StackBehaviourPush
How the intermediate language (IL) instruction pushes operand onto the stack.
override bool Equals(object obj)
Tests whether the given object is equal to this Opcode.
CallingConvention
Specifies the calling convention required to call methods implemented in unmanaged code.
ConstructorInfo GetConstructor(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
Searches for a constructor whose parameters match the specified argument types and modifiers,...
virtual void BeginScope()
Begins a lexical scope.
Provides methods for building signatures.
Exposes the T:System.Reflection.Emit.ILGenerator class to unmanaged code.
virtual void EmitCalli(OpCode opcode, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type[] optionalParameterTypes)
Puts a F:System.Reflection.Emit.OpCodes.Calli instruction onto the Microsoft intermediate language (M...
static readonly OpCode Ldloca_S
Loads the address of the local variable at a specific index onto the evaluation stack,...
SignatureToken GetSignatureToken(SignatureHelper sigHelper)
Defines a token for the signature that is defined by the specified T:System.Reflection....
virtual LocalBuilder DeclareLocal(Type localType)
Declares a local variable of the specified type.
virtual void BeginFaultBlock()
Begins an exception fault block in the Microsoft intermediate language (MSIL) stream.
bool IsStatic
Gets a value indicating whether the method is static.
static bool TakesSingleByteArgument(OpCode inst)
Returns true or false if the supplied opcode takes a single byte argument.
virtual bool IsSubclassOf(Type c)
Determines whether the current T:System.Type derives from the specified T:System.Type.
static readonly OpCode Stloc_0
Pops the current value from the top of the evaluation stack and stores it in a the local variable lis...
virtual unsafe void Emit(OpCode opcode, double arg)
Puts the specified instruction and numerical argument onto the Microsoft intermediate language (MSIL)...
void Emit(OpCode opcode, sbyte arg)
Puts the specified instruction and character argument onto the Microsoft intermediate language (MSIL)...
static readonly OpCode Ldtoken
Converts a metadata token to its runtime representation, pushing it onto the evaluation stack.
Generates Microsoft intermediate language (MSIL) instructions.
virtual void EndExceptionBlock()
Ends an exception block.
CallingConventions
Defines the valid calling conventions for a method.
static readonly OpCode Endfilter
Transfers control from the filter clause of an exception back to the Common Language Infrastructure (...
virtual void Emit(OpCode opcode, Label[] labels)
Puts the specified instruction onto the Microsoft intermediate language (MSIL) stream and leaves spac...
Provides information about, and means to manipulate, the current environment and platform....
virtual void EmitWriteLine(FieldInfo fld)
Emits the Microsoft intermediate language (MSIL) necessary to call Overload:System....
Represents a globally unique identifier (GUID).To browse the .NET Framework source code for this type...
virtual void Emit(OpCode opcode, LocalBuilder local)
Puts the specified instruction onto the Microsoft intermediate language (MSIL) stream followed by the...
virtual void EmitCall(OpCode opcode, MethodInfo methodInfo, Type[] optionalParameterTypes)
Puts a call or callvirt instruction onto the Microsoft intermediate language (MSIL) stream to call a ...
static readonly OpCode Ldloca
Loads the address of the local variable at a specific index onto the evaluation stack.
virtual void BeginExceptFilterBlock()
Begins an exception block for a filtered exception.
FieldToken GetFieldToken(FieldInfo field)
Returns the token used to identify the specified field within this module.
virtual Label BeginExceptionBlock()
Begins an exception block for a non-filtered exception.
Defines and creates new instances of classes during run time.
static readonly Type [] EmptyTypes
Represents an empty array of type T:System.Type. This field is read-only.
virtual void Emit(OpCode opcode, int arg)
Puts the specified instruction and numerical argument onto the Microsoft intermediate language (MSIL)...
virtual void EmitWriteLine(LocalBuilder localBuilder)
Emits the Microsoft intermediate language (MSIL) necessary to call Overload:System....
Defines and represents a module in a dynamic assembly.
void GetTypeInfoCount(out uint pcTInfo)
Retrieves the number of type information interfaces that an object provides (either 0 or 1).
FieldAttributes
Specifies flags that describe the attributes of a field.
virtual void BeginCatchBlock(Type exceptionType)
Begins a catch block.
virtual void Emit(OpCode opcode, ConstructorInfo con)
Puts the specified instruction and metadata token for the specified constructor onto the Microsoft in...
Represents a writer that can write a sequential series of characters. This class is abstract.
ILGenerator GetILGenerator()
Returns an ILGenerator for this method with a default Microsoft intermediate language (MSIL) stream s...
A platform-specific type that is used to represent a pointer or a handle.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Represents type declarations: class types, interface types, array types, value types,...
Represents a local variable within a method or constructor.
static readonly OpCode Ldloc_S
Loads the local variable at a specific index onto the evaluation stack, short form.
virtual void Emit(OpCode opcode, Type cls)
Puts the specified instruction onto the Microsoft intermediate language (MSIL) stream followed by the...
static readonly OpCode Call
Calls the method indicated by the passed method descriptor.
static readonly OpCode Stloc_1
Pops the current value from the top of the evaluation stack and stores it in a the local variable lis...
static readonly OpCode Ldsfld
Pushes the value of a static field onto the evaluation stack.
virtual void Emit(OpCode opcode, FieldInfo field)
Puts the specified instruction and metadata token for the specified field onto the Microsoft intermed...
static SignatureHelper GetLocalVarSigHelper()
Returns a signature helper for a local variable.
Defines and represents a method (or constructor) on a dynamic class.
Represents a label in the instruction stream. Label is used in conjunction with the T:System....
Provides field representations of the Microsoft Intermediate Language (MSIL) instructions for emissio...
static readonly OpCode Calli
Calls the method indicated on the evaluation stack (as a pointer to an entry point) with arguments de...
abstract FieldAttributes Attributes
Gets the attributes associated with this field.
int Token
Retrieves the metadata token for the local variable signature for this method.
The exception that is thrown when one of the arguments provided to a method is not valid.
static readonly OpCode Ldloc_1
Loads the local variable at index 1 onto the evaluation stack.
static void Copy(Array sourceArray, Array destinationArray, int length)
Copies a range of elements from an T:System.Array starting at the first element and pastes them into ...
virtual void Emit(OpCode opcode)
Puts the specified instruction onto the stream of instructions.
StackBehaviour StackBehaviourPop
How the intermediate language (IL) instruction pops the stack.
Represents errors that occur during application execution.To browse the .NET Framework source code fo...
virtual void ThrowException(Type excType)
Emits an instruction to throw an exception.
static readonly OpCode Ldfld
Finds the value of a field in the object whose reference is currently on the evaluation stack.
static readonly OpCode Ldloc_3
Loads the local variable at index 3 onto the evaluation stack.
virtual void Emit(OpCode opcode, string str)
Puts the specified instruction onto the Microsoft intermediate language (MSIL) stream followed by the...
virtual Module Module
Gets the module in which the type that declares the member represented by the current T:System....
Describes an intermediate language (IL) instruction.
Represents a document referenced by a symbol store.
static readonly OpCode Stloc_S
Pops the current value from the top of the evaluation stack and stores it in a the local variable lis...
static readonly OpCode Ldftn
Pushes an unmanaged pointer (type native int) to the native code implementing a specific method onto ...
virtual void Emit(OpCode opcode, byte arg)
Puts the specified instruction and character argument onto the Microsoft intermediate language (MSIL)...
virtual Label DefineLabel()
Declares a new label.
static readonly OpCode Callvirt
Calls a late-bound method on an object, pushing the return value onto the evaluation stack.
The exception that is thrown when a method call is invalid for the object's current state.
static SignatureHelper GetMethodSigHelper(Module mod, Type returnType, Type[] parameterTypes)
Returns a signature helper for a method with a standard calling convention, given the method's module...
virtual void Emit(OpCode opcode, long arg)
Puts the specified instruction and numerical argument onto the Microsoft intermediate language (MSIL)...
virtual void UsingNamespace(string usingNamespace)
Specifies the namespace to be used in evaluating locals and watches for the current active lexical sc...
static readonly OpCode Ldvirtftn
Pushes an unmanaged pointer (type native int) to the native code implementing a particular virtual me...
static readonly OpCode Ldloc
Loads the local variable at a specific index onto the evaluation stack.
ClassInterfaceType
Identifies the type of class interface that is generated for a class.
StackBehaviour
Describes how values are pushed onto a stack or popped off a stack.
virtual void EmitWriteLine(string value)
Emits the Microsoft intermediate language (MSIL) to call Overload:System.Console.WriteLine with a str...
int Token
Retrieves the metadata token for this class.
void GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo)
Retrieves the type information for an object, which can be used to get the type information for an in...
The exception that is thrown when an invoked method is not supported, or when there is an attempt to ...
static readonly OpCode Ldloc_0
Loads the local variable at index 0 onto the evaluation stack.
void Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
Provides access to properties and methods exposed by an object.
static readonly OpCode Leave
Exits a protected region of code, unconditionally transferring control to a specific target instructi...
static readonly OpCode Newobj
Creates a new object or a new instance of a value type, pushing an object reference (type O) onto the...
virtual void EmitCalli(OpCode opcode, CallingConvention unmanagedCallConv, Type returnType, Type[] parameterTypes)
Puts a F:System.Reflection.Emit.OpCodes.Calli instruction onto the Microsoft intermediate language (M...
TypeToken GetTypeToken(Type type)
Returns the token used to identify the specified type within this module.
The exception that is thrown when a requested method or operation is not implemented.
static readonly OpCode Stloc_2
Pops the current value from the top of the evaluation stack and stores it in a the local variable lis...
int Token
Retrieves the metadata token for this field.
override Type LocalType
Gets the type of the local variable.
virtual void Emit(OpCode opcode, short arg)
Puts the specified instruction and numerical argument onto the Microsoft intermediate language (MSIL)...
static readonly OpCode Ldstr
Pushes a new object reference to a string literal stored in the metadata.
static readonly OpCode Stloc
Pops the current value from the top of the evaluation stack and stores it in a the local variable lis...
virtual void BeginFinallyBlock()
Begins a finally block in the Microsoft intermediate language (MSIL) instruction stream.
virtual void Emit(OpCode opcode, Label label)
Puts the specified instruction onto the Microsoft intermediate language (MSIL) stream and leaves spac...