List of usage examples for org.objectweb.asm.util Textifier Textifier
protected Textifier(final int api)
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 w ww.ja v a 2 s . co m public void visitMethodEnd() { print(new PrintWriter(System.out)); // print it after it has // been visited } }; return new TraceMethodVisitor(mv, p); }
From source file:com.google.template.soy.jbcsrc.BytecodeProducer.java
License:Apache License
/** * Returns a human readable string for the code that this {@link BytecodeProducer} generates. *///ww w. j a v a 2 s . com final String trace() { // TODO(lukes): textifier has support for custom label names by overriding appendLabel. // Consider trying to make use of (using the Label.info field? adding a custom NamedLabel // sub type?) Textifier textifier = new Textifier(Opcodes.ASM5) { { // reset tab sizes. Since we don't care about formatting class names or method signatures // (only code). We only need to set the tab2,tab3 and ltab settings (tab is for class // members). this.tab = null; // trigger an error if used. this.tab2 = " "; // tab setting for instructions this.tab3 = ""; // tab setting for switch cases this.ltab = ""; // tab setting for labels } }; gen(new CodeBuilder(new TraceMethodVisitor(textifier), 0, "trace", "()V")); StringWriter writer = new StringWriter(); textifier.print(new PrintWriter(writer)); return writer.toString(); // Note textifier always adds a trailing newline }
From source file:com.google.template.soy.jbcsrc.restricted.BytecodeProducer.java
License:Apache License
/** Returns a human readable string for the code that this {@link BytecodeProducer} generates. */ public final String trace() { // TODO(lukes): textifier has support for custom label names by overriding appendLabel. // Consider trying to make use of (using the Label.info field? adding a custom NamedLabel // sub type?) Textifier textifier = new Textifier(Opcodes.ASM6) { {/*w w w. ja v a 2s.c o m*/ // reset tab sizes. Since we don't care about formatting class names or method // signatures (only code). We only need to set the tab2,tab3 and ltab settings (tab is // for class members). this.tab = null; // trigger an error if used. this.tab2 = " "; // tab setting for instructions this.tab3 = ""; // tab setting for switch cases this.ltab = ""; // tab setting for labels } }; gen(new CodeBuilder(new TraceMethodVisitor(textifier), 0, "trace", "()V")); StringWriter writer = new StringWriter(); textifier.print(new PrintWriter(writer)); return writer.toString(); // Note textifier always adds a trailing newline }