Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix for loops that have an exit at both the header and the latch

  • Loading branch information...
commit 82eb7644b90b828c55e56a16f7506e74a80fe732 1 parent 0cf4301
@flaub authored
Showing with 15 additions and 4 deletions.
  1. +15 −4 src/DotWeb.Decompiler/Core/Loop.cs
View
19 src/DotWeb.Decompiler/Core/Loop.cs
@@ -121,15 +121,26 @@ public class Loop
foreach (var succ in node.Successors) {
if (!Nodes.Contains(succ)) {
if (Tails.Contains(node)) {
- LoopType = LoopType.Repeat;
- Follow = succ;
+ if (LoopType == LoopType.While) {
+ LoopType = LoopType.Endless;
+ node.Conditional = new Conditional(this.graph, node);
+ }
+ else {
+ LoopType = LoopType.Repeat;
+ }
+ Exits.AddUnique(succ);
}
else if (node == Header) {
- if (LoopType == LoopType.None)
+ if (LoopType == LoopType.Repeat) {
+ LoopType = LoopType.Endless;
+ node.Conditional = new Conditional(this.graph, node);
+ }
+ else {
LoopType = LoopType.While;
+ }
// we can't be certain here if this header has some
// extra statements that would make the loop endless with
- // if(cond) { <then>; break; }
+ // if(cond) { <stmts>; break; }
// so just mark it as an exit and proceed
Exits.AddUnique(succ);
}
Please sign in to comment.
Something went wrong with that request. Please try again.