From e8803390d2b0e73a9a591dc0152e8ca57000c15d Mon Sep 17 00:00:00 2001 From: konsoletyper Date: Sun, 15 Feb 2015 19:22:37 +0400 Subject: [PATCH] When transforming final JS method to static methods, map phis and try-catches as well --- .../teavm/jso/plugin/JavascriptNativeProcessor.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/teavm-jso/src/main/java/org/teavm/jso/plugin/JavascriptNativeProcessor.java b/teavm-jso/src/main/java/org/teavm/jso/plugin/JavascriptNativeProcessor.java index e1a5b3274..94ffa2b67 100644 --- a/teavm-jso/src/main/java/org/teavm/jso/plugin/JavascriptNativeProcessor.java +++ b/teavm-jso/src/main/java/org/teavm/jso/plugin/JavascriptNativeProcessor.java @@ -92,6 +92,18 @@ class JavascriptNativeProcessor { for (Instruction insn : block.getInstructions()) { insn.acceptVisitor(variableMapper); } + for (Phi phi : block.getPhis()) { + phi.setReceiver(program.variableAt(phi.getReceiver().getIndex() + 1)); + for (Incoming incoming : phi.getIncomings()) { + incoming.setValue(program.variableAt(incoming.getValue().getIndex() + 1)); + } + } + for (TryCatchBlock tryCatch : block.getTryCatchBlocks()) { + if (tryCatch.getExceptionVariable() != null) { + tryCatch.setExceptionVariable(program.variableAt( + tryCatch.getExceptionVariable().getIndex() + 1)); + } + } } callerMethod.setProgram(program); cls.addMethod(callerMethod);