List of usage examples for org.objectweb.asm.util TraceMethodVisitor TraceMethodVisitor
public TraceMethodVisitor(final MethodVisitor methodVisitor, final Printer printer)
From source file:ch.eiafr.cojac.FloatReplaceClassVisitor.java
License:Apache License
private MethodVisitor instrumentMethod(MethodVisitor parentMv, int access, String desc, String oldDesc, String name) {// w w w . j a v a 2 s .co m MethodVisitor mv; // Create the MethodVisitor delegation chain: // MyLocalAdder adds two local variables // -> FloatReplacerMethodVisitor main bytecode transformation (with helper class FloatProxyMethod) // -> FloatVariableSorter remaps parameters index (due to the replacement of double (2 slots) as objects (1 slot)) // -> AnalyzerAdapter keeps track of effective stack, so that we know the type of the top // -> parentMv typically the final Writer // the last one (parentMv) is typically a MethodWriter // With maybe some intermediate TraceMethodVisitor to help debugging... if (wantsToDump(crtClassName, name)) { // name.contains("dumpMethod")) { // "dumpMethod" parentMv = new TraceMethodVisitor(parentMv, newPrinter("FINAL " + name + desc)); } AnalyzerAdapter aa = new AnalyzerAdapter(crtClassName, access, name, desc, parentMv); FloatVariablesSorter lvs = new FloatVariablesSorter(access, oldDesc, aa); MethodVisitor aux = lvs; if (wantsToDump(crtClassName, name)) { aux = new TraceMethodVisitor(lvs, newPrinter("JUST BEFORE LVS " + name + desc)); } ReplaceFloatsMethods rfm = new ReplaceFloatsMethods(fpm, crtClassName, references); FloatReplacerMethodVisitor frmv = new FloatReplacerMethodVisitor(aa, aux, rfm, stats, factory, references); MyLocalAdder mla = new MyLocalAdder(access, oldDesc, frmv); fpm.setUsefulPartners(aa, mla); mv = mla; if (wantsToDump(crtClassName, name)) mv = new TraceMethodVisitor(mv, newPrinter("BEFORE " + name + desc)); return mv; }
From source file:ch.sourcepond.utils.podescoin.devel.PrintClassVisitor.java
License:Apache License
@Override public MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions) { final MethodVisitor mv = cv.visitMethod(access, name, desc, signature, exceptions); final Printer p = new Textifier(Opcodes.ASM5) { @Override/*from ww w.ja va 2 s .com*/ public void visitMethodEnd() { print(new PrintWriter(System.out)); // print it after it has // been visited } }; return new TraceMethodVisitor(mv, p); }