Browse Source

Ignore arguments of 'leave'. Closes #185

pull/252/merge
David Srbecký 14 years ago
parent
commit
3b692d9c7c
  1. 8
      ICSharpCode.Decompiler/ILAst/ILAstOptimizer.cs

8
ICSharpCode.Decompiler/ILAst/ILAstOptimizer.cs

@ -240,6 +240,7 @@ namespace ICSharpCode.Decompiler.ILAst @@ -240,6 +240,7 @@ namespace ICSharpCode.Decompiler.ILAst
/// <summary>
/// Removes redundatant Br, Nop, Dup, Pop
/// Ignore arguments of 'leave'
/// </summary>
/// <param name="method"></param>
void RemoveRedundantCode(ILBlock method)
@ -278,6 +279,13 @@ namespace ICSharpCode.Decompiler.ILAst @@ -278,6 +279,13 @@ namespace ICSharpCode.Decompiler.ILAst
block.Body = newBody;
}
// Ignore arguments of 'leave'
foreach (ILExpression expr in method.GetSelfAndChildrenRecursive<ILExpression>(e => e.Code == ILCode.Leave)) {
if (expr.Arguments.Any(arg => !arg.Match(ILCode.Ldloc)))
throw new Exception("Leave should have just ldloc at this stage");
expr.Arguments.Clear();
}
// 'dup' removal
foreach (ILExpression expr in method.GetSelfAndChildrenRecursive<ILExpression>()) {
for (int i = 0; i < expr.Arguments.Count; i++) {

Loading…
Cancel
Save