ILGenerator.EmitCalli メソッド

定義

Microsoft Intermediate Language (MSIL) ストリームに Calli 命令を書き込みます。

オーバーロード

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

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

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

間接的な呼び出しにマネージド呼び出し規約を指定して、MSIL (Microsoft Intermediate Language) ストリームに Calli 命令を書き込みます。

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

ソース:
ILGenerator.cs
ソース:
ILGenerator.cs
ソース:
ILGenerator.cs

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

public:
 virtual void EmitCalli(System::Reflection::Emit::OpCode opcode, System::Runtime::InteropServices::CallingConvention unmanagedCallConv, Type ^ returnType, cli::array <Type ^> ^ parameterTypes);
public:
 abstract void EmitCalli(System::Reflection::Emit::OpCode opcode, System::Runtime::InteropServices::CallingConvention unmanagedCallConv, Type ^ returnType, cli::array <Type ^> ^ parameterTypes);
public:
 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);
public abstract void EmitCalli (System.Reflection.Emit.OpCode opcode, System.Runtime.InteropServices.CallingConvention unmanagedCallConv, Type? returnType, Type[]? parameterTypes);
public virtual void EmitCalli (System.Reflection.Emit.OpCode opcode, System.Runtime.InteropServices.CallingConvention unmanagedCallConv, Type returnType, Type[] parameterTypes);
public 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
abstract member EmitCalli : System.Reflection.Emit.OpCode * System.Runtime.InteropServices.CallingConvention * Type * Type[] -> unit
member this.EmitCalli : System.Reflection.Emit.OpCode * System.Runtime.InteropServices.CallingConvention * Type * Type[] -> unit
Public Overridable Sub EmitCalli (opcode As OpCode, unmanagedCallConv As CallingConvention, returnType As Type, parameterTypes As Type())
Public MustOverride Sub EmitCalli (opcode As OpCode, unmanagedCallConv As CallingConvention, returnType As Type, parameterTypes As Type())
Public Sub EmitCalli (opcode As OpCode, unmanagedCallConv As CallingConvention, returnType As Type, parameterTypes As Type())

パラメーター

opcode
OpCode

ストリームに生成する MSIL 命令。 Calliである必要があります。

unmanagedCallConv
CallingConvention

使用するアンマネージ呼び出し規約。

returnType
Type

結果の Type

parameterTypes
Type[]

命令に必要な引数の型。

次のコード サンプルは、動的クラスの外部で EmitCalli アンマネージド型メソッドを呼び出すメソッドのコンテキストでの使用方法を示しています。

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 ...

注釈

を使用して EmitCalliCalli ストリームに命令を配置します。 Emitは使用しないでください。

適用対象

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

ソース:
ILGenerator.cs
ソース:
ILGenerator.cs
ソース:
ILGenerator.cs

間接的な呼び出しにマネージド呼び出し規約を指定して、MSIL (Microsoft Intermediate Language) ストリームに Calli 命令を書き込みます。

public:
 virtual void EmitCalli(System::Reflection::Emit::OpCode opcode, System::Reflection::CallingConventions callingConvention, Type ^ returnType, cli::array <Type ^> ^ parameterTypes, cli::array <Type ^> ^ optionalParameterTypes);
public:
 abstract void EmitCalli(System::Reflection::Emit::OpCode opcode, System::Reflection::CallingConventions callingConvention, Type ^ returnType, cli::array <Type ^> ^ parameterTypes, cli::array <Type ^> ^ optionalParameterTypes);
public:
 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);
public abstract void EmitCalli (System.Reflection.Emit.OpCode opcode, System.Reflection.CallingConventions callingConvention, Type? returnType, Type[]? parameterTypes, Type[]? optionalParameterTypes);
public virtual void EmitCalli (System.Reflection.Emit.OpCode opcode, System.Reflection.CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type[] optionalParameterTypes);
public 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
abstract member EmitCalli : System.Reflection.Emit.OpCode * System.Reflection.CallingConventions * Type * Type[] * Type[] -> unit
member this.EmitCalli : System.Reflection.Emit.OpCode * System.Reflection.CallingConventions * Type * Type[] * Type[] -> unit
Public Overridable Sub EmitCalli (opcode As OpCode, callingConvention As CallingConventions, returnType As Type, parameterTypes As Type(), optionalParameterTypes As Type())
Public MustOverride Sub EmitCalli (opcode As OpCode, callingConvention As CallingConventions, returnType As Type, parameterTypes As Type(), optionalParameterTypes As Type())
Public Sub EmitCalli (opcode As OpCode, callingConvention As CallingConventions, returnType As Type, parameterTypes As Type(), optionalParameterTypes As Type())

パラメーター

opcode
OpCode

ストリームに生成する MSIL 命令。 Calliである必要があります。

callingConvention
CallingConventions

使用するマネージド呼び出し規則。

returnType
Type

結果の Type

parameterTypes
Type[]

命令に必要な引数の型。

optionalParameterTypes
Type[]

varargs 呼び出しの省略可能な引数の型。

例外

optionalParameterTypesnull でないにもかかわらず、callingConventionVarArgs フラグが含まれていません。

注釈

を使用して EmitCalliCalli ストリームに命令を配置します。 Emitは使用しないでください。

省略可能な引数を指定する場合 optionalParameterTypes は、 callingConvention フラグを CallingConventions.VarArgs 含める必要があります。

適用対象