/[slime]/slime/null-swank-impl.lisp
ViewVC logotype

Contents of /slime/null-swank-impl.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Fri Dec 19 01:08:59 2003 UTC (10 years, 4 months ago) by lgorrie
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +1 -1 lines
FILE REMOVED
Deleted this old file. See swank-backend.lisp instead.
1 ;;;; -*- Mode: lisp; indent-tabs-mode: nil -*-
2 ;;;
3 ;;; null-swank-impl.lisp --- Empty SWANK-IMPL reference implementation.
4 ;;;
5 ;;; Copyright (C) 2003, James Bielman <jamesjb@jamesjb.com>
6 ;;; Released into the public domain; all warranties are disclaimed.
7 ;;;
8 ;;; $Id: null-swank-impl.lisp,v 1.4 2003/12/19 01:08:59 lgorrie dead $
9 ;;;
10
11 ;; The "SWANK-IMPL" package contains functions that access the naughty
12 ;; bits of the Lisp implementation, such as debugger or compiler
13 ;; internals. In an ideal world, each function in this package would
14 ;; be a thin wrapper around a public interface defined by the vendor
15 ;; that massages the input/output into the format we need.
16 ;;
17 ;; Additionally, there is nothing Slime-specific about the functions
18 ;; in this module---ilisp could use this as a portability layer, for
19 ;; example.
20 ;;
21 ;; This is the simplest possible SWANK-IMPL implementation; it signals
22 ;; unimplemented errors for all exported entry points. When porting
23 ;; Swank to new Lisp implementations, start by copying this interface.
24 ;;
25 ;; Open Issues:
26 ;;
27 ;; We need to work out exactly what "source position designators" are;
28 ;; for now I'm assuming the plists that we use currently---is it worth
29 ;; formalizing that into a class that we flatten to/from a plist
30 ;; during transmission to Emacs? What about the plists used for frame
31 ;; locals?
32 ;;
33 ;; Currently there is some duplicate functionality in the compiler
34 ;; note and xref source position plist stuff. It might be useful to
35 ;; merge both these things into the aforementioned position
36 ;; designators.
37 ;;
38 ;; There is some inconsistency about when the functions in this module
39 ;; return nil or signal a not-implemented-error---I think what's in
40 ;; here is the right thing but it may be worth specifying precisely
41 ;; for each exported function whether it must return a meaningful
42 ;; value or not.
43 ;;
44 ;; Many of these functions have the same name as the slimefuns defined
45 ;; in swank.lisp---this is okay but the intent is not to use the
46 ;; functions defined here as the slimefuns; instead the entry points
47 ;; should package-qualify calls into SLIME-IMPL (or we could rename
48 ;; everything).
49 ;;
50 ;; I haven't attempt to refactor the inspector in the CMU backend.
51
52 ;;; Administrivia
53
54 (defpackage :null-swank-impl
55 ;; Commented out because this conflicts with the existing
56 ;; "SWANK-IMPL" package, we'll want to uncomment this eventually.
57 ;; (:nicknames :swank-impl)
58 (:use :common-lisp)
59 (:export
60 #:backtrace
61 #:compile-file-trapping-conditions
62 #:compile-stream-trapping-conditions
63 #:compiler-condition
64 #:compiler-condition-message
65 #:compiler-condition-original-condition
66 #:compiler-condition-source-pathname
67 #:compiler-condition-source-position
68 #:compiler-error
69 #:compiler-note
70 #:compiler-style-warning
71 #:compiler-warning
72 #:debug-condition
73 #:define-debugger-hook
74 #:eval-in-frame
75 #:frame-catch-tags
76 #:frame-locals
77 #:frame-source-position
78 #:function-arglist
79 #:function-source-location
80 #:not-implemented-error
81 #:not-implemented-function-name
82 #:setf-function-name
83 #:type-information
84 #:walk-form
85 #:who-binds
86 #:who-calls
87 #:who-macroexpands
88 #:who-sets))
89
90 (in-package :null-swank-impl)
91
92 ;;; Conditions and Handlers
93
94 ;; XXX We may want to move the conditions out of here to avoid
95 ;; duplicating them. The intent was to specify a general interface
96 ;; but allow each backend to add extra slots or derive from
97 ;; implementation-specific conditions. I don't know if that will be
98 ;; useful.
99
100 ;; Condition signalled when functionality is not implemented for this
101 ;; Lisp. It is desirable to handle this and notify the user
102 ;; accordingly.
103 (define-condition not-implemented-error (error)
104 ((function-name
105 ;; The name of the unimplemented function.
106 :reader not-implemented-function-name
107 :initarg :function-name))
108 (:report (lambda (condition stream)
109 (format stream "The Slime function ~S is not implemented."
110 (not-implemented-function-name condition)))))
111
112 ;; Base condition type for compiler errors, warnings, and notes.
113 (define-condition compiler-condition (condition)
114 ((original-condition
115 ;; The original condition signalled by the compiler, if appropriate.
116 ;; May be nil if the compiler does not report using conditions.
117 :initarg :original-condition
118 :reader compiler-condition-original-condition)
119
120 (message
121 ;; The error or warning message, must be a non-nil string.
122 ;; [Would it be better to make this a method?]
123 :initarg :message
124 :reader compiler-condition-message)
125
126 (source-pathname
127 ;; A pathname designator of the source file in which the condition
128 ;; originated, or nil if no pathname information is available.
129 :initarg :source-pathname
130 :reader compiler-condition-source-pathname)
131
132 (source-position
133 ;; A "source position designator" indicating the precise location
134 ;; within SOURCE-PATHNAME of the condition.
135 :initarg :source-position
136 :reader compiler-condition-source-position)))
137
138 ;; Portable interface for errors during complication.
139 (define-condition compiler-error (compiler-condition)
140 ())
141
142 ;; Portable interface to warnings during compilation.
143 (define-condition compiler-warning (compiler-condition)
144 ())
145
146 ;; Portable interface to compiler style warnings.
147 (define-condition compiler-style-warning (compiler-condition)
148 ())
149
150 ;; Portable interface to informational compiler notes.
151 (define-condition compiler-note (compiler-condition)
152 ())
153
154 ;; XXX what is this used for?
155 (define-condition debug-condition (condition)
156 ())
157
158 ;;; Compilation
159
160 (defun compile-file-trapping-conditions (filename &key (load t))
161 "Compile FILENAME like COMPILE-FILE but resignal compilation
162 conditions as Swank compiler conditions."
163 (declare (ignore filename load))
164 (error 'not-implemented-error
165 :function-name 'compile-file-trapping-conditions))
166
167 (defun compile-stream-trapping-conditions (stream &key
168 filename position (load t))
169 "Compile source from STREAM. During compilation, compiler
170 conditions must be trapped and resignalled as
171 COMPILER-CONDITIONs.
172
173 If supplied, FILENAME and POSITION are used in any cross
174 referencing or source file recording systems supported by the
175 compiler.
176
177 Additionally, if POSITION is supplied, it must be added to
178 source positions reported in compiler conditions."
179 (declare (ignore stream filename position load))
180 (error 'not-implemented-error
181 :function-name 'compile-stream-trapping-conditions))
182
183 ;;; Symbol and Function Introspection
184
185 (defun function-arglist (symbol)
186 "Return the function argument list of SYMBOL if it is fbound,
187 either as a list of symbols, a string or nil if no such function
188 exists or no argument list is available."
189 (declare (ignore symbol))
190 nil)
191
192 (defun type-information (type-name)
193 "Return information XXX in what format about TYPE-NAME."
194 (declare (ignore type-name))
195 nil)
196
197 (defun setf-function-name (symbol)
198 "Given a function name, return the compiler's notion of the
199 function name of (SETF SYMBOL), or nil if no such symbol exists
200 or cannot be calculated. This is used by SWANK:APROPOS to show
201 documentation for (setf foo)."
202 (declare (ignore symbol))
203 nil)
204
205 (defun walk-form (form)
206 "Recursively expand all macros in FORM and return the result
207 expression."
208 (declare (ignore form))
209 (error 'not-implemented-error :function-name 'walk-form))
210
211 ;;; Cross-Referencing
212
213 ;; XXX do these return "source position designators" the same as the
214 ;; compiler note conditions? in the current slime these seem to be
215 ;; handled differently---we should probably merge them
216
217 (defun function-source-location (function-name)
218 "Return the canonical source location of the definition of
219 FUNCTION-NAME."
220 (declare (ignore function-name))
221 (error 'not-implemented-error :function-name 'function-source-location))
222
223 (defun who-calls (symbol)
224 "Return the places where FUNCTION-NAME is called."
225 (declare (ignore symbol))
226 (error 'not-implemented-error :function-name 'who-calls))
227
228 (defun who-references (variable-name)
229 "Return the places where VARIABLE-NAME is referenced."
230 (declare (ignore variable-name))
231 (error 'not-implemented-error :function-name 'who-references))
232
233 (defun who-binds (variable-name)
234 "Return the places where VARIABLE-NAME is bound."
235 (declare (ignore variable-name))
236 (error 'not-implemented-error :function-name 'who-binds))
237
238 (defun who-sets (variable-name)
239 "Return the places where VARIABLE-NAME is set."
240 (declare (ignore variable-name))
241 (error 'not-implemented-error :function-name 'who-sets))
242
243 (defun who-macroexpands (macro)
244 "Return the places where MACRO is expanded."
245 (declare (ignore macro))
246 (error 'not-implemented-error :function-name 'who-macroexpands))
247
248 ;;; Debugging
249
250 (defmacro define-debugger-hook (name (condition hook) &body body)
251 "Define a function NAME taking arguments CONDITION and HOOK.
252
253 Before executing BODY, the defined function executes whatever
254 implementation-specific setup is necessary to enable other
255 SWANK-IMPL debugging functions to work.
256
257 This usually consists of marking the current frame pointer
258 somehow as to avoid seeing the Slime debugger itself in the
259 backtrace. For some backends there is no setup and this macro
260 simply expands into DEFUN."
261 `(defun ,name (,condition ,hook)
262 ,@body))
263
264 (defun backtrace (&optional (start 0) (end most-positive-fixnum))
265 "Return a list containing a backtrace of the condition current
266 being debugged. The results are unspecified if this function is
267 called outside the dynamic contour of a debugger hook defined by
268 DEFINE-DEBUGGER-HOOK.
269
270 START and END are zero-based indices constraining the number of
271 frames returned. Frame zero is defined as the frame which invoked
272 the debugger.
273
274 The backtrace is returned as a list of tuples of the form
275 \(FRAME-NUMBER FRAME-DESCRIPTION), where FRAME-NUMBER is the
276 index of the frame, defined like START/END, and FRAME-DESCRIPTION
277 is a string containing text to display in the debugger for this
278 frame.
279
280 An example return value:
281
282 ((0 \"(HELLO \"world\")\")
283 (1 \"(RUN-EXCITING-LISP-DEMO)\")
284 (2 \"(SYS::%TOPLEVEL #<SYS::ENVIRONMENT #x394834>)\"))"
285 (declare (ignore start end))
286 (error 'not-implemented-error :function-name 'backtrace))
287
288 (defun frame-source-position (frame-number)
289 "Return a source position designator for a debugger stack frame
290 index. The results are undefined unless this is called within
291 the dynamic contour of a function defined by
292 DEFINE-DEBUGGER-HOOK.
293
294 FRAME-NUMBER must be a positive integer with 0 indicating the
295 frame which invoked the debugger."
296 (declare (ignore frame-number))
297 nil)
298
299 (defun frame-catch-tags (frame-number)
300 "Return a list of XXX list of what? catch tags for a debugger
301 stack frame. The results are undefined unless this is called
302 within the dynamic contour of a function defined by
303 DEFINE-DEBUGGER-HOOK."
304 (declare (ignore frame-number))
305 nil)
306
307 (defun frame-locals (frame-number)
308 "Return a list of XXX local variable designators define me
309 for a debugger stack frame. The results are undefined unless
310 this is called within the dynamic contour of a function defined
311 by DEFINE-DEBUGGER-HOOK."
312 (declare (ignore frame-number))
313 nil)
314
315 (defun eval-in-frame (form frame-number)
316 "Evaluate a Lisp form in the lexical context of a stack frame
317 in the debugger. The results are undefined unless called in the
318 dynamic contour of a function defined by DEFINE-DEBUGGER-HOOK.
319
320 FRAME-NUMBER must be a positive integer with 0 indicating the
321 frame which invoked the debugger.
322
323 The return value is the result of evaulating FORM in the
324 appropriate context."
325 (declare (ignore form frame-number))
326 (error 'not-implemented-error :function-name 'eval-in-frame))

  ViewVC Help
Powered by ViewVC 1.1.5