Browse Source

Fix order of switch blocks.

pull/887/head
Siegfried Pammer 8 years ago
parent
commit
f7f583056a
  1. 6
      ICSharpCode.Decompiler/IL/ControlFlow/SwitchDetection.cs

6
ICSharpCode.Decompiler/IL/ControlFlow/SwitchDetection.cs

@ -81,6 +81,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
innerBlock.Instructions.Clear();
}
blockContainerNeedsCleanup = true;
SortSwitchSections(sw);
} else {
// 2nd pass of SimplifySwitchInstruction (after duplicating return blocks),
// (1st pass was in ControlFlowSimplification)
@ -115,6 +116,11 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
return false;
});
AdjustLabels(sw);
SortSwitchSections(sw);
}
static void SortSwitchSections(SwitchInstruction sw)
{
sw.Sections.ReplaceList(sw.Sections.OrderBy(s => (s.Body as Branch)?.TargetILOffset).ThenBy(s => s.Labels.Values.FirstOrDefault()));
}

Loading…
Cancel
Save