Package org.objectweb.asm

Examples of org.objectweb.asm.CodeVisitor


    }

    public void visitEnd() {
        // Merge the static initializer
        if (methodNames.size() > 0) {
            CodeVisitor mv = this.cv.visitMethod(Constants.ACC_STATIC,
                    "<clinit>", "()V", null, null);
            for (int i = 0; i < methodNames.size(); i++) {
                String methodName = (String) methodNames.get(i);
                mv.visitMethodInsn(Constants.INVOKESTATIC, classToWrite,
                        methodName, "()V");
            }
            mv.visitInsn(Constants.RETURN);
        }
        super.visitEnd();
    }
View Full Code Here


     */
    private void generateGetCeObjectMethod() {
        if (debug) {
            logger.log(BasicLevel.DEBUG, "Generate the method: getCeObject");
        }
        CodeVisitor mv = cv.visitMethod(ACC_PUBLIC, "getCeObject",
                "()Ljava/lang/Object;", null, null);
        // return this;
        mv.visitVarInsn(ALOAD, 0);
        mv.visitInsn(ARETURN);
        mv.visitMaxs(0, 0);
    }
View Full Code Here

        if (debug) {
            logger
                    .log(BasicLevel.DEBUG,
                            "Generate the method: getCeIdentifier");
        }
        CodeVisitor mv = cv.visitMethod(ACC_PUBLIC, "getCeIdentifier",
                "()Ljava/lang/Object;", null, null);
        // return getPName();
        mv.visitVarInsn(ALOAD, 0);
        mv.visitMethodInsn(INVOKEVIRTUAL, classToWrite, "getPName",
                "()Lorg/objectweb/jorm/naming/api/PName;");
        mv.visitInsn(ARETURN);
        mv.visitMaxs(0, 0);
    }
View Full Code Here

     */
    private void generateFixCeMethod() {
        if (debug) {
            logger.log(BasicLevel.DEBUG, "Generate the method: fixCe");
        }
        CodeVisitor mv = cv.visitMethod(ACC_PUBLIC, "fixCe", "()V", null, null);
        // speedoFixCount++;
        mv.visitVarInsn(ALOAD, 0);
        mv.visitInsn(DUP);
        mv.visitFieldInsn(GETFIELD, classToWrite, FIX_FIELD_NAME, "I");
        mv.visitInsn(ICONST_1);
        mv.visitInsn(IADD);
        mv.visitFieldInsn(PUTFIELD, classToWrite, FIX_FIELD_NAME, "I");

        mv.visitInsn(RETURN);
        mv.visitMaxs(0, 0);
    }
View Full Code Here

     */
    private void generateUnfixCeMethod() {
        if (debug) {
            logger.log(BasicLevel.DEBUG, "Generate the method: unfixCe");
        }
        CodeVisitor mv = cv.visitMethod(ACC_PUBLIC, "unfixCe", "()V", null,
                null);
        // speedoFixCount--;
        mv.visitVarInsn(ALOAD, 0);
        mv.visitInsn(DUP);
        mv.visitFieldInsn(GETFIELD, classToWrite, FIX_FIELD_NAME, "I");
        mv.visitInsn(ICONST_1);
        mv.visitInsn(ISUB);
        mv.visitFieldInsn(PUTFIELD, classToWrite, FIX_FIELD_NAME, "I");

        mv.visitInsn(RETURN);
        mv.visitMaxs(0, 0);
    }
View Full Code Here

     */
    private void generateGetCeFixCountMethod() {
        if (debug) {
            logger.log(BasicLevel.DEBUG, "Generate the method: getCeFixCount");
        }
        CodeVisitor mv = cv.visitMethod(ACC_PUBLIC, "getCeFixCount", "()I",
                null, null);
        // return speedoFixCount;
        mv.visitVarInsn(ALOAD, 0);
        mv.visitFieldInsn(GETFIELD, classToWrite, FIX_FIELD_NAME, "I");
        mv.visitInsn(IRETURN);
        mv.visitMaxs(0, 0);
    }
View Full Code Here

     */
    private void generateGetCeAgeMethod() {
        if (debug) {
            logger.log(BasicLevel.DEBUG, "Generate the method: getCeAge");
        }
        CodeVisitor mv = cv.visitMethod(ACC_PUBLIC, "getCeAge", "()J", null,
                null);
        // return speedoAge;
        mv.visitVarInsn(ALOAD, 0);
        mv.visitFieldInsn(GETFIELD, classToWrite, AGE_FIELD_NAME, "J");
        mv.visitInsn(LRETURN);
        mv.visitMaxs(0, 0);
    }
View Full Code Here

     */
    private void generateSetCeAgeMethod() {
        if (debug) {
            logger.log(BasicLevel.DEBUG, "Generate the method: setCeAge");
        }
        CodeVisitor mv = cv.visitMethod(ACC_PUBLIC, "setCeAge", "(J)V", null,
                null);
        // this.speedoAge = a;
        mv.visitVarInsn(ALOAD, 0);
        mv.visitVarInsn(LLOAD, 1);
        mv.visitFieldInsn(PUTFIELD, classToWrite, AGE_FIELD_NAME, "J");
        mv.visitInsn(RETURN);
        mv.visitMaxs(0, 0);
    }
View Full Code Here

    public CodeVisitor visitMethod(final int access,
                                   final String name,
                                   final String desc,
                                   final String[] exceptions,
                                   final Attribute attrs) {
        CodeVisitor covis = this.cv.visitMethod(access, name, desc, exceptions, attrs);
        if ((access & Constants.ACC_ABSTRACT) != 0) {
            // nothing to be modified for abstract methods
      logger.log(BasicLevel.DEBUG,
          "ignore the abstract method " + name + " " + desc);
            return covis;
View Full Code Here

            final String[] interfaces,
            final String sourceFile) {
    cv.visit(version, access, name, superName, interfaces, sourceFile);
    //Generate a no-arg constructor if required
    if (status == SpeedoClass.NO_NO_ARG_CONSTRUCTOR) {
      CodeVisitor _cv = this.cv.visitMethod(
        Constants.ACC_PUBLIC, "<init>", "()V", null, null);
      _cv.visitVarInsn(Constants.ALOAD, 0);
      _cv.visitMethodInsn(Constants.INVOKESPECIAL, superName, "<init>", "()V");
      _cv.visitInsn(Constants.RETURN);
      _cv.visitMaxs(1, 1);
    }
  }
View Full Code Here

TOP

Related Classes of org.objectweb.asm.CodeVisitor

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.