Browse Source

Respect context.Settings.AnonymousMethods in CachedDelegateInitialization.

pull/728/merge
Daniel Grunwald 9 years ago
parent
commit
85bab79e19
  1. 7
      ICSharpCode.Decompiler/IL/Transforms/CachedDelegateInitialization.cs

7
ICSharpCode.Decompiler/IL/Transforms/CachedDelegateInitialization.cs

@ -27,8 +27,13 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -27,8 +27,13 @@ namespace ICSharpCode.Decompiler.IL.Transforms
{
public class CachedDelegateInitialization : IBlockTransform
{
BlockTransformContext context;
public void Run(Block block, BlockTransformContext context)
{
this.context = context;
if (!context.Settings.AnonymousMethods)
return;
for (int i = block.Instructions.Count - 1; i >= 0; i--) {
if (block.Instructions[i] is IfInstruction inst) {
if (CachedDelegateInitializationWithField(inst)) {
@ -79,6 +84,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -79,6 +84,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
var usages = nextInstruction.Descendants.Where(i => i.MatchLdsFld(field)).ToArray();
if (usages.Length != 1)
return false;
context.Step("CachedDelegateInitializationWithField", inst);
usages[0].ReplaceWith(value);
return true;
}
@ -135,6 +141,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -135,6 +141,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
var usages = nextInstruction.Descendants.OfType<LdLoc>().Where(i => i.Variable == v).ToArray();
if (usages.Length != 1)
return false;
context.Step("CachedDelegateInitializationWithLocal", inst);
local = v;
usages[0].ReplaceWith(value);
return true;

Loading…
Cancel
Save