Package org.objectweb.asm

Examples of org.objectweb.asm.Label


        // if the method is extending something, then we have
        // to test if the handler is initialized...

        if (md.isImplemented()) {
            ga.dup();
            Label ok = ga.newLabel();
            ga.ifNonNull(ok);

            ga.loadThis();
            ga.loadArgs();
            ga.invokeConstructor(superType, m);
            ga.returnValue();
            ga.mark(ok);
        }

        ga.loadThis();
        ga.getStatic(selfType, field_name, PROXY_METHOD_TYPE);

        if (m.getArgumentTypes().length == 0) {
            // load static empty array
            ga.getStatic(JAVA_PROXY_TYPE, "NO_ARGS", Type
                    .getType(Object[].class));
        } else {
            // box arguments
            ga.loadArgArray();
        }

        Label before = ga.mark();

        ga.invokeInterface(INVOCATION_HANDLER_TYPE,
                INVOCATION_HANDLER_INVOKE_METHOD);

        Label after = ga.mark();

        ga.unbox(m.getReturnType());
        ga.returnValue();

        // this is a simple rethrow handler
        Label rethrow = ga.mark();
        ga.visitInsn(Opcodes.ATHROW);

        for (int i = 0; i < ex.length; i++) {
            ga.visitTryCatchBlock(before, after, rethrow, ex[i]
                    .getInternalName());
        }

        ga.visitTryCatchBlock(before, after, rethrow, "java/lang/Error");
        ga.visitTryCatchBlock(before, after, rethrow,
                "java/lang/RuntimeException");

        Type thr = Type.getType(Throwable.class);
        Label handler = ga.mark();
        Type udt = Type.getType(UndeclaredThrowableException.class);
        int loc = ga.newLocal(thr);
        ga.storeLocal(loc, thr);
        ga.newInstance(udt);
        ga.dup();
View Full Code Here


                mv.start();

                String fieldName = mangleMethodFieldName(simpleName, paramTypes);
               
                // try specific name first, falling back on simple name
                Label dispatch = new Label();
                cw.visitField(ACC_STATIC | ACC_PUBLIC | ACC_VOLATILE, fieldName, ci(DynamicMethod.class), null, null).visitEnd();
                mv.getstatic(name, fieldName, ci(DynamicMethod.class));
                mv.dup();
                mv.ifnonnull(dispatch);
                mv.pop();
