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

Contents of /slime/swank-backend.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Sun Nov 23 12:13:19 2003 UTC (10 years, 4 months ago) by lgorrie
Branch: MAIN
Changes since 1.1: +57 -3 lines
* swank-backend.lisp (call-with-debugging-environment,
sldb-condition, debugger-info-for-emacs): More callbacks defined.
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 ;;; $Id: swank-backend.lisp,v 1.2 2003/11/23 12:13:19 lgorrie Exp $
9 ;;;
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 (:export #:start-server #:create-swank-server
20 #:*sldb-pprint-frames*))
21
22
23 (in-package :swank)
24
25
26 ;;;; Conditions and Error Handling
27
28 ;; XXX need to specify restart behavior for errors/warnings?
29
30 (define-condition not-implemented-error (error)
31 ())
32
33 (deftype severity () '(member :error :warning :style-warning :note))
34
35 ;; Base condition type for compiler errors, warnings and notes.
36 (define-condition compiler-condition (condition)
37 ((original-condition
38 ;; The original condition thrown by the compiler if appropriate.
39 ;; May be NIL if a compiler does not report using conditions.
40 :initarg :original-condition
41 :accessor original-condition)
42
43 (severity
44 :type severity
45 :initarg :severity
46 :accessor severity)
47
48 (message
49 :documentation "The error or warning message, must be a non-NIL string."
50 :initarg :message
51 :accessor message)
52
53 (location
54 :initarg :location
55 :accessor location)))
56
57
58 ;;;; Compilation
59
60 (defgeneric compile-string-for-emacs (string &key buffer position)
61 (:documentation
62 "Compile source from STRING. During compilation, compiler
63 conditions must be trapped and resignalled as COMPILER-CONDITIONs.
64
65 If supplied, BUFFER and POSITION specify the source location in Emacs.
66
67 Additionally, if POSITION is supplied, it must be added to source
68 positions reported in compiler conditions."))
69
70 (defgeneric compile-file-for-emacs (filename load-p)
71 (:documentation
72 "Compile FILENAME signalling COMPILE-CONDITIONs.
73 If LOAD-P is true, load the file after compilation."))
74
75
76 ;;;; Documentation
77
78 (defgeneric arglist-string (function-name)
79 (:documentation
80 "Return the argument for FUNCTION-NAME as a string.
81 The result should begin and end with parenthesis."))
82
83 (defgeneric macroexpand-all (form)
84 (:documentation
85 "Recursively expand all macros in FORM.
86 Return the resulting form."))
87
88 (defgeneric describe-symbol-for-emacs (symbol)
89 (:documentation
90 "Return a property list describing SYMBOL.
91
92 The property list has an entry for each interesting aspect of the
93 symbol. The recognised keys are:
94
95 :VARIABLE :FUNCTION :SETF :TYPE :CLASS :MACRO :COMPILER-MACRO
96 :ALIEN-TYPE :ALIEN-STRUCT :ALIEN-UNION :ALIEN-ENUM
97
98 The value of each property is the corresponding documentation string,
99 or :NOT-DOCUMENTED. It is legal to include keys not listed here.
100
101 Properties should be included if and only if they are applicable to
102 the symbol. For example, only (and all) fbound symbols should include
103 the :FUNCTION property.
104
105 Example:
106 \(describe-symbol-for-emacs 'vector)
107 => (:CLASS :NOT-DOCUMENTED
108 :TYPE :NOT-DOCUMENTED
109 :FUNCTION \"Constructs a simple-vector from the given objects.\")"))
110
111
112 ;;;; Debugging
113
114 (defgeneric call-with-debugging-environment (debugger-loop-fn)
115 (:documentation
116 "Call DEBUGGER-LOOP-FN in a suitable debugging environment.
117
118 This function is called recursively at each debug level to invoke the
119 debugger loop. The purpose is to setup any necessary environment for
120 other debugger callbacks that will be called within the debugger loop.
121
122 For example, this is a reasonable place to compute a backtrace, switch
123 to safe reader/printer settings, and so on."))
124
125 (define-condition sldb-condition (condition)
126 ((original-condition
127 :initarg :original-condition
128 :accessor :original-condition))
129 (:documentation
130 "Wrapper for conditions that should not be debugged.
131
132 When a condition arises from the internals of the debugger, it is not
133 desirable to debug it -- we'd risk entering an endless loop trying to
134 debug the debugger! Instead, such conditions can be reported to the
135 user without (re)entering the debugger by wrapping them as
136 `sldb-condition's."))
137
138 (defgeneric debugger-info-for-emacs (start end)
139 (:documentation
140 "Return debugger state, with stack frames from START to END.
141 The result is a list:
142 (condition-description ({restart}*) ({stack-frame}*)
143 where
144 restart ::= (name description)
145 stack-frame ::= (number description)
146
147 condition-description---a string describing the condition that
148 triggered the debugger.
149
150 restart---a pair of strings: restart name, and description.
151
152 stack-frame---a number from zero (the top), and a printed
153 representation of the frame's call.
154
155 Below is an example return value. In this case the condition was a
156 division by zero (multi-line description), and only one frame is being
157 fetched (start=0, end=1).
158
159 (\"Arithmetic error DIVISION-BY-ZERO signalled.
160 Operation was KERNEL::DIVISION, operands (1 0).
161 [Condition of type DIVISION-BY-ZERO]\"
162 ((\"ABORT\" \"Return to Slime toplevel.\")
163 (\"ABORT\" \"Return to Top-Level.\"))
164 ((0 \"0: (KERNEL::INTEGER-/-INTEGER 1 0)\")))"))
165
166

  ViewVC Help
Powered by ViewVC 1.1.5