Browse Source

Fix ExpectedResultType of main BlockContainer.

pull/863/head
Daniel Grunwald 8 years ago
parent
commit
6b3ab66300
  1. 1
      ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs
  2. 2
      ICSharpCode.Decompiler/IL/ILReader.cs
  3. 2
      ICSharpCode.Decompiler/IL/Instructions/BlockContainer.cs
  4. 1
      ICSharpCode.Decompiler/IL/Instructions/Leave.cs

1
ICSharpCode.Decompiler/IL/ControlFlow/AsyncAwaitDecompiler.cs

@ -95,6 +95,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -95,6 +95,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
TranslateCachedFieldsToLocals();
FinalizeInlineMoveNext(function);
((BlockContainer)function.Body).ExpectedResultType = underlyingReturnType.GetStackType();
// Re-run control flow simplification over the newly constructed set of gotos,
// and inlining because TranslateFieldsToLocalAccess() might have opened up new inlining opportunities.

2
ICSharpCode.Decompiler/IL/ILReader.cs

@ -83,7 +83,7 @@ namespace ICSharpCode.Decompiler.IL @@ -83,7 +83,7 @@ namespace ICSharpCode.Decompiler.IL
v.HasInitialValue = true;
}
}
mainContainer = new BlockContainer();
mainContainer = new BlockContainer(methodReturnStackType);
this.instructionBuilder = new List<ILInstruction>();
this.isBranchTarget = new BitArray(body.CodeSize);
this.stackByOffset = new Dictionary<int, ImmutableStack<ILVariable>>();

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

@ -39,7 +39,7 @@ namespace ICSharpCode.Decompiler.IL @@ -39,7 +39,7 @@ namespace ICSharpCode.Decompiler.IL
public static readonly SlotInfo BlockSlot = new SlotInfo("Block", isCollection: true);
public readonly InstructionCollection<Block> Blocks;
public StackType ExpectedResultType { get; }
public StackType ExpectedResultType { get; set; }
/// <summary>
/// Gets the number of 'leave' instructions that target this BlockContainer.

1
ICSharpCode.Decompiler/IL/Instructions/Leave.cs

@ -97,6 +97,7 @@ namespace ICSharpCode.Decompiler.IL @@ -97,6 +97,7 @@ namespace ICSharpCode.Decompiler.IL
{
base.CheckInvariant(phase);
Debug.Assert(phase <= ILPhase.InILReader || this.IsDescendantOf(targetContainer));
Debug.Assert(phase <= ILPhase.InILReader || value.ResultType == targetContainer.ResultType);
}
public override void WriteTo(ITextOutput output)

Loading…
Cancel
Save