OpCodes 类

定义

通过 ILGenerator 类成员(例如 Emit(OpCode))为发出提供 Microsoft 中间语言 (MSIL) 指令的字段表示形式。

public ref class OpCodes
public class OpCodes
[System.Runtime.InteropServices.ComVisible(true)]
public class OpCodes
type OpCodes = class
[<System.Runtime.InteropServices.ComVisible(true)>]
type OpCodes = class
Public Class OpCodes
继承
OpCodes
属性

示例

以下示例演示了使用 ILGenerator 发出到 OpCodesMethodBuilder动态方法的构造。

using namespace System;
using namespace System::Threading;
using namespace System::Reflection;
using namespace System::Reflection::Emit;
Type^ CreateDynamicType()
{
   array<Type^>^ctorParams = {int::typeid,int::typeid};
   AppDomain^ myDomain = Thread::GetDomain();
   AssemblyName^ myAsmName = gcnew AssemblyName;
   myAsmName->Name = "MyDynamicAssembly";
   AssemblyBuilder^ myAsmBuilder = myDomain->DefineDynamicAssembly( myAsmName, AssemblyBuilderAccess::Run );
   ModuleBuilder^ pointModule = myAsmBuilder->DefineDynamicModule( "PointModule", "Point.dll" );
   TypeBuilder^ pointTypeBld = pointModule->DefineType( "Point", TypeAttributes::Public );
   FieldBuilder^ xField = pointTypeBld->DefineField( "x", int::typeid, FieldAttributes::Public );
   FieldBuilder^ yField = pointTypeBld->DefineField( "y", int::typeid, FieldAttributes::Public );
   Type^ objType = Type::GetType( "System.Object" );
   ConstructorInfo^ objCtor = objType->GetConstructor( gcnew array<Type^>(0) );
   ConstructorBuilder^ pointCtor = pointTypeBld->DefineConstructor( MethodAttributes::Public, CallingConventions::Standard, ctorParams );
   ILGenerator^ ctorIL = pointCtor->GetILGenerator();
   
   // First, you build the constructor.
   ctorIL->Emit( OpCodes::Ldarg_0 );
   ctorIL->Emit( OpCodes::Call, objCtor );
   ctorIL->Emit( OpCodes::Ldarg_0 );
   ctorIL->Emit( OpCodes::Ldarg_1 );
   ctorIL->Emit( OpCodes::Stfld, xField );
   ctorIL->Emit( OpCodes::Ldarg_0 );
   ctorIL->Emit( OpCodes::Ldarg_2 );
   ctorIL->Emit( OpCodes::Stfld, yField );
   ctorIL->Emit( OpCodes::Ret );
   
   //  Now, you'll build a method to output some information on the
   // inside your dynamic class. This method will have the following
   // definition in C#:
   //  public void WritePoint()
   MethodBuilder^ writeStrMthd = pointTypeBld->DefineMethod( "WritePoint", MethodAttributes::Public, void::typeid, nullptr );
   ILGenerator^ writeStrIL = writeStrMthd->GetILGenerator();
   
   // The below ILGenerator created demonstrates a few ways to create
   // String* output through STDIN.
   // ILGenerator::EmitWriteLine(String*) will generate a ldstr and a
   // call to WriteLine for you.
   writeStrIL->EmitWriteLine( "The value of this current instance is:" );
   
   // Here, you will do the hard work yourself. First, you need to create
   // the String* we will be passing and obtain the correct WriteLine overload
   // for said String*. In the below case, you are substituting in two values,
   // so the chosen overload is Console::WriteLine(String*, Object*, Object*).
   String^ inStr = "( {0}, {1})";
   array<Type^>^wlParams = {String::typeid,Object::typeid,Object::typeid};
   
   // We need the MethodInfo to pass into EmitCall later.
   MethodInfo^ writeLineMI = Console::typeid->GetMethod( "WriteLine", wlParams );
   
   // Push the String* with the substitutions onto the stack.
   // This is the first argument for WriteLine - the String* one.
   writeStrIL->Emit( OpCodes::Ldstr, inStr );
   
   // Since the second argument is an Object*, and it corresponds to
   // to the substitution for the value of our integer field, you
   // need to box that field to an Object*. First, push a reference
   // to the current instance, and then push the value stored in
   // field 'x'. We need the reference to the current instance (stored
   // in local argument index 0) so Ldfld can load from the correct
   // instance (this one).
   writeStrIL->Emit( OpCodes::Ldarg_0 );
   writeStrIL->Emit( OpCodes::Ldfld, xField );
   
   // Now, we execute the box opcode, which pops the value of field 'x',
   // returning a reference to the integer value boxed as an Object*.
   writeStrIL->Emit( OpCodes::Box, int::typeid );
   
   // Atop the stack, you'll find our String* inStr, followed by a reference
   // to the boxed value of 'x'. Now, you need to likewise box field 'y'.
   writeStrIL->Emit( OpCodes::Ldarg_0 );
   writeStrIL->Emit( OpCodes::Ldfld, yField );
   writeStrIL->Emit( OpCodes::Box, int::typeid );
   
   // Now, you have all of the arguments for your call to
   // Console::WriteLine(String*, Object*, Object*) atop the stack:
   // the String* InStr, a reference to the boxed value of 'x', and
   // a reference to the boxed value of 'y'.
   // Call Console::WriteLine(String*, Object*, Object*) with EmitCall.
   writeStrIL->EmitCall( OpCodes::Call, writeLineMI, nullptr );
   
   // Lastly, EmitWriteLine can also output the value of a field
   // using the overload EmitWriteLine(FieldInfo).
   writeStrIL->EmitWriteLine( "The value of 'x' is:" );
   writeStrIL->EmitWriteLine( xField );
   writeStrIL->EmitWriteLine( "The value of 'y' is:" );
   writeStrIL->EmitWriteLine( yField );
   
   // Since we return no value (void), the ret opcode will not
   // return the top stack value.
   writeStrIL->Emit( OpCodes::Ret );
   return pointTypeBld->CreateType();
}

