1695 } |
1695 } |
1696 |
1696 |
1697 public void visitReturn(JCReturn tree) { |
1697 public void visitReturn(JCReturn tree) { |
1698 int limit = code.nextreg; |
1698 int limit = code.nextreg; |
1699 final Env<GenContext> targetEnv; |
1699 final Env<GenContext> targetEnv; |
|
1700 |
|
1701 /* Save and then restore the location of the return in case a finally |
|
1702 * is expanded (with unwind()) in the middle of our bytecodes. |
|
1703 */ |
|
1704 int tmpPos = code.pendingStatPos; |
1700 if (tree.expr != null) { |
1705 if (tree.expr != null) { |
1701 Item r = genExpr(tree.expr, pt).load(); |
1706 Item r = genExpr(tree.expr, pt).load(); |
1702 if (hasFinally(env.enclMethod, env)) { |
1707 if (hasFinally(env.enclMethod, env)) { |
1703 r = makeTemp(pt); |
1708 r = makeTemp(pt); |
1704 r.store(); |
1709 r.store(); |
1705 } |
1710 } |
1706 targetEnv = unwind(env.enclMethod, env); |
1711 targetEnv = unwind(env.enclMethod, env); |
|
1712 code.pendingStatPos = tmpPos; |
1707 r.load(); |
1713 r.load(); |
1708 code.emitop0(ireturn + Code.truncate(Code.typecode(pt))); |
1714 code.emitop0(ireturn + Code.truncate(Code.typecode(pt))); |
1709 } else { |
1715 } else { |
1710 /* If we have a statement like: |
|
1711 * |
|
1712 * return; |
|
1713 * |
|
1714 * we need to store the code.pendingStatPos value before generating |
|
1715 * the finalizer. |
|
1716 */ |
|
1717 int tmpPos = code.pendingStatPos; |
|
1718 targetEnv = unwind(env.enclMethod, env); |
1716 targetEnv = unwind(env.enclMethod, env); |
1719 code.pendingStatPos = tmpPos; |
1717 code.pendingStatPos = tmpPos; |
1720 code.emitop0(return_); |
1718 code.emitop0(return_); |
1721 } |
1719 } |
1722 endFinalizerGaps(env, targetEnv); |
1720 endFinalizerGaps(env, targetEnv); |