From: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - 2007-10-08 10:05:53
|
On 10/8/07, Mark Evenson <mar...@gm...> wrote: > XXXXXXXXXXXXXX wrote: > > >> What I don't understand is that if I just compile a function from the > >> REPL like: > >> > >> (compile 'f '(lambda () (jcall (jmethod "java.lang.Object" "toString") > >> (jclass "java.lang.String")))) > >> > >> this returns the expected "class java.lang.String". What is different > >> from such an compiled function and one loaded from an 'abcl' file? > > > > If you compile a file and you want to inspect the output files, there > > are 2 things you can do: unzip the files and inspect them with a > > binary/text editor (binary for .cls files; text for .abcl files). Or > > you can make sure they don't get compressed by enclosing the > > COMPILE-FILE call in the following LET form: > > > > (let ((system:*compile-file-zip* nil)) > > (compile-file ...)) > > My problem is not getting the compiled representation after its been > written to disk. I mean getting at the representation after a function > has been compiled, but not written to an *.abcl: > > CL-USER> (defun foo () 1) > FOO > CL-USER> (type-of #'foo) > FUNCTION > CL-USER> (compile 'foo) > FOO > NIL > NIL > CL-USER> (type-of #'foo) > COMPILED-FUNCTION > CL-USER> > > One could construct a tool that uses the byte-code representation > available from: > > CL-USER> (getf (system:function-plist #'foo) 'system:class-bytes) > > but since I didn't see an easy way to do this other than serializing the > bytes to disk, and calling the dissassembler anyways, I didn't really > pursue the task. Note to future ABCL compiler hackers (including > myself): a useful utility would be to create a decent java-byte code > dissassembler as ABCL Lisp code. Most of the work is already present > in 'jvm.lisp'. You are aware that there's a facility built into abcl which uses JAD (http://www.kpdus.com/jad.html) as the disassembler? It's underdocumented (I learned about it when chatting on IRC with Peter), but if jad is on your path, abcl calls it to generate (disassemble ) output. HTH, Erik. |