View Full Code Here

                } else if(simpleName.equals("toString") && paramTypes.length == 0 && returnType == String.class) {
                    mv.aload(0);
                    mv.invokespecial(p(Object.class), "toString", sig(String.class));
                    mv.areturn();
                } else {
                    Label dispatch = new Label();
                    Label end = new Label();
                    Label recheckMethod = new Label();

                    // Try to look up field for simple name

                    // get field; if nonnull, go straight to dispatch
                    mv.getstatic(pathName, simpleName, ci(DynamicMethod.class));
                    mv.dup();
                    mv.ifnonnull(dispatch);

                    // field is null, lock class and try to populate
                    mv.pop();
                    mv.getstatic(pathName, "rubyClass", ci(RubyClass.class));
                    mv.monitorenter();

                    // try/finally block to ensure unlock
                    Label tryStart = new Label();
                    Label tryEnd = new Label();
                    Label finallyStart = new Label();
                    Label finallyEnd = new Label();
                    mv.label(tryStart);

                    mv.aload(0);
                    mv.getfield(pathName, "self", ci(IRubyObject.class));
                    for (String eachName : nameSet) {
                        mv.ldc(eachName);
                    }
                    mv.invokestatic(p(MiniJava.class), "searchMethod", sig(DynamicMethod.class, params(IRubyObject.class, String.class, nameSet.size())));
                    mv.dup();
               
                    // if it's not undefined...
                    mv.getstatic(p(UndefinedMethod.class), "INSTANCE", ci(UndefinedMethod.class));
                    Label noStore = new Label();
                    mv.if_acmpeq(noStore);

                    // store it
                    mv.dup();
                    mv.putstatic(pathName, simpleName, ci(DynamicMethod.class));
View Full Code Here

            mv.visitFieldInsn(GETFIELD, _internalClassName, _subjectAnalysisDataContainer._syntheticProxyFieldName, "Lcom/mobixess/jodb/core/query/NQueryDataObjectProxy;");
            //mv.visitFieldInsn(GETFIELD, "com/mobixess/jodb/tests/transformations/TestTrans", "_dataObjectProxy", "Lcom/mobixess/jodb/core/query/NQueryDataObjectProxy;");
            mv.visitLdcInsn(referringFieldId);
            //mv.visitIntInsn(SIPUSH, 32000);
            mv.visitMethodInsn(INVOKEVIRTUAL, "com/mobixess/jodb/core/query/NQueryDataObjectProxy", "isFieldRequested", "(I)Z");
            Label l1 = new Label();
            mv.visitJumpInsn(IFNE, l1);
            Label l2 = new Label();
            mv.visitLabel(l2);
            //mv.visitLineNumber(33, l2);
            mv.visitVarInsn(ALOAD, 0);
            mv.visitVarInsn(ALOAD, 0);
            mv.visitFieldInsn(GETFIELD, _internalClassName, _subjectAnalysisDataContainer._syntheticProxyFieldName, "Lcom/mobixess/jodb/core/query/NQueryDataObjectProxy;");
View Full Code Here

            //mv.visitFieldInsn(PUTFIELD, "com/mobixess/jodb/tests/transformations/TestTrans", "_localVar", "I");
            mv.visitLabel(l1);
        }
       
        private void writeReturn(MethodVisitor mv, Field field){
            Label l4 = new Label();
            mv.visitLabel(l4);
            Type declaringClassType = Type.getType(field.getDeclaringClass());
            Class fieldTypeClass = field.getType();
           
            int returnOpcode = -1;
            if(!fieldTypeClass.isPrimitive()){
                returnOpcode = Opcodes.ARETURN;
            }else{
                try {
                    PRIMITIVES_ENUMERATION primitives_enumeration = PrimitiveJavaTypesUtil.getEnumeratedType(fieldTypeClass.getName());
                    switch (primitives_enumeration) {
                        case _long:
                            returnOpcode = Opcodes.LRETURN;
                            break;
                        case _double:
                            returnOpcode = Opcodes.DRETURN;
                            break;
                        case _float:
                            returnOpcode = Opcodes.FRETURN;
                            break;
                        default:
                            returnOpcode = Opcodes.IRETURN;
                            break;
                    }
                } catch (JodbIOException e) {
                    //should never happen
                    e.printStackTrace();
                }
            }
            Type type = Type.getType(field.getType());
            mv.visitVarInsn(ALOAD, 0);
            mv.visitFieldInsn(GETFIELD, declaringClassType.getInternalName(), field.getName(), type.getDescriptor());
            mv.visitInsn(returnOpcode);
            mv.visitEnd();
            Label l3 = new Label();
            mv.visitLabel(l3);
            //mv.visitLocalVariable("this", "Lcom/mobixess/jodb/tests/transformations/TestTrans;", null, l0, l3, 0);
            mv.visitLocalVariable("this", declaringClassType.getDescriptor(), null, l4, l3, 0);
            mv.visitMaxs(3, 1);
            mv.visitEnd();
View Full Code Here

        @Override
        public void visitTypeInsn(int opcode, String desc) {
            if (opcode == Opcodes.NEW) {
                if (_labels == null) {
                    Label l = new Label();
                    _labels = new ArrayList<Label>(5);
                    _labels.add(l);
                    if (mv != null) {
                        mv.visitLabel(l);
                    }
View Full Code Here

        cw.visit(V1_4, ACC_PUBLIC + ACC_SUPER, namePath, null, SUPER_CLASS, null);
        MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
        mv.visitCode();
        mv.visitVarInsn(ALOAD, 0);
        mv.visitMethodInsn(INVOKESPECIAL, SUPER_CLASS, "<init>", "()V");
        Label line = new Label();
        mv.visitLineNumber(0, line);
        mv.visitInsn(RETURN);
        mv.visitMaxs(1, 1);
        mv.visitEnd();
        return cw;
View Full Code Here

        cw.visit(V1_4, ACC_PUBLIC + ACC_SUPER, namePath, null, FAST_SUPER_CLASS, null);
        MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
        mv.visitCode();
        mv.visitVarInsn(ALOAD, 0);
        mv.visitMethodInsn(INVOKESPECIAL, FAST_SUPER_CLASS, "<init>", "()V");
        Label line = new Label();
        mv.visitLineNumber(0, line);
        mv.visitInsn(RETURN);
        mv.visitMaxs(1, 1);
        mv.visitEnd();
        return cw;
View Full Code Here

    @Deprecated
    private MethodVisitor startCall(ClassWriter cw) {
        MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "call", CALL_SIG, null, null);
       
        mv.visitCode();
        Label line = new Label();
        mv.visitLineNumber(0, line);
        mv.visitVarInsn(ALOAD, 1);
        mv.visitTypeInsn(CHECKCAST, typePath);
        return mv;
    }
View Full Code Here

    @Deprecated
    private MethodVisitor startCallS(ClassWriter cw) {
        MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "call", CALL_SIG, null, null);
       
        mv.visitCode();
        Label line = new Label();
        mv.visitLineNumber(0, line);
        mv.visitVarInsn(ALOAD, 1);
        checkCast(mv, IRubyObject.class);
        return mv;
    }
View Full Code Here

TOP

Related Classes of org.objectweb.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.