System.Reflection.Emit.DynamicILGenerator.EmitCalli C# (CSharp) Method

EmitCalli() public method

public EmitCalli ( OpCode opcode, CallingConvention unmanagedCallConv, Type returnType, Type parameterTypes ) : void
opcode OpCode
unmanagedCallConv CallingConvention
returnType System.Type
parameterTypes System.Type
return void
        public override void EmitCalli(OpCode opcode,
                                       CallingConvention unmanagedCallConv,
                                       Type returnType,
                                       Type[] parameterTypes) {
            int             stackchange = 0;
            int             cParams = 0;
            int             i;
            SignatureHelper sig;
            
            // The opcode passed in must be the calli instruction.
            BCLDebug.Assert(opcode.Equals(OpCodes.Calli),
                            "Unexpected opcode passed to EmitCalli.");
            if (parameterTypes != null)
                cParams = parameterTypes.Length;
            
            sig = SignatureHelper.GetMethodSigHelper(unmanagedCallConv, returnType);
                            
            if (parameterTypes != null)
                for (i = 0; i < cParams; i++) 
                    sig.AddArgument(parameterTypes[i]);
                                  
            // If there is a non-void return type, push one.
            if (returnType != typeof(void))
                stackchange++;
                
            // Pop off arguments if any.
            if (parameterTypes != null)
                stackchange -= cParams;
                
            // Pop the native function pointer.
            stackchange--;
            UpdateStackSize(opcode, stackchange);
            
            EnsureCapacity(7);
            Emit(OpCodes.Calli);
            int token = AddSignature(sig.GetSignature(true));
            m_length = PutInteger4(token, m_length, m_ILStream);
        }

Same methods

DynamicILGenerator::EmitCalli ( OpCode opcode, CallingConventions callingConvention, Type returnType, Type parameterTypes, Type optionalParameterTypes ) : void