List of usage examples for org.objectweb.asm.util Textifier print
public void print(final PrintWriter printWriter)
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. *//* w w w . ja va 2s . c o m*/ 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) { {//from w w w. j av a 2s . c om // 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:org.elasticsearch.painless.Debugger.java
License:Apache License
/** compiles to bytecode, and returns debugging output */ static String toString(String source, CompilerSettings settings) { StringWriter output = new StringWriter(); PrintWriter outputWriter = new PrintWriter(output); Textifier textifier = new Textifier(); try {/* w w w. j a v a 2 s . c o m*/ Compiler.compile("<debugging>", source, settings, textifier); } catch (Exception e) { textifier.print(outputWriter); e.addSuppressed(new Exception("current bytecode: \n" + output)); IOUtils.reThrowUnchecked(e); throw new AssertionError(); } textifier.print(outputWriter); return output.toString(); }
From source file:org.jacoco.core.internal.analysis.AC_MethodAnalyzerTest.java
License:Open Source License
@SuppressWarnings("unused") private void printMethod(MethodNode m) { Textifier t = new Textifier(); m.accept(new TraceMethodVisitor(t)); PrintWriter writer = new PrintWriter(System.out); t.print(writer); writer.flush();// www . j av a2 s . co m }