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

12
ICSharpCode.Decompiler/IL/ILReader.cs

@ -1085,6 +1085,11 @@ namespace ICSharpCode.Decompiler.IL @@ -1085,6 +1085,11 @@ namespace ICSharpCode.Decompiler.IL
ILInstruction Pop(StackType expectedType)
{
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 (inst is InvalidExpression) {
((InvalidExpression)inst).ExpectedResultType = expectedType;
@ -1134,6 +1139,13 @@ namespace ICSharpCode.Decompiler.IL @@ -1134,6 +1139,13 @@ namespace ICSharpCode.Decompiler.IL
}
}
return inst;
void Warn(string message)
{
if (warnings != null) {
warnings.Add(string.Format("IL_{0:x4}: {1}", ilOffset, message));
}
}
}
ILInstruction PopPointer()

Loading…
Cancel
Save