Browse Source

Fix #1235: Insert StackType conversion when filling in Leave target.

pull/1243/head
Daniel Grunwald 7 years ago
parent
commit
0006330c1a
  1. 1
      ICSharpCode.Decompiler/IL/BlockBuilder.cs
  2. 12
      ICSharpCode.Decompiler/IL/ILReader.cs

1
ICSharpCode.Decompiler/IL/BlockBuilder.cs

@ -205,6 +205,7 @@ namespace ICSharpCode.Decompiler.IL
if (leave.TargetContainer == null) { if (leave.TargetContainer == null) {
// assign the finally/filter container // assign the finally/filter container
leave.TargetContainer = containerStack.Peek(); leave.TargetContainer = containerStack.Peek();
leave.Value = ILReader.Cast(leave.Value, leave.TargetContainer.ExpectedResultType, null, leave.ILRange.Start);
} }
break; break;
case BlockContainer container: case BlockContainer container:

12
ICSharpCode.Decompiler/IL/ILReader.cs

@ -1085,6 +1085,11 @@ namespace ICSharpCode.Decompiler.IL
ILInstruction Pop(StackType expectedType) ILInstruction Pop(StackType expectedType)
{ {
ILInstruction inst = Pop(); ILInstruction inst = Pop();
return Cast(inst, expectedType, Warnings, reader.Offset);
}
internal static ILInstruction Cast(ILInstruction inst, StackType expectedType, List<string> warnings, int ilOffset)
{
if (expectedType != inst.ResultType) { if (expectedType != inst.ResultType) {
if (inst is InvalidExpression) { if (inst is InvalidExpression) {
((InvalidExpression)inst).ExpectedResultType = expectedType; ((InvalidExpression)inst).ExpectedResultType = expectedType;
@ -1134,6 +1139,13 @@ namespace ICSharpCode.Decompiler.IL
} }
} }
return inst; return inst;
void Warn(string message)
{
if (warnings != null) {
warnings.Add(string.Format("IL_{0:x4}: {1}", ilOffset, message));
}
}
} }
ILInstruction PopPointer() ILInstruction PopPointer()

Loading…
Cancel
Save