int main()
{
   array<Object^>^ctorParams = gcnew array<Object^>(2);
   Console::Write( "Enter a integer value for X: " );
   String^ myX = Console::ReadLine();
   Console::Write( "Enter a integer value for Y: " );
   String^ myY = Console::ReadLine();
   Console::WriteLine( "---" );
   ctorParams[ 0 ] = Convert::ToInt32( myX );
   ctorParams[ 1 ] = Convert::ToInt32( myY );
   Type^ ptType = CreateDynamicType();
   Object^ ptInstance = Activator::CreateInstance( ptType, ctorParams );
   ptType->InvokeMember( "WritePoint", BindingFlags::InvokeMethod, nullptr, ptInstance, gcnew array<Object^>(0) );
}

using System;
using System.Threading;
using System.Reflection;
using System.Reflection.Emit;

class EmitWriteLineDemo {

   public static Type CreateDynamicType() {
       Type[] ctorParams = new Type[] {typeof(int),
                   typeof(int)};
    
       AppDomain myDomain = Thread.GetDomain();
       AssemblyName myAsmName = new AssemblyName();
       myAsmName.Name = "MyDynamicAssembly";

       AssemblyBuilder myAsmBuilder = myDomain.DefineDynamicAssembly(
                      myAsmName,
                      AssemblyBuilderAccess.Run);

       ModuleBuilder pointModule = myAsmBuilder.DefineDynamicModule("PointModule",
                                    "Point.dll");

       TypeBuilder pointTypeBld = pointModule.DefineType("Point",
                                  TypeAttributes.Public);

       FieldBuilder xField = pointTypeBld.DefineField("x", typeof(int),
                                                      FieldAttributes.Public);
       FieldBuilder yField = pointTypeBld.DefineField("y", typeof(int),
                                                      FieldAttributes.Public);

       Type objType = Type.GetType("System.Object");
       ConstructorInfo objCtor = objType.GetConstructor(new Type[0]);

       ConstructorBuilder pointCtor = pointTypeBld.DefineConstructor(
                                   MethodAttributes.Public,
                                   CallingConventions.Standard,
                                   ctorParams);
       ILGenerator ctorIL = pointCtor.GetILGenerator();

       // First, you build the constructor.
       ctorIL.Emit(OpCodes.Ldarg_0);
       ctorIL.Emit(OpCodes.Call, objCtor);
       ctorIL.Emit(OpCodes.Ldarg_0);
       ctorIL.Emit(OpCodes.Ldarg_1);
       ctorIL.Emit(OpCodes.Stfld, xField);
       ctorIL.Emit(OpCodes.Ldarg_0);
       ctorIL.Emit(OpCodes.Ldarg_2);
       ctorIL.Emit(OpCodes.Stfld, yField);
       ctorIL.Emit(OpCodes.Ret);

       //  Now, you'll build a method to output some information on the
       // inside your dynamic class. This method will have the following
       // definition in C#:
    //  public void WritePoint()

       MethodBuilder writeStrMthd = pointTypeBld.DefineMethod(
                                     "WritePoint",
                             MethodAttributes.Public,
                                             typeof(void),
                                             null);

       ILGenerator writeStrIL = writeStrMthd.GetILGenerator();

       // The below ILGenerator created demonstrates a few ways to create
       // string output through STDIN.

       // ILGenerator.EmitWriteLine(string) will generate a ldstr and a
       // call to WriteLine for you.

       writeStrIL.EmitWriteLine("The value of this current instance is:");

       // Here, you will do the hard work yourself. First, you need to create
       // the string we will be passing and obtain the correct WriteLine overload
       // for said string. In the below case, you are substituting in two values,
       // so the chosen overload is Console.WriteLine(string, object, object).

       String inStr = "({0}, {1})";
       Type[] wlParams = new Type[] {typeof(string),
                     typeof(object),
                     typeof(object)};

       // We need the MethodInfo to pass into EmitCall later.

       MethodInfo writeLineMI = typeof(Console).GetMethod(
                            "WriteLine",
                        wlParams);

       // Push the string with the substitutions onto the stack.
       // This is the first argument for WriteLine - the string one.

       writeStrIL.Emit(OpCodes.Ldstr, inStr);

       // Since the second argument is an object, and it corresponds to
       // to the substitution for the value of our integer field, you
       // need to box that field to an object. First, push a reference
       // to the current instance, and then push the value stored in
       // field 'x'. We need the reference to the current instance (stored
       // in local argument index 0) so Ldfld can load from the correct
       // instance (this one).

       writeStrIL.Emit(OpCodes.Ldarg_0);
       writeStrIL.Emit(OpCodes.Ldfld, xField);

       // Now, we execute the box opcode, which pops the value of field 'x',
       // returning a reference to the integer value boxed as an object.

       writeStrIL.Emit(OpCodes.Box, typeof(int));

       // Atop the stack, you'll find our string inStr, followed by a reference
       // to the boxed value of 'x'. Now, you need to likewise box field 'y'.

       writeStrIL.Emit(OpCodes.Ldarg_0);
       writeStrIL.Emit(OpCodes.Ldfld, yField);
       writeStrIL.Emit(OpCodes.Box, typeof(int));

       // Now, you have all of the arguments for your call to
       // Console.WriteLine(string, object, object) atop the stack:
       // the string InStr, a reference to the boxed value of 'x', and
       // a reference to the boxed value of 'y'.

       // Call Console.WriteLine(string, object, object) with EmitCall.

       writeStrIL.EmitCall(OpCodes.Call, writeLineMI, null);

       // Lastly, EmitWriteLine can also output the value of a field
       // using the overload EmitWriteLine(FieldInfo).

       writeStrIL.EmitWriteLine("The value of 'x' is:");
       writeStrIL.EmitWriteLine(xField);
       writeStrIL.EmitWriteLine("The value of 'y' is:");
       writeStrIL.EmitWriteLine(yField);

       // Since we return no value (void), the ret opcode will not
       // return the top stack value.

       writeStrIL.Emit(OpCodes.Ret);

       return pointTypeBld.CreateType();
   }

