From a83f385cf5b8b64e8265e06f430f2a38995cd7a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Sat, 9 Feb 2013 16:12:48 +0100 Subject: [PATCH] AS3: stub of for..continue decompilation, try fix --- .../jpexs/asdec/abc/avm2/flowgraph/Graph.java | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/flowgraph/Graph.java b/trunk/src/com/jpexs/asdec/abc/avm2/flowgraph/Graph.java index 03da121a6..74e6b1afd 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/flowgraph/Graph.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/flowgraph/Graph.java @@ -331,18 +331,25 @@ public class Graph { } for (int i = 0; i < caseBodies.size(); i++) { - List cc = printGraph(methodPath,stack, scopeStack, allParts, parsedExceptions, finallyJumps, level, switchLoc, caseBodies.get(i), next, loops, localRegs, body, ignoredSwitches); + List cc = new ArrayList(); + GraphPart nextCase=null; + nextCase=next; if (next != null) { if (i < caseBodies.size() - 1) { if (!caseBodies.get(i).leadsTo(caseBodies.get(i + 1), ignored)) { cc.add(new BreakTreeItem(null, next.start)); + }else{ + nextCase=caseBodies.get(i + 1); } } else if (hasDefault) { if (!caseBodies.get(i).leadsTo(defaultPart, ignored)) { cc.add(new BreakTreeItem(null, next.start)); + }else{ + nextCase=defaultPart; } } } + cc.addAll(0,printGraph(methodPath,stack, scopeStack, allParts, parsedExceptions, finallyJumps, level, switchLoc, caseBodies.get(i), nextCase, loops, localRegs, body, ignoredSwitches)); caseCommands.add(cc); } @@ -391,6 +398,7 @@ public class Graph { if (catchedExceptions.size() > 0) { parsedExceptions.addAll(catchedExceptions); int endpos = code.adr2pos(code.fixAddrAfterDebugLine(catchedExceptions.get(0).end)); + int endposStartBlock=code.adr2pos(catchedExceptions.get(0).end); List> catchedCommands = new ArrayList>(); @@ -491,8 +499,9 @@ public class Graph { } GraphPart nepart = null; + for (GraphPart p : allParts) { - if (p.start == endpos) { + if (p.start == endposStartBlock) { nepart = p; break; } @@ -605,7 +614,7 @@ public class Graph { if (debugMode) { System.err.println("ONTRUE: (inside " + part + ")"); } - onTrue = printGraph(methodPath,trueStack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, part, part.nextParts.get(1), stopPart, loops, localRegs, body, ignoredSwitches); + onTrue = printGraph(methodPath,trueStack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, part, part.nextParts.get(1), next==null?stopPart:next, loops, localRegs, body, ignoredSwitches); if (debugMode) { System.err.println("/ONTRUE (inside " + part + ")"); } @@ -617,7 +626,7 @@ public class Graph { if (debugMode) { System.err.println("ONFALSE: (inside " + part + ")"); } - onFalse = (((next == part.nextParts.get(0)) || (part.nextParts.get(0).path.equals(part.path) || part.nextParts.get(0).path.length() < part.path.length())) ? new ArrayList() : printGraph(methodPath,falseStack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, part, part.nextParts.get(0), stopPart, loops, localRegs, body, ignoredSwitches)); + onFalse = (((next == part.nextParts.get(0)) || (part.nextParts.get(0).path.equals(part.path) || part.nextParts.get(0).path.length() < part.path.length())) ? new ArrayList() : printGraph(methodPath,falseStack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, part, part.nextParts.get(0), next==null?stopPart:next, loops, localRegs, body, ignoredSwitches)); if (debugMode) { System.err.println("/ONFALSE (inside " + part + ")"); } @@ -711,8 +720,12 @@ public class Graph { GraphPart p = part.nextParts.get(0); TreeItem lop = checkLoop(p, stopPart, loops); if (lop == null) { - if (part.nextParts.get(0).path.length() == part.path.length()) { + if (p.path.length() == part.path.length()) { ret.addAll(printGraph(methodPath,stack, scopeStack, allParts, parsedExceptions, finallyJumps, level, part, part.nextParts.get(0), stopPart, loops, localRegs, body, ignoredSwitches)); + }else{ + if(p!=stopPart){ + ret.add(new CommentTreeItem(null, "Jump to different path")); + } } } else { ret.add(lop); @@ -738,14 +751,20 @@ public class Graph { for(int i=0;i caseBody=printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level, part, part.nextParts.get(1+i), stopPart, loops, localRegs, body, ignoredSwitches); + GraphPart nextCase=next; + List caseBody=new ArrayList(); if(i())){ caseBody.add(new BreakTreeItem(null, breakPos)); + }else{ + nextCase=part.nextParts.get(1+i+1); } }else if(!part.nextParts.get(1+i).leadsTo(part.nextParts.get(0), new ArrayList())){ caseBody.add(new BreakTreeItem(null, breakPos)); + }else{ + nextCase=part.nextParts.get(0); } + caseBody.addAll(0,printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level, part, part.nextParts.get(1+i), nextCase, loops, localRegs, body, ignoredSwitches)); caseCommands.add(caseBody); }