;;; -*- Mode: Lisp -*-
;;; lispworks.lisp --
;;; This file is part of ILISP.
;;; Version: 5.8
;;; Copyright (C) 1990, 1991, 1992, 1993 Chris McConnell
;;; 1993, 1994 Ivan Vasquez
;;; 1994, 1995, 1996 Marco Antoniotti and Rick Busdiecker
;;; 1996 Marco Antoniotti and Rick Campbell
;;; Other authors' names for which this Copyright notice also holds
;;; may appear later in this file.
;;; Send mail to 'email@example.com' to be included in the
;;; ILISP mailing list. 'firstname.lastname@example.org' is the general ILISP
;;; mailing list were bugs and improvements are discussed.
;;; ILISP is freely redistributable under the terms found in the file
;;; LispWorks ILISP initializations.
;;; Independently written by:
;;; Jason Trenouth: email@example.com
;;; Qiegang Long: firstname.lastname@example.org
;;; and later merged together by Jason
(defun ilisp-callers (symbol package)
"Print a list of all of the functions that call FUNCTION.
Return T if successful."
(let ((function-name (ilisp-find-symbol symbol package))
(*package* (find-package 'lisp))
(when (and function-name (fboundp function-name))
(setf callers (munge-who-calls (lw:who-calls function-name)))
(dolist (caller callers)
;; gross hack to munge who-calls output for ILISP
(defun munge-who-calls (who-calls)
(labels ((top-level-caller (form)
(if (atom form)
(top-level-caller (second form)))))
(delete-duplicates (mapcar #'top-level-caller who-calls)))))
;; Jason 6 SEP 94 -- tabularized Qiegang's code
;; There are some problems lurking here:
;; - the mapping ought to be done by LispWorks
;; - surely you really want just three source types:
;; function, type, and variable
("variable" defvar defparameter defconstant)
(defun translate-source-type-to-dspec (symbol type)
(let ((entry (find type *source-type-translations*
:key 'first :test 'equal)))
(let ((wrappers (rest entry)))
(loop for wrap in wrappers collecting `(,wrap ,symbol))
(error "unknown source type for ~S requested from ILISP: ~S"
(defun ilisp-source-files (symbol package type)
"Print each file for PACKAGE:SYMBOL's TYPE definition on a line and
return T if successful. A function to limit the search with type?"
(let* ((symbol (ilisp-find-symbol symbol package))
(all (equal type "any"))
(paths (when symbol (compiler::find-source-file symbol)))
(dspecs (or all (translate-source-type-to-dspec symbol type)))
(if (and paths (not all))
(loop for path in paths
when (find (car path) dspecs :test 'equal)
(setq cands paths))
(dolist (file (remove-duplicates paths
:key #'cdr :test #'equal))
(print (namestring (cadr file))))
(unless (compiled-function-p #'ilisp-callers)
(format t "\"ILISP: File is not compiled, use M-x ilisp-compile-inits\""))
;;; end of file -- lispworks.lisp --