diff --git a/teavm-cli/src/main/java/org/teavm/cli/TeaVMRunner.java b/teavm-cli/src/main/java/org/teavm/cli/TeaVMRunner.java index 18e3daa67..9062cd5cf 100644 --- a/teavm-cli/src/main/java/org/teavm/cli/TeaVMRunner.java +++ b/teavm-cli/src/main/java/org/teavm/cli/TeaVMRunner.java @@ -93,13 +93,13 @@ public final class TeaVMRunner { .create('c')); options.addOption(OptionBuilder .withDescription("Wait for command after compilation, in order to enable hot recompilation") - .withLongOpt("--wait") + .withLongOpt("wait") .create('w')); options.addOption(OptionBuilder .withArgName("classpath") .hasArgs() .withDescription("Additional classpath that will be reloaded by TeaVM each time in wait mode") - .withLongOpt("--classpath") + .withLongOpt("classpath") .create('p')); if (args.length == 0) { diff --git a/teavm-core/src/main/java/org/teavm/javascript/BreakEliminator.java b/teavm-core/src/main/java/org/teavm/javascript/BreakEliminator.java index b0421551a..ccf116da6 100644 --- a/teavm-core/src/main/java/org/teavm/javascript/BreakEliminator.java +++ b/teavm-core/src/main/java/org/teavm/javascript/BreakEliminator.java @@ -143,9 +143,9 @@ class BreakEliminator implements StatementVisitor { outerStatements = new HashSet<>(); blockSuccessors = new HashMap<>(); processSequence(statement.getProtectedBody()); - processSequence(statement.getHandler()); outerStatements = oldOuterStatements; blockSuccessors = oldBlockSuccessors; + processSequence(statement.getHandler()); } @Override diff --git a/teavm-core/src/main/java/org/teavm/javascript/Decompiler.java b/teavm-core/src/main/java/org/teavm/javascript/Decompiler.java index ee4752d02..efba6b520 100644 --- a/teavm-core/src/main/java/org/teavm/javascript/Decompiler.java +++ b/teavm-core/src/main/java/org/teavm/javascript/Decompiler.java @@ -289,7 +289,7 @@ public class Decompiler { private AsyncMethodPart getRegularMethodStatement(Program program, int[] targetBlocks, boolean async) { AsyncMethodPart result = new AsyncMethodPart(); lastBlockId = 1; - graph = ProgramUtils.buildControlFlowGraph(program); + graph = ProgramUtils.buildControlFlowGraphWithTryCatch(program); int[] weights = new int[graph.size()]; for (int i = 0; i < weights.length; ++i) { weights[i] = program.basicBlockAt(i).getInstructions().size(); @@ -349,7 +349,9 @@ public class Decompiler { List blockPart = oldBlock.body.subList(bookmark.offset, oldBlock.body.size()); tryCatchStmt.getProtectedBody().addAll(blockPart); blockPart.clear(); - blockPart.add(tryCatchStmt); + if (!tryCatchStmt.getProtectedBody().isEmpty()) { + blockPart.add(tryCatchStmt); + } inheritedBookmarks.add(bookmark); } oldBlock.tryCatches.clear(); @@ -439,7 +441,9 @@ public class Decompiler { program.basicBlockAt(bookmark.exceptionHandler))); tryCatchStmt.getProtectedBody().addAll(block.body); block.body.clear(); - block.body.add(tryCatchStmt); + if (!tryCatchStmt.getProtectedBody().isEmpty()) { + block.body.add(tryCatchStmt); + } block = block.parent; } @@ -451,11 +455,15 @@ public class Decompiler { List blockPart = block.body.subList(bookmark.offset, block.body.size()); tryCatchStmt.getProtectedBody().addAll(blockPart); blockPart.clear(); - blockPart.add(tryCatchStmt); + if (!tryCatchStmt.getProtectedBody().isEmpty()) { + blockPart.add(tryCatchStmt); + } bookmark.block.tryCatches.remove(bookmark); } + tryCatchBookmarks.subList(start, tryCatchBookmarks.size()).clear(); + // Add new bookmarks for (int i = start; i < tryCatchBlocks.size(); ++i) { TryCatchBlock tryCatch = tryCatchBlocks.get(i);