(C context, ObjExpr objx, GeneratorAdapter gen)
| 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++) |
| 2728 | { |
| 2729 | CatchClause clause = (CatchClause) catchExprs.nth(i); |
| 2730 | gen.mark(clause.label); |
| 2731 | //exception should be on stack |
| 2732 | //put in clause local |
| 2733 | gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ISTORE), clause.lb.idx); |
| 2734 | clause.handler.emit(context, objx, gen); |
| 2735 | if(context != C.STATEMENT) |
| 2736 | gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ISTORE), retLocal); |
| 2737 | gen.mark(clause.endLabel); |
| 2738 | |
| 2739 | if(finallyExpr != null) |
| 2740 | finallyExpr.emit(C.STATEMENT, objx, gen); |
| 2741 | gen.goTo(ret); |
| 2742 | } |
| 2743 | if(finallyExpr != null) |
| 2744 | { |
| 2745 | gen.mark(finallyLabel); |
| 2746 | //exception should be on stack |
| 2747 | gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ISTORE), finallyLocal); |
| 2748 | finallyExpr.emit(C.STATEMENT, objx, gen); |
| 2749 | gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ILOAD), finallyLocal); |
| 2750 | gen.throwException(); |
| 2751 | } |
| 2752 | gen.mark(ret); |
| 2753 | if(context != C.STATEMENT) |
| 2754 | gen.visitVarInsn(OBJECT_TYPE.getOpcode(Opcodes.ILOAD), retLocal); |
| 2755 | gen.mark(end); |
| 2756 | for(int i = 0; i < catchExprs.count(); i++) |
| 2757 | { |
| 2758 | CatchClause clause = (CatchClause) catchExprs.nth(i); |
| 2759 | gen.visitTryCatchBlock(startTry, endTry, clause.label, clause.c.getName().replace('.', '/')); |
| 2760 | } |
| 2761 | if(finallyExpr != null) |
| 2762 | { |
nothing calls this directly
no test coverage detected