Browse Source

more step groups

pull/728/merge
Daniel Grunwald 9 years ago
parent
commit
d50695c218
  1. 18
      ICSharpCode.Decompiler/IL/Instructions/Block.cs
  2. 2
      ICSharpCode.Decompiler/IL/Instructions/ILFunction.cs
  3. 7
      ICSharpCode.Decompiler/IL/Transforms/BlockTransform.cs
  4. 14
      ICSharpCode.Decompiler/IL/Transforms/LoopingTransform.cs
  5. 8
      ILSpy/Languages/ILAstLanguage.cs

18
ICSharpCode.Decompiler/IL/Instructions/Block.cs

@ -1,4 +1,4 @@
// Copyright (c) 2014 Daniel Grunwald // Copyright (c) 2014-2016 Daniel Grunwald
// //
// Permission is hereby granted, free of charge, to any person obtaining a copy of this // Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software // software and associated documentation files (the "Software"), to deal in the Software
@ -23,6 +23,7 @@ using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using ICSharpCode.Decompiler.IL.Transforms;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem.Implementation; using ICSharpCode.NRefactory.TypeSystem.Implementation;
@ -211,6 +212,21 @@ namespace ICSharpCode.Decompiler.IL
Debug.Assert(container.Blocks[ChildIndex] == this); Debug.Assert(container.Blocks[ChildIndex] == this);
container.Blocks.SwapRemoveAt(ChildIndex); container.Blocks.SwapRemoveAt(ChildIndex);
} }
/// <summary>
/// Apply a list of transforms to this function.
/// </summary>
public void RunTransforms(IEnumerable<IBlockTransform> transforms, BlockTransformContext context)
{
this.CheckInvariant(ILPhase.Normal);
foreach (var transform in transforms) {
context.CancellationToken.ThrowIfCancellationRequested();
context.Stepper.StartGroup(transform.GetType().Name);
transform.Run(this, context);
this.CheckInvariant(ILPhase.Normal);
context.Stepper.EndGroup();
}
}
} }
public enum BlockType { public enum BlockType {

2
ICSharpCode.Decompiler/IL/Instructions/ILFunction.cs

@ -84,8 +84,8 @@ namespace ICSharpCode.Decompiler.IL
context.CancellationToken.ThrowIfCancellationRequested(); context.CancellationToken.ThrowIfCancellationRequested();
context.Stepper.StartGroup(transform.GetType().Name); context.Stepper.StartGroup(transform.GetType().Name);
transform.Run(this, context); transform.Run(this, context);
context.Stepper.EndGroup(keepIfEmpty: true);
this.CheckInvariant(ILPhase.Normal); this.CheckInvariant(ILPhase.Normal);
context.Stepper.EndGroup(keepIfEmpty: true);
} }
} }

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

@ -106,12 +106,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
context.ControlFlowNode = cfgNode; context.ControlFlowNode = cfgNode;
context.Block = block; context.Block = block;
block.CheckInvariant(ILPhase.Normal); block.RunTransforms(blockTransforms, context);
foreach (var transform in blockTransforms) {
context.CancellationToken.ThrowIfCancellationRequested();
transform.Run(context.Block, context);
block.CheckInvariant(ILPhase.Normal);
}
context.Stepper.EndGroup(); context.Stepper.EndGroup();
} }
} }

14
ICSharpCode.Decompiler/IL/Transforms/LoopingTransform.cs

@ -39,12 +39,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
{ {
do { do {
function.ResetDirty(); function.ResetDirty();
function.CheckInvariant(ILPhase.Normal); function.RunTransforms(children, context);
foreach (var transform in children) {
context.CancellationToken.ThrowIfCancellationRequested();
transform.Run(function, context);
function.CheckInvariant(ILPhase.Normal);
}
} while (function.IsDirty); } while (function.IsDirty);
} }
@ -70,12 +65,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
{ {
do { do {
block.ResetDirty(); block.ResetDirty();
block.CheckInvariant(ILPhase.Normal); block.RunTransforms(children, context);
foreach (var transform in children) {
context.CancellationToken.ThrowIfCancellationRequested();
transform.Run(block, context);
block.CheckInvariant(ILPhase.Normal);
}
} while (block.IsDirty); } while (block.IsDirty);
} }

8
ILSpy/Languages/ILAstLanguage.cs

@ -157,17 +157,17 @@ namespace ICSharpCode.ILSpy
ILFunction il = reader.ReadIL(method.Body, options.CancellationToken); ILFunction il = reader.ReadIL(method.Body, options.CancellationToken);
ILTransformContext context = new ILTransformContext { Settings = options.DecompilerSettings, TypeSystem = typeSystem }; ILTransformContext context = new ILTransformContext { Settings = options.DecompilerSettings, TypeSystem = typeSystem };
context.Stepper.StepLimit = options.StepLimit; context.Stepper.StepLimit = options.StepLimit;
// Because the UI only allows viewing the result of a step, add a dummy initial step.
context.Stepper.Step("Initial");
try { try {
il.RunTransforms(transforms, context); il.RunTransforms(transforms, context);
} catch (StepLimitReachedException) { } catch (StepLimitReachedException) {
il.WriteTo(output); il.WriteTo(output);
return; return;
} }
Stepper = context.Stepper;
il.WriteTo(output); il.WriteTo(output);
OnStepperUpdated(new EventArgs()); if (options.StepLimit == int.MaxValue) {
Stepper = context.Stepper;
OnStepperUpdated(new EventArgs());
}
} }
} }
} }

Loading…
Cancel
Save