source: trunk/j/src/org/armedbear/lisp/disassemble.lisp @ 9266

Last change on this file since 9266 was 9230, checked in by piso, 16 years ago

sys:generic-function-discriminating-function => mop::funcallable-instance-function

File size: 1.9 KB
Line 
1;;; disassemble.lisp
2;;;
3;;; Copyright (C) 2005 Peter Graves
4;;; $Id: disassemble.lisp,v 1.3 2005-05-22 17:30:02 piso Exp $
5;;;
6;;; This program is free software; you can redistribute it and/or
7;;; modify it under the terms of the GNU General Public License
8;;; as published by the Free Software Foundation; either version 2
9;;; of the License, or (at your option) any later version.
10;;;
11;;; This program is distributed in the hope that it will be useful,
12;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with this program; if not, write to the Free Software
18;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
20(in-package #:system)
21
22(require '#:clos)
23
24(defun disassemble (fn)
25  (require-type fn '(OR FUNCTION
26                     SYMBOL
27                     (CONS (EQL SETF) (CONS SYMBOL NULL))
28                     (CONS (EQL LAMBDA) LIST)))
29  (when (symbolp fn)
30    (setf fn (symbol-function fn)))
31  (let ((function (cond ((typep fn 'generic-function)
32                         (mop::funcallable-instance-function fn))
33                        ((functionp fn)
34                         fn))))
35    (when (functionp function)
36      (unless (compiled-function-p function)
37        (setf function (compile nil function)))
38      (when (getf (function-plist function) 'class-bytes)
39        (with-input-from-string
40          (stream (disassemble-class-bytes (getf (function-plist function) 'class-bytes)))
41          (loop
42            (let ((line (read-line stream nil)))
43              (unless line (return))
44              (write-string "; ")
45              (write-string line)
46              (terpri))))
47        (return-from disassemble)))
48    (%format t "; Disassembly is not available.~%")))
Note: See TracBrowser for help on using the repository browser.