annotate lisp/ilisp/lispworks.lisp @ 128:13db4aa44a2e

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