From 7ffb18880003711f093bfbd0486e4e46f5c5b6fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Sat, 29 Mar 2014 09:50:50 +0100 Subject: [PATCH] Issue #552 Timeout exception, max recursion level fix => fixGraph removed --- .../src/com/jpexs/decompiler/graph/Graph.java | 177 ------------------ 1 file changed, 177 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/graph/Graph.java b/trunk/src/com/jpexs/decompiler/graph/Graph.java index e8fe1b0d5..e89a1b74b 100644 --- a/trunk/src/com/jpexs/decompiler/graph/Graph.java +++ b/trunk/src/com/jpexs/decompiler/graph/Graph.java @@ -76,8 +76,6 @@ public class Graph { List visited = new ArrayList<>(); for (GraphPart head : heads) { time = head.setTime(time, ordered, visited); - fixGraph(localData, head); - makeMulti(head, new ArrayList()); } } @@ -91,181 +89,6 @@ public class Graph { } } - private void fixGraph(BaseLocalData localData, GraphPart part) throws InterruptedException { - //if(true) return; - try { - while (fixGraphOnce(localData, part, new ArrayList(), false)) { - } - } catch (InterruptedException ex) { - throw ex; - } catch (Exception | Error ex) { - String s = ex.toString(); - //ignore - } - } - - private boolean fixGraphOnce(BaseLocalData localData, GraphPart part, List visited, boolean doChildren) throws InterruptedException { - if (Thread.currentThread().isInterrupted()) { - throw new InterruptedException(); - } - - if (visited.contains(part)) { - return false; - } - visited.add(part); - boolean fixed = false; - int i = 0; - GraphPath lastpref; - boolean modify = true; - int prvni = -1; - - if (!doChildren) { - - List uniqueRefs = new ArrayList<>(); - for (GraphPart r : part.refs) { - if (!uniqueRefs.contains(r)) { - uniqueRefs.add(r); - } - } - loopi: - for (; i <= part.path.length(); i++) { - lastpref = null; - int pos = -1; - for (GraphPart r : uniqueRefs) { - pos++; - if (r.path.rootName.equals("e") && !part.path.rootName.equals("e")) { - continue; - } - if (part.leadsTo(localData, this, code, r, new ArrayList())) { - modify = false; - continue; - } - - prvni = pos; - if (i > r.path.length()) { - i--; - break loopi; - } - if (lastpref == null) { - lastpref = r.path.parent(i); - } else { - if (!r.path.startsWith(lastpref)) { - i--; - break loopi; - } - } - } - } - if (i > part.path.length()) { - i = part.path.length(); - } - if (modify && ((uniqueRefs.size() > 1) && (prvni >= 0))) { - GraphPath prvniUniq = uniqueRefs.get(prvni).path; - GraphPath newpath = prvniUniq.parent(i); - if (!part.path.equals(newpath)) { - if (part.path.startsWith(newpath) && ((newpath.length() == prvniUniq.length()) || (prvniUniq.getKey(newpath.length()) == part.path.getKey(newpath.length())))) { - GraphPath origPath = part.path; - GraphPart p = part; - part.path = newpath; - while (p.nextParts.size() == 1) { - p = p.nextParts.get(0); - if (!p.path.equals(origPath)) { - break; - } - - p.path = newpath; - } - fixGraphOnce(localData, part, new ArrayList(), true); - fixed = true; - } - } - } - } else { - - if (!fixed) { - if (part.nextParts.size() == 1) { - if (!(part.path.rootName.equals("e") && (!part.nextParts.get(0).path.rootName.equals("e")))) { - if (part.nextParts.get(0).path.length() > part.path.length()) { - part.nextParts.get(0).path = part.path; - fixed = true; - } - } - } - if (part.nextParts.size() > 1) { - for (int j = 0; j < part.nextParts.size(); j++) { - GraphPart npart = part.nextParts.get(j); - - if (npart.path.length() > part.path.length() + 1) { - npart.path = part.path.sub(j, part.end); - fixed = true; - } - } - } - } - - } - if (part.nextParts.size() == 2) { - if (part.nextParts.get(1).leadsTo(localData, this, code, part.nextParts.get(0), new ArrayList() /*visited*/)) { - fixGraphOnce(localData, part.nextParts.get(1), visited, doChildren); - fixGraphOnce(localData, part.nextParts.get(0), visited, doChildren); - } else { - fixGraphOnce(localData, part.nextParts.get(0), visited, doChildren); - fixGraphOnce(localData, part.nextParts.get(1), visited, doChildren); - } - } else { - for (int j = part.nextParts.size() - 1; j >= 0; j--) { - GraphPart p = part.nextParts.get(j); - fixGraphOnce(localData, p, visited, doChildren); - } - } - return fixed; - } - - private void makeMulti(GraphPart part, List visited) { - if (true) { - return; - } - if (visited.contains(part)) { - return; - } - visited.add(part); - GraphPart p = part; - List multiList = new ArrayList<>(); - multiList.add(p); - while ((p.nextParts.size() == 1) && (p.nextParts.get(0).refs.size() == 1)) { - p = p.nextParts.get(0); - multiList.add(p); - } - if (multiList.size() > 1) { - GraphPartMulti gpm = new GraphPartMulti(multiList); - gpm.refs = part.refs; - GraphPart lastPart = multiList.get(multiList.size() - 1); - gpm.nextParts = lastPart.nextParts; - for (GraphPart next : gpm.nextParts) { - int index = next.refs.indexOf(lastPart); - if (index == -1) { - - continue; - } - next.refs.remove(lastPart); - next.refs.add(index, gpm); - } - for (GraphPart parent : part.refs) { - if (parent.start == -1) { - continue; - } - int index = parent.nextParts.indexOf(part); - if (index == -1) { - continue; - } - parent.nextParts.remove(part); - parent.nextParts.add(index, gpm); - } - } - for (int i = 0; i < part.nextParts.size(); i++) { - makeMulti(part.nextParts.get(i), visited); - } - } public GraphPart deepCopy(GraphPart part, List visited, List copies) { if (visited == null) {