Package scala.tools.asm

Examples of scala.tools.asm.MethodVisitor


    @Override
    public MethodVisitor visitMethod(final int access, final String name,
            final String desc, final String signature, final String[] exceptions) {
        Printer p = this.p.visitMethod(access, name, desc, signature,
                exceptions);
        MethodVisitor mv = cv == null ? null : cv.visitMethod(access, name,
                desc, signature, exceptions);
        return new TraceMethodVisitor(mv, p);
    }
View Full Code Here


     *            a class visitor.
     */
    public void accept(final ClassVisitor cv) {
        String[] exceptions = new String[this.exceptions.size()];
        this.exceptions.toArray(exceptions);
        MethodVisitor mv = cv.visitMethod(access, name, desc, signature,
                exceptions);
        if (mv != null) {
            accept(mv);
        }
    }
View Full Code Here

  }

  public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
    // delegate the method call to the next
    // chained visitor
    MethodVisitor mv = cv.visitMethod(access, name, desc, signature, exceptions);
    if (!profilerClass.equals(className)) {
      // only instrument non-abstract methods
      if((access & ACC_ABSTRACT) == 0) {
        assert(className != null);
        /* The following instructions do not modify compressed stack frame map so
         * we don't need to worry about recalculating stack frame map. Specifically,
         * let's quote "ASM 4.0, A Java bytecode engineering library" guide (p. 40):
         *
         *   In order to save space, a compiled method does not contain one frame per
         *   instruction: in fact it contains only the frames for the instructions
         *   that correspond to jump targets or exception handlers, or that follow
         *   unconditional jump instructions. Indeed the other frames can be easily
         *   and quickly inferred from these ones.
         *
         * Instructions below are just loading constants and calling a method so according
         * to definition above they do not contribute to compressed stack frame map.
         */
        mv.visitLdcInsn(className);
        mv.visitLdcInsn(name);
        mv.visitLdcInsn(desc);
        mv.visitMethodInsn(INVOKESTATIC, profilerClass, "methodCalled",
            "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", false);
      }
    }
    return mv;
  }
View Full Code Here

TOP

Related Classes of scala.tools.asm.MethodVisitor

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.