   public static void Main() {

      object[] ctorParams = new object[2];

      Console.Write("Enter a integer value for X: ");
      string myX = Console.ReadLine();
      Console.Write("Enter a integer value for Y: ");
      string myY = Console.ReadLine();

      Console.WriteLine("---");

      ctorParams[0] = Convert.ToInt32(myX);
      ctorParams[1] = Convert.ToInt32(myY);

      Type ptType = CreateDynamicType();

      object ptInstance = Activator.CreateInstance(ptType, ctorParams);
      ptType.InvokeMember("WritePoint",
              BindingFlags.InvokeMethod,
              null,
              ptInstance,
              new object[0]);
   }
}

Imports System.Threading
Imports System.Reflection
Imports System.Reflection.Emit

 _

Class EmitWriteLineDemo
   
   
   Public Shared Function CreateDynamicType() As Type

      Dim ctorParams() As Type = {GetType(Integer), GetType(Integer)}
      
      Dim myDomain As AppDomain = Thread.GetDomain()
      Dim myAsmName As New AssemblyName()
      myAsmName.Name = "MyDynamicAssembly"
      
      Dim myAsmBuilder As AssemblyBuilder = myDomain.DefineDynamicAssembly(myAsmName, AssemblyBuilderAccess.RunAndSave)
      
      Dim pointModule As ModuleBuilder = myAsmBuilder.DefineDynamicModule("PointModule", "Point.dll")
      
      Dim pointTypeBld As TypeBuilder = pointModule.DefineType("Point", _
                                   TypeAttributes.Public)
      
      Dim xField As FieldBuilder = pointTypeBld.DefineField("x", _
                                GetType(Integer), _
                                FieldAttributes.Public)
      Dim yField As FieldBuilder = pointTypeBld.DefineField("y", _
                                GetType(Integer), _
                                FieldAttributes.Public)
      
      
      Dim objType As Type = Type.GetType("System.Object")
      Dim objCtor As ConstructorInfo = objType.GetConstructor(New Type(){})
      
      Dim pointCtor As ConstructorBuilder = pointTypeBld.DefineConstructor( _
                             MethodAttributes.Public, _
                             CallingConventions.Standard, _
                             ctorParams)
      Dim ctorIL As ILGenerator = pointCtor.GetILGenerator()
      
      
      ' First, you build the constructor.

      ctorIL.Emit(OpCodes.Ldarg_0)
      ctorIL.Emit(OpCodes.Call, objCtor)
      ctorIL.Emit(OpCodes.Ldarg_0)
      ctorIL.Emit(OpCodes.Ldarg_1)
      ctorIL.Emit(OpCodes.Stfld, xField)
      ctorIL.Emit(OpCodes.Ldarg_0)
      ctorIL.Emit(OpCodes.Ldarg_2)
      ctorIL.Emit(OpCodes.Stfld, yField)
      ctorIL.Emit(OpCodes.Ret)
      
      '  Now, you'll build a method to output some information on the
      ' inside your dynamic class. This method will have the following
      ' definition in C#:
      '  Public Sub WritePoint() 

      Dim writeStrMthd As MethodBuilder = pointTypeBld.DefineMethod("WritePoint", _
                                    MethodAttributes.Public, _
                                    Nothing, Nothing)
      
      Dim writeStrIL As ILGenerator = writeStrMthd.GetILGenerator()
      
      ' The below ILGenerator created demonstrates a few ways to create
      ' string output through STDIN. 
      ' ILGenerator.EmitWriteLine(string) will generate a ldstr and a 
      ' call to WriteLine for you.

      writeStrIL.EmitWriteLine("The value of this current instance is:")
      
      ' Here, you will do the hard work yourself. First, you need to create
      ' the string we will be passing and obtain the correct WriteLine overload
      ' for said string. In the below case, you are substituting in two values,
      ' so the chosen overload is Console.WriteLine(string, object, object).

      Dim inStr As [String] = "({0}, {1})"
      Dim wlParams() As Type = {GetType(String), GetType(Object), GetType(Object)}
      
      ' We need the MethodInfo to pass into EmitCall later.

      Dim writeLineMI As MethodInfo = GetType(Console).GetMethod("WriteLine", wlParams)
      
      ' Push the string with the substitutions onto the stack.
      ' This is the first argument for WriteLine - the string one. 

      writeStrIL.Emit(OpCodes.Ldstr, inStr)
      
      ' Since the second argument is an object, and it corresponds to
      ' to the substitution for the value of our integer field, you 
      ' need to box that field to an object. First, push a reference
      ' to the current instance, and then push the value stored in
      ' field 'x'. We need the reference to the current instance (stored
      ' in local argument index 0) so Ldfld can load from the correct
      ' instance (this one).

      writeStrIL.Emit(OpCodes.Ldarg_0)
      writeStrIL.Emit(OpCodes.Ldfld, xField)
      
      ' Now, we execute the box opcode, which pops the value of field 'x',
      ' returning a reference to the integer value boxed as an object.

      writeStrIL.Emit(OpCodes.Box, GetType(Integer))
      
      ' Atop the stack, you'll find our string inStr, followed by a reference
      ' to the boxed value of 'x'. Now, you need to likewise box field 'y'.

      writeStrIL.Emit(OpCodes.Ldarg_0)
      writeStrIL.Emit(OpCodes.Ldfld, yField)
      writeStrIL.Emit(OpCodes.Box, GetType(Integer))
      
      ' Now, you have all of the arguments for your call to
      ' Console.WriteLine(string, object, object) atop the stack:
      ' the string InStr, a reference to the boxed value of 'x', and
      ' a reference to the boxed value of 'y'.
      ' Call Console.WriteLine(string, object, object) with EmitCall.

      writeStrIL.EmitCall(OpCodes.Call, writeLineMI, Nothing)
      
      ' Lastly, EmitWriteLine can also output the value of a field
      ' using the overload EmitWriteLine(FieldInfo).

      writeStrIL.EmitWriteLine("The value of 'x' is:")
      writeStrIL.EmitWriteLine(xField)
      writeStrIL.EmitWriteLine("The value of 'y' is:")
      writeStrIL.EmitWriteLine(yField)
      
      ' Since we return no value (void), the ret opcode will not
      ' return the top stack value.

      writeStrIL.Emit(OpCodes.Ret)
      
      Return pointTypeBld.CreateType()

   End Function 'CreateDynamicType
    
   
   Public Shared Sub Main()
      
      Dim ctorParams(1) As Object
      
      Console.Write("Enter a integer value for X: ")
      Dim myX As String = Console.ReadLine()
      Console.Write("Enter a integer value for Y: ")
      Dim myY As String = Console.ReadLine()
      
      Console.WriteLine("---")
      
      ctorParams(0) = Convert.ToInt32(myX)
      ctorParams(1) = Convert.ToInt32(myY)
      
      Dim ptType As Type = CreateDynamicType()

      Dim ptInstance As Object = Activator.CreateInstance(ptType, ctorParams)

      ptType.InvokeMember("WritePoint", _
              BindingFlags.InvokeMethod, _
              Nothing, ptInstance, Nothing)

   End Sub

