annotate lisp/edebug/edebug-cl-read.el @ 108:360340f9fd5f r20-1b6

Import from CVS: tag r20-1b6
author cvs
date Mon, 13 Aug 2007 09:18:39 +0200
parents b9518feda344
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
1 ;;; edebug-cl-read.el --- Edebug reader macros for use with cl-read.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1993 Daniel LaLiberte
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: lisp, tools, maint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
7 ;; This file is part of XEmacs.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
8
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
9 ;; XEmacs is free software; you can redistribute it and/or modify it
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
10 ;; under the terms of the GNU General Public License as published by
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
12 ;; any later version.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
13
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
14 ;; XEmacs is distributed in the hope that it will be useful, but
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
17 ;; General Public License for more details.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
18
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
19 ;; You should have received a copy of the GNU General Public License
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
20 ;; along with XEmacs; see the file COPYING. If not, write to the Free
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
21 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
22 ;; 02111-1307, USA.
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
23
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
24 ;;; Synched up with: Not in FSF
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
25
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
26 ;;; Commentary:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
27
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
28 ;; LCD Archive Entry:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
29 ;; edebug-cl-read.el|Daniel LaLiberte|liberte@cs.uiuc.edu
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 4
diff changeset
30 ;; |Edebug reader macros for cl-read.el
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
31 ;; |$Date: 1996/12/18 22:51:45 $|$Revision: 1.1.1.2 $|~/modes/edebug-cl-read.el|
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; If you use cl-read.el and want to use edebug with any code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; in a file written with CL read syntax, then you need to use this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; package.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; To Do:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; Handle shared structures, but this is not normally used in executable code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; Read-time evaluation shouldn't be used in a form argument since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; there is no way to instrument the result of the evaluation, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; no way to tell Edebug not to try.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; Need to mangle all local variable names that might be visible to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; eval, e.g. stream, char. Alternatively, packages could hide them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
72
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
47 ;;; Code:
b9518feda344 Import from CVS: tag r20-0b31
cvs
parents: 70
diff changeset
48
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (require 'cl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; For byte compiling cl-read is needed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; But edebug-cl-read should not even be loaded unless cl-read already is.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (require 'cl-read)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (provide 'edebug-cl-read)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; Do the above provide before the following require to avoid load loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (require 'edebug)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (defvar reader::stack)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; The following modifications of reader functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;; could be done via advice. But we need to switch between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; edebug versions and originals frequently. Also advice.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; doesn't support advising anonymous functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (defun edebug-reader::read-sexp-func (point func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; dummy def
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 (defvar edebug-read-dotted-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (defun edebug-read-sexp-func (point func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 "Edebug offset storing is happening."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (edebug-storing-offsets point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (let (edebug-read-dotted-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (edebug-reader::read-sexp-func point func))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (defun edebug-end-list-handler (stream char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; If the dotted form is a list, signal to offset routines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (setq edebug-read-dotted-list (listp (car reader::stack)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (edebug-reader::end-list-handler stream char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;;=========================================================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;; Redefine the edebug reader to check whether CL syntax is active.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; This might be a little cleaner using advice.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (defvar edebug-reading-with-cl-read nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (or (fboundp 'edebug-original-read-storing-offsets)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (defalias 'edebug-original-read-storing-offsets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (symbol-function 'edebug-read-storing-offsets)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (defun edebug-read-storing-offsets (stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;; Read a sexp from STREAM.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;; STREAM is limited to the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;; Create a parallel offset structure as described in doc for edebug-offsets.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;; This version, from edebug-cl-read, uses cl-read.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (if (not cl-read-active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;; Use the reader for standard Emacs Lisp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (edebug-original-read-storing-offsets stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;; Use cl-read with edebug hooks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (if edebug-reading-with-cl-read nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;; Only do this if it's not already been done, else it loops.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (fset 'edebug-reader::read-sexp-func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (symbol-function 'reader::read-sexp-func))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (fset 'reader::read-sexp-func 'edebug-read-sexp-func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (fset 'edebug-reader::end-list-handler (get-macro-character ?\)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (set-macro-character ?\) 'edebug-end-list-handler)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (let ((edebug-reading-with-cl-read t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (reader::read stream))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (if edebug-reading-with-cl-read nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (set-macro-character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ?\) (symbol-function 'edebug-reader::end-list-handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (fset 'reader::read-sexp-func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (symbol-function 'edebug-reader::read-sexp-func)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118