annotate lisp/ilisp/lucid.lisp @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children b82b59fe008d
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 ;;; lucid.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.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;;; Version: 5.7
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; 1994, 1995 Marco Antoniotti and Rick Busdiecker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; Other authors' names for which this Copyright notice also holds
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; may appear later in this file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; Send mail to 'ilisp-request@lehman.com' to be included in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; ILISP mailing list. 'ilisp@lehman.com' is the general ILISP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;; mailing list were bugs and improvements are discussed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; ILISP is freely redistributable under the terms found in the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; COPYING.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
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 ;;; Lucid initializations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; Author: Chris McConnell, ccm@cs.cmu.edu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 (in-package "ILISP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (defun ilisp-callers (symbol package &aux (list-of-callers nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 "Print the callers of PACKAGE::SYMBOL. Only compiled functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 currently. Return T if successful."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (ilisp-errors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (let ((function-name (ilisp-find-symbol symbol package))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (*print-level* nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (*print-length* nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (*package* (find-package 'lisp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (when (and function-name (fboundp function-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (flet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ((check-symbol (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (labels
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ((check-function (function &optional exclusions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (do ((i 4 (1+ i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ((>= i (lucid::procedure-length function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (let ((element (sys:procedure-ref function i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (cond ((eq element function-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (pushnew symbol list-of-callers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ((and (compiled-function-p element)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (not (find element exclusions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (check-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (cons element exclusions))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (check-function (symbol-function symbol)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (do-all-symbols (symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (when (fboundp symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (check-symbol symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (dolist (caller list-of-callers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (print caller))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (defun ilisp-source-files (symbol package type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 "Print each file for PACKAGE:SYMBOL's TYPE definition on a line and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 return T if successful."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (ilisp-errors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (let* ((symbol (ilisp-find-symbol symbol package))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (all (equal type "any"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (type (unless all (ilisp-find-symbol type package)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (paths (when symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (lucid::get-source-file symbol type all))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (if paths
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (if all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (dolist (file (remove-duplicates paths
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 :key #'cdr :test #'equal))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (print (namestring (cdr file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (print (namestring paths)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 nil))))
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 (dolist (symbol '(ilisp-callers ilisp-source-files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (export symbol))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (unless (compiled-function-p #'ilisp-callers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (format t "\"ILISP: File is not compiled, use M-x ilisp-compile-inits\""))