End Class

注解

有关成员操作代码的详细说明,请参阅公共语言基础结构 (CLI) 文档,特别是“Partition III: CIL 指令集”和“Partition II: Metadata Definition and Semantics”。 有关详细信息,请参阅 ECMA 335 公共语言基础结构 (CLI)

字段

Add

将两个值相加并将结果推送到计算堆栈上。

Add_Ovf

将两个整数相加,执行溢出检查,并且将结果推送到计算堆栈上。

Add_Ovf_Un

将两个无符号整数值相加,执行溢出检查,并且将结果推送到计算堆栈上。

And

计算两个值的按位“与”并将结果推送到计算堆栈上。

Arglist

返回指向当前方法的参数列表的非托管指针。

Beq

如果两个值相等,则将控制转移到目标指令。

Beq_S

如果两个值相等,则将控制转移到目标指令(短格式)。

Bge

如果第一个值大于或等于第二个值,则将控制转移到目标指令。

Bge_S

如果第一个值大于或等于第二个值,则将控制转移到目标指令(短格式)。

Bge_Un

当比较无符号整数值或未经排序的浮点值时,如果第一个值大于第二个值,则将控制转移到目标指令。

Bge_Un_S

当比较无符号整数值或未经排序的浮点值时,如果第一个值大于第二个值,则将控制转移到目标指令(短格式)。

Bgt

如果第一个值大于第二个值,则将控制转移到目标指令。

Bgt_S

如果第一个值大于第二个值,则将控制转移到目标指令(短格式)。

Bgt_Un

当比较无符号整数值或未经排序的浮点值时,如果第一个值大于第二个值,则将控制转移到目标指令。

Bgt_Un_S

当比较无符号整数值或未经排序的浮点值时,如果第一个值大于第二个值,则将控制转移到目标指令(短格式)。

Ble

如果第一个值小于或等于第二个值,则将控制转移到目标指令。

Ble_S

