[Dashg-commit] SF.net SVN: dashg:[33] trunk/dashg/src/com/mebigfatguy/dashg/ DashGMethodSourcePrin
Status: Pre-Alpha
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2008-10-28 19:47:06
|
Revision: 33
http://dashg.svn.sourceforge.net/dashg/?rev=33&view=rev
Author: dbrosius
Date: 2008-10-28 19:47:02 +0000 (Tue, 28 Oct 2008)
Log Message:
-----------
add tableswitch
Modified Paths:
--------------
trunk/dashg/src/com/mebigfatguy/dashg/DashGMethodSourcePrintingVisitor.java
Modified: trunk/dashg/src/com/mebigfatguy/dashg/DashGMethodSourcePrintingVisitor.java
===================================================================
--- trunk/dashg/src/com/mebigfatguy/dashg/DashGMethodSourcePrintingVisitor.java 2008-10-28 19:27:07 UTC (rev 32)
+++ trunk/dashg/src/com/mebigfatguy/dashg/DashGMethodSourcePrintingVisitor.java 2008-10-28 19:47:02 UTC (rev 33)
@@ -20,6 +20,8 @@
import java.io.PrintWriter;
import java.text.NumberFormat;
+import java.util.HashMap;
+import java.util.Map;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Attribute;
@@ -33,6 +35,7 @@
private PrintWriter pw;
private DashGLineNumberer ln;
private NumberFormat nf;
+ private Map<String, Integer> labelsToOffset;
public DashGMethodSourcePrintingVisitor(MethodVisitor mVisitor, PrintWriter pWriter, DashGLineNumberer lineNumberer) {
mv = mVisitor;
@@ -41,8 +44,13 @@
nf = NumberFormat.getIntegerInstance();
nf.setMinimumIntegerDigits(5);
nf.setGroupingUsed(false);
+ labelsToOffset = new HashMap<String, Integer>();
}
+ public Map<String, Integer> getLabelOffsets() {
+ return labelsToOffset;
+ }
+
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
return mv.visitAnnotation(desc, visible);
}
@@ -98,12 +106,14 @@
public void visitJumpInsn(int opcode, Label label) {
String insn = TraceClassVisitor.OPCODES[opcode];
+ insn += " " + label.toString();
emitInsn(insn);
mv.visitJumpInsn(opcode, label);
}
public void visitLabel(Label label) {
mv.visitLabel(label);
+ labelsToOffset.put(label.toString(), Integer.valueOf(label.getOffset()));
}
public void visitLdcInsn(Object cst) {
@@ -144,6 +154,18 @@
}
public void visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels) {
+ StringBuilder insn = new StringBuilder();
+ insn.append("TABLESWITCH {");
+ String comma = "";
+ for (int i = min; i <= max; i++) {
+ insn.append(comma);
+ comma = ",";
+ insn.append(i);
+ insn.append(':');
+ insn.append(labels[i-min].toString());
+ }
+ insn.append("}");
+ emitInsn(insn.toString());
mv.visitTableSwitchInsn(min, max, dflt, labels);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|