ILGenerator.EmitCalli ILGenerator.EmitCalli ILGenerator.EmitCalli Method

定義

Microsoft Intermediate Language (MSIL) ストリームに Calli 命令を書き込みます。Puts a Calli instruction onto the Microsoft intermediate language (MSIL) stream.

オーバーロード

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

間接的な呼び出しにアンマネージ呼び出し規約を指定して、MSIL (Microsoft Intermediate Language) ストリームに Calli 命令を書き込みます。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[])

間接的な呼び出しにマネージド呼び出し規約を指定して、MSIL (Microsoft Intermediate Language) ストリームに Calli 命令を書き込みます。Puts a Calli instruction onto the Microsoft intermediate language (MSIL) stream, specifying a managed calling convention for the indirect call.

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

間接的な呼び出しにアンマネージ呼び出し規約を指定して、MSIL (Microsoft Intermediate Language) ストリームに Calli 命令を書き込みます。Puts a Calli instruction onto the Microsoft intermediate language (MSIL) stream, specifying an unmanaged calling convention for the indirect call.

public:
 virtual void EmitCalli(System::Reflection::Emit::OpCode opcode, System::Runtime::InteropServices::CallingConvention unmanagedCallConv, Type ^ returnType, cli::array <Type ^> ^ parameterTypes);
public virtual void EmitCalli (System.Reflection.Emit.OpCode opcode, System.Runtime.InteropServices.CallingConvention unmanagedCallConv, Type returnType, Type[] parameterTypes);
abstract member EmitCalli : System.Reflection.Emit.OpCode * System.Runtime.InteropServices.CallingConvention * Type * Type[] -> unit
override this.EmitCalli : System.Reflection.Emit.OpCode * System.Runtime.InteropServices.CallingConvention * Type * Type[] -> unit

パラメーター

opcode
OpCode OpCode OpCode

ストリームに生成する MSIL 命令。The MSIL instruction to be emitted onto the stream. Calli にする必要があります。Must be Calli.

unmanagedCallConv
CallingConvention CallingConvention CallingConvention

使用するアンマネージ呼び出し規約。The unmanaged calling convention to be used.

returnType
Type Type Type

結果の TypeThe Type of the result.

parameterTypes
Type[]

命令に必要な引数の型。The types of the required arguments to the instruction.

次のコード サンプルは、のコンテキストの使用を示して、EmitCalli動的クラスの外部、アンマネージ型のメソッドを呼び出すメソッド。The following code sample demonstrates the contextual usage of the EmitCalli method to call an unmanaged type method external to the dynamic class.

MethodBuilder^ myMthdBuilder = myTypeBuilder->DefineMethod( "MyMethod",
                               MethodAttributes::Public,
                               returnType, mthdParamTypes );

// We will assume that an external unmanaged type "LegacyNumber" has been loaded, and
// that it has a method "ToString" which returns a String.

MethodInfo^ unmanagedMthdMI = Type::GetType( "LegacyNumber" )->GetMethod( "ToString" );
ILGenerator^ myMthdIL = myMthdBuilder->GetILGenerator();

// Code to emit various IL opcodes here ...

// Load a reference to the specific Object instance onto the stack.

myMthdIL->Emit( OpCodes::Ldc_I4, addrOfLegacyNumberObject );
myMthdIL->Emit( OpCodes::Ldobj, Type::GetType( "LegacyNumber" ) );

// Make the call to the unmanaged type method, telling it that the method is
// the member of a specific instance, to expect a String
// as a return value, and that there are no explicit parameters.
myMthdIL->EmitCalli( OpCodes::Calli,
                     System::Runtime::InteropServices::CallingConvention::ThisCall,
                     String::typeid,
                     gcnew array<Type^>( 0 ) );

// More IL code emission here ...
MethodBuilder myMthdBuilder = myTypeBuilder.DefineMethod("MyMethod", 
			      MethodAttributes.Public,
			      returnType, mthdParamTypes);
							
// We will assume that an external unmanaged type "LegacyNumber" has been loaded, and
// that it has a method "ToString" which returns a string.

MethodInfo unmanagedMthdMI = Type.GetType("LegacyNumber").GetMethod("ToString");
ILGenerator myMthdIL = myMthdBuilder.GetILGenerator();

