Package org.ow2.asm

Examples of org.ow2.asm.Label


     *
     * I don't believe this can be represented in Java.
     */
    public void testCommonCodeWhichMustBeDuplicated() {
        {
            Label L1 = new Label();
            Label L2 = new Label();
            Label L3 = new Label();

            setCurrent(jsr);
            ICONST_0();
            ISTORE(1);

            // Invoke the two subroutines, each twice:
            JSR(L1);
            JSR(L1);
            JSR(L2);
            JSR(L2);
            RETURN();

            // L1: subroutine 1
            LABEL(L1);
            IINC(1, 1);
            GOTO(L3); // ...note that it does not return!

            // L2: subroutine 2
            LABEL(L2);
            IINC(1, 2);
            GOTO(L3); // ...note that it does not return!

            // L3: common code to both subroutines: exit method
            LABEL(L3);
            RETURN();

            END(1, 2);
        }

        {
            Label L1_1a = new Label();
            Label L1_1b = new Label();
            Label L1_2a = new Label();
            Label L1_2b = new Label();
            Label L2_1a = new Label();
            Label L2_1b = new Label();
            Label L2_2a = new Label();
            Label L2_2b = new Label();
            Label L3_1 = new Label();
            Label L3_2 = new Label();
            Label L3_3 = new Label();
            Label L3_4 = new Label();

            setCurrent(exp);
            ICONST_0();
            ISTORE(1);

            // Invoke the two subroutines, each twice:
            ACONST_NULL();
            GOTO(L1_1a);
            LABEL(L1_1b);
            ACONST_NULL();
            GOTO(L1_2a);
            LABEL(L1_2b);
            ACONST_NULL();
            GOTO(L2_1a);
            LABEL(L2_1b);
            ACONST_NULL();
            GOTO(L2_2a);
            LABEL(L2_2b);
            RETURN();
            LABEL(new Label()); // extra label emitted due to impl quirks

            // L1_1a: instantiation 1 of subroutine 1
            LABEL(L1_1a);
            IINC(1, 1);
            GOTO(L3_1); // ...note that it does not return!
View Full Code Here


     *
     * This would not normally be produced by a java compiler.
     */
    public void testInterleavedCode() {
        {
            Label L1 = new Label();
            Label L2 = new Label();
            Label L3 = new Label();
            Label L4 = new Label();

            setCurrent(jsr);
            ICONST_0();
            ISTORE(1);

            // Invoke the subroutine, each twice:
            JSR(L1);
            GOTO(L2);

            // L1: subroutine 1
            LABEL(L1);
            ASTORE(2);
            IINC(1, 1);
            GOTO(L3);

            // L2: second part of main subroutine
            LABEL(L2);
            IINC(1, 2);
            GOTO(L4);

            // L3: second part of subroutine 1
            LABEL(L3);
            IINC(1, 4);
            RET(2);

            // L4: third part of main subroutine
            LABEL(L4);
            JSR(L1);
            RETURN();

            END(1, 3);
        }

        {
            Label L1_1a = new Label();
            Label L1_1b = new Label();
            Label L1_2a = new Label();
            Label L1_2b = new Label();
            Label L2 = new Label();
            Label L3_1 = new Label();
            Label L3_2 = new Label();
            Label L4 = new Label();

            setCurrent(exp);

            // Main routine:
            ICONST_0();
            ISTORE(1);
            ACONST_NULL();
            GOTO(L1_1a);
            LABEL(L1_1b);
            GOTO(L2);
            LABEL(L2);
            IINC(1, 2);
            GOTO(L4);
            LABEL(L4);
            ACONST_NULL();
            GOTO(L1_2a);
            LABEL(L1_2b);
            RETURN();

            // L1_1: instantiation #1
            LABEL(L1_1a);
            ASTORE(2);
            IINC(1, 1);
            GOTO(L3_1);
            LABEL(L3_1);
            IINC(1, 4);
            GOTO(L1_1b);
            LABEL(new Label()); // extra label emitted due to impl quirks

            // L1_2: instantiation #2
            LABEL(L1_2a);
            ASTORE(2);
            IINC(1, 1);
            GOTO(L3_2);
            LABEL(L3_2);
            IINC(1, 4);
            GOTO(L1_2b);
            LABEL(new Label()); // extra label emitted due to impl quirks

            END(1, 3);
        }

        assertEquals(exp, jsr);
View Full Code Here

     * }
     * </pre>
     */
    public void testImplicitExitInTryCatch() {
        {
            Label T1 = new Label();
            Label C1 = new Label();
            Label S1 = new Label();
            Label L = new Label();
            Label C2 = new Label();
            Label S2 = new Label();
            Label W = new Label();
            Label X = new Label();
            Label OT = new Label();
            Label OC = new Label();

            // variable numbers:
            int b = 1;
            int e1 = 2;
            int e2 = 3;
            int r1 = 4;
            int r2 = 5;

            setCurrent(jsr);

            ICONST_0();
            ISTORE(1);

            // OT: outermost try
            LABEL(OT);

            // T1: first try:
            LABEL(T1);
            JSR(S1);
            RETURN();

            // C1: exception handler for first try
            LABEL(C1);
            ASTORE(e1);
            JSR(S1);
            ALOAD(e1);
            ATHROW();

            // S1: first finally handler
            LABEL(S1);
            ASTORE(r1);
            GOTO(W);

            // L: body of while loop, also second try
            LABEL(L);
            JSR(S2);
            RETURN();

            // C2: exception handler for second try
            LABEL(C2);
            ASTORE(e2);
            JSR(S2);
            ALOAD(e2);
            ATHROW();

            // S2: second finally handler
            LABEL(S2);
            ASTORE(r2);
            ILOAD(b);
            IFNE(X);
            RET(r2);

            // W: test for the while loop
            LABEL(W);
            ILOAD(b);
            IFNE(L); // falls through to X

            // X: exit from finally{} block
            LABEL(X);
            RET(r1);

            // OC: outermost catch
            LABEL(OC);
            IINC(b, 3);
            RETURN();

            TRYCATCH(T1, C1, C1);
            TRYCATCH(L, C2, C2);
            TRYCATCH(OT, OC, OC);

            END(1, 6);
        }

        {
            Label T1 = new Label();
            Label C1 = new Label();
            Label S1_1a = new Label();
            Label S1_1b = new Label();
            Label S1_2a = new Label();
            Label S1_2b = new Label();
            Label L_1 = new Label();
            Label L_2 = new Label();
            Label C2_1 = new Label();
            Label C2_2 = new Label();
            Label S2_1_1a = new Label();
            Label S2_1_1b = new Label();
            Label S2_1_2a = new Label();
            Label S2_1_2b = new Label();
            Label S2_2_1a = new Label();
            Label S2_2_1b = new Label();
            Label S2_2_2a = new Label();
            Label S2_2_2b = new Label();
            Label W_1 = new Label();
            Label W_2 = new Label();
            Label X_1 = new Label();
            Label X_2 = new Label();
            Label OT_1 = S1_1a;
            Label OT_2 = S1_2a;
            Label OT_1_1 = S2_1_1a;
            Label OT_1_2 = S2_1_2a;
            Label OT_2_1 = S2_2_1a;
            Label OT_2_2 = S2_2_2a;
            Label OC = new Label();
            Label OC_1 = new Label();
            Label OC_2 = new Label();
            Label OC_1_1 = new Label();
            Label OC_1_2 = new Label();
            Label OC_2_1 = new Label();
            Label OC_2_2 = new Label();

            // variable numbers:
            int b = 1;
            int e1 = 2;
            int e2 = 3;
View Full Code Here

     *   LV "a" from 1 to 6
     * </pre>
     */
    public void testBasicLineNumberAndLocalVars() {
        {
            Label LM1 = new Label();
            Label L0 = new Label();
            Label L1 = new Label();
            Label L2 = new Label();
            Label L3 = new Label();
            Label L4 = new Label();

            setCurrent(jsr);
            LABEL(LM1);
            LINE(1, LM1);
            ICONST_0();
            ISTORE(1);

            /* L0: body of try block */
            LABEL(L0);
            LINE(3, L0);
            IINC(1, 1);
            GOTO(L1);

            /* L2: exception handler */
            LABEL(L2);
            ASTORE(3);
            JSR(L3);
            ALOAD(3);
            ATHROW();

            /* L3: subroutine */
            LABEL(L3);
            LINE(5, L3);
            ASTORE(2);
            IINC(1, -1);
            RET(2);

            /* L1: non-exceptional exit from try block */
            LABEL(L1);
            JSR(L3);
            LABEL(L4); // L4
            RETURN();

            TRYCATCH(L0, L2, L2);
            TRYCATCH(L1, L4, L2);
            LOCALVAR("a", "I", 1, LM1, L4);

            END(1, 4);
        }

        {
            Label LM1 = new Label();
            Label L0 = new Label();
            Label L1 = new Label();
            Label L2 = new Label();
            Label L3_1a = new Label();
            Label L3_1b = new Label();
            Label L3_1c = new Label();
            Label L3_2a = new Label();
            Label L3_2b = new Label();
            Label L3_2c = new Label();
            Label L4 = new Label();

            setCurrent(exp);
            LABEL(LM1);
            LINE(1, LM1);
            ICONST_0();
View Full Code Here

                    @Override
                    public void visitMaxs(
                        final int maxStack,
                        final int maxLocals)
                    {
                        Label end = new Label();
                        mv.visitLabel(end);
                        mv.visitMaxs(maxStack, maxLocals);
                        int size = end.getOffset();
                        assertTrue(getMinSize() + " <= " + size + " <= "
                                + getMaxSize(), getMinSize() <= size
                                && size <= getMaxSize());
                    }
                };
View Full Code Here

    }

    @Override
    protected Label[] getLabels() {
        super.getLabels();
        return new Label[] { new Label() };
    }
View Full Code Here

        l1.add(new InsnNode(55));
        l1.add(labelNode);
        l1.add(new InsnNode(55));
       
        Label label = labelNode.getLabel();
        assertNotNull(label);
       
        l1.resetLabels();
       
        assertNotSame(label, labelNode.getLabel());
View Full Code Here

                "(I)V",
                null,
                null);
        mv.visitCode();
        mv.visitVarInsn(ALOAD, 0);
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitTypeInsn(NEW, "pkg/FrameTable");
        mv.visitInsn(DUP);
        mv.visitVarInsn(ILOAD, 1);
        Label l1 = new Label();
        mv.visitJumpInsn(IFNE, l1);
        mv.visitInsn(ACONST_NULL);
        Label l2 = new Label();
        mv.visitJumpInsn(GOTO, l2);
        mv.visitFrame(F_FULL,
                2,
                new Object[] { UNINITIALIZED_THIS, INTEGER },
                3,
View Full Code Here

                "uninitializedLocalType",
                "(Z)V",
                null,
                null);
        mv.visitCode();
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitTypeInsn(NEW, "java/lang/Long");
        mv.visitVarInsn(ASTORE, 2);
        mv.visitVarInsn(ALOAD, 2);
        mv.visitVarInsn(ILOAD, 1);
        Label l1 = new Label();
        mv.visitJumpInsn(IFEQ, l1);
        mv.visitInsn(LCONST_0);
        Label l2 = new Label();
        mv.visitJumpInsn(GOTO, l2);
        mv.visitFrame(F_FULL,
                3,
                new Object[] { "pkg/FrameTable", INTEGER, l0 },
                1,
View Full Code Here

                "uninitializedStackType",
                "(Z)V",
                null,
                null);
        mv.visitCode();
        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitTypeInsn(NEW, "java/lang/Long");
        mv.visitInsn(DUP);
        mv.visitVarInsn(ILOAD, 1);
        Label l1 = new Label();
        mv.visitJumpInsn(IFEQ, l1);
        mv.visitInsn(LCONST_0);
        mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Long", "<init>", "(J)V");
        Label l2 = new Label();
        mv.visitJumpInsn(GOTO, l2);
        mv.visitFrame(F_FULL,
                1,
                new Object[] { "pkg/FrameTable" },
                2,
View Full Code Here

TOP

Related Classes of org.ow2.asm.Label

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.