|
|
|
@ -82,7 +82,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -82,7 +82,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
ConditionDetection.InvertIf(loopBody, ifInstruction, context); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
context.Step("Transform to while (condition) loop", loop); |
|
|
|
|
context.Step("Transform to while (condition) loop: " + loop.EntryPoint.Label, loop); |
|
|
|
|
loop.Kind = ContainerKind.While; |
|
|
|
|
//invert comparison
|
|
|
|
|
ifInstruction.Condition = Comp.LogicNot(ifInstruction.Condition); |
|
|
|
@ -150,7 +150,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -150,7 +150,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
// not a do-while loop, exit.
|
|
|
|
|
if (conditions == null || conditions.Count == 0) |
|
|
|
|
return false; |
|
|
|
|
context.Step("Transform to do-while loop", loop); |
|
|
|
|
context.Step("Transform to do-while loop: " + loop.EntryPoint.Label, loop); |
|
|
|
|
Block conditionBlock; |
|
|
|
|
// first we remove all extracted instructions from the original block.
|
|
|
|
|
var originalBlock = (Block)exit.Parent; |
|
|
|
@ -358,7 +358,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -358,7 +358,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
// - increment block
|
|
|
|
|
if (incrementBlock.Instructions.Count <= 1 || loop.Blocks.Count < 3) |
|
|
|
|
return false; |
|
|
|
|
context.Step("Transform to for loop", loop); |
|
|
|
|
context.Step("Transform to for loop: " + loop.EntryPoint.Label, loop); |
|
|
|
|
// move the block to the end of the loop:
|
|
|
|
|
loop.Blocks.MoveElementToEnd(incrementBlock); |
|
|
|
|
loop.Kind = ContainerKind.For; |
|
|
|
@ -398,7 +398,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -398,7 +398,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
} |
|
|
|
|
if (numberOfConditions == 0) |
|
|
|
|
return false; |
|
|
|
|
context.Step("Transform to for loop", loop); |
|
|
|
|
context.Step("Transform to for loop: " + loop.EntryPoint.Label, loop); |
|
|
|
|
// split condition block:
|
|
|
|
|
whileCondition.ReplaceWith(forCondition); |
|
|
|
|
ExpressionTransforms.RunOnSingleStatement(forCondition, context); |
|
|
|
|