[armedbear-cvs] r12518 - trunk/abcl/src/org/armedbear/lisp
Mark Evenson
mevenson at common-lisp.net
Thu Mar 4 14:52:38 UTC 2010
Author: mevenson
Date: Thu Mar 4 09:52:35 2010
New Revision: 12518
Log:
*DISASSEMBLER* may now contain a function to return the disassembler command.
If *DISASSEMBLER* contains a function it specifies the command string
to use for the DISASSEMBLE primitive by taking an argument for the
pathname containing the class bytes and returning the string of a
command that will output a representation to standard output. We also
change the default suffix of the temporary file to ".class". All of
this now enables "javap" to be used as the dissambler with the
following assignment (in "~/.abclrc" for example):
(setf *disassembler*
(lambda (p)
(let ((class (make-pathname :name (pathname-name p)))
(path (directory-namestring p)))
(format nil "javap -c -l -verbose -classpath ~A ~A" path class))))
It might be nice in the future if ABCL had a default value of
*DISASSEMBLER* that would actually probe the filesystem for the
existence of the various disassmemblers for fallback strategies.
Modified:
trunk/abcl/src/org/armedbear/lisp/disassemble_class_bytes.java
Modified: trunk/abcl/src/org/armedbear/lisp/disassemble_class_bytes.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/disassemble_class_bytes.java (original)
+++ trunk/abcl/src/org/armedbear/lisp/disassemble_class_bytes.java Thu Mar 4 09:52:35 2010
@@ -53,23 +53,28 @@
if (arg instanceof JavaObject) {
byte[] bytes = (byte[]) ((JavaObject)arg).getObject();
try {
- File file = File.createTempFile("abcl", null, null);
+ File file = File.createTempFile("abcl", ".class", null);
FileOutputStream out = new FileOutputStream(file);
out.write(bytes);
out.close();
LispObject disassembler = _DISASSEMBLER_.symbolValue();
+ StringBuffer command = new StringBuffer();
if (disassembler instanceof AbstractString) {
- StringBuffer sb = new StringBuffer(disassembler.getStringValue());
- sb.append(' ');
- sb.append(file.getPath());
- ShellCommand sc = new ShellCommand(sb.toString(), null, null);
- sc.run();
- file.delete();
- return new SimpleString(sc.getOutput());
- } else
+ command.append(disassembler.getStringValue());
+ command.append(" ");
+ command.append(file.getPath());
+ } else if (disassembler instanceof Operator) {
+ Pathname p = Pathname.makePathname(file);
+ LispObject commandResult = disassembler.execute(p);
+ command.append(commandResult.getStringValue());
+ } else {
return new SimpleString("No disassembler is available.");
- }
- catch (IOException e) {
+ }
+ ShellCommand sc = new ShellCommand(command.toString(), null, null);
+ sc.run();
+ file.delete();
+ return new SimpleString(sc.getOutput());
+ } catch (IOException e) {
Debug.trace(e);
}
}
More information about the armedbear-cvs
mailing list