Skip to content

Commit

Permalink
Try catch bug is magically fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Kroppeb committed Aug 29, 2024
1 parent d21ba2d commit 2133f72
Showing 1 changed file with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -704,20 +704,11 @@ private static void addEdges(
}
}
} else if (block instanceof DomTryCatchBlock tryCatchBlock) {
SequenceStatement stat = (SequenceStatement) blockToStatement.get(block);
CatchStatement tryCatch = (CatchStatement) stat.getStats().get(0);
Statement body = tryCatch.getFirst();
BasicBlockStatement postStat = (BasicBlockStatement) stat.getStats().get(1);
body.addSuccessor(new StatEdge(StatEdge.TYPE_BREAK, body, postStat, tryCatch));
body.addSuccessor(new StatEdge(StatEdge.TYPE_REGULAR, tryCatch, postStat));
for (var edge : body.getAllSuccessorEdges()) {
if (edge.getType() == StatEdge.TYPE_BREAK) {
edge.changeSource(postStat);
}
}
for (var edge : stat.getLabelEdges()) {
CatchStatement tryCatch = (CatchStatement) blockToStatement.get(block);

for (var edge : tryCatch.getLabelEdges()) {
if (edge.getType() == StatEdge.TYPE_BREAK) {
stat.addSuccessor(new StatEdge(StatEdge.TYPE_REGULAR, stat, edge.getDestination()));
tryCatch.addSuccessor(new StatEdge(StatEdge.TYPE_REGULAR, tryCatch, edge.getDestination()));
break; // only add regular out edge
}
}
Expand Down Expand Up @@ -757,10 +748,8 @@ private static Statement convertToStatement(
handlers.put(entry.getValue().exceptionTypes, handler);
}
CatchStatement tryCatch = new CatchStatement(head, handlers);
Statement postStat = BasicBlockStatement.create();
SequenceStatement stat = new SequenceStatement(new ArrayList<>(Arrays.asList(tryCatch, postStat)));
blockToStatement.put(block, stat);
return stat;
blockToStatement.put(block, tryCatch);
return tryCatch;
} else if (block instanceof DomCatchBlock) {
Statement stat = BasicBlockStatement.create();
blockToStatement.put(block, stat);
Expand Down

0 comments on commit 2133f72

Please sign in to comment.