/[slime]/slime/swank-backend.lisp
ViewVC logotype

Contents of /slime/swank-backend.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (hide annotations)
Sun Dec 7 19:16:24 2003 UTC (10 years, 4 months ago) by heller
Branch: MAIN
CVS Tags: SLIME-0-9
Changes since 1.6: +39 -5 lines
(function-source-locations): Is replaces
function-source-location-for-emacs. Make it at generic function.
(function-source-location-for-emacs): Remove.
1 lgorrie 1.1 ;;;; -*- Mode: lisp; indent-tabs-mode: nil; outline-regexp: ";;;;;*" -*-
2     ;;;
3     ;;; slime-impl.lisp --- Slime interface reference implementation.
4     ;;;
5     ;;; Copyright (C) 2003, James Bielman <jamesjb@jamesjb.com>
6     ;;; Released into the public domain.
7     ;;;
8 heller 1.7 ;;; $Id: swank-backend.lisp,v 1.7 2003/12/07 19:16:24 heller Exp $
9 lgorrie 1.1 ;;;
10    
11     ;; This is a skeletal implementation of the Slime internals interface.
12     ;;
13     ;; The idea is to create a de-facto standard interface that can be
14     ;; used by editor <-> CL integration software, such as Slime. Vendors
15     ;; are encouraged to comment on this interface.
16    
17     (defpackage :swank
18     (:use :common-lisp)
19 lgorrie 1.3 (:nicknames #:swank-backend)
20 lgorrie 1.1 (:export #:start-server #:create-swank-server
21 heller 1.5 #:*sldb-pprint-frames*
22     #:eval-string
23     #:interactive-eval-region
24     #:interactive-eval
25     #:pprint-eval
26     #:re-evaluate-defvar
27     #:listener-eval
28     #:swank-compile-file
29     #:swank-compile-string
30     #:compiler-notes-for-emacs
31     #:load-file
32     #:set-default-directory
33     #:set-package
34     #:list-all-package-names
35     #:getpid
36     #:disassemble-symbol
37     #:describe-symbol
38     #:describe-alien-type
39     #:describe-function
40     #:describe-type
41     #:describe-alien-struct
42     #:describe-class
43     #:describe-inspectee
44     #:describe-alien-union
45     #:describe-alien-enum
46     #:describe-setf-function
47     #:documentation-symbol
48     #:arglist-string
49     #:completions
50     #:apropos-list-for-emacs
51     #:inspect-nth-part
52     #:inspect-in-frame
53     #:init-inspector
54     #:quit-inspector
55     #:inspector-next
56     #:swank-macroexpand-all
57     #:swank-macroexpand
58     #:swank-macroexpand-1
59     #:untrace-all
60     #:toggle-trace-fdefinition
61 heller 1.7 #:find-function-locations
62 heller 1.5 #:who-binds
63     #:who-references
64     #:who-calls
65     #:who-sets
66     #:who-macroexpands
67     #:list-callers
68     #:list-callees
69     #:backtrace
70     #:frame-catch-tags
71     #:frame-source-position
72     #:frame-locals
73     #:throw-to-toplevel
74     #:inspector-pop
75     #:invoke-nth-restart
76     #:pprint-eval-string-in-frame
77     #:frame-source-location-for-emacs
78     #:eval-in-frame
79     #:eval-string-in-frame
80     #:sldb-abort
81     #:sldb-continue
82     #:take-input
83 dbarlow 1.6 #:slime-debugger-function
84 heller 1.5 ))
85 lgorrie 1.1
86     (in-package :swank)
87    
88    
89     ;;;; Conditions and Error Handling
90    
91     ;; XXX need to specify restart behavior for errors/warnings?
92    
93     (define-condition not-implemented-error (error)
94     ())
95    
96     (deftype severity () '(member :error :warning :style-warning :note))
97    
98     ;; Base condition type for compiler errors, warnings and notes.
99     (define-condition compiler-condition (condition)
100     ((original-condition
101     ;; The original condition thrown by the compiler if appropriate.
102     ;; May be NIL if a compiler does not report using conditions.
103     :initarg :original-condition
104     :accessor original-condition)
105    
106     (severity
107     :type severity
108     :initarg :severity
109     :accessor severity)
110    
111     (message
112     :initarg :message
113     :accessor message)
114    
115     (location
116     :initarg :location
117     :accessor location)))
118    
119    
120     ;;;; Compilation
121    
122     (defgeneric compile-string-for-emacs (string &key buffer position)
123     (:documentation
124     "Compile source from STRING. During compilation, compiler
125     conditions must be trapped and resignalled as COMPILER-CONDITIONs.
126    
127     If supplied, BUFFER and POSITION specify the source location in Emacs.
128    
129     Additionally, if POSITION is supplied, it must be added to source
130     positions reported in compiler conditions."))
131    
132     (defgeneric compile-file-for-emacs (filename load-p)
133     (:documentation
134     "Compile FILENAME signalling COMPILE-CONDITIONs.
135     If LOAD-P is true, load the file after compilation."))
136    
137    
138     ;;;; Documentation
139    
140     (defgeneric arglist-string (function-name)
141     (:documentation
142     "Return the argument for FUNCTION-NAME as a string.
143     The result should begin and end with parenthesis."))
144    
145     (defgeneric macroexpand-all (form)
146     (:documentation
147     "Recursively expand all macros in FORM.
148     Return the resulting form."))
149    
150     (defgeneric describe-symbol-for-emacs (symbol)
151     (:documentation
152     "Return a property list describing SYMBOL.
153    
154     The property list has an entry for each interesting aspect of the
155     symbol. The recognised keys are:
156    
157     :VARIABLE :FUNCTION :SETF :TYPE :CLASS :MACRO :COMPILER-MACRO
158     :ALIEN-TYPE :ALIEN-STRUCT :ALIEN-UNION :ALIEN-ENUM
159    
160     The value of each property is the corresponding documentation string,
161     or :NOT-DOCUMENTED. It is legal to include keys not listed here.
162    
163     Properties should be included if and only if they are applicable to
164     the symbol. For example, only (and all) fbound symbols should include
165     the :FUNCTION property.
166    
167     Example:
168     \(describe-symbol-for-emacs 'vector)
169     => (:CLASS :NOT-DOCUMENTED
170     :TYPE :NOT-DOCUMENTED
171     :FUNCTION \"Constructs a simple-vector from the given objects.\")"))
172 lgorrie 1.2
173    
174     ;;;; Debugging
175    
176     (defgeneric call-with-debugging-environment (debugger-loop-fn)
177     (:documentation
178     "Call DEBUGGER-LOOP-FN in a suitable debugging environment.
179    
180     This function is called recursively at each debug level to invoke the
181     debugger loop. The purpose is to setup any necessary environment for
182     other debugger callbacks that will be called within the debugger loop.
183    
184     For example, this is a reasonable place to compute a backtrace, switch
185     to safe reader/printer settings, and so on."))
186    
187     (define-condition sldb-condition (condition)
188     ((original-condition
189     :initarg :original-condition
190 heller 1.5 :accessor original-condition))
191 lgorrie 1.2 (:documentation
192     "Wrapper for conditions that should not be debugged.
193    
194     When a condition arises from the internals of the debugger, it is not
195     desirable to debug it -- we'd risk entering an endless loop trying to
196     debug the debugger! Instead, such conditions can be reported to the
197     user without (re)entering the debugger by wrapping them as
198     `sldb-condition's."))
199    
200     (defgeneric debugger-info-for-emacs (start end)
201     (:documentation
202     "Return debugger state, with stack frames from START to END.
203     The result is a list:
204     (condition-description ({restart}*) ({stack-frame}*)
205     where
206     restart ::= (name description)
207     stack-frame ::= (number description)
208    
209     condition-description---a string describing the condition that
210     triggered the debugger.
211    
212     restart---a pair of strings: restart name, and description.
213    
214     stack-frame---a number from zero (the top), and a printed
215     representation of the frame's call.
216    
217     Below is an example return value. In this case the condition was a
218     division by zero (multi-line description), and only one frame is being
219     fetched (start=0, end=1).
220    
221     (\"Arithmetic error DIVISION-BY-ZERO signalled.
222     Operation was KERNEL::DIVISION, operands (1 0).
223     [Condition of type DIVISION-BY-ZERO]\"
224     ((\"ABORT\" \"Return to Slime toplevel.\")
225     (\"ABORT\" \"Return to Top-Level.\"))
226     ((0 \"0: (KERNEL::INTEGER-/-INTEGER 1 0)\")))"))
227 lgorrie 1.1
228 lgorrie 1.3 (defgeneric backtrace (start end)
229     (:documentation
230     "Return a list containing a backtrace of the condition current
231     being debugged. The results are unspecified if this function is
232     called outside the dynamic contour of a debugger hook defined by
233     DEFINE-DEBUGGER-HOOK.
234    
235     START and END are zero-based indices constraining the number of
236     frames returned. Frame zero is defined as the frame which invoked
237     the debugger.
238    
239     The backtrace is returned as a list of tuples of the form
240     \(FRAME-NUMBER FRAME-DESCRIPTION), where FRAME-NUMBER is the
241     index of the frame, defined like START/END, and FRAME-DESCRIPTION
242     is a string containing text to display in the debugger for this
243     frame.
244    
245     An example return value:
246    
247     ((0 \"(HELLO \"world\")\")
248     (1 \"(RUN-EXCITING-LISP-DEMO)\")
249     (2 \"(SYS::%TOPLEVEL #<SYS::ENVIRONMENT #x394834>)\"))"))
250    
251     (defgeneric frame-source-location-for-emacs (frame-number)
252     (:documentation
253     "Return the source location for FRAME-NUMBER."))
254    
255     (defgeneric frame-catch-tags (frame-number)
256     (:documentation
257     "Return a list of XXX list of what? catch tags for a debugger
258     stack frame. The results are undefined unless this is called
259     within the dynamic contour of a function defined by
260     DEFINE-DEBUGGER-HOOK."))
261    
262     (defgeneric frame-locals (frame-number)
263     (:documentation
264     "Return a list of XXX local variable designators define me
265     for a debugger stack frame. The results are undefined unless
266     this is called within the dynamic contour of a function defined
267     by DEFINE-DEBUGGER-HOOK."))
268    
269     (defgeneric eval-in-frame (form frame-number)
270     (:documentation
271     "Evaluate a Lisp form in the lexical context of a stack frame
272     in the debugger. The results are undefined unless called in the
273     dynamic contour of a function defined by DEFINE-DEBUGGER-HOOK.
274    
275     FRAME-NUMBER must be a positive integer with 0 indicating the
276     frame which invoked the debugger.
277    
278     The return value is the result of evaulating FORM in the
279     appropriate context."))
280    
281    
282     ;;;; Queries
283    
284 heller 1.7 #+(or)
285     ;;; This is probably a better interface than find-function-locations.
286     (defgeneric find-definitions (name)
287 lgorrie 1.3 (:documentation
288 heller 1.7 "Return a list of (LABEL . LOCATION) pairs for NAME's definitions.
289 lgorrie 1.3
290 heller 1.7 NAME is string denoting a symbol or \"definition specifier\".
291    
292     LABEL is a string describing the definition, e.g., \"foo\" or
293     \"(method foo (string number))\" or \"(variable bar)\".
294    
295     LOCATION is a source location of the form:
296    
297     <location> ::= (:location <buffer> <position>)
298     | (:error <message>)
299    
300     <buffer> ::= (:file <filename>)
301     | (:buffer <buffername>)
302     | (:source-form <string>)
303    
304     <position> ::= (:position <fixnum> [<align>]) ; 1 based
305     | (:function-name <string>)
306     "))
307    
308     (defgeneric find-function-locations (name)
309     (:documentation
310     "Return a list (LOCATION LOCATION ...) for NAME's definitions.
311    
312     LOCATION is a source location of the form:
313    
314     <location> ::= (:location <buffer> <position>)
315     | (:error <message>)
316    
317     <buffer> ::= (:file <filename>)
318     | (:buffer <buffername>)
319     | (:source-form <string>)
320    
321     <position> ::= (:position <fixnum> [<align>]) ; 1 based
322     | (:function-name <string>)"))
323 lgorrie 1.1

  ViewVC Help
Powered by ViewVC 1.1.5