如果第一个值小于或等于第二个值,则将控制转移到目标指令(短格式)。

Ble_Un

当比较无符号整数值或未经排序的浮点值时,如果第一个值小于或等于第二个值,则将控制转移到目标指令。

Ble_Un_S

当比较无符号整数值或未经排序的浮点值时,如果第一个值小于或等于第二个值,则将控制转移到目标指令(短格式)。

Blt

如果第一个值小于第二个值,则将控制转移到目标指令。

Blt_S

如果第一个值小于第二个值,则将控制转移到目标指令(短格式)。

Blt_Un

当比较无符号整数值或未经排序的浮点值时,如果第一个值小于第二个值,则将控制转移到目标指令。

Blt_Un_S

当比较无符号整数值或未经排序的浮点值时,如果第一个值小于第二个值,则将控制转移到目标指令(短格式)。

Bne_Un

当两个无符号整数值或未经排序的浮点值不相等时,将控制转移到目标指令。

Bne_Un_S

当两个无符号整数值或未经排序的浮点值不相等时,将控制转移到目标指令(短格式)。

Box

将值类转换为对象引用(O 类型)。

Br

无条件地将控制转移到目标指令。

Br_S

无条件地将控制转移到目标指令(短格式)。

Break

向公共语言结构 (CLI) 发出信号以通知调试器已撞上了一个断点。

Brfalse

如果 valuefalse、空引用(Visual Basic 中的 Nothing)或零,则将控制转移到目标指令。

Brfalse_S

如果 valuefalse、空引用或零,则将控制转移到目标指令。

Brtrue

如果 valuetrue、非空或非零,则将控制转移到目标指令。

Brtrue_S

如果 valuetrue、非空或非零,则将控制转移到目标指令(短格式)。

Call

调用由传递的方法说明符指示的方法。

Calli

通过调用约定描述的参数调用在计算堆栈上指示的方法(作为指向入口点的指针)。

Callvirt

对对象调用后期绑定方法,并且将返回值推送到计算堆栈上。

Castclass

尝试将引用传递的对象转换为指定的类。

Ceq

比较两个值。 如果这两个值相等,则将整数值 1 (int32) 推送到计算堆栈上;否则,将 0 (int32) 推送到计算堆栈上。

Cgt

比较两个值。 如果第一个值大于第二个值,则将整数值 1 (int32) 推送到计算堆栈上;反之,将 0 (int32) 推送到计算堆栈上。

Cgt_Un

比较两个无符号的或未经排序的值。 如果第一个值大于第二个值,则将整数值 1 (int32) 推送到计算堆栈上;反之,将 0 (int32) 推送到计算堆栈上。

Ckfinite

如果值不是有限数,则引发 ArithmeticException

Clt

比较两个值。 如果第一个值小于第二个值,则将整数值 1 (int32) 推送到计算堆栈上;反之,将 0 (int32) 推送到计算堆栈上。

Clt_Un

比较无符号的或不可排序的值 value1value2。 如果 value1 小于 value2,则将整数值 1 (int32 ) 推送到计算堆栈上;反之,将 0 ( int32 ) 推送到计算堆栈上。

Constrained

约束要对其进行虚方法调用的类型。

Conv_I

将位于计算堆栈顶部的值转换为 native int

Conv_I1

将位于计算堆栈顶部的值转换为 int8,然后将其扩展(填充)为 int32

Conv_I2

将位于计算堆栈顶部的值转换为 int16,然后将其扩展(填充)为 int32

Conv_I4

将位于计算堆栈顶部的值转换为 int32

Conv_I8

将位于计算堆栈顶部的值转换为 int64

Conv_Ovf_I

将位于计算堆栈顶部的有符号值转换为有符号的 native int,并在溢出时引发 OverflowException

Conv_Ovf_I_Un

将位于计算堆栈顶部的无符号值转换为有符号 native int,并在溢出时引发 OverflowException

Conv_Ovf_I1

将位于计算堆栈顶部的有符号值转换为有符号的 int8 并将其扩展为 int32,并在溢出时引发 OverflowException

Conv_Ovf_I1_Un

将位于计算堆栈顶部的无符号值转换为有符号 int8 并将其扩展为 int32,并在溢出时引发 OverflowException

Conv_Ovf_I2

将位于计算堆栈顶部的有符号值转换为有符号 int16 并将其扩展为 int32,并在溢出时引发 OverflowException

Conv_Ovf_I2_Un

将位于计算堆栈顶部的无符号值转换为有符号 int16 并将其扩展为 int32,并在溢出时引发 OverflowException

Conv_Ovf_I4

将位于计算堆栈顶部的有符号值转换为有符号的 int32,并在溢出时引发 OverflowException

Conv_Ovf_I4_Un

将位于计算堆栈顶部的无符号值转换为有符号 int32,并在溢出时引发 OverflowException

Conv_Ovf_I8

将位于计算堆栈顶部的有符号值转换为有符号的 int64,并在溢出时引发 OverflowException

Conv_Ovf_I8_Un

将位于计算堆栈顶部的无符号值转换为有符号 int64,并在溢出时引发 OverflowException

Conv_Ovf_U

将位于计算堆栈顶部的有符号值转换为 unsigned native int,并在溢出时引发 OverflowException

Conv_Ovf_U_Un

