use of org.objectweb.asm.util.Textifier in project closure-templates by google.
the class BytecodeProducer method trace.
/**
* 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) {
{
// 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).
// trigger an error if used.
this.tab = null;
// tab setting for instructions
this.tab2 = " ";
// tab setting for switch cases
this.tab3 = "";
// tab setting for labels
this.ltab = "";
}
};
gen(new CodeBuilder(new TraceMethodVisitor(textifier), 0, "trace", "()V"));
StringWriter writer = new StringWriter();
textifier.print(new PrintWriter(writer));
// Note textifier always adds a trailing newline
return writer.toString();
}
use of org.objectweb.asm.util.Textifier in project dex2jar by pxb1988.
the class TestUtils method printAnalyzerResult.
static void printAnalyzerResult(MethodNode method, Analyzer a, final PrintWriter pw) throws IllegalArgumentException, IllegalAccessException {
Frame[] frames = a.getFrames();
Textifier t = new Textifier();
TraceMethodVisitor mv = new TraceMethodVisitor(t);
String format = "%05d %-" + (method.maxStack + method.maxLocals + 6) + "s|%s";
for (int j = 0; j < method.instructions.size(); ++j) {
method.instructions.get(j).accept(mv);
StringBuffer s = new StringBuffer();
Frame f = frames[j];
if (f == null) {
s.append('?');
} else {
for (int k = 0; k < f.getLocals(); ++k) {
s.append(getShortName(f.getLocal(k).toString()));
}
s.append(" : ");
for (int k = 0; k < f.getStackSize(); ++k) {
s.append(getShortName(f.getStack(k).toString()));
}
}
// mv.text.get(j));
pw.printf(format, j, s, buf.get(t));
}
for (int j = 0; j < method.tryCatchBlocks.size(); ++j) {
((TryCatchBlockNode) method.tryCatchBlocks.get(j)).accept(mv);
pw.print(" " + buf.get(t));
}
pw.println();
pw.flush();
}
use of org.objectweb.asm.util.Textifier in project dex2jar by pxb1988.
the class AsmVerify method printAnalyzerResult.
static void printAnalyzerResult(MethodNode method, Analyzer a, final PrintWriter pw) throws IllegalArgumentException {
Frame[] frames = a.getFrames();
Textifier t = new Textifier();
TraceMethodVisitor mv = new TraceMethodVisitor(t);
String format = "%05d %-" + (method.maxStack + method.maxLocals + 6) + "s|%s";
for (int j = 0; j < method.instructions.size(); ++j) {
method.instructions.get(j).accept(mv);
StringBuffer s = new StringBuffer();
Frame f = frames[j];
if (f == null) {
s.append('?');
} else {
for (int k = 0; k < f.getLocals(); ++k) {
s.append(getShortName(f.getLocal(k).toString()));
}
s.append(" : ");
for (int k = 0; k < f.getStackSize(); ++k) {
s.append(getShortName(f.getStack(k).toString()));
}
}
try {
// mv.text.get(j));
pw.printf(format, j, s, buf.get(t));
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
for (TryCatchBlockNode tryCatchBlockNode : method.tryCatchBlocks) {
tryCatchBlockNode.accept(mv);
try {
pw.print(" " + buf.get(t));
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
pw.println();
pw.flush();
}
use of org.objectweb.asm.util.Textifier in project quasar by puniverse.
the class Retransform method dumpClass.
public static void dumpClass(String className, byte[] data) {
System.err.println("DUMP OF CLASS: " + className);
ClassReader cr = new ClassReader(data);
ClassVisitor cv = new TraceClassVisitor(null, new Textifier(), new PrintWriter(System.err));
cr.accept(cv, ClassReader.SKIP_FRAMES);
System.out.println("=================");
}
use of org.objectweb.asm.util.Textifier in project groovy by apache.
the class LoggableTextifier method visitParameterAnnotation.
@Override
public Textifier visitParameterAnnotation(int parameter, String desc, boolean visible) {
Textifier t = super.visitParameterAnnotation(parameter, desc, visible);
log();
return t;
}
Aggregations