public virtual void EmitCalli(OpCode opcode, CallingConvention unmanagedCallConv, Type returnType, Type[] parameterTypes) { int stackchange = 0; int length = 0; ModuleBuilder module = (ModuleBuilder)this.m_methodBuilder.Module; if (parameterTypes != null) { length = parameterTypes.Length; } SignatureHelper sigHelper = SignatureHelper.GetMethodSigHelper(module, unmanagedCallConv, returnType); if (parameterTypes != null) { for (int i = 0; i < length; i++) { sigHelper.AddArgument(parameterTypes[i]); } } if (returnType != typeof(void)) { stackchange++; } if (parameterTypes != null) { stackchange -= length; } stackchange--; this.UpdateStackSize(OpCodes.Calli, stackchange); this.EnsureCapacity(7); this.Emit(OpCodes.Calli); this.RecordTokenFixup(); this.PutInteger4(module.GetSignatureToken(sigHelper).Token); }
public virtual void EmitCalli(OpCode opcode, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type[] optionalParameterTypes) { int stackchange = 0; if ((optionalParameterTypes != null) && ((callingConvention & CallingConventions.VarArgs) == 0)) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAVarArgCallingConvention")); } ModuleBuilder module = (ModuleBuilder)this.m_methodBuilder.Module; SignatureHelper sigHelper = this.GetMemberRefSignature(callingConvention, returnType, parameterTypes, optionalParameterTypes); this.EnsureCapacity(7); this.Emit(OpCodes.Calli); if (returnType != typeof(void)) { stackchange++; } if (parameterTypes != null) { stackchange -= parameterTypes.Length; } if (optionalParameterTypes != null) { stackchange -= optionalParameterTypes.Length; } if ((callingConvention & CallingConventions.HasThis) == CallingConventions.HasThis) { stackchange--; } stackchange--; this.UpdateStackSize(OpCodes.Calli, stackchange); this.RecordTokenFixup(); this.PutInteger4(module.GetSignatureToken(sigHelper).Token); }
public virtual void Emit(OpCode opcode, SignatureHelper signature) { if (signature == null) { throw new ArgumentNullException("signature"); } int stackchange = 0; ModuleBuilder module = (ModuleBuilder)this.m_methodBuilder.Module; int token = module.GetSignatureToken(signature).Token; this.EnsureCapacity(7); this.InternalEmit(opcode); if (opcode.m_pop == StackBehaviour.Varpop) { stackchange -= signature.ArgumentCount; stackchange--; this.UpdateStackSize(opcode, stackchange); } this.RecordTokenFixup(); this.PutInteger4(token); }