将位于计算堆栈顶部的无符号值转换为 unsigned native int,并在溢出时引发 OverflowException

Conv_Ovf_U1

将位于计算堆栈顶部的有符号值转换为 unsigned int8 并将其扩展为 int32,并在溢出时引发 OverflowException

Conv_Ovf_U1_Un

将位于计算堆栈顶部的无符号值转换为 unsigned int8 并将其扩展为 int32,并在溢出时引发 OverflowException

Conv_Ovf_U2

将位于计算堆栈顶部的有符号值转换为 unsigned int16 并将其扩展为 int32,并在溢出时引发 OverflowException

Conv_Ovf_U2_Un

将位于计算堆栈顶部的无符号值转换为 unsigned int16 并将其扩展为 int32,并在溢出时引发 OverflowException

Conv_Ovf_U4

将位于计算堆栈顶部的有符号值转换为 unsigned int32,并在溢出时引发 OverflowException

Conv_Ovf_U4_Un

将位于计算堆栈顶部的无符号值转换为 unsigned int32,并在溢出时引发 OverflowException

Conv_Ovf_U8

将位于计算堆栈顶部的有符号值转换为 unsigned int64,并在溢出时引发 OverflowException

Conv_Ovf_U8_Un

将位于计算堆栈顶部的无符号值转换为 unsigned int64,并在溢出时引发 OverflowException

Conv_R_Un

将位于计算堆栈顶部的无符号整数值转换为 float32

Conv_R4

将位于计算堆栈顶部的值转换为 float32

Conv_R8

将位于计算堆栈顶部的值转换为 float64

Conv_U

将位于计算堆栈顶部的值转换为 unsigned native int,然后将其扩展为 native int

Conv_U1

将位于计算堆栈顶部的值转换为 unsigned int8,然后将其扩展为 int32

Conv_U2

将位于计算堆栈顶部的值转换为 unsigned int16,然后将其扩展为 int32

Conv_U4

将位于计算堆栈顶部的值转换为 unsigned int32,然后将其扩展为 int32

Conv_U8

将位于计算堆栈顶部的值转换为 unsigned int64,然后将其扩展为 int64

Cpblk

将指定数目的字节从源地址复制到目标地址。

Cpobj

将位于 对象地址处的值类型 (类型&native int) 复制到目标对象的地址 (类型&native int) 。

Div

将两个值相除并将结果作为浮点(F 类型)或商(int32 类型)推送到计算堆栈上。

Div_Un

两个无符号整数值相除并将结果 ( int32 ) 推送到计算堆栈上。

Dup

复制计算堆栈上当前最顶端的值,然后将副本推送到计算堆栈上。

Endfilter

将控制从异常的 filter 子句转移回公共语言结构 (CLI) 异常处理程序。

Endfinally

将控制从异常块的 faultfinally 子句转移回公共语言结构 (CLI) 异常处理程序。

Initblk

将位于特定地址的内存的指定块初始化为给定大小和初始值。

Initobj

将位于指定地址的值类型的每个字段初始化为空引用或适当的基元类型的 0。

Isinst

测试对象引用(O 类型)是否为特定类的实例。

Jmp

退出当前方法并跳至指定方法。

Ldarg

将自变量(由指定索引值引用)加载到堆栈上。

Ldarg_0

将索引为 0 的自变量加载到计算堆栈上。

Ldarg_1

将索引 1 处的参数加载到计算堆栈上。

Ldarg_2

将索引为 2 的参数加载到计算堆栈上。

Ldarg_3

将索引为 3 的自变量加载到计算堆栈上。

Ldarg_S

将自变量(由指定的短格式索引引用)加载到计算堆栈上。

Ldarga

将参数地址加载到计算堆栈上。

Ldarga_S

以短格式将自变量地址加载到计算堆栈上。

Ldc_I4

将所提供的 int32 类型的值作为 int32 推送到计算堆栈上。

Ldc_I4_0

将整数值 0 作为 int32 推送到计算堆栈上。

Ldc_I4_1

将整数值 1 作为 int32 推送到计算堆栈上。

Ldc_I4_2

将整数值 2 作为 int32 推送到计算堆栈上。

Ldc_I4_3

将整数值 3 作为 int32 推送到计算堆栈上。

Ldc_I4_4

将整数值 4 作为 int32 推送到计算堆栈上。

Ldc_I4_5

将整数值 5 作为 int32 推送到计算堆栈上。

Ldc_I4_6

将整数值 6 作为 int32 推送到计算堆栈上。

Ldc_I4_7

将整数值 7 作为 int32 推送到计算堆栈上。

Ldc_I4_8

将整数值 8 作为 int32 推送到计算堆栈上。

Ldc_I4_M1

将整数值 -1 作为 int32 推送到计算堆栈上。

Ldc_I4_S

将提供的 int8 值作为 int32 推送到计算堆栈上(短格式)。

Ldc_I8

将所提供的 int64 类型的值作为 int64 推送到计算堆栈上。

Ldc_R4

将所提供的 float32 类型的值作为 F (float) 类型推送到计算堆栈上。

Ldc_R8

将所提供的 float64 类型的值作为 F (float) 类型推送到计算堆栈上。

Ldelem

按照指令中指定的类型,将指定数组索引中的元素加载到计算堆栈的顶部。

Ldelem_I

