本文整理汇总了C#中System.Reflection.MethodBase.IsFunction方法的典型用法代码示例。如果您正苦于以下问题:C# MethodBase.IsFunction方法的具体用法?C# MethodBase.IsFunction怎么用?C# MethodBase.IsFunction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.MethodBase
的用法示例。
在下文中一共展示了MethodBase.IsFunction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Rewrite
public override bool Rewrite(CodeDescriptor decompilee, MethodBase callee, StackElement[] args, IDecompiler stack, IFunctionBuilder builder)
{
object[] vargs = args.Select(arg => arg.Sample).ToArray();
Expression[] eargs = args.Select(arg => arg.Expr).ToArray();
object sample = null;
try
{
sample = callee.Invoke(vargs);
}
catch (Exception)
{
}
Expression result = new BinOp()
{
Operation = Kind
};
Array.Copy(eargs, result.Children, 2);
if (sample != null)
result.ResultType = TypeDescriptor.GetTypeOf(sample);
else
{
Type rtype;
callee.IsFunction(out rtype);
result.ResultType = (TypeDescriptor)rtype;
}
stack.Push(result, sample);
return true;
}
示例2: GetStackBilance
/// <summary>
/// Determines, how many operands a given CIL instruction will remove from the stack, and how many it will push onto the stack.
/// </summary>
/// <param name="ili">a CIL instruction</param>
/// <param name="method">the method inside whose context the given instruction is executed</param>
/// <param name="npop">number of removed stack operands</param>
/// <param name="npush">number of stack operands pushed onto the stack</param>
public static void GetStackBilance(ILInstruction ili, MethodBase method, out int npop, out int npush)
{
if (ili.Code.Equals(OpCodes.Ret))
{
Type returnType;
if (method.IsFunction(out returnType))
npop = 1;
else
npop = 0;
npush = 0;
}
else if (ili.Code.Equals(OpCodes.Call) ||
ili.Code.Equals(OpCodes.Calli) ||
ili.Code.Equals(OpCodes.Callvirt) ||
ili.Code.Equals(OpCodes.Newobj))
{
MethodBase mi = (MethodBase)ili.Operand;
ParameterInfo[] pis = mi.GetParameters();
npop = pis.Length;
if (ili.Code.Equals(OpCodes.Calli))
++npop;
if (mi.CallingConvention.HasFlag(CallingConventions.HasThis) &&
!ili.Code.Equals(OpCodes.Newobj))
++npop;
Type returnType;
if (mi.IsFunction(out returnType) ||
ili.Code.Equals(OpCodes.Newobj))
npush = 1;
else
npush = 0;
}
else
{
npop = -StackOperands.GetNumOperands(ili.Code.StackBehaviourPop);
npush = StackOperands.GetNumOperands(ili.Code.StackBehaviourPush);
}
}