Browse Source

Add parent pointers to ILAst

pull/728/head
Daniel Grunwald 11 years ago
parent
commit
2f1e229046
  1. 4
      ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj
  2. 1
      ICSharpCode.Decompiler/IL/BlockBuilder.cs
  3. 153
      ICSharpCode.Decompiler/IL/Instructions.cs
  4. 19
      ICSharpCode.Decompiler/IL/Instructions.tt
  5. 11
      ICSharpCode.Decompiler/IL/Instructions/Block.cs
  6. 13
      ICSharpCode.Decompiler/IL/Instructions/BlockContainer.cs
  7. 8
      ICSharpCode.Decompiler/IL/Instructions/CallInstruction.cs
  8. 109
      ICSharpCode.Decompiler/IL/Instructions/ILInstruction.cs
  9. 11
      ICSharpCode.Decompiler/IL/Instructions/Return.cs
  10. 8
      ICSharpCode.Decompiler/IL/Instructions/SimpleInstruction.cs
  11. 13
      ICSharpCode.Decompiler/IL/Instructions/TryCatch.cs
  12. 40
      ICSharpCode.Decompiler/IL/Visitors/CountPopInstructionsVisitor.cs

4
ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj

@ -87,7 +87,6 @@ @@ -87,7 +87,6 @@
<Compile Include="IL\Instructions\TryCatch.cs" />
<Compile Include="IL\Instructions\TryFinally.cs" />
<Compile Include="IL\Instructions\UnaryInstruction.cs" />
<Compile Include="IL\Visitors\CountPopInstructionsVisitor.cs" />
<Compile Include="TypesHierarchyHelpers.cs" />
<Compile Include="CecilExtensions.cs" />
<Compile Include="Disassembler\DisassemblerHelpers.cs" />
@ -148,9 +147,6 @@ @@ -148,9 +147,6 @@
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup>
<Folder Include="IL\Visitors" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<Target Name="BeforeBuild">
<MSBuild Projects="$(MSBuildProjectDirectory)\..\BuildTools\UpdateAssemblyInfo\UpdateAssemblyInfo.csproj" Targets="Build" Properties="Configuration=Debug" />

1
ICSharpCode.Decompiler/IL/BlockBuilder.cs

