Package org.objectweb.asm.util

Examples of org.objectweb.asm.util.TraceMethodVisitor


                        a.analyze(cn.name, method);
                    } catch (Exception ignored) {
                    }
                    final Frame[] frames = a.getFrames();

                    TraceMethodVisitor mv = new TraceMethodVisitor() {
                        public void visitMaxs(
                            final int maxStack,
                            final int maxLocals)
                        {
                            for (int i = 0; i < text.size(); ++i) {
                                String s = frames[i] == null
                                        ? "null"
                                        : frames[i].toString();
                                while (s.length() < Math.max(20, maxStack
                                        + maxLocals + 1))
                                {
                                    s += " ";
                                }
                                System.err.print(Integer.toString(i + 1000)
                                        .substring(1)
                                        + " " + s + " : " + text.get(i));
                            }
                            System.err.println();
                        }
                    };
                    for (int j = 0; j < method.instructions.size(); ++j) {
                        Object insn = method.instructions.get(j);
                        ((AbstractInsnNode) insn).accept(mv);
                    }
                    mv.visitMaxs(0, 0);
                }
            }
        }
    }
View Full Code Here


    protected void setUp() throws Exception {
        super.setUp();
        jsr = new JSRInlinerAdapter(null, 0, "m", "()V", null, null) {
            public void visitEnd() {
                System.err.println("started w/ method:" + name);
                TraceMethodVisitor mv = new TraceMethodVisitor();
                for (int i = 0; i < instructions.size(); ++i) {
                    instructions.get(i).accept(mv);
                    System.err.print(Integer.toString(i + 100000).substring(1));
                    System.err.print(" : " + mv.text.get(i));
                }
View Full Code Here

        System.err.println("Actual=" + textact);
        assertEquals(textexp, textact);
    }

    private String getText(final MethodNode mn) {
        TraceMethodVisitor tmv = new TraceMethodVisitor(null);
        mn.accept(tmv);

        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < tmv.text.size(); i++) {
            sb.append(tmv.text.get(i));
View Full Code Here

    }
   
    public void setMethodVisitor(MethodVisitor mv) {
        if (DEBUG) {
            this.printer = new Textifier();
            this.method = new TraceMethodVisitor(mv, printer);
        } else {
            this.method = mv;
        }
    }
View Full Code Here

                if (!failed) {
                    failed = true;
                    log("verifying of class " + clazz + " failed");
                }
                if (verbose) log(method.name + method.desc);
                TraceMethodVisitor mv = new TraceMethodVisitor(null) {
                    public void visitMaxs(int maxStack, int maxLocals) {
                        StringBuffer buffer = new StringBuffer();
                        for (int i = 0; i < text.size(); ++i) {
                            String s = frames[i] == null ? "null" : frames[i].toString();
                            while (s.length() < maxStack + maxLocals + 1) {
                                s += " ";
                            }
                            buffer.append(Integer.toString(i + 100000).substring(1));
                            buffer.append(" ");
                            buffer.append(s);
                            buffer.append(" : ");
                            buffer.append(text.get(i));
                        }
                        if (verbose) log(buffer.toString());
                    }
                };
                for (int j = 0; j < method.instructions.size(); ++j) {
                    Object insn = method.instructions.get(j);
                    if (insn instanceof AbstractInsnNode) {
                        ((AbstractInsnNode) insn).accept(mv);
                    } else {
                        mv.visitLabel((Label) insn);
                    }
                }
                mv.visitMaxs(method.maxStack, method.maxLocals);
            }
        }
        return !failed;
    }
View Full Code Here

    }
   
    public void setMethodVisitor(MethodVisitor mv) {
        if (DEBUG) {
            this.printer = new Textifier();
            this.method = new TraceMethodVisitor(mv, printer);
        } else {
            this.method = mv;
        }
    }
View Full Code Here

    @Override
    public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
        if (method.matches(name, desc)) {
            Printer localPrinter = asmifier.visitMethod(access, name, desc, signature, exceptions);
            return new TraceMethodVisitor(null, localPrinter);
        }

        return null;
    }
View Full Code Here

        return this;
    }

    public String toString() {
        Textifier t = new Textifier();
        accept(new TraceMethodVisitor(t));
        StringWriter sw = new StringWriter();
        t.print(new PrintWriter(sw));
        return sw.toString();
    }
View Full Code Here

    public void visitEnd() {
      try{
        accept(inner);
      }catch(Exception e){
        Textifier t = new Textifier();
        accept(new TraceMethodVisitor(t));
        StringBuilderWriter sw = new StringBuilderWriter();
        PrintWriter pw = new PrintWriter(sw);
        t.print(pw);
        pw.flush();
        String bytecode = sw.getBuilder().toString();
View Full Code Here

  private final Printer printer;
  private final MethodVisitor visitor;

  public MethodRecorder() {
    printer = new Textifier();
    visitor = new TraceMethodVisitor(printer);
  }
View Full Code Here

TOP

Related Classes of org.objectweb.asm.util.TraceMethodVisitor

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.