|
|
@ -64,6 +64,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
if (!ifInstruction.FalseInst.MatchNop()) |
|
|
|
if (!ifInstruction.FalseInst.MatchNop()) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
if (UsesVariableCapturedInLoop(loop, ifInstruction.Condition)) |
|
|
|
|
|
|
|
return false; |
|
|
|
condition = ifInstruction; |
|
|
|
condition = ifInstruction; |
|
|
|
var trueInst = ifInstruction.TrueInst; |
|
|
|
var trueInst = ifInstruction.TrueInst; |
|
|
|
if (!loop.EntryPoint.Instructions[1].MatchLeave(loop)) |
|
|
|
if (!loop.EntryPoint.Instructions[1].MatchLeave(loop)) |
|
|
@ -188,6 +190,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
while (i >= 0 && block.Instructions[i] is IfInstruction ifInst) { |
|
|
|
while (i >= 0 && block.Instructions[i] is IfInstruction ifInst) { |
|
|
|
if (!ifInst.FalseInst.MatchNop()) |
|
|
|
if (!ifInst.FalseInst.MatchNop()) |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
if (UsesVariableCapturedInLoop(loop, ifInst.Condition)) |
|
|
|
|
|
|
|
break; |
|
|
|
if (swap) { |
|
|
|
if (swap) { |
|
|
|
if (!ifInst.TrueInst.MatchLeave(loop)) |
|
|
|
if (!ifInst.TrueInst.MatchLeave(loop)) |
|
|
|
break; |
|
|
|
break; |
|
|
@ -203,6 +207,15 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
return list; |
|
|
|
return list; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool UsesVariableCapturedInLoop(BlockContainer loop, ILInstruction condition) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
foreach (var inst in condition.Descendants.OfType<IInstructionWithVariableOperand>()) { |
|
|
|
|
|
|
|
if (inst.Variable.CaptureScope == loop) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static bool MatchDoWhileConditionBlock(BlockContainer loop, Block block, out bool swapBranches) |
|
|
|
static bool MatchDoWhileConditionBlock(BlockContainer loop, Block block, out bool swapBranches) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// match the end of the block:
|
|
|
|
// match the end of the block:
|
|
|
|