将位于指定数组索引处的 native int 类型的元素作为 native int 加载到计算堆栈的顶部。

Ldelem_I1

将位于指定数组索引处的 int8 类型的元素作为 int32 加载到计算堆栈的顶部。

Ldelem_I2

将位于指定数组索引处的 int16 类型的元素作为 int32 加载到计算堆栈的顶部。

Ldelem_I4

将位于指定数组索引处的 int32 类型的元素作为 int32 加载到计算堆栈的顶部。

Ldelem_I8

将位于指定数组索引处的 int64 类型的元素作为 int64 加载到计算堆栈的顶部。

Ldelem_R4

将位于指定数组索引处的 float32 类型的元素作为 F 类型(浮点型)加载到计算堆栈的顶部。

Ldelem_R8

将位于指定数组索引处的 float64 类型的元素作为 F 类型(浮点型)加载到计算堆栈的顶部。

Ldelem_Ref

将位于指定数组索引处的包含对象引用的元素作为 O 类型(对象引用)加载到计算堆栈的顶部。

Ldelem_U1

将位于指定数组索引处的 unsigned int8 类型的元素作为 int32 加载到计算堆栈的顶部。

Ldelem_U2

将位于指定数组索引处的 unsigned int16 类型的元素作为 int32 加载到计算堆栈的顶部。

Ldelem_U4

将位于指定数组索引处的 unsigned int32 类型的元素作为 int32 加载到计算堆栈的顶部。

Ldelema

将位于指定数组索引的数组元素的地址作为 & 类型(托管指针)加载到计算堆栈的顶部。

Ldfld

查找对象中其引用当前位于计算堆栈的字段的值。

Ldflda

查找对象中其引用当前位于计算堆栈的字段的地址。

Ldftn

将指向实现特定方法的本机代码的非托管指针(native int 类型)推送到计算堆栈上。

Ldind_I

native int 类型的值作为 native int 间接加载到计算堆栈上。

Ldind_I1

int8 类型的值作为 int32 间接加载到计算堆栈上。

Ldind_I2

int16 类型的值作为 int32 间接加载到计算堆栈上。

Ldind_I4

int32 类型的值作为 int32 间接加载到计算堆栈上。

Ldind_I8

int64 类型的值作为 int64 间接加载到计算堆栈上。

Ldind_R4

float32 类型的值作为 F (float) 类型间接加载到计算堆栈上。

Ldind_R8

float64 类型的值作为 F (float) 类型间接加载到计算堆栈上。

Ldind_Ref

将对象引用作为 O(对象引用)类型间接加载到计算堆栈上。

Ldind_U1

unsigned int8 类型的值作为 int32 间接加载到计算堆栈上。

Ldind_U2

unsigned int16 类型的值作为 int32 间接加载到计算堆栈上。

Ldind_U4

unsigned int32 类型的值作为 int32 间接加载到计算堆栈上。

Ldlen

将从零开始的、一维数组的元素的数目推送到计算堆栈上。

Ldloc

将指定索引处的局部变量加载到计算堆栈上。

Ldloc_0

将索引 0 处的局部变量加载到计算堆栈上。

Ldloc_1

将索引 1 处的局部变量加载到计算堆栈上。

Ldloc_2

将索引 2 处的局部变量加载到计算堆栈上。

Ldloc_3

将索引 3 处的局部变量加载到计算堆栈上。

Ldloc_S

将特定索引处的局部变量加载到计算堆栈上(短格式)。

Ldloca

将位于特定索引处的局部变量的地址加载到计算堆栈上。

Ldloca_S

将位于特定索引处的局部变量的地址加载到计算堆栈上(短格式)。

Ldnull

将空引用(O 类型)推送到计算堆栈上。

Ldobj

将地址指向的值类型对象复制到计算堆栈的顶部。

Ldsfld

将静态字段的值推送到计算堆栈上。

Ldsflda

将静态字段的地址推送到计算堆栈上。

Ldstr

推送对元数据中存储的字符串的新对象引用。

Ldtoken

将元数据标记转换为其运行时表示形式,并将其推送到计算堆栈上。

Ldvirtftn

将指向实现与指定对象关联的特定虚方法的本机代码的非托管指针(native int 类型)推送到计算堆栈上。

Leave

退出受保护的代码区域,无条件将控制转移到特定目标指令。

Leave_S

退出受保护的代码区域,无条件将控制转移到目标指令(缩写形式)。

Localloc

从本地动态内存池分配特定数目的字节并将第一个分配的字节的地址(瞬态指针,* 类型)推送到计算堆栈上。

Mkrefany

将对特定类型实例的类型化引用推送到计算堆栈上。

Mul

将两个值相乘并将结果推送到计算堆栈上。

Mul_Ovf

将两个整数值相乘,执行溢出检查,并将结果推送到计算堆栈上。

Mul_Ovf_Un

将两个无符号整数值相乘,执行溢出检查,并将结果推送到计算堆栈上。

Neg

对一个值执行求反并将结果推送到计算堆栈上。

Newarr

将对新的从零开始的一维数组(其元素属于特定类型)的对象引用推送到计算堆栈上。

Newobj

创建一个值类型的新对象或新实例,并将对象引用(O 类型)推送到计算堆栈上。

Nop

如果修补操作码,则填充空间。 尽管可能消耗处理周期,但未执行任何有意义的操作。