@ -43,6 +43,7 @@ namespace ICSharpCode.Decompiler.IL @@ -43,6 +43,7 @@ namespace ICSharpCode.Decompiler.IL
public BlockContainer CreateBlocks(List<ILInstruction> instructions, BitArray incomingBranches)
{
currentContainer = new BlockContainer();
currentContainer.AddRef(); // mark the root node
incomingBranches[0] = true; // see entrypoint as incoming branch

153
ICSharpCode.Decompiler/IL/Instructions.cs

@ -184,11 +184,10 @@ namespace ICSharpCode.Decompiler.IL @@ -184,11 +184,10 @@ namespace ICSharpCode.Decompiler.IL
SetChildInstruction(ref this.argument, value);
}
}
public override TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func)
{
TAccumulate value = initial;
value = func(value, this.argument.AcceptVisitor(visitor));
return value;
public override IEnumerable<ILInstruction> Children {
get {
yield return this.argument;
}
}
public override void TransformChildren(ILVisitor<ILInstruction> visitor)
{
@ -236,12 +235,11 @@ namespace ICSharpCode.Decompiler.IL @@ -236,12 +235,11 @@ namespace ICSharpCode.Decompiler.IL
SetChildInstruction(ref this.right, value);
}
}
public override TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func)
{
TAccumulate value = initial;
value = func(value, this.left.AcceptVisitor(visitor));
value = func(value, this.right.AcceptVisitor(visitor));
return value;
public override IEnumerable<ILInstruction> Children {
get {
yield return this.left;
yield return this.right;
}
}
public override void TransformChildren(ILVisitor<ILInstruction> visitor)
{
@ -559,13 +557,12 @@ namespace ICSharpCode.Decompiler.IL @@ -559,13 +557,12 @@ namespace ICSharpCode.Decompiler.IL
SetChildInstruction(ref this.falseInst, value);
}
}
public override TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func)
{
TAccumulate value = initial;
value = func(value, this.condition.AcceptVisitor(visitor));
value = func(value, this.trueInst.AcceptVisitor(visitor));
value = func(value, this.falseInst.AcceptVisitor(visitor));
return value;
public override IEnumerable<ILInstruction> Children {
get {
yield return this.condition;
yield return this.trueInst;
yield return this.falseInst;
}
}
public override void TransformChildren(ILVisitor<ILInstruction> visitor)
{
@ -614,12 +611,11 @@ namespace ICSharpCode.Decompiler.IL @@ -614,12 +611,11 @@ namespace ICSharpCode.Decompiler.IL
SetChildInstruction(ref this.body, value);
}
}
public override TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func)
{
TAccumulate value = initial;
value = func(value, this.filter.AcceptVisitor(visitor));
value = func(value, this.body.AcceptVisitor(visitor));
return value;
public override IEnumerable<ILInstruction> Children {
get {
yield return this.filter;
yield return this.body;
}
}
public override void TransformChildren(ILVisitor<ILInstruction> visitor)
{
@ -664,12 +660,11 @@ namespace ICSharpCode.Decompiler.IL @@ -664,12 +660,11 @@ namespace ICSharpCode.Decompiler.IL
SetChildInstruction(ref this.finallyBlock, value);
}
}
public override TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func)
{
TAccumulate value = initial;
value = func(value, this.tryBlock.AcceptVisitor(visitor));
value = func(value, this.finallyBlock.AcceptVisitor(visitor));
return value;
public override IEnumerable<ILInstruction> Children {
get {
yield return this.tryBlock;
yield return this.finallyBlock;
}
}
public override void TransformChildren(ILVisitor<ILInstruction> visitor)
{
@ -706,12 +701,11 @@ namespace ICSharpCode.Decompiler.IL @@ -706,12 +701,11 @@ namespace ICSharpCode.Decompiler.IL
SetChildInstruction(ref this.faultBlock, value);
}
}
public override TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func)
{
TAccumulate value = initial;
value = func(value, this.tryBlock.AcceptVisitor(visitor));
value = func(value, this.faultBlock.AcceptVisitor(visitor));
return value;
public override IEnumerable<ILInstruction> Children {
get {
yield return this.tryBlock;
yield return this.faultBlock;
}
}
public override void TransformChildren(ILVisitor<ILInstruction> visitor)
{
@ -921,11 +915,10 @@ namespace ICSharpCode.Decompiler.IL @@ -921,11 +915,10 @@ namespace ICSharpCode.Decompiler.IL
SetChildInstruction(ref this.value, value);
}
}
public override TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func)
{
TAccumulate value = initial;
value = func(value, this.value.AcceptVisitor(visitor));
return value;
public override IEnumerable<ILInstruction> Children {
get {
yield return this.value;
}
}
public override void TransformChildren(ILVisitor<ILInstruction> visitor)
{
@ -1205,11 +1198,10 @@ namespace ICSharpCode.Decompiler.IL @@ -1205,11 +1198,10 @@ namespace ICSharpCode.Decompiler.IL
SetChildInstruction(ref this.target, value);
}
}
public override TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func)
{
TAccumulate value = initial;
value = func(value, this.target.AcceptVisitor(visitor));
return value;
public override IEnumerable<ILInstruction> Children {
get {
yield return this.target;
}
}
public override void TransformChildren(ILVisitor<ILInstruction> visitor)
{
@ -1267,11 +1259,10 @@ namespace ICSharpCode.Decompiler.IL @@ -1267,11 +1259,10 @@ namespace ICSharpCode.Decompiler.IL
SetChildInstruction(ref this.target, value);
}
}
public override TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func)
{
TAccumulate value = initial;
value = func(value, this.target.AcceptVisitor(visitor));
return value;
public override IEnumerable<ILInstruction> Children {
get {
yield return this.target;
}
}
public override void TransformChildren(ILVisitor<ILInstruction> visitor)
{
@ -1330,12 +1321,11 @@ namespace ICSharpCode.Decompiler.IL @@ -1330,12 +1321,11 @@ namespace ICSharpCode.Decompiler.IL
SetChildInstruction(ref this.value, value);
}
}
public override TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func)
{
TAccumulate value = initial;
value = func(value, this.target.AcceptVisitor(visitor));
value = func(value, this.value.AcceptVisitor(visitor));
return value;
public override IEnumerable<ILInstruction> Children {
get {
yield return this.target;
yield return this.value;
}
}
public override void TransformChildren(ILVisitor<ILInstruction> visitor)
{
@ -1456,11 +1446,10 @@ namespace ICSharpCode.Decompiler.IL @@ -1456,11 +1446,10 @@ namespace ICSharpCode.Decompiler.IL
SetChildInstruction(ref this.value, value);
}
}
public override TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func)
{
TAccumulate value = initial;
value = func(value, this.value.AcceptVisitor(visitor));
return value;
public override IEnumerable<ILInstruction> Children {
get {
yield return this.value;
}
}
public override void TransformChildren(ILVisitor<ILInstruction> visitor)
{
@ -1574,11 +1563,10 @@ namespace ICSharpCode.Decompiler.IL @@ -1574,11 +1563,10 @@ namespace ICSharpCode.Decompiler.IL
SetChildInstruction(ref this.target, value);
}
}
public override TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func)
{
TAccumulate value = initial;
value = func(value, this.target.AcceptVisitor(visitor));
return value;
public override IEnumerable<ILInstruction> Children {
get {
yield return this.target;
}
}
public override void TransformChildren(ILVisitor<ILInstruction> visitor)
{
@ -1645,12 +1633,11 @@ namespace ICSharpCode.Decompiler.IL @@ -1645,12 +1633,11 @@ namespace ICSharpCode.Decompiler.IL
SetChildInstruction(ref this.value, value);
}
}
public override TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func)
{
TAccumulate value = initial;
value = func(value, this.target.AcceptVisitor(visitor));
value = func(value, this.value.AcceptVisitor(visitor));
return value;
public override IEnumerable<ILInstruction> Children {
get {
yield return this.target;
yield return this.value;
}
}
public override void TransformChildren(ILVisitor<ILInstruction> visitor)
{
@ -1921,11 +1908,10 @@ namespace ICSharpCode.Decompiler.IL @@ -1921,11 +1908,10 @@ namespace ICSharpCode.Decompiler.IL
SetChildInstruction(ref this.target, value);
}
}
public override TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func)
{
TAccumulate value = initial;
value = func(value, this.target.AcceptVisitor(visitor));
return value;
public override IEnumerable<ILInstruction> Children {
get {
yield return this.target;
}
}
public override void TransformChildren(ILVisitor<ILInstruction> visitor)
{
@ -1979,12 +1965,11 @@ namespace ICSharpCode.Decompiler.IL @@ -1979,12 +1965,11 @@ namespace ICSharpCode.Decompiler.IL
SetChildInstruction(ref this.index, value);
}
}
public override TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func)
{
TAccumulate value = initial;
value = func(value, this.array.AcceptVisitor(visitor));
value = func(value, this.index.AcceptVisitor(visitor));
return value;
public override IEnumerable<ILInstruction> Children {
get {
yield return this.array;
yield return this.index;
}
}
public override void TransformChildren(ILVisitor<ILInstruction> visitor)
{

19
ICSharpCode.Decompiler/IL/Instructions.tt

@ -540,7 +540,9 @@ namespace ICSharpCode.Decompiler.IL @@ -540,7 +540,9 @@ namespace ICSharpCode.Decompiler.IL
+ "}");
}
opCode.WriteArguments.Add("output.Write(')');");
StringBuilder b = new StringBuilder();
StringBuilder b;
/*
b = new StringBuilder();
b.AppendLine("public override TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func)");
b.AppendLine("{");
b.AppendLine("\tTAccumulate value = initial;");
@ -553,7 +555,22 @@ namespace ICSharpCode.Decompiler.IL @@ -553,7 +555,22 @@ namespace ICSharpCode.Decompiler.IL
}
b.AppendLine("\treturn value;");
b.Append("}");
opCode.Members.Add(b.ToString());*/
b = new StringBuilder();
b.AppendLine("public override IEnumerable<ILInstruction> Children {");
b.AppendLine("\tget {");
foreach (var child in children) {
if (child.IsOptional) {
b.AppendLine("\t\tif (this." + child.Name + " != null)");
b.Append('\t');
}
b.AppendLine("\t\tyield return this." + child.Name + ";");
}
b.AppendLine("\t}");
b.Append("}");
opCode.Members.Add(b.ToString());
b = new StringBuilder();
b.AppendLine("public override void TransformChildren(ILVisitor<ILInstruction> visitor)");
b.AppendLine("{");

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

