| 2668 | } |
| 2669 | |
| 2670 | public static class TryExpr implements Expr{ |
| 2671 | public final Expr tryExpr; |
| 2672 | public final Expr finallyExpr; |
| 2673 | public final PersistentVector catchExprs; |
| 2674 | public final int retLocal; |
| 2675 | public final int finallyLocal; |
| 2676 | |
| 2677 | public static class CatchClause{ |
| 2678 | //final String className; |
| 2679 | public final Class c; |
| 2680 | public final LocalBinding lb; |
| 2681 | public final Expr handler; |
| 2682 | Label label; |
| 2683 | Label endLabel; |
| 2684 | |
| 2685 | |
| 2686 | public CatchClause(Class c, LocalBinding lb, Expr handler){ |
| 2687 | this.c = c; |
| 2688 | this.lb = lb; |
| 2689 | this.handler = handler; |
| 2690 | } |
| 2691 | } |
| 2692 | |
| 2693 | public TryExpr(Expr tryExpr, PersistentVector catchExprs, Expr finallyExpr, int retLocal, int finallyLocal){ |
| 2694 | this.tryExpr = tryExpr; |
| 2695 | this.catchExprs = catchExprs; |
| 2696 | this.finallyExpr = finallyExpr; |
| 2697 | this.retLocal = retLocal; |
| 2698 | this.finallyLocal = finallyLocal; |
| 2699 | } |
| 2700 | |
| 2701 | public Object eval() { |
| 2702 | throw new UnsupportedOperationException("Can't eval try"); |
| 2703 | } |
| 2704 | |
| 2705 | public void emit(C context, ObjExpr objx, GeneratorAdapter gen){ |
| 2706 | Label startTry = gen.newLabel(); |
| 2707 | Label endTry = gen.newLabel(); |
| 2708 | Label end = gen.newLabel(); |
| 2709 | Label ret = gen.newLabel(); |
| 2710 | Label finallyLabel = gen.newLabel(); |
| 2711 | for(int i = 0; i < catchExprs.count(); i++) |
| 2712 | { |
| 2713 | CatchClause clause = (CatchClause) catchExprs.nth(i); |
| 2714 | clause.label = gen.newLabel(); |
| 2715 | clause.endLabel = gen.newLabel(); |
| 2716 | } |
| 2717 | |
| 2718 | gen.mark(startTry); |
| 2719 | tryExpr.emit(context, objx, gen); |
| 2720 | if(context != C.STATEMENT) |
| 2721 | gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ISTORE), retLocal); |
| 2722 | gen.mark(endTry); |
| 2723 | if(finallyExpr != null) |
| 2724 | finallyExpr.emit(C.STATEMENT, objx, gen); |
| 2725 | gen.goTo(ret); |
| 2726 | |
| 2727 | for(int i = 0; i < catchExprs.count(); i++) |
nothing calls this directly
no outgoing calls
no test coverage detected