本文整理匯總了C#中ILExpression.GetSelfAndChildrenRecursiveILRanges方法的典型用法代碼示例。如果您正苦於以下問題:C# ILExpression.GetSelfAndChildrenRecursiveILRanges方法的具體用法?C# ILExpression.GetSelfAndChildrenRecursiveILRanges怎麽用?C# ILExpression.GetSelfAndChildrenRecursiveILRanges使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ILExpression
的用法示例。
在下文中一共展示了ILExpression.GetSelfAndChildrenRecursiveILRanges方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: TransformExpression
AstNode TransformExpression(ILExpression expr)
{
List<ILRange> ilRanges = ILRange.OrderAndJoin(expr.GetSelfAndChildrenRecursiveILRanges());
AstNode node = TransformByteCode(expr);
Expression astExpr = node as Expression;
AstNode result;
if (astExpr != null)
result = Convert(astExpr, expr.InferredType, expr.ExpectedType);
else
result = node;
if (result != null)
result = result.WithAnnotation(new TypeInformation(expr.InferredType, expr.ExpectedType));
if (result != null)
return result.WithAnnotation(ilRanges);
return result;
}
示例2: MakeAssignmentExpression
bool MakeAssignmentExpression(ILBlockBase block, List<ILNode> body, ILExpression expr, int pos)
{
// exprVar = ...
// stloc(v, exprVar)
// ->
// exprVar = stloc(v, ...))
ILVariable exprVar;
ILExpression initializer;
if (!(expr.Match(ILCode.Stloc, out exprVar, out initializer) && exprVar.GeneratedByDecompiler))
return false;
ILExpression nextExpr = body.ElementAtOrDefault(pos + 1) as ILExpression;
if (nextExpr == null)
return false;
ILVariable v;
ILExpression stLocArg;
if (nextExpr.Match(ILCode.Stloc, out v, out stLocArg) && stLocArg.MatchLdloc(exprVar)) {
ILExpression store2 = body.ElementAtOrDefault(pos + 2) as ILExpression;
if (StoreCanBeConvertedToAssignment(store2, exprVar)) {
// expr_44 = ...
// stloc(v1, expr_44)
// anystore(v2, expr_44)
// ->
// stloc(v1, anystore(v2, ...))
ILInlining inlining = new ILInlining(method);
if (inlining.numLdloc.GetOrDefault(exprVar) == 2 && inlining.numStloc.GetOrDefault(exprVar) == 1) {
body.RemoveAt(pos + 2); // remove store2
body.RemoveAt(pos); // remove expr = ...
nextExpr.ILRanges.AddRange(nextExpr.Arguments[0].GetSelfAndChildrenRecursiveILRanges());
nextExpr.Arguments[0] = store2;
store2.ILRanges.AddRange(expr.GetSelfAndChildrenRecursiveILRanges());
store2.ILRanges.AddRange(store2.Arguments[store2.Arguments.Count - 1].GetSelfAndChildrenRecursiveILRanges());
store2.Arguments[store2.Arguments.Count - 1] = initializer;
inlining.InlineIfPossible(block, body, ref pos);
return true;
}
}
body.RemoveAt(pos + 1); // remove stloc
nextExpr.ILRanges.AddRange(nextExpr.Arguments[0].GetSelfAndChildrenRecursiveILRanges());
nextExpr.Arguments[0] = initializer;
nextExpr.ILRanges.AddRange(expr.Arguments[0].GetSelfAndChildrenRecursiveILRanges());
expr.Arguments[0] = nextExpr;
return true;
} else if ((nextExpr.Code == ILCode.Stsfld || nextExpr.Code == ILCode.CallSetter || nextExpr.Code == ILCode.CallvirtSetter) && nextExpr.Arguments.Count == 1) {
// exprVar = ...
// stsfld(fld, exprVar)
// ->
// exprVar = stsfld(fld, ...))
if (nextExpr.Arguments[0].MatchLdloc(exprVar)) {
body.RemoveAt(pos + 1); // remove stsfld
nextExpr.ILRanges.AddRange(nextExpr.Arguments[0].GetSelfAndChildrenRecursiveILRanges());
nextExpr.Arguments[0] = initializer;
expr.ILRanges.AddRange(expr.Arguments[0].GetSelfAndChildrenRecursiveILRanges());
expr.Arguments[0] = nextExpr;
return true;
}
}
return false;
}