// Code to emit various IL opcodes here ...

// Load a reference to the specific object instance onto the stack.

myMthdIL.Emit(OpCodes.Ldc_I4, addrOfLegacyNumberObject);
myMthdIL.Emit(OpCodes.Ldobj, Type.GetType("LegacyNumber"));

// Make the call to the unmanaged type method, telling it that the method is
// the member of a specific instance, to expect a string 
// as a return value, and that there are no explicit parameters.
myMthdIL.EmitCalli(OpCodes.Calli, 
		   System.Runtime.InteropServices.CallingConvention.ThisCall,
	    	   typeof(string),
		   new Type[] {});

// More IL code emission here ...

     	Dim myMthdBuilder As MethodBuilder = myTypeBuilder.DefineMethod("MyMethod", _
					MethodAttributes.Public, _
					returnType, mthdParamTypes)
     
     	' We will assume that an external unmanaged type "LegacyNumber" has been loaded, and
     	' that it has a method "ToString" which returns a string.

     	Dim unmanagedMthdMI As MethodInfo = Type.GetType("LegacyNumber").GetMethod("ToString")
     	Dim myMthdIL As ILGenerator = myMthdBuilder.GetILGenerator()
     
     	' Code to emit various IL opcodes here ...
     	' Load a reference to the specific object instance onto the stack.

     	myMthdIL.Emit(OpCodes.Ldc_I4, addrOfLegacyNumberObject)
     	myMthdIL.Emit(OpCodes.Ldobj, Type.GetType("LegacyNumber"))
     
     	' Make the call to the unmanaged type method, telling it that the method is
     	' the member of a specific instance, to expect a string 
     	' as a return value, and that there are no explicit parameters.

     	myMthdIL.EmitCalli(OpCodes.Calli, System.Runtime.InteropServices.CallingConvention.ThisCall, _
				  GetType(String), New Type() {})

' More IL code emission here ...

注釈

使用EmitCalliを配置する、Calliをストリームに命令します。Use EmitCalli to put a Calli instruction onto the stream. Emitは使用しないでください。Do not use Emit.

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

間接的な呼び出しにマネージド呼び出し規約を指定して、MSIL (Microsoft Intermediate Language) ストリームに Calli 命令を書き込みます。Puts a Calli instruction onto the Microsoft intermediate language (MSIL) stream, specifying a managed calling convention for the indirect call.

public:
 virtual void EmitCalli(System::Reflection::Emit::OpCode opcode, System::Reflection::CallingConventions callingConvention, Type ^ returnType, cli::array <Type ^> ^ parameterTypes, cli::array <Type ^> ^ optionalParameterTypes);
public virtual void EmitCalli (System.Reflection.Emit.OpCode opcode, System.Reflection.CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type[] optionalParameterTypes);
abstract member EmitCalli : System.Reflection.Emit.OpCode * System.Reflection.CallingConventions * Type * Type[] * Type[] -> unit
override this.EmitCalli : System.Reflection.Emit.OpCode * System.Reflection.CallingConventions * Type * Type[] * Type[] -> unit

パラメーター

opcode
OpCode OpCode OpCode

ストリームに生成する MSIL 命令。The MSIL instruction to be emitted onto the stream. Calli にする必要があります。Must be Calli.

callingConvention
CallingConventions CallingConventions CallingConventions

使用するマネージド呼び出し規則。The managed calling convention to be used.

returnType
Type Type Type

結果の TypeThe Type of the result.

parameterTypes
Type[]

命令に必要な引数の型。The types of the required arguments to the instruction.

optionalParameterTypes
Type[]

varargs 呼び出しの省略可能な引数の型。The types of the optional arguments for varargs calls.

例外

optionalParameterTypesnull でないにもかかわらず、callingConventionVarArgs フラグが含まれていません。optionalParameterTypes is not null, but callingConvention does not include the VarArgs flag.

注釈

使用EmitCalliを配置する、Calliをストリームに命令します。Use EmitCalli to put a Calli instruction onto the stream. Emitは使用しないでください。Do not use Emit.

場合optionalParameterTypesオプションの引数を指定しますcallingConvention含める必要があります、CallingConventions.VarArgsフラグ。If optionalParameterTypes specifies optional arguments, callingConvention must include the CallingConventions.VarArgs flag.

適用対象