Not

计算堆栈顶部整数值的按位求补并将结果作为相同的类型推送到计算堆栈上。

Or

计算位于堆栈顶部的两个整数值的按位求补并将结果推送到计算堆栈上。

Pop

移除当前位于计算堆栈顶部的值。

Prefix1

此指令为保留指令。

Prefix2

此指令为保留指令。

Prefix3

此指令为保留指令。

Prefix4

此指令为保留指令。

Prefix5

此指令为保留指令。

Prefix6

此指令为保留指令。

Prefix7

此指令为保留指令。

Prefixref

此指令为保留指令。

Readonly

指定后面的数组地址操作在运行时不执行类型检查,并且返回可变性受限的托管指针。

Refanytype

检索嵌入在类型化引用内的类型标记。

Refanyval

检索嵌入在类型化引用内的地址(& 类型)。

Rem

将两个值相除并将余数推送到计算堆栈上。

Rem_Un

将两个无符号值相除并将余数推送到计算堆栈上。

Ret

从当前方法返回,并将返回值(如果存在)从被调用方的计算堆栈推送到调用方的计算堆栈上。

Rethrow

再次引发当前异常。

Shl

将整数值左移(用零填充)指定的位数,并将结果推送到计算堆栈上。

Shr

将整数值右移(保留符号)指定的位数,并将结果推送到计算堆栈上。

Shr_Un

将无符号整数值右移(用零填充)指定的位数,并将结果推送到计算堆栈上。

Sizeof

将提供的值类型的大小(以字节为单位)推送到计算堆栈上。

Starg

将位于计算堆栈顶部的值存储到位于指定索引的自变量槽中。

Starg_S

将位于计算堆栈顶部的值存储在自变量槽中的指定索引处(短格式)。

Stelem

用计算堆栈中的值替换给定索引处的数组元素,其类型在指令中指定。

Stelem_I

用计算堆栈上的 native int 值替换给定索引处的数组元素。

Stelem_I1

用计算堆栈上的 int8 值替换给定索引处的数组元素。

Stelem_I2

用计算堆栈上的 int16 值替换给定索引处的数组元素。

Stelem_I4

用计算堆栈上的 int32 值替换给定索引处的数组元素。

Stelem_I8

用计算堆栈上的 int64 值替换给定索引处的数组元素。

Stelem_R4

用计算堆栈上的 float32 值替换给定索引处的数组元素。

Stelem_R8

用计算堆栈上的 float64 值替换给定索引处的数组元素。

Stelem_Ref

用计算堆栈上的对象 ref 值(O 类型)替换给定索引处的数组元素。

Stfld

用新值替换在对象引用或指针的字段中存储的值。

Stind_I

在所提供的地址存储 native int 类型的值。

Stind_I1

在所提供的地址存储 int8 类型的值。

Stind_I2

在所提供的地址存储 int16 类型的值。

Stind_I4

在所提供的地址存储 int32 类型的值。

Stind_I8

在所提供的地址存储 int64 类型的值。

Stind_R4

在所提供的地址存储 float32 类型的值。

Stind_R8

在所提供的地址存储 float64 类型的值。

Stind_Ref

存储所提供地址处的对象引用值。

Stloc

从计算堆栈顶部弹出当前值,并将其存储在指定索引处的局部变量列表中。

Stloc_0

从计算堆栈顶部弹出当前值,并将其存储在索引 0 处的局部变量列表中。

Stloc_1

从计算堆栈顶部弹出当前值,并将其存储在索引 1 处的局部变量列表中。

Stloc_2

从计算堆栈顶部弹出当前值,并将其存储在索引 2 的局部变量列表中。

Stloc_3

从计算堆栈顶部弹出当前值,并将其存储在索引 3 处的局部变量列表中。

Stloc_S

从计算堆栈顶部弹出当前值,并将其存储在 (短格式) 的 index 局部变量列表中。

Stobj

将指定类型的值从计算堆栈复制到所提供的内存地址中。

Stsfld

用来自计算堆栈的值替换静态字段的值。

Sub

从其他值中减去一个值并将结果推送到计算堆栈上。

Sub_Ovf

从另一值中减去一个整数值,执行溢出检查,并且将结果推送到计算堆栈上。

Sub_Ovf_Un

从另一值中减去一个无符号整数值,执行溢出检查,并且将结果推送到计算堆栈上。

Switch

实现跳转表。

Tailcall

执行后缀的方法调用指令,以便在执行实际调用指令前移除当前方法的堆栈帧。

Throw

引发当前位于计算堆栈上的异常对象。

Unaligned

指示当前位于计算堆栈上的地址可能没有与紧接的 ldindstindldfldstfldldobjstobjinitblkcpblk 指令的自然大小对齐。

Unbox

将值类型的已装箱的表示形式转换为其未装箱的形式。

Unbox_Any

将指令中指定类型的已装箱的表示形式转换成未装箱形式。

Volatile

指定当前位于计算堆栈顶部的地址可以是易失的,并且读取该位置的结果不能被缓存,或者对该地址的多个存储区不能被取消。

Xor

计算位于计算堆栈顶部的两个值的按位异或,并且将结果推送到计算堆栈上。

方法

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
TakesSingleByteArgument(OpCode)

如果提供的操作码采用单字节自变量则返回真或假。

ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于