annotate lisp/ilisp/cmulisp.lisp @ 119:d101af7320b8

Added tag r20-1b11 for changeset 7d55a9ba150c
author cvs
date Mon, 13 Aug 2007 09:24:19 +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 ;;; cmulisp.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 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Todd Kaufmann May 1990
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; Make CMU CL run better within GNU inferior-lisp (by ccm).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (in-package "ILISP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;;% CMU CL does not define defun as a macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (defun ilisp-compile (form package filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 "Compile FORM in PACKAGE recording FILENAME as the source file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (ilisp-errors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (ilisp-eval
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (format nil "(funcall (compile nil '(lambda () ~A)))" form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 package filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;;% Stream settings, when running connected to pipes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;; This fixes a problem when running piped: When CMU is running as a piped
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;; process, *terminal-io* really is a terminal; ie, /dev/tty. This means an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;; error will cause lisp to stop and wait for input from /dev/tty, which it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;; won't be able to grab, and you'll have to restart your lisp. But we want
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;; it to use the same input that the user is typing in, ie, the pipe (stdin).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;; This fixes that problem, which only occurs in the CMU cores of this year.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (defvar *Fix-pipe-streams* T
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 "Set to Nil if you want them left alone. And tell me you don't get stuck.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (when (and *Fix-pipe-streams*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (lisp::synonym-stream-p *terminal-io*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (eq (lisp::synonym-stream-symbol *terminal-io*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 'SYSTEM::*TTY*))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (setf *terminal-io* (make-two-way-stream system::*stdin* system::*stdout*))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; *query-io* and *debug-io* are synonym streams to this, so this fixes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;; everything.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;;% Debugger extensions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;;;%% Implementation of a :pop command for CMU CL debugger
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;; Normally, errors which occur while in the debugger are just ignored, unless
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;; the user issues the "flush" command, which toggles this behavior.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (setq debug:*flush-debug-errors* nil) ;; allow multiple error levels.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;;; This implementation of "POP" simply looks for the first restart that says
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;; "Return to debug level n" or "Return to top level." and executes it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (debug::def-debug-command "POP" #+:new-compiler ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; find the first "Return to ..." restart
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (if (not (boundp 'debug::*debug-restarts*))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (error "You're not in the debugger; how can you call this!?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (labels ((find-return-to (restart-list num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (let ((first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (member-if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 #'(lambda (restart)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (string= (funcall
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (conditions::restart-report-function restart)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 "Return to " :end1 10))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 restart-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (cond ((zerop num) (car first))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ((cdr first) (find-return-to (cdr first) (1- num)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (let* ((level (debug::read-if-available 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (first-return-to (find-return-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 debug::*debug-restarts* (1- level))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (if (null first-return-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (format *debug-io* "pop: ~d is too far" level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (debug::invoke-restart-interactively first-return-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;;;%% arglist/source-file utils.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (defun get-correct-fn-object (sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 "Deduce how to get the \"right\" function object and return it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (let ((fun (or (macro-function sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (and (fboundp sym) (symbol-function sym)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (cond (fun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (when (and (= (lisp::get-type fun) #.vm:closure-header-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (not (eval:interpreted-function-p fun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (setq fun (lisp::%closure-function fun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (error "Unknown function ~a. Check package." sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (export '(arglist source-file cmulisp-trace))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;;;%% arglist - return arglist of function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (defun arglist (symbol package)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (ilisp-errors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (let* ((x (ilisp-find-symbol symbol package))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (fun (get-correct-fn-object x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (cond ((eval:interpreted-function-p fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (eval:interpreted-function-arglist fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ((= (lisp::get-type fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 #.vm:funcallable-instance-header-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;; generic function / method
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (pcl::generic-function-pretty-arglist fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ((compiled-function-p fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (let ((string-or-nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (#+CMU17 lisp::%function-arglist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 #-CMU17 lisp::%function-header-arglist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 fun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (if string-or-nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (read-from-string string-or-nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 "No argument info.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (t (error "Unknown type of function")))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;;; source-file symbol package type --
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;;; New version provided by Richard Harris <rharris@chestnut.com> with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;;; suggestions by Larry Hunter <hunter@work.nlm.nih.gov>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (defun source-file (symbol package type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (declare (ignore type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (ilisp-errors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (let* ((x (ilisp-find-symbol symbol package))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (fun (get-correct-fn-object x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (when (and fun (not (eval:interpreted-function-p fun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;; The hack above is necessary because CMUCL does not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;; correctly record source file information when 'loading'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;; a non compiled file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;; In this case we fall back on the TAGS machinery.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;; (At least as I underestand the code).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;; Marco Antoniotti 11/22/94.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (cond (#+CMU17 (pcl::generic-function-p fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 #-CMU17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (= (lisp::get-type fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 #.vm:funcallable-instance-header-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (dolist (method (pcl::generic-function-methods fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (print-simple-source-info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (or #+CMU17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (pcl::method-fast-function method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (pcl::method-function method))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (t (print-simple-source-info fun)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;;; Old version. Left here for the time being.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;(defun source-file (symbol package type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ; (declare (ignore type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ; (ilisp-errors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ; (let* ((x (ilisp-find-symbol symbol package))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ; (fun (get-correct-fn-object x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ; (when fun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ; (cond ((= (lisp::get-type fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ; #.vm:funcallable-instance-header-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ; ;; A PCL method! Uh boy!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ; (dolist (method (pcl::generic-function-methods fun))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ; (print-simple-source-info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ; (lisp::%closure-function (pcl::method-function method))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ; t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ; (t (print-simple-source-info fun)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;;; Patch suggested by Richard Harris <rharris@chestnut.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;;; FUN-DEFINED-FROM-PATHNAME takes a symbol or function object. It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;;; returns a pathname for the file the function was defined in. If it was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;;; not defined in some file, then nil is returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;;; FUN-DEFINED-FROM-PATHNAME is from hemlock/rompsite.lisp (cmucl17f),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;;; with added read-time conditionalization to work in older versions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ;;; of cmucl. It may need a little bit more conditionalization for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;;; some older versions of cmucl.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (defun fun-defined-from-pathname (function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 "Returns the file where FUNCTION is defined in (if the file can be found).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 Takes a symbol or function and returns the pathname for the file the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 function was defined in. If it was not defined in some file, nil is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 returned."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (flet ((frob (code)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (let ((info #+CMU17 (kernel:%code-debug-info code)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 #-CMU17 (kernel:code-debug-info code)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (when info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (let ((sources (c::debug-info-source info)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (when sources
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (let ((source (car sources)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (when (eq (c::debug-source-from source) :file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (c::debug-source-name source)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (typecase function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (symbol (fun-defined-from-pathname (fdefinition function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 #+CMU17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (kernel:byte-closure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (fun-defined-from-pathname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (kernel:byte-closure-function function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 #+CMU17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (kernel:byte-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (frob (c::byte-function-component function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (frob (kernel:function-code-header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (kernel:%function-self function))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (t nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;;; print-simple-source-info --
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;;; Patches suggested by Larry Hunter <hunter@work.nlm.nih.gov> and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ;;; Richard Harris <rharris@chestnut.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ;;; Nov 21, 1994.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (defun print-simple-source-info (fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (let ((path (fun-defined-from-pathname fun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (when (and path (probe-file path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (print (namestring (truename path)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 ;;; Old version (semi patched). Left here for the time being.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ;(defun print-simple-source-info (fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ; (let ((info (#+CMU17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ; kernel:%code-debug-info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ; #-CMU17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ; kernel:code-debug-info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ; (kernel:function-code-header fun))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 ; (when info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ; (let ((sources (c::compiled-debug-info-source info)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ; (when sources
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ; (dolist (source sources)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 ; (let ((name (c::debug-source-name source)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ; (when (eq (c::debug-source-from source) :file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ; ;; Patch suggested by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ; ;; hunter@work.nlm.nih.gov (Larry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ; ;; Hunter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ; ;; (print (namestring name)) ; old
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ; (print (truename name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ; )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ; t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (defun cmulisp-trace (symbol package breakp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 "Trace SYMBOL in PACKAGE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (ilisp-errors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (let ((real-symbol (ilisp-find-symbol symbol package)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (setq breakp (read-from-string breakp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (when real-symbol (eval `(trace ,real-symbol :break ,breakp))))))