0
|
1 ;;; -*- Mode: Lisp -*-
|
|
2
|
|
3 ;;; lispworks.lisp --
|
|
4
|
|
5 ;;; This file is part of ILISP.
|
4
|
6 ;;; Version: 5.8
|
0
|
7 ;;;
|
|
8 ;;; Copyright (C) 1990, 1991, 1992, 1993 Chris McConnell
|
|
9 ;;; 1993, 1994 Ivan Vasquez
|
4
|
10 ;;; 1994, 1995, 1996 Marco Antoniotti and Rick Busdiecker
|
|
11 ;;; 1996 Marco Antoniotti and Rick Campbell
|
0
|
12 ;;;
|
|
13 ;;; Other authors' names for which this Copyright notice also holds
|
|
14 ;;; may appear later in this file.
|
|
15 ;;;
|
4
|
16 ;;; Send mail to 'ilisp-request@naggum.no' to be included in the
|
|
17 ;;; ILISP mailing list. 'ilisp@naggum.no' is the general ILISP
|
0
|
18 ;;; mailing list were bugs and improvements are discussed.
|
|
19 ;;;
|
|
20 ;;; ILISP is freely redistributable under the terms found in the file
|
|
21 ;;; COPYING.
|
|
22
|
|
23
|
|
24
|
|
25 ;;; LispWorks ILISP initializations.
|
|
26 ;;;
|
|
27 ;;; Independently written by:
|
|
28 ;;;
|
|
29 ;;; Jason Trenouth: jason@harlequin.co.uk
|
|
30 ;;; Qiegang Long: qlong@cs.umass.edu
|
|
31 ;;;
|
|
32 ;;; and later merged together by Jason
|
|
33
|
|
34
|
|
35 (in-package "ILISP")
|
|
36
|
|
37 (defun ilisp-callers (symbol package)
|
|
38 "Print a list of all of the functions that call FUNCTION.
|
|
39 Return T if successful."
|
|
40 (ilisp-errors
|
|
41 (let ((function-name (ilisp-find-symbol symbol package))
|
|
42 (*print-level* nil)
|
|
43 (*print-length* nil)
|
|
44 (*package* (find-package 'lisp))
|
|
45 (callers ())
|
|
46 )
|
|
47 (when (and function-name (fboundp function-name))
|
|
48 (setf callers (munge-who-calls (lw:who-calls function-name)))
|
|
49 (dolist (caller callers)
|
|
50 (print caller))
|
|
51 t))))
|
|
52
|
|
53 ;; gross hack to munge who-calls output for ILISP
|
|
54 (defun munge-who-calls (who-calls)
|
|
55 (labels ((top-level-caller (form)
|
|
56 (if (atom form)
|
|
57 form
|
|
58 (top-level-caller (second form)))))
|
|
59 (delete-if-not 'symbolp
|
|
60 (delete-duplicates (mapcar #'top-level-caller who-calls)))))
|
|
61
|
|
62
|
|
63 ;; Jason 6 SEP 94 -- tabularized Qiegang's code
|
|
64 ;;
|
|
65 ;; There are some problems lurking here:
|
|
66 ;; - the mapping ought to be done by LispWorks
|
|
67 ;; - surely you really want just three source types:
|
|
68 ;; function, type, and variable
|
|
69 ;;
|
|
70 (defconstant *source-type-translations*
|
|
71 '(
|
|
72 ("class" defclass)
|
|
73 ("function" )
|
|
74 ("macro" )
|
|
75 ("structure" defstruct)
|
|
76 ("setf" defsetf)
|
|
77 ("type" deftype)
|
|
78 ("variable" defvar defparameter defconstant)
|
|
79 ))
|
|
80
|
|
81
|
|
82 (defun translate-source-type-to-dspec (symbol type)
|
|
83 (let ((entry (find type *source-type-translations*
|
|
84 :key 'first :test 'equal)))
|
|
85 (if entry
|
|
86 (let ((wrappers (rest entry)))
|
|
87 (if wrappers
|
|
88 (loop for wrap in wrappers collecting `(,wrap ,symbol))
|
|
89 `(,symbol)))
|
|
90 (error "unknown source type for ~S requested from ILISP: ~S"
|
|
91 symbol type))))
|
|
92
|
|
93
|
|
94 (defun ilisp-source-files (symbol package type)
|
|
95 "Print each file for PACKAGE:SYMBOL's TYPE definition on a line and
|
|
96 return T if successful. A function to limit the search with type?"
|
|
97 (ilisp-errors
|
|
98 (let* ((symbol (ilisp-find-symbol symbol package))
|
|
99 (all (equal type "any"))
|
|
100 (paths (when symbol (compiler::find-source-file symbol)))
|
|
101 (dspecs (or all (translate-source-type-to-dspec symbol type)))
|
|
102 (cands ())
|
|
103 )
|
|
104 (if (and paths (not all))
|
|
105 (setq cands
|
|
106 (loop for path in paths
|
|
107 when (find (car path) dspecs :test 'equal)
|
|
108 collect path))
|
|
109 (setq cands paths))
|
|
110 (if cands
|
|
111 (progn
|
|
112 (dolist (file (remove-duplicates paths
|
|
113 :key #'cdr :test #'equal))
|
|
114 (print (namestring (cadr file))))
|
|
115 t)
|
|
116 nil))))
|
|
117
|
|
118 (unless (compiled-function-p #'ilisp-callers)
|
|
119 (format t "\"ILISP: File is not compiled, use M-x ilisp-compile-inits\""))
|
|
120
|
|
121 ;;; end of file -- lispworks.lisp --
|