[Dashg-commit] SF.net SVN: dashg:[29] trunk/dashg/src/com/mebigfatguy/dashg
Status: Pre-Alpha
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2008-10-28 18:12:11
|
Revision: 29
http://dashg.svn.sourceforge.net/dashg/?rev=29&view=rev
Author: dbrosius
Date: 2008-10-28 18:12:04 +0000 (Tue, 28 Oct 2008)
Log Message:
-----------
Move in another direction, TraceClassVisitor caches output, which wrecks the notion that we can use it to get line numbers
Added Paths:
-----------
trunk/dashg/src/com/mebigfatguy/dashg/DashGClassSourcePrintingVisitor.java
trunk/dashg/src/com/mebigfatguy/dashg/DashGMethodSourcePrintingVisitor.java
Added: trunk/dashg/src/com/mebigfatguy/dashg/DashGClassSourcePrintingVisitor.java
===================================================================
--- trunk/dashg/src/com/mebigfatguy/dashg/DashGClassSourcePrintingVisitor.java (rev 0)
+++ trunk/dashg/src/com/mebigfatguy/dashg/DashGClassSourcePrintingVisitor.java 2008-10-28 18:12:04 UTC (rev 29)
@@ -0,0 +1,127 @@
+/*
+ * dashg - A debug symbols (-g) injector
+ * Copyright (C) 2008 Dave Brosius
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.mebigfatguy.dashg;
+
+import java.io.PrintWriter;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+
+public class DashGClassSourcePrintingVisitor implements ClassVisitor, DashGLineNumberer {
+
+ private ClassWriter cw;
+ private PrintWriter pw;
+ private String packageName;
+ private String clsName;
+ private int lineNumber = 1;
+
+ public DashGClassSourcePrintingVisitor(ClassWriter classWriter, PrintWriter srcWriter) {
+ cw = classWriter;
+ pw = srcWriter;
+ }
+
+ public int getLineNumber() {
+ return lineNumber;
+ }
+
+ public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
+ int dotPos = name.lastIndexOf('.');
+ if (dotPos >= 0) {
+ packageName = name.substring(0, dotPos);
+ clsName = name.substring(dotPos+1);
+
+ pw.println("package " + packageName + ";");
+ pw.println();
+
+ lineNumber += 2;
+ } else {
+ packageName = null;
+ clsName = name;
+ }
+
+ if ((access & Opcodes.ACC_PUBLIC) != 0) {
+ pw.print("public ");
+ } else if ((access & Opcodes.ACC_PRIVATE) != 0) {
+ pw.print("private ");
+ } else if ((access & Opcodes.ACC_PROTECTED) != 0) {
+ pw.print("protected ");
+ }
+
+ if ((access & Opcodes.ACC_STATIC) != 0) {
+ pw.println("static ");
+ } else if ((access & Opcodes.ACC_ABSTRACT) != 0) {
+ pw.print("abstract ");
+ }
+
+ if ((access & Opcodes.ACC_FINAL) != 0) {
+ pw.print("final ");
+ }
+
+ pw.print(clsName + ' ');
+
+ if (superName != null)
+ pw.print("extends " + superName + ' ');
+
+ String comma = "implements ";
+ for (String inf : interfaces) {
+ pw.print(comma);
+ comma = ", ";
+ pw.print(inf);
+ }
+
+ pw.println();
+
+ lineNumber+=1;
+
+ cw.visit(version, access, name, signature, superName, interfaces);
+ }
+
+ public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+ return null;
+ }
+
+ public void visitAttribute(Attribute attr) {
+ }
+
+ public void visitEnd() {
+ }
+
+ public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
+ return null;
+ }
+
+ public void visitInnerClass(String name, String outerName, String innerName, int access) {
+ }
+
+ public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
+ return new DashGMethodSourcePrintingVisitor(cw, pw);
+ }
+
+ public void visitOuterClass(String owner, String name, String desc) {
+ }
+
+ public void visitSource(String source, String debug) {
+ }
+
+}
Property changes on: trunk/dashg/src/com/mebigfatguy/dashg/DashGClassSourcePrintingVisitor.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/dashg/src/com/mebigfatguy/dashg/DashGMethodSourcePrintingVisitor.java
===================================================================
--- trunk/dashg/src/com/mebigfatguy/dashg/DashGMethodSourcePrintingVisitor.java (rev 0)
+++ trunk/dashg/src/com/mebigfatguy/dashg/DashGMethodSourcePrintingVisitor.java 2008-10-28 18:12:04 UTC (rev 29)
@@ -0,0 +1,119 @@
+/*
+ * dashg - A debug symbols (-g) injector
+ * Copyright (C) 2008 Dave Brosius
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.mebigfatguy.dashg;
+
+import java.io.PrintWriter;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+
+public class DashGMethodSourcePrintingVisitor implements MethodVisitor {
+
+ private ClassWriter cw;
+ private PrintWriter pw;
+
+ public DashGMethodSourcePrintingVisitor(ClassWriter cWriter, PrintWriter pWriter) {
+ cw = cWriter;
+ pw = pWriter;
+ }
+
+ public AnnotationVisitor visitAnnotation(String arg0, boolean arg1) {
+ return null;
+ }
+
+ public AnnotationVisitor visitAnnotationDefault() {
+ return null;
+ }
+
+ public void visitAttribute(Attribute arg0) {
+ }
+
+ public void visitCode() {
+ }
+
+ public void visitEnd() {
+ }
+
+ public void visitFieldInsn(int arg0, String arg1, String arg2, String arg3) {
+
+ }
+
+ public void visitFrame(int arg0, int arg1, Object[] arg2, int arg3,
+ Object[] arg4) {
+ }
+
+ public void visitIincInsn(int arg0, int arg1) {
+ }
+
+ public void visitInsn(int arg0) {
+ }
+
+ public void visitIntInsn(int arg0, int arg1) {
+ }
+
+ public void visitJumpInsn(int arg0, Label arg1) {
+ }
+
+ public void visitLabel(Label arg0) {
+ }
+
+ public void visitLdcInsn(Object arg0) {
+ }
+
+ public void visitLineNumber(int arg0, Label arg1) {
+ }
+
+ public void visitLocalVariable(String arg0, String arg1, String arg2,
+ Label arg3, Label arg4, int arg5) {
+ }
+
+ public void visitLookupSwitchInsn(Label arg0, int[] arg1, Label[] arg2) {
+ }
+
+ public void visitMaxs(int arg0, int arg1) {
+ }
+
+ public void visitMethodInsn(int arg0, String arg1, String arg2, String arg3) {
+ }
+
+ public void visitMultiANewArrayInsn(String arg0, int arg1) {
+ }
+
+ public AnnotationVisitor visitParameterAnnotation(int arg0, String arg1,
+ boolean arg2) {
+ return null;
+ }
+
+ public void visitTableSwitchInsn(int arg0, int arg1, Label arg2,
+ Label[] arg3) {
+ }
+
+ public void visitTryCatchBlock(Label arg0, Label arg1, Label arg2,
+ String arg3) {
+ }
+
+ public void visitTypeInsn(int arg0, String arg1) {
+ }
+
+ public void visitVarInsn(int arg0, int arg1) {
+ }
+}
Property changes on: trunk/dashg/src/com/mebigfatguy/dashg/DashGMethodSourcePrintingVisitor.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|