@ -42,14 +42,9 @@ namespace ICSharpCode.Decompiler.IL @@ -42,14 +42,9 @@ namespace ICSharpCode.Decompiler.IL
output.Unindent();
output.WriteLine("}");
}
public override TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func)
{
TAccumulate value = initial;
foreach (var inst in Instructions) {
value = func(value, inst.AcceptVisitor(visitor));
}
return value;
public override IEnumerable<ILInstruction> Children {
get { return Instructions; }
}
public override void TransformChildren(ILVisitor<ILInstruction> visitor)

13
ICSharpCode.Decompiler/IL/Instructions/BlockContainer.cs

@ -52,16 +52,11 @@ namespace ICSharpCode.Decompiler.IL @@ -52,16 +52,11 @@ namespace ICSharpCode.Decompiler.IL
output.Unindent();
output.WriteLine("}");
}
public override TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func)
{
TAccumulate value = initial;
foreach (var block in Blocks) {
value = func(value, block.AcceptVisitor(visitor));
}
return value;
public override IEnumerable<ILInstruction> Children {
get { return Blocks; }
}
public override void TransformChildren(ILVisitor<ILInstruction> visitor)
{
foreach (var block in Blocks) {

8
ICSharpCode.Decompiler/IL/Instructions/CallInstruction.cs

@ -69,12 +69,8 @@ namespace ICSharpCode.Decompiler.IL @@ -69,12 +69,8 @@ namespace ICSharpCode.Decompiler.IL
}
}
public override TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func)
{
TAccumulate value = initial;
foreach (var op in Arguments)
value = func(value, op.AcceptVisitor(visitor));
return value;
public override IEnumerable<ILInstruction> Children {
get { return Arguments; }
}
public override void TransformChildren(ILVisitor<ILInstruction> visitor)

109
ICSharpCode.Decompiler/IL/Instructions/ILInstruction.cs

@ -70,11 +70,13 @@ namespace ICSharpCode.Decompiler.IL @@ -70,11 +70,13 @@ namespace ICSharpCode.Decompiler.IL
return a;
}
InstructionFlags flags = (InstructionFlags)(-1);
const InstructionFlags invalidFlags = (InstructionFlags)(-1);
InstructionFlags flags = invalidFlags;
public InstructionFlags Flags {
get {
if (flags == (InstructionFlags)(-1)) {
if (flags == invalidFlags) {
flags = ComputeFlags();
}
return flags;
@ -89,20 +91,10 @@ namespace ICSharpCode.Decompiler.IL @@ -89,20 +91,10 @@ namespace ICSharpCode.Decompiler.IL
return (this.Flags & flags) != 0;
}
protected void SetChildInstruction(ref ILInstruction childPointer, ILInstruction newValue)
{
childPointer = newValue;
flags = (InstructionFlags)(-1);
}
protected internal void AddChildInstruction(ILInstruction newChild)
protected void InvalidateFlags()
{
flags = (InstructionFlags)(-1);
}
protected internal void RemoveChildInstruction(ILInstruction newChild)
{
flags = (InstructionFlags)(-1);
for (ILInstruction inst = this; inst != null && inst.flags != invalidFlags; inst = inst.parent)
inst.flags = invalidFlags;
}
protected abstract InstructionFlags ComputeFlags();
@ -130,13 +122,9 @@ namespace ICSharpCode.Decompiler.IL @@ -130,13 +122,9 @@ namespace ICSharpCode.Decompiler.IL
public abstract T AcceptVisitor<T>(ILVisitor<T> visitor);
/// <summary>
/// Computes an aggregate value over the direct children of this instruction.
/// Gets the child nodes of this instruction.
/// </summary>
/// <param name="initial">The initial value used to initialize the accumulator.</param>
/// <param name="visitor">The visitor used to compute the value for the child instructions.</param>
/// <param name="func">The function that combines the accumulator with the computed child value.</param>
/// <returns>The final value in the accumulator.</returns>
public abstract TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func);
public abstract IEnumerable<ILInstruction> Children { get; }
/// <summary>
/// Transforms the children of this instruction by applying the specified visitor.
@ -151,5 +139,84 @@ namespace ICSharpCode.Decompiler.IL @@ -151,5 +139,84 @@ namespace ICSharpCode.Decompiler.IL
/// <param name="instructionStack">The instruction stack.</param>
/// <param name="finished">Receives 'true' if all open 'pop' or 'peek' placeholders were inlined into; false otherwise.</param>
internal abstract ILInstruction Inline(InstructionFlags flagsBefore, Stack<ILInstruction> instructionStack, out bool finished);
/// <summary>
/// Number of parents that refer to this instruction and are connected to the root.
/// Usually is 0 for unconnected nodes and 1 for connected nodes, but may temporarily increase to 2
/// when the ILAst is re-arranged (e.g. within SetChildInstruction).
/// </summary>
byte refCount;
internal void AddRef()
{
if (refCount++ == 0) {
Connected();
}
}
internal void ReleaseRef()
{
Debug.Assert(refCount > 0);
if (--refCount == 0) {
Disconnected();
}
}
protected bool IsConnected {
get { return refCount > 0; }
}
protected virtual void Connected()
{
foreach (var child in Children)
child.AddRef();
}
protected virtual void Disconnected()
{
foreach (var child in Children)
child.ReleaseRef();
}
ILInstruction parent;
/// <summary>
/// Gets the parent of this ILInstruction.
/// </summary>
public ILInstruction Parent {
get { return parent; }
}
protected void SetChildInstruction(ref ILInstruction childPointer, ILInstruction newValue)
{
if (childPointer == newValue)
return;
if (refCount > 0) {
// The new value may be a subtree of the old value.
// We first call AddRef(), then ReleaseRef() to prevent the subtree
// that stays connected from receiving a Disconnected() notification followed by a Connected() notification.
newValue.AddRef();
childPointer.ReleaseRef();
}
childPointer = newValue;
newValue.parent = this;
InvalidateFlags();
}
protected internal void AddChildInstruction(ILInstruction newChild)
{
if (refCount > 0)
newChild.AddRef();
newChild.parent = this;
InvalidateFlags();
}
protected internal void RemoveChildInstruction(ILInstruction newChild)
{
if (refCount > 0)
newChild.ReleaseRef();
InvalidateFlags();
}
}
}

