protected internal void EmitCallHelper(MethodBase mth, Operand target)
{
MethodInfo mi = mth as MethodInfo;
if (mi != null)
{
bool suppressVirtual = ((object)target != null && target.SuppressVirtual) || mi.IsStatic || (((object)target != null)
&& (target.GetReturnType(TypeMapper).IsValueType|| target.GetReturnType(TypeMapper).IsArray) && !mi.IsVirtual);
if (!suppressVirtual && (object)target != null && target.GetReturnType(TypeMapper).IsValueType && mi.IsVirtual)
{
IL.Emit(OpCodes.Constrained, target.GetReturnType(TypeMapper));
}
//Console.WriteLine("Emitting " + mth + ", using " + (suppressVirtual ? "call" : "callvirt"));
IL.Emit(suppressVirtual ? OpCodes.Call : OpCodes.Callvirt, mi);
return;
}
ConstructorInfo ci = mth as ConstructorInfo;
if (ci != null)
{
IL.Emit(OpCodes.Call, ci);
return;
}
throw new ArgumentException(Properties.Messages.ErrInvalidMethodBase, nameof(mth));
}
}