Browse Source

Add ExpectedResultType to BlockContainer (default is StackType.Void)

pull/863/head
Siegfried Pammer 8 years ago
parent
commit
53322a6ba7
  1. 2
      ICSharpCode.Decompiler/IL/Instructions.cs
  2. 2
      ICSharpCode.Decompiler/IL/Instructions.tt
  3. 5
      ICSharpCode.Decompiler/IL/Instructions/BlockContainer.cs

2
ICSharpCode.Decompiler/IL/Instructions.cs

@ -631,7 +631,7 @@ namespace ICSharpCode.Decompiler.IL @@ -631,7 +631,7 @@ namespace ICSharpCode.Decompiler.IL
/// <summary>A container of IL blocks.</summary>
public sealed partial class BlockContainer : ILInstruction
{
public override StackType ResultType { get { return StackType.Void; } }
public override StackType ResultType { get { return this.ExpectedResultType; } }
public override void AcceptVisitor(ILVisitor visitor)
{
visitor.VisitBlockContainer(this);

2
ICSharpCode.Decompiler/IL/Instructions.tt

@ -49,7 +49,7 @@ @@ -49,7 +49,7 @@
}), CustomConstructor, CustomWriteTo, CustomComputeFlags, CustomVariableName("function"), ResultType("O")
),
new OpCode("BlockContainer", "A container of IL blocks.",
VoidResult, CustomConstructor, CustomVariableName("container"),
ResultType("this.ExpectedResultType"), CustomConstructor, CustomVariableName("container"),
MatchCondition("Patterns.ListMatch.DoMatch(this.Blocks, o.Blocks, ref match)")),
new OpCode("Block", "A block of IL instructions.",
CustomConstructor, CustomVariableName("block"),

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

@ -38,6 +38,8 @@ namespace ICSharpCode.Decompiler.IL @@ -38,6 +38,8 @@ namespace ICSharpCode.Decompiler.IL
{
public static readonly SlotInfo BlockSlot = new SlotInfo("Block", isCollection: true);
public readonly InstructionCollection<Block> Blocks;
public StackType ExpectedResultType { get; }
/// <summary>
/// Gets the number of 'leave' instructions that target this BlockContainer.
@ -60,9 +62,10 @@ namespace ICSharpCode.Decompiler.IL @@ -60,9 +62,10 @@ namespace ICSharpCode.Decompiler.IL
}
}
public BlockContainer() : base(OpCode.BlockContainer)
public BlockContainer(StackType expectedResultType = StackType.Void) : base(OpCode.BlockContainer)
{
this.Blocks = new InstructionCollection<Block>(this, 0);
this.ExpectedResultType = expectedResultType;
}
public override ILInstruction Clone()

Loading…
Cancel
Save