11
ICSharpCode.Decompiler/IL/Instructions/Return.cs

@ -57,12 +57,11 @@ namespace ICSharpCode.Decompiler.IL @@ -57,12 +57,11 @@ namespace ICSharpCode.Decompiler.IL
}
}
public override TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func)
{
TAccumulate value = initial;
if (returnValue != null)
value = func(value, returnValue.AcceptVisitor(visitor));
return value;
public override IEnumerable<ILInstruction> Children {
get {
if (returnValue != null)
yield return returnValue;
}
}
public override void TransformChildren(ILVisitor<ILInstruction> visitor)

8
ICSharpCode.Decompiler/IL/Instructions/SimpleInstruction.cs

@ -21,6 +21,7 @@ using System.Collections.Generic; @@ -21,6 +21,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ICSharpCode.NRefactory;
namespace ICSharpCode.Decompiler.IL
{
@ -38,9 +39,10 @@ namespace ICSharpCode.Decompiler.IL @@ -38,9 +39,10 @@ namespace ICSharpCode.Decompiler.IL
output.Write(OpCode);
}
public sealed override TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func)
{
return initial;
public sealed override IEnumerable<ILInstruction> Children {
get {
return EmptyList<ILInstruction>.Instance;
}
}
public sealed override void TransformChildren(ILVisitor<ILInstruction> visitor)

13
ICSharpCode.Decompiler/IL/Instructions/TryCatch.cs

@ -68,13 +68,12 @@ namespace ICSharpCode.Decompiler.IL @@ -68,13 +68,12 @@ namespace ICSharpCode.Decompiler.IL
return this;
}
public override TAccumulate AggregateChildren<TSource, TAccumulate>(TAccumulate initial, ILVisitor<TSource> visitor, Func<TAccumulate, TSource, TAccumulate> func)
{
TAccumulate value = initial;
value = func(value, tryBlock.AcceptVisitor(visitor));
foreach (var handler in CatchHandlers)
value = func(value, handler.AcceptVisitor(visitor));
return value;
public override IEnumerable<ILInstruction> Children {
get {
yield return tryBlock;
foreach (var handler in CatchHandlers)
yield return handler;
}
}
public override void TransformChildren(ILVisitor<ILInstruction> visitor)

40
ICSharpCode.Decompiler/IL/Visitors/CountPopInstructionsVisitor.cs

@ -1,40 +0,0 @@ @@ -1,40 +0,0 @@
// Copyright (c) 2014 Daniel Grunwald
//
// 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
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
namespace ICSharpCode.Decompiler.IL.Visitors
{
sealed class CountPopInstructionsVisitor : ILVisitor<int>
{
protected override int Default(ILInstruction inst)
{
return inst.AggregateChildren(0, this, (a, b) => a + b);
}
protected internal override int VisitPop(Pop inst)
{
return 1;
}
protected internal override int VisitBlock(Block inst)
{
throw new NotImplementedException();
}
}
}
Loading…
Cancel
Save