|
|
@ -112,7 +112,6 @@ namespace ICSharpCode.Decompiler.CSharp |
|
|
|
|
|
|
|
SwitchStatement TranslateSwitch(BlockContainer switchContainer, SwitchInstruction inst) |
|
|
|
{ |
|
|
|
Debug.Assert(switchContainer.EntryPoint.IncomingEdgeCount == 1); |
|
|
|
var oldBreakTarget = breakTarget; |
|
|
|
breakTarget = switchContainer; // 'break' within a switch would only leave the switch
|
|
|
|
var oldCaseLabelMapping = caseLabelMapping; |
|
|
@ -159,7 +158,7 @@ namespace ICSharpCode.Decompiler.CSharp |
|
|
|
switch (section.Body) { |
|
|
|
case Branch br: |
|
|
|
// we can only inline the block, if all branches are in the switchContainer.
|
|
|
|
if (br.TargetBlock.Parent == switchContainer && switchContainer.Descendants.OfType<Branch>().Where(b => b.TargetBlock == br.TargetBlock).All(b => BlockContainer.FindClosestSwitchContainer(b) == switchContainer)) |
|
|
|
if (br.TargetContainer == switchContainer && switchContainer.Descendants.OfType<Branch>().Where(b => b.TargetBlock == br.TargetBlock).All(b => BlockContainer.FindClosestSwitchContainer(b) == switchContainer)) |
|
|
|
caseLabelMapping.Add(br.TargetBlock, firstValueResolveResult); |
|
|
|
break; |
|
|
|
default: |
|
|
@ -173,7 +172,7 @@ namespace ICSharpCode.Decompiler.CSharp |
|
|
|
switch (section.Body) { |
|
|
|
case Branch br: |
|
|
|
// we can only inline the block, if all branches are in the switchContainer.
|
|
|
|
if (br.TargetBlock.Parent == switchContainer && switchContainer.Descendants.OfType<Branch>().Where(b => b.TargetBlock == br.TargetBlock).All(b => BlockContainer.FindClosestSwitchContainer(b) == switchContainer)) |
|
|
|
if (br.TargetContainer == switchContainer && switchContainer.Descendants.OfType<Branch>().Where(b => b.TargetBlock == br.TargetBlock).All(b => BlockContainer.FindClosestSwitchContainer(b) == switchContainer)) |
|
|
|
ConvertSwitchSectionBody(astSection, br.TargetBlock); |
|
|
|
else |
|
|
|
ConvertSwitchSectionBody(astSection, section.Body); |
|
|
|