本文整理匯總了C#中ILExpression.ToString方法的典型用法代碼示例。如果您正苦於以下問題:C# ILExpression.ToString方法的具體用法?C# ILExpression.ToString怎麽用?C# ILExpression.ToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ILExpression
的用法示例。
在下文中一共展示了ILExpression.ToString方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: MatchEnumeratorCreationNewObj
bool MatchEnumeratorCreationNewObj(ILExpression expr, out MethodDefinition ctor)
{
// newobj(CurrentType/...::.ctor, ldc.i4(-2))
ctor = null;
// N3X15 WAS: if (expr.Code != ILCode.Newobj || expr.Arguments.Count != 1)
if (expr.Code != ILCode.Newobj)
{
Console.WriteLine("[YLD] REJECTED " + expr.ToString() + " BECAUSE "+expr.Code.GetName()+"!=ILCode.Newobj");
return false;
}
if(expr.Arguments.Count > 1)
{
Console.WriteLine("[YLD] REJECTED " + expr.ToString() + " BECAUSE " + expr.Arguments.Count + ">1");
return false;
}
// N3X15: Handle stuff like newobj('<Load>c__Iterator7'::.ctor)
if (expr.Arguments.Count==0 || expr.Arguments[0].Code != ILCode.Ldc_I4)
{
//return false;
Console.WriteLine("[YLD] WARNING " + expr.ToString() + ": LDC_I4 not present");
}
else
{
int initialState = (int)expr.Arguments[0].Operand;
if (!(initialState == -2 || initialState == 0))
{
Console.WriteLine("[YLD] REJECTED " + expr.ToString() + " BECAUSE " + initialState + "!= (-2 | 0)");
return false;
}
}
// End N3X15
ctor = GetMethodDefinition(expr.Operand as MethodReference);
if (ctor == null || ctor.DeclaringType.DeclaringType != context.CurrentType)
{
Console.WriteLine("[YLD] REJECT " + expr.ToString() + ": ctor null or not in context");
return false;
}
return IsCompilerGeneratorEnumerator(ctor.DeclaringType);
}