diff --git a/src/me/topchetoeu/jscript/compilation/control/TryStatement.java b/src/me/topchetoeu/jscript/compilation/control/TryStatement.java index ca25589..430a943 100644 --- a/src/me/topchetoeu/jscript/compilation/control/TryStatement.java +++ b/src/me/topchetoeu/jscript/compilation/control/TryStatement.java @@ -27,9 +27,10 @@ public class TryStatement extends Statement { @Override public void compile(List target, ScopeRecord scope) { + target.add(Instruction.nop()); + int start = target.size(), tryN, catchN = -1, finN = -1; - target.add(Instruction.nop()); tryBody.compileNoPollution(target, scope); tryN = target.size() - start; @@ -60,7 +61,7 @@ public class TryStatement extends Statement { // } // } - target.set(start, Instruction.tryInstr(tryN, catchN, finN).locate(loc())); + target.set(start - 1, Instruction.tryInstr(tryN, catchN, finN).locate(loc())); } public TryStatement(Location loc, Statement tryBody, Statement catchBody, Statement finallyBody, String name) { diff --git a/src/me/topchetoeu/jscript/engine/frame/CodeFrame.java b/src/me/topchetoeu/jscript/engine/frame/CodeFrame.java index 4e3a6c5..1ea750c 100644 --- a/src/me/topchetoeu/jscript/engine/frame/CodeFrame.java +++ b/src/me/topchetoeu/jscript/engine/frame/CodeFrame.java @@ -195,6 +195,7 @@ public class CodeFrame { if (!jumpFlag) { if (tmp.state == TryCtx.STATE_FINALLY_THREW) throw tmp.err; else if (tmp.state == TryCtx.STATE_FINALLY_RETURNED) return tmp.retVal; + else if (tmp.state == TryCtx.STATE_FINALLY_JUMPED) codePtr = tmp.jumpPtr; } else codePtr = tmp.jumpPtr; remove = true;