mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-02 20:04:37 +00:00
Better continue in for / goto detection.
This commit is contained in:
@@ -1152,6 +1152,7 @@ public class Graph {
|
||||
}
|
||||
|
||||
if (stopPart.contains(part)) {
|
||||
//System.err.println("/stopped part " + part);
|
||||
return;
|
||||
}
|
||||
for (Loop el : loops) {
|
||||
@@ -1174,9 +1175,11 @@ public class Graph {
|
||||
|
||||
if (visited.contains(part)) {
|
||||
part.level = 0;
|
||||
//System.err.println("set level " + part + " to zero");
|
||||
} else {
|
||||
visited.add(part);
|
||||
part.level = level;
|
||||
//System.err.println("set level " + part + " to " + level);
|
||||
}
|
||||
|
||||
boolean isLoop = false;
|
||||
@@ -1194,9 +1197,18 @@ public class Graph {
|
||||
if (nextParts == null) {
|
||||
nextParts = part.nextParts;
|
||||
}
|
||||
nextParts = new ArrayList<>(nextParts);
|
||||
|
||||
if (nextParts.size() == 2 && stopPart.contains(nextParts.get(1))) {
|
||||
nextParts.remove(1);
|
||||
}
|
||||
if (nextParts.size() >= 1 && stopPart.contains(nextParts.get(0))) {
|
||||
nextParts.remove(0);
|
||||
}
|
||||
|
||||
if (nextParts.size() == 2) {
|
||||
GraphPart next = getCommonPart(localData, nextParts, loops);//part.getNextPartPath(new ArrayList<GraphPart>());
|
||||
//System.err.println("- common part of " + nextParts.get(0) + " and " + nextParts.get(1) + " is " + next);
|
||||
List<GraphPart> stopParts2 = new ArrayList<>(); //stopPart);
|
||||
if (next != null) {
|
||||
stopParts2.add(next);
|
||||
@@ -1204,12 +1216,20 @@ public class Graph {
|
||||
stopParts2.add(stopPart.get(stopPart.size() - 1));
|
||||
}
|
||||
if (next != nextParts.get(0)) {
|
||||
// System.err.println("- going to branch 0 nextpart from " + part + " to " + nextParts.get(0));
|
||||
markLevels(path, localData, nextParts.get(0), allParts, loops, next == null ? stopPart : stopParts2, level + 1, visited, recursionLevel + 1);
|
||||
} else {
|
||||
//System.err.println("- branch 0 of " + part + " is skipped (=next)");
|
||||
}
|
||||
|
||||
if (next != nextParts.get(1)) {
|
||||
//System.err.println("- going to branch 1 nextpart from " + part + " to " + nextParts.get(1));
|
||||
markLevels(path, localData, nextParts.get(1), allParts, loops, next == null ? stopPart : stopParts2, level + 1, visited, recursionLevel + 1);
|
||||
} else {
|
||||
//System.err.println("- branch 1 of " + part + " is skipped (=next)");
|
||||
}
|
||||
if (next != null) {
|
||||
//System.err.println("- going to next from " + part + " to " + next);
|
||||
markLevels(path, localData, next, allParts, loops, stopPart, level, visited, recursionLevel + 1);
|
||||
}
|
||||
}
|
||||
@@ -1246,6 +1266,7 @@ public class Graph {
|
||||
}
|
||||
|
||||
if (nextParts.size() == 1) {
|
||||
//System.err.println("going to one nexpart from " + part + " to " + nextParts.get(0));
|
||||
markLevels(path, localData, nextParts.get(0), allParts, loops, stopPart, level, visited, recursionLevel + 1);
|
||||
}
|
||||
|
||||
@@ -1269,6 +1290,7 @@ public class Graph {
|
||||
if (isLoop) {
|
||||
if (currentLoop != null && currentLoop.loopBreak != null) {
|
||||
currentLoop.phase = 2;
|
||||
//System.err.println("- going to break of loop " + currentLoop.loopBreak);
|
||||
markLevels(path, localData, currentLoop.loopBreak, allParts, loops, stopPart, level, visited, recursionLevel + 1);
|
||||
}
|
||||
}
|
||||
@@ -2190,13 +2212,6 @@ public class Graph {
|
||||
|
||||
if (!bodyBranch.isEmpty()) {
|
||||
ret.add(index, loopItem);
|
||||
/*
|
||||
loopItem.commands.remove(loopItem.commands.size() - 1);
|
||||
exprList.addAll(loopItem.commands);
|
||||
commands.addAll(bodyBranch);
|
||||
exprList.add(expr);
|
||||
checkContinueAtTheEnd(commands, currentLoop);
|
||||
ret.add(index, li = new WhileItem(null, currentLoop, exprList, commands));*/
|
||||
} else {
|
||||
loopItem.commands.remove(loopItem.commands.size() - 1);
|
||||
commands.addAll(loopItem.commands);
|
||||
|
||||
Reference in New Issue
Block a user