Spaces:
Sleeping
Sleeping
Commit
·
f65fe85
1
Parent(s):
d605f27
added node-addon-lilypond
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- node-addon-lilypond/output/extra/libc.so.6 +3 -0
- node-addon-lilypond/output/extra/libdl.so.2 +3 -0
- node-addon-lilypond/output/extra/libexpat.so.1 +3 -0
- node-addon-lilypond/output/extra/libgcc_s.so.1 +3 -0
- node-addon-lilypond/output/extra/libgmp.so.10 +3 -0
- node-addon-lilypond/output/extra/libm.so.6 +3 -0
- node-addon-lilypond/output/extra/libpcre.so.3 +3 -0
- node-addon-lilypond/output/extra/libpthread.so.0 +3 -0
- node-addon-lilypond/output/extra/libstdc++.so.6 +3 -0
- node-addon-lilypond/output/extra/libz.so.1 +3 -0
- node-addon-lilypond/output/libdatrie.so.1 +3 -0
- node-addon-lilypond/output/libffi.so.6 +3 -0
- node-addon-lilypond/output/libfontconfig.so.1 +3 -0
- node-addon-lilypond/output/libfreetype.so.6 +3 -0
- node-addon-lilypond/output/libglib-2.0.so.0 +3 -0
- node-addon-lilypond/output/libgobject-2.0.so.0 +3 -0
- node-addon-lilypond/output/libgraphite2.so.3 +3 -0
- node-addon-lilypond/output/libguile-srfi-srfi-1-v-3.so +3 -0
- node-addon-lilypond/output/libguile.so +3 -0
- node-addon-lilypond/output/libharfbuzz.so.0 +3 -0
- node-addon-lilypond/output/liblilypond.so +3 -0
- node-addon-lilypond/output/libpango-1.0.so.0 +3 -0
- node-addon-lilypond/output/libpangoft2-1.0.so.0 +3 -0
- node-addon-lilypond/output/libpng16.so.16 +3 -0
- node-addon-lilypond/output/libthai.so.0 +3 -0
- node-addon-lilypond/output/lilypond.node +3 -0
- node-addon-lilypond/output/share/guile/1.8/guile-procedures.txt +0 -0
- node-addon-lilypond/output/share/guile/1.8/ice-9/and-let-star.scm +49 -0
- node-addon-lilypond/output/share/guile/1.8/ice-9/boot-9.scm +0 -0
- node-addon-lilypond/output/share/guile/1.8/ice-9/buffered-input.scm +112 -0
- node-addon-lilypond/output/share/guile/1.8/ice-9/calling.scm +326 -0
- node-addon-lilypond/output/share/guile/1.8/ice-9/channel.scm +170 -0
- node-addon-lilypond/output/share/guile/1.8/ice-9/common-list.scm +278 -0
- node-addon-lilypond/output/share/guile/1.8/ice-9/debug.scm +134 -0
- node-addon-lilypond/output/share/guile/1.8/ice-9/debugger.scm +146 -0
- node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/command-loop.scm +542 -0
- node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/commands.scm +154 -0
- node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/state.scm +47 -0
- node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/trc.scm +63 -0
- node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/utils.scm +203 -0
- node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/example-fns.scm +17 -0
- node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/ice-9-debugger-extensions.scm +173 -0
- node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/steps.scm +106 -0
- node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/trace.scm +157 -0
- node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/traps.scm +1037 -0
- node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/trc.scm +63 -0
- node-addon-lilypond/output/share/guile/1.8/ice-9/deprecated.scm +180 -0
- node-addon-lilypond/output/share/guile/1.8/ice-9/documentation.scm +213 -0
- node-addon-lilypond/output/share/guile/1.8/ice-9/emacs.scm +276 -0
- node-addon-lilypond/output/share/guile/1.8/ice-9/expect.scm +171 -0
node-addon-lilypond/output/extra/libc.so.6
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:467d8d5596e31cec78cdcde0c589bd04c031ec36598531bfd77e346ac447d9d6
|
3 |
+
size 2030928
|
node-addon-lilypond/output/extra/libdl.so.2
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:398f33bacb604813ef22a5ae10b73a319180a6467a5e3e60a412dd271b2aff3b
|
3 |
+
size 14560
|
node-addon-lilypond/output/extra/libexpat.so.1
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f15cdbce5b1b9a0032fe1ab4e17eea95601dd8a6404ba20c98a7103e3089676e
|
3 |
+
size 202880
|
node-addon-lilypond/output/extra/libgcc_s.so.1
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2f0e486606bd477c6a6ad3588176a16099ed05a8bf47cf3bd27b490bea3d59e9
|
3 |
+
size 96616
|
node-addon-lilypond/output/extra/libgmp.so.10
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d54e955d21688b5b840ac49dda592be5e1f5546df67eb18fea400116e76b9852
|
3 |
+
size 526688
|
node-addon-lilypond/output/extra/libm.so.6
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:464dcab115cca26b8715cf3521f9ca1d9b7eb6b0500b7d3bed7a2353fd744c52
|
3 |
+
size 1700792
|
node-addon-lilypond/output/extra/libpcre.so.3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d14920b8c1cb4e4cbe5f7c9ad23f6d9cf7b4ab1ddce1a29c9fc766b51c29ebea
|
3 |
+
size 464824
|
node-addon-lilypond/output/extra/libpthread.so.0
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:99c0999f13790d4365986180bc2e6dccbabd4d9b874a76799014c0c397e8f02a
|
3 |
+
size 144976
|
node-addon-lilypond/output/extra/libstdc++.so.6
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a7ce5e3ab89895f02ad5d55f6b2090c3882ba5f4e12fbd9b96f0ed1712e2a1f6
|
3 |
+
size 1594864
|
node-addon-lilypond/output/extra/libz.so.1
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:219c6c0efe93bd6d751bba1e8ae84a162309c665cc5e36beddcf295b72f9bc09
|
3 |
+
size 116960
|
node-addon-lilypond/output/libdatrie.so.1
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6c30fb636f01c4bbce7a5ac3eadcba61720d0821a2cbaa5238a675b7370caaad
|
3 |
+
size 26544
|
node-addon-lilypond/output/libffi.so.6
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5a675e4f4e40312eebbaf9816e009793a394ae9385115bf10b82b83643f84963
|
3 |
+
size 31032
|
node-addon-lilypond/output/libfontconfig.so.1
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7a8a2c7373cd9483fa9af3e797a33144979de9125d578bb6b63e47f56e4f58de
|
3 |
+
size 281984
|
node-addon-lilypond/output/libfreetype.so.6
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d2e48e02376decc11d1b8cf5b09c8e0f991d31d8909d0fd2c006dc2b1209e860
|
3 |
+
size 735704
|
node-addon-lilypond/output/libglib-2.0.so.0
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9450de63b8dfe0e3dfc753d77c8cf86531365efeccee68578dd6b08ad9a68779
|
3 |
+
size 1137968
|
node-addon-lilypond/output/libgobject-2.0.so.0
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:677342b9e18f64c658d7b8133ecc8c5654cbca07484fdceabdbd2331e18e4cd8
|
3 |
+
size 342072
|
node-addon-lilypond/output/libgraphite2.so.3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5efccb06571c46f4aef27805688f4dc5e168d1224edea3fc61b339f2a33aa348
|
3 |
+
size 182424
|
node-addon-lilypond/output/libguile-srfi-srfi-1-v-3.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:dfb0db9ad891809b90ed161022eb340959d93ec701b2c88b1aa437fe4f284b74
|
3 |
+
size 108192
|
node-addon-lilypond/output/libguile.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6722c0302a80aa446436ad49fdc0678ebd0782ed92ddea70ebf9e0e902ebebf3
|
3 |
+
size 1235424
|
node-addon-lilypond/output/libharfbuzz.so.0
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3ed819725042eb62aed9c0e257ad35e9d6834912a8ceafccd5333005567cac0a
|
3 |
+
size 646064
|
node-addon-lilypond/output/liblilypond.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:25cfa4b0972c0dbaa66e71b5a652479e3a67a3611cf518614317a8819f075711
|
3 |
+
size 8707312
|
node-addon-lilypond/output/libpango-1.0.so.0
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d0bb21da459593889d1f60319779d35840915620d0f96c385c4711a32199e26a
|
3 |
+
size 313264
|
node-addon-lilypond/output/libpangoft2-1.0.so.0
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2663e090308fd304b0931775da8c4664f8871ddc4392937178e2e996818b36f8
|
3 |
+
size 87904
|
node-addon-lilypond/output/libpng16.so.16
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0353da90d7c3699685c99c2cabf17d7b4a4212c3a2d6c29beb739e1c83da418e
|
3 |
+
size 202672
|
node-addon-lilypond/output/libthai.so.0
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:39373a82e85412d5a6ed68d2ff3e37da5452895894844eb8523eca5f3c687092
|
3 |
+
size 36904
|
node-addon-lilypond/output/lilypond.node
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:980e421accd2cc159019be6c9cfe0a32d77b2eb7fd702070f3910f9c3cc4ff54
|
3 |
+
size 305080
|
node-addon-lilypond/output/share/guile/1.8/guile-procedures.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
node-addon-lilypond/output/share/guile/1.8/ice-9/and-let-star.scm
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
;;;; and-let-star.scm --- and-let* syntactic form (draft SRFI-2) for Guile
|
2 |
+
;;;; written by Michael Livshin <mike@olan.com>
|
3 |
+
;;;;
|
4 |
+
;;;; Copyright (C) 1999, 2001, 2004, 2006 Free Software Foundation, Inc.
|
5 |
+
;;;;
|
6 |
+
;;;; This library is free software; you can redistribute it and/or
|
7 |
+
;;;; modify it under the terms of the GNU Lesser General Public
|
8 |
+
;;;; License as published by the Free Software Foundation; either
|
9 |
+
;;;; version 2.1 of the License, or (at your option) any later version.
|
10 |
+
;;;;
|
11 |
+
;;;; This library is distributed in the hope that it will be useful,
|
12 |
+
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
+
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
+
;;;; Lesser General Public License for more details.
|
15 |
+
;;;;
|
16 |
+
;;;; You should have received a copy of the GNU Lesser General Public
|
17 |
+
;;;; License along with this library; if not, write to the Free Software
|
18 |
+
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
19 |
+
|
20 |
+
(define-module (ice-9 and-let-star)
|
21 |
+
:export-syntax (and-let*))
|
22 |
+
|
23 |
+
(defmacro and-let* (vars . body)
|
24 |
+
|
25 |
+
(define (expand vars body)
|
26 |
+
(cond
|
27 |
+
((null? vars)
|
28 |
+
(if (null? body)
|
29 |
+
#t
|
30 |
+
`(begin ,@body)))
|
31 |
+
((pair? vars)
|
32 |
+
(let ((exp (car vars)))
|
33 |
+
(cond
|
34 |
+
((pair? exp)
|
35 |
+
(cond
|
36 |
+
((null? (cdr exp))
|
37 |
+
`(and ,(car exp) ,(expand (cdr vars) body)))
|
38 |
+
(else
|
39 |
+
(let ((var (car exp)))
|
40 |
+
`(let (,exp)
|
41 |
+
(and ,var ,(expand (cdr vars) body)))))))
|
42 |
+
(else
|
43 |
+
`(and ,exp ,(expand (cdr vars) body))))))
|
44 |
+
(else
|
45 |
+
(error "not a proper list" vars))))
|
46 |
+
|
47 |
+
(expand vars body))
|
48 |
+
|
49 |
+
(cond-expand-provide (current-module) '(srfi-2))
|
node-addon-lilypond/output/share/guile/1.8/ice-9/boot-9.scm
ADDED
The diff for this file is too large to render.
See raw diff
|
|
node-addon-lilypond/output/share/guile/1.8/ice-9/buffered-input.scm
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
;;;; buffered-input.scm --- construct a port from a buffered input reader
|
2 |
+
;;;;
|
3 |
+
;;;; Copyright (C) 2001, 2006 Free Software Foundation, Inc.
|
4 |
+
;;;;
|
5 |
+
;;;; This library is free software; you can redistribute it and/or
|
6 |
+
;;;; modify it under the terms of the GNU Lesser General Public
|
7 |
+
;;;; License as published by the Free Software Foundation; either
|
8 |
+
;;;; version 2.1 of the License, or (at your option) any later version.
|
9 |
+
;;;;
|
10 |
+
;;;; This library is distributed in the hope that it will be useful,
|
11 |
+
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
+
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13 |
+
;;;; Lesser General Public License for more details.
|
14 |
+
;;;;
|
15 |
+
;;;; You should have received a copy of the GNU Lesser General Public
|
16 |
+
;;;; License along with this library; if not, write to the Free Software
|
17 |
+
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18 |
+
|
19 |
+
(define-module (ice-9 buffered-input)
|
20 |
+
#:export (make-buffered-input-port
|
21 |
+
make-line-buffered-input-port
|
22 |
+
set-buffered-input-continuation?!))
|
23 |
+
|
24 |
+
;; @code{buffered-input-continuation?} is a property of the ports
|
25 |
+
;; created by @code{make-line-buffered-input-port} that stores the
|
26 |
+
;; read continuation flag for each such port.
|
27 |
+
(define buffered-input-continuation? (make-object-property))
|
28 |
+
|
29 |
+
(define (set-buffered-input-continuation?! port val)
|
30 |
+
"Set the read continuation flag for @var{port} to @var{val}.
|
31 |
+
|
32 |
+
See @code{make-buffered-input-port} for the meaning and use of this
|
33 |
+
flag."
|
34 |
+
(set! (buffered-input-continuation? port) val))
|
35 |
+
|
36 |
+
(define (make-buffered-input-port reader)
|
37 |
+
"Construct a line-buffered input port from the specified @var{reader}.
|
38 |
+
@var{reader} should be a procedure of one argument that somehow reads
|
39 |
+
a chunk of input and returns it as a string.
|
40 |
+
|
41 |
+
The port created by @code{make-buffered-input-port} does @emph{not}
|
42 |
+
interpolate any additional characters between the strings returned by
|
43 |
+
@var{reader}.
|
44 |
+
|
45 |
+
@var{reader} should take a boolean @var{continuation?} argument.
|
46 |
+
@var{continuation?} indicates whether @var{reader} is being called to
|
47 |
+
start a logically new read operation (in which case
|
48 |
+
@var{continuation?} is @code{#f}) or to continue a read operation for
|
49 |
+
which some input has already been read (in which case
|
50 |
+
@var{continuation?} is @code{#t}). Some @var{reader} implementations
|
51 |
+
use the @var{continuation?} argument to determine what prompt to
|
52 |
+
display to the user.
|
53 |
+
|
54 |
+
The new/continuation distinction is largely an application-level
|
55 |
+
concept: @code{set-buffered-input-continuation?!} allows an
|
56 |
+
application to specify when a read operation is considered to be new.
|
57 |
+
But note that if there is non-whitespace data already buffered in the
|
58 |
+
port when a new read operation starts, this data will be read before
|
59 |
+
the first call to @var{reader}, and so @var{reader} will be called
|
60 |
+
with @var{continuation?} set to @code{#t}."
|
61 |
+
(let ((read-string "")
|
62 |
+
(string-index -1))
|
63 |
+
(letrec ((get-character
|
64 |
+
(lambda ()
|
65 |
+
(cond
|
66 |
+
((eof-object? read-string)
|
67 |
+
read-string)
|
68 |
+
((>= string-index (string-length read-string))
|
69 |
+
(set! string-index -1)
|
70 |
+
(get-character))
|
71 |
+
((= string-index -1)
|
72 |
+
(set! read-string (reader (buffered-input-continuation? port)))
|
73 |
+
(set! string-index 0)
|
74 |
+
(if (not (eof-object? read-string))
|
75 |
+
(get-character)
|
76 |
+
read-string))
|
77 |
+
(else
|
78 |
+
(let ((res (string-ref read-string string-index)))
|
79 |
+
(set! string-index (+ 1 string-index))
|
80 |
+
(if (not (char-whitespace? res))
|
81 |
+
(set! (buffered-input-continuation? port) #t))
|
82 |
+
res)))))
|
83 |
+
(input-waiting
|
84 |
+
(lambda ()
|
85 |
+
(if (eof-object? read-string)
|
86 |
+
1
|
87 |
+
(- (string-length read-string) string-index))))
|
88 |
+
(port #f))
|
89 |
+
(set! port (make-soft-port (vector #f #f #f get-character #f input-waiting) "r"))
|
90 |
+
(set! (buffered-input-continuation? port) #f)
|
91 |
+
port)))
|
92 |
+
|
93 |
+
(define (make-line-buffered-input-port reader)
|
94 |
+
"Construct a line-buffered input port from the specified @var{reader}.
|
95 |
+
@var{reader} should be a procedure of one argument that somehow reads
|
96 |
+
a line of input and returns it as a string @emph{without} the
|
97 |
+
terminating newline character.
|
98 |
+
|
99 |
+
The port created by @code{make-line-buffered-input-port} automatically
|
100 |
+
interpolates a newline character after each string returned by
|
101 |
+
@var{reader}.
|
102 |
+
|
103 |
+
@var{reader} should take a boolean @var{continuation?} argument. For
|
104 |
+
the meaning and use of this argument, see
|
105 |
+
@code{make-buffered-input-port}."
|
106 |
+
(make-buffered-input-port (lambda (continuation?)
|
107 |
+
(let ((str (reader continuation?)))
|
108 |
+
(if (eof-object? str)
|
109 |
+
str
|
110 |
+
(string-append str "\n"))))))
|
111 |
+
|
112 |
+
;;; buffered-input.scm ends here
|
node-addon-lilypond/output/share/guile/1.8/ice-9/calling.scm
ADDED
@@ -0,0 +1,326 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
;;;; calling.scm --- Calling Conventions
|
2 |
+
;;;;
|
3 |
+
;;;; Copyright (C) 1995, 1996, 1997, 2000, 2001, 2006 Free Software Foundation, Inc.
|
4 |
+
;;;;
|
5 |
+
;;;; This library is free software; you can redistribute it and/or
|
6 |
+
;;;; modify it under the terms of the GNU Lesser General Public
|
7 |
+
;;;; License as published by the Free Software Foundation; either
|
8 |
+
;;;; version 2.1 of the License, or (at your option) any later version.
|
9 |
+
;;;;
|
10 |
+
;;;; This library is distributed in the hope that it will be useful,
|
11 |
+
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
+
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13 |
+
;;;; Lesser General Public License for more details.
|
14 |
+
;;;;
|
15 |
+
;;;; You should have received a copy of the GNU Lesser General Public
|
16 |
+
;;;; License along with this library; if not, write to the Free Software
|
17 |
+
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18 |
+
;;;;
|
19 |
+
|
20 |
+
(define-module (ice-9 calling)
|
21 |
+
:export-syntax (with-excursion-function
|
22 |
+
with-getter-and-setter
|
23 |
+
with-getter
|
24 |
+
with-delegating-getter-and-setter
|
25 |
+
with-excursion-getter-and-setter
|
26 |
+
with-configuration-getter-and-setter
|
27 |
+
with-delegating-configuration-getter-and-setter
|
28 |
+
let-with-configuration-getter-and-setter))
|
29 |
+
|
30 |
+
;;;;
|
31 |
+
;;;
|
32 |
+
;;; This file contains a number of macros that support
|
33 |
+
;;; common calling conventions.
|
34 |
+
|
35 |
+
;;;
|
36 |
+
;;; with-excursion-function <vars> proc
|
37 |
+
;;; <vars> is an unevaluated list of names that are bound in the caller.
|
38 |
+
;;; proc is a procedure, called:
|
39 |
+
;;; (proc excursion)
|
40 |
+
;;;
|
41 |
+
;;; excursion is a procedure isolates all changes to <vars>
|
42 |
+
;;; in the dynamic scope of the call to proc. In other words,
|
43 |
+
;;; the values of <vars> are saved when proc is entered, and when
|
44 |
+
;;; proc returns, those values are restored. Values are also restored
|
45 |
+
;;; entering and leaving the call to proc non-locally, such as using
|
46 |
+
;;; call-with-current-continuation, error, or throw.
|
47 |
+
;;;
|
48 |
+
(defmacro with-excursion-function (vars proc)
|
49 |
+
`(,proc ,(excursion-function-syntax vars)))
|
50 |
+
|
51 |
+
|
52 |
+
|
53 |
+
;;; with-getter-and-setter <vars> proc
|
54 |
+
;;; <vars> is an unevaluated list of names that are bound in the caller.
|
55 |
+
;;; proc is a procedure, called:
|
56 |
+
;;; (proc getter setter)
|
57 |
+
;;;
|
58 |
+
;;; getter and setter are procedures used to access
|
59 |
+
;;; or modify <vars>.
|
60 |
+
;;;
|
61 |
+
;;; setter, called with keywords arguments, modifies the named
|
62 |
+
;;; values. If "foo" and "bar" are among <vars>, then:
|
63 |
+
;;;
|
64 |
+
;;; (setter :foo 1 :bar 2)
|
65 |
+
;;; == (set! foo 1 bar 2)
|
66 |
+
;;;
|
67 |
+
;;; getter, called with just keywords, returns
|
68 |
+
;;; a list of the corresponding values. For example,
|
69 |
+
;;; if "foo" and "bar" are among the <vars>, then
|
70 |
+
;;;
|
71 |
+
;;; (getter :foo :bar)
|
72 |
+
;;; => (<value-of-foo> <value-of-bar>)
|
73 |
+
;;;
|
74 |
+
;;; getter, called with no arguments, returns a list of all accepted
|
75 |
+
;;; keywords and the corresponding values. If "foo" and "bar" are
|
76 |
+
;;; the *only* <vars>, then:
|
77 |
+
;;;
|
78 |
+
;;; (getter)
|
79 |
+
;;; => (:foo <value-of-bar> :bar <value-of-foo>)
|
80 |
+
;;;
|
81 |
+
;;; The unusual calling sequence of a getter supports too handy
|
82 |
+
;;; idioms:
|
83 |
+
;;;
|
84 |
+
;;; (apply setter (getter)) ;; save and restore
|
85 |
+
;;;
|
86 |
+
;;; (apply-to-args (getter :foo :bar) ;; fetch and bind
|
87 |
+
;;; (lambda (foo bar) ....))
|
88 |
+
;;;
|
89 |
+
;;; ;; [ "apply-to-args" is just like two-argument "apply" except that it
|
90 |
+
;;; ;; takes its arguments in a different order.
|
91 |
+
;;;
|
92 |
+
;;;
|
93 |
+
(defmacro with-getter-and-setter (vars proc)
|
94 |
+
`(,proc ,@ (getter-and-setter-syntax vars)))
|
95 |
+
|
96 |
+
;;; with-getter vars proc
|
97 |
+
;;; A short-hand for a call to with-getter-and-setter.
|
98 |
+
;;; The procedure is called:
|
99 |
+
;;; (proc getter)
|
100 |
+
;;;
|
101 |
+
(defmacro with-getter (vars proc)
|
102 |
+
`(,proc ,(car (getter-and-setter-syntax vars))))
|
103 |
+
|
104 |
+
|
105 |
+
;;; with-delegating-getter-and-setter <vars> get-delegate set-delegate proc
|
106 |
+
;;; Compose getters and setters.
|
107 |
+
;;;
|
108 |
+
;;; <vars> is an unevaluated list of names that are bound in the caller.
|
109 |
+
;;;
|
110 |
+
;;; get-delegate is called by the new getter to extend the set of
|
111 |
+
;;; gettable variables beyond just <vars>
|
112 |
+
;;; set-delegate is called by the new setter to extend the set of
|
113 |
+
;;; gettable variables beyond just <vars>
|
114 |
+
;;;
|
115 |
+
;;; proc is a procedure that is called
|
116 |
+
;;; (proc getter setter)
|
117 |
+
;;;
|
118 |
+
(defmacro with-delegating-getter-and-setter (vars get-delegate set-delegate proc)
|
119 |
+
`(,proc ,@ (delegating-getter-and-setter-syntax vars get-delegate set-delegate)))
|
120 |
+
|
121 |
+
|
122 |
+
;;; with-excursion-getter-and-setter <vars> proc
|
123 |
+
;;; <vars> is an unevaluated list of names that are bound in the caller.
|
124 |
+
;;; proc is called:
|
125 |
+
;;;
|
126 |
+
;;; (proc excursion getter setter)
|
127 |
+
;;;
|
128 |
+
;;; See also:
|
129 |
+
;;; with-getter-and-setter
|
130 |
+
;;; with-excursion-function
|
131 |
+
;;;
|
132 |
+
(defmacro with-excursion-getter-and-setter (vars proc)
|
133 |
+
`(,proc ,(excursion-function-syntax vars)
|
134 |
+
,@ (getter-and-setter-syntax vars)))
|
135 |
+
|
136 |
+
|
137 |
+
(define (excursion-function-syntax vars)
|
138 |
+
(let ((saved-value-names (map gensym vars))
|
139 |
+
(tmp-var-name (gensym "temp"))
|
140 |
+
(swap-fn-name (gensym "swap"))
|
141 |
+
(thunk-name (gensym "thunk")))
|
142 |
+
`(lambda (,thunk-name)
|
143 |
+
(letrec ((,tmp-var-name #f)
|
144 |
+
(,swap-fn-name
|
145 |
+
(lambda () ,@ (map (lambda (n sn)
|
146 |
+
`(begin (set! ,tmp-var-name ,n)
|
147 |
+
(set! ,n ,sn)
|
148 |
+
(set! ,sn ,tmp-var-name)))
|
149 |
+
vars saved-value-names)))
|
150 |
+
,@ (map (lambda (sn n) `(,sn ,n)) saved-value-names vars))
|
151 |
+
(dynamic-wind
|
152 |
+
,swap-fn-name
|
153 |
+
,thunk-name
|
154 |
+
,swap-fn-name)))))
|
155 |
+
|
156 |
+
|
157 |
+
(define (getter-and-setter-syntax vars)
|
158 |
+
(let ((args-name (gensym "args"))
|
159 |
+
(an-arg-name (gensym "an-arg"))
|
160 |
+
(new-val-name (gensym "new-value"))
|
161 |
+
(loop-name (gensym "loop"))
|
162 |
+
(kws (map symbol->keyword vars)))
|
163 |
+
(list `(lambda ,args-name
|
164 |
+
(let ,loop-name ((,args-name ,args-name))
|
165 |
+
(if (null? ,args-name)
|
166 |
+
,(if (null? kws)
|
167 |
+
''()
|
168 |
+
`(let ((all-vals (,loop-name ',kws)))
|
169 |
+
(let ,loop-name ((vals all-vals)
|
170 |
+
(kws ',kws))
|
171 |
+
(if (null? vals)
|
172 |
+
'()
|
173 |
+
`(,(car kws) ,(car vals) ,@(,loop-name (cdr vals) (cdr kws)))))))
|
174 |
+
(map (lambda (,an-arg-name)
|
175 |
+
(case ,an-arg-name
|
176 |
+
,@ (append
|
177 |
+
(map (lambda (kw v) `((,kw) ,v)) kws vars)
|
178 |
+
`((else (throw 'bad-get-option ,an-arg-name))))))
|
179 |
+
,args-name))))
|
180 |
+
|
181 |
+
`(lambda ,args-name
|
182 |
+
(let ,loop-name ((,args-name ,args-name))
|
183 |
+
(or (null? ,args-name)
|
184 |
+
(null? (cdr ,args-name))
|
185 |
+
(let ((,an-arg-name (car ,args-name))
|
186 |
+
(,new-val-name (cadr ,args-name)))
|
187 |
+
(case ,an-arg-name
|
188 |
+
,@ (append
|
189 |
+
(map (lambda (kw v) `((,kw) (set! ,v ,new-val-name))) kws vars)
|
190 |
+
`((else (throw 'bad-set-option ,an-arg-name)))))
|
191 |
+
(,loop-name (cddr ,args-name)))))))))
|
192 |
+
|
193 |
+
(define (delegating-getter-and-setter-syntax vars get-delegate set-delegate)
|
194 |
+
(let ((args-name (gensym "args"))
|
195 |
+
(an-arg-name (gensym "an-arg"))
|
196 |
+
(new-val-name (gensym "new-value"))
|
197 |
+
(loop-name (gensym "loop"))
|
198 |
+
(kws (map symbol->keyword vars)))
|
199 |
+
(list `(lambda ,args-name
|
200 |
+
(let ,loop-name ((,args-name ,args-name))
|
201 |
+
(if (null? ,args-name)
|
202 |
+
(append!
|
203 |
+
,(if (null? kws)
|
204 |
+
''()
|
205 |
+
`(let ((all-vals (,loop-name ',kws)))
|
206 |
+
(let ,loop-name ((vals all-vals)
|
207 |
+
(kws ',kws))
|
208 |
+
(if (null? vals)
|
209 |
+
'()
|
210 |
+
`(,(car kws) ,(car vals) ,@(,loop-name (cdr vals) (cdr kws)))))))
|
211 |
+
(,get-delegate))
|
212 |
+
(map (lambda (,an-arg-name)
|
213 |
+
(case ,an-arg-name
|
214 |
+
,@ (append
|
215 |
+
(map (lambda (kw v) `((,kw) ,v)) kws vars)
|
216 |
+
`((else (car (,get-delegate ,an-arg-name)))))))
|
217 |
+
,args-name))))
|
218 |
+
|
219 |
+
`(lambda ,args-name
|
220 |
+
(let ,loop-name ((,args-name ,args-name))
|
221 |
+
(or (null? ,args-name)
|
222 |
+
(null? (cdr ,args-name))
|
223 |
+
(let ((,an-arg-name (car ,args-name))
|
224 |
+
(,new-val-name (cadr ,args-name)))
|
225 |
+
(case ,an-arg-name
|
226 |
+
,@ (append
|
227 |
+
(map (lambda (kw v) `((,kw) (set! ,v ,new-val-name))) kws vars)
|
228 |
+
`((else (,set-delegate ,an-arg-name ,new-val-name)))))
|
229 |
+
(,loop-name (cddr ,args-name)))))))))
|
230 |
+
|
231 |
+
|
232 |
+
|
233 |
+
|
234 |
+
;;; with-configuration-getter-and-setter <vars-etc> proc
|
235 |
+
;;;
|
236 |
+
;;; Create a getter and setter that can trigger arbitrary computation.
|
237 |
+
;;;
|
238 |
+
;;; <vars-etc> is a list of variable specifiers, explained below.
|
239 |
+
;;; proc is called:
|
240 |
+
;;;
|
241 |
+
;;; (proc getter setter)
|
242 |
+
;;;
|
243 |
+
;;; Each element of the <vars-etc> list is of the form:
|
244 |
+
;;;
|
245 |
+
;;; (<var> getter-hook setter-hook)
|
246 |
+
;;;
|
247 |
+
;;; Both hook elements are evaluated; the variable name is not.
|
248 |
+
;;; Either hook may be #f or procedure.
|
249 |
+
;;;
|
250 |
+
;;; A getter hook is a thunk that returns a value for the corresponding
|
251 |
+
;;; variable. If omitted (#f is passed), the binding of <var> is
|
252 |
+
;;; returned.
|
253 |
+
;;;
|
254 |
+
;;; A setter hook is a procedure of one argument that accepts a new value
|
255 |
+
;;; for the corresponding variable. If omitted, the binding of <var>
|
256 |
+
;;; is simply set using set!.
|
257 |
+
;;;
|
258 |
+
(defmacro with-configuration-getter-and-setter (vars-etc proc)
|
259 |
+
`((lambda (simpler-get simpler-set body-proc)
|
260 |
+
(with-delegating-getter-and-setter ()
|
261 |
+
simpler-get simpler-set body-proc))
|
262 |
+
|
263 |
+
(lambda (kw)
|
264 |
+
(case kw
|
265 |
+
,@(map (lambda (v) `((,(symbol->keyword (car v)))
|
266 |
+
,(cond
|
267 |
+
((cadr v) => list)
|
268 |
+
(else `(list ,(car v))))))
|
269 |
+
vars-etc)))
|
270 |
+
|
271 |
+
(lambda (kw new-val)
|
272 |
+
(case kw
|
273 |
+
,@(map (lambda (v) `((,(symbol->keyword (car v)))
|
274 |
+
,(cond
|
275 |
+
((caddr v) => (lambda (proc) `(,proc new-val)))
|
276 |
+
(else `(set! ,(car v) new-val)))))
|
277 |
+
vars-etc)))
|
278 |
+
|
279 |
+
,proc))
|
280 |
+
|
281 |
+
(defmacro with-delegating-configuration-getter-and-setter (vars-etc delegate-get delegate-set proc)
|
282 |
+
`((lambda (simpler-get simpler-set body-proc)
|
283 |
+
(with-delegating-getter-and-setter ()
|
284 |
+
simpler-get simpler-set body-proc))
|
285 |
+
|
286 |
+
(lambda (kw)
|
287 |
+
(case kw
|
288 |
+
,@(append! (map (lambda (v) `((,(symbol->keyword (car v)))
|
289 |
+
,(cond
|
290 |
+
((cadr v) => list)
|
291 |
+
(else `(list ,(car v))))))
|
292 |
+
vars-etc)
|
293 |
+
`((else (,delegate-get kw))))))
|
294 |
+
|
295 |
+
(lambda (kw new-val)
|
296 |
+
(case kw
|
297 |
+
,@(append! (map (lambda (v) `((,(symbol->keyword (car v)))
|
298 |
+
,(cond
|
299 |
+
((caddr v) => (lambda (proc) `(,proc new-val)))
|
300 |
+
(else `(set! ,(car v) new-val)))))
|
301 |
+
vars-etc)
|
302 |
+
`((else (,delegate-set kw new-val))))))
|
303 |
+
|
304 |
+
,proc))
|
305 |
+
|
306 |
+
|
307 |
+
;;; let-configuration-getter-and-setter <vars-etc> proc
|
308 |
+
;;;
|
309 |
+
;;; This procedure is like with-configuration-getter-and-setter (q.v.)
|
310 |
+
;;; except that each element of <vars-etc> is:
|
311 |
+
;;;
|
312 |
+
;;; (<var> initial-value getter-hook setter-hook)
|
313 |
+
;;;
|
314 |
+
;;; Unlike with-configuration-getter-and-setter, let-configuration-getter-and-setter
|
315 |
+
;;; introduces bindings for the variables named in <vars-etc>.
|
316 |
+
;;; It is short-hand for:
|
317 |
+
;;;
|
318 |
+
;;; (let ((<var1> initial-value-1)
|
319 |
+
;;; (<var2> initial-value-2)
|
320 |
+
;;; ...)
|
321 |
+
;;; (with-configuration-getter-and-setter ((<var1> v1-get v1-set) ...) proc))
|
322 |
+
;;;
|
323 |
+
(defmacro let-with-configuration-getter-and-setter (vars-etc proc)
|
324 |
+
`(let ,(map (lambda (v) `(,(car v) ,(cadr v))) vars-etc)
|
325 |
+
(with-configuration-getter-and-setter ,(map (lambda (v) `(,(car v) ,(caddr v) ,(cadddr v))) vars-etc)
|
326 |
+
,proc)))
|
node-addon-lilypond/output/share/guile/1.8/ice-9/channel.scm
ADDED
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
;;; Guile object channel
|
2 |
+
|
3 |
+
;; Copyright (C) 2001, 2006 Free Software Foundation, Inc.
|
4 |
+
|
5 |
+
;; This library is free software; you can redistribute it and/or
|
6 |
+
;; modify it under the terms of the GNU Lesser General Public
|
7 |
+
;; License as published by the Free Software Foundation; either
|
8 |
+
;; version 2.1 of the License, or (at your option) any later version.
|
9 |
+
;;
|
10 |
+
;; This library is distributed in the hope that it will be useful,
|
11 |
+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13 |
+
;; Lesser General Public License for more details.
|
14 |
+
;;
|
15 |
+
;; You should have received a copy of the GNU Lesser General Public
|
16 |
+
;; License along with this library; if not, write to the Free Software
|
17 |
+
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18 |
+
|
19 |
+
;;; Commentary:
|
20 |
+
|
21 |
+
;; Now you can use Guile's modules in Emacs Lisp like this:
|
22 |
+
;;
|
23 |
+
;; (guile-import current-module)
|
24 |
+
;; (guile-import module-ref)
|
25 |
+
;;
|
26 |
+
;; (setq assq (module-ref (current-module) 'assq))
|
27 |
+
;; => ("<guile>" %%1%% . "#<primitive-procedure assq>")
|
28 |
+
;;
|
29 |
+
;; (guile-use-modules (ice-9 documentation))
|
30 |
+
;;
|
31 |
+
;; (object-documentation assq)
|
32 |
+
;; =>
|
33 |
+
;; " - primitive: assq key alist
|
34 |
+
;; - primitive: assv key alist
|
35 |
+
;; - primitive: assoc key alist
|
36 |
+
;; Fetches the entry in ALIST that is associated with KEY. To decide
|
37 |
+
;; whether the argument KEY matches a particular entry in ALIST,
|
38 |
+
;; `assq' compares keys with `eq?', `assv' uses `eqv?' and `assoc'
|
39 |
+
;; uses `equal?'. If KEY cannot be found in ALIST (according to
|
40 |
+
;; whichever equality predicate is in use), then `#f' is returned.
|
41 |
+
;; These functions return the entire alist entry found (i.e. both the
|
42 |
+
;; key and the value)."
|
43 |
+
;;
|
44 |
+
;; Probably we can use GTK in Emacs Lisp. Can anybody try it?
|
45 |
+
;;
|
46 |
+
;; I have also implemented Guile Scheme mode and Scheme Interaction mode.
|
47 |
+
;; Just put the following lines in your ~/.emacs:
|
48 |
+
;;
|
49 |
+
;; (require 'guile-scheme)
|
50 |
+
;; (setq initial-major-mode 'scheme-interaction-mode)
|
51 |
+
;;
|
52 |
+
;; Currently, the following commands are available:
|
53 |
+
;;
|
54 |
+
;; M-TAB guile-scheme-complete-symbol
|
55 |
+
;; M-C-x guile-scheme-eval-define
|
56 |
+
;; C-x C-e guile-scheme-eval-last-sexp
|
57 |
+
;; C-c C-b guile-scheme-eval-buffer
|
58 |
+
;; C-c C-r guile-scheme-eval-region
|
59 |
+
;; C-c : guile-scheme-eval-expression
|
60 |
+
;;
|
61 |
+
;; I'll write more commands soon, or if you want to hack, please take
|
62 |
+
;; a look at the following files:
|
63 |
+
;;
|
64 |
+
;; guile-core/ice-9/channel.scm ;; object channel
|
65 |
+
;; guile-core/emacs/guile.el ;; object adapter
|
66 |
+
;; guile-core/emacs/guile-emacs.scm ;; Guile <-> Emacs channels
|
67 |
+
;; guile-core/emacs/guile-scheme.el ;; Guile Scheme mode
|
68 |
+
;;
|
69 |
+
;; As always, there are more than one bugs ;)
|
70 |
+
|
71 |
+
;;; Code:
|
72 |
+
|
73 |
+
(define-module (ice-9 channel)
|
74 |
+
:export (make-object-channel
|
75 |
+
channel-open
|
76 |
+
channel-print-value
|
77 |
+
channel-print-token))
|
78 |
+
|
79 |
+
;;;
|
80 |
+
;;; Channel type
|
81 |
+
;;;
|
82 |
+
|
83 |
+
(define channel-type
|
84 |
+
(make-record-type 'channel '(stdin stdout printer token-module)))
|
85 |
+
|
86 |
+
(define make-channel (record-constructor channel-type))
|
87 |
+
|
88 |
+
(define (make-object-channel printer)
|
89 |
+
(make-channel (current-input-port)
|
90 |
+
(current-output-port)
|
91 |
+
printer
|
92 |
+
(make-module)))
|
93 |
+
|
94 |
+
(define channel-stdin (record-accessor channel-type 'stdin))
|
95 |
+
(define channel-stdout (record-accessor channel-type 'stdout))
|
96 |
+
(define channel-printer (record-accessor channel-type 'printer))
|
97 |
+
(define channel-token-module (record-accessor channel-type 'token-module))
|
98 |
+
|
99 |
+
;;;
|
100 |
+
;;; Channel
|
101 |
+
;;;
|
102 |
+
|
103 |
+
(define (channel-open ch)
|
104 |
+
(let ((stdin (channel-stdin ch))
|
105 |
+
(stdout (channel-stdout ch))
|
106 |
+
(printer (channel-printer ch))
|
107 |
+
(token-module (channel-token-module ch)))
|
108 |
+
(let loop ()
|
109 |
+
(catch #t
|
110 |
+
(lambda ()
|
111 |
+
(channel:prompt stdout)
|
112 |
+
(let ((cmd (read stdin)))
|
113 |
+
(if (eof-object? cmd)
|
114 |
+
(throw 'quit)
|
115 |
+
(case cmd
|
116 |
+
((eval)
|
117 |
+
(module-use! (current-module) token-module)
|
118 |
+
(printer ch (eval (read stdin) (current-module))))
|
119 |
+
((destroy)
|
120 |
+
(let ((token (read stdin)))
|
121 |
+
(if (module-defined? token-module token)
|
122 |
+
(module-remove! token-module token)
|
123 |
+
(channel:error stdout "Invalid token: ~S" token))))
|
124 |
+
((quit)
|
125 |
+
(throw 'quit))
|
126 |
+
(else
|
127 |
+
(channel:error stdout "Unknown command: ~S" cmd)))))
|
128 |
+
(loop))
|
129 |
+
(lambda (key . args)
|
130 |
+
(case key
|
131 |
+
((quit) (throw 'quit))
|
132 |
+
(else
|
133 |
+
(format stdout "exception = ~S\n"
|
134 |
+
(list key (apply format #f (cadr args) (caddr args))))
|
135 |
+
(loop))))))))
|
136 |
+
|
137 |
+
(define (channel-print-value ch val)
|
138 |
+
(format (channel-stdout ch) "value = ~S\n" val))
|
139 |
+
|
140 |
+
(define (channel-print-token ch val)
|
141 |
+
(let* ((token (symbol-append (gensym "%%") '%%))
|
142 |
+
(pair (cons token (object->string val))))
|
143 |
+
(format (channel-stdout ch) "token = ~S\n" pair)
|
144 |
+
(module-define! (channel-token-module ch) token val)))
|
145 |
+
|
146 |
+
(define (channel:prompt port)
|
147 |
+
(display "channel> " port)
|
148 |
+
(force-output port))
|
149 |
+
|
150 |
+
(define (channel:error port msg . args)
|
151 |
+
(display "ERROR: " port)
|
152 |
+
(apply format port msg args)
|
153 |
+
(newline port))
|
154 |
+
|
155 |
+
;;;
|
156 |
+
;;; Guile 1.4 compatibility
|
157 |
+
;;;
|
158 |
+
|
159 |
+
(define guile:eval eval)
|
160 |
+
(define eval
|
161 |
+
(if (= (car (procedure-property guile:eval 'arity)) 1)
|
162 |
+
(lambda (x e) (guile:eval x))
|
163 |
+
guile:eval))
|
164 |
+
|
165 |
+
(define object->string
|
166 |
+
(if (defined? 'object->string)
|
167 |
+
object->string
|
168 |
+
(lambda (x) (format #f "~S" x))))
|
169 |
+
|
170 |
+
;;; channel.scm ends here
|
node-addon-lilypond/output/share/guile/1.8/ice-9/common-list.scm
ADDED
@@ -0,0 +1,278 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
;;;; common-list.scm --- COMMON LISP list functions for Scheme
|
2 |
+
;;;;
|
3 |
+
;;;; Copyright (C) 1995, 1996, 1997, 2001, 2006 Free Software Foundation, Inc.
|
4 |
+
;;;;
|
5 |
+
;;;; This library is free software; you can redistribute it and/or
|
6 |
+
;;;; modify it under the terms of the GNU Lesser General Public
|
7 |
+
;;;; License as published by the Free Software Foundation; either
|
8 |
+
;;;; version 2.1 of the License, or (at your option) any later version.
|
9 |
+
;;;;
|
10 |
+
;;;; This library is distributed in the hope that it will be useful,
|
11 |
+
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
+
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13 |
+
;;;; Lesser General Public License for more details.
|
14 |
+
;;;;
|
15 |
+
;;;; You should have received a copy of the GNU Lesser General Public
|
16 |
+
;;;; License along with this library; if not, write to the Free Software
|
17 |
+
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18 |
+
;;;;
|
19 |
+
|
20 |
+
;;; Commentary:
|
21 |
+
|
22 |
+
;; These procedures are exported:
|
23 |
+
;; (adjoin e l)
|
24 |
+
;; (union l1 l2)
|
25 |
+
;; (intersection l1 l2)
|
26 |
+
;; (set-difference l1 l2)
|
27 |
+
;; (reduce-init p init l)
|
28 |
+
;; (reduce p l)
|
29 |
+
;; (some pred l . rest)
|
30 |
+
;; (every pred l . rest)
|
31 |
+
;; (notany pred . ls)
|
32 |
+
;; (notevery pred . ls)
|
33 |
+
;; (count-if pred l)
|
34 |
+
;; (find-if pred l)
|
35 |
+
;; (member-if pred l)
|
36 |
+
;; (remove-if pred l)
|
37 |
+
;; (remove-if-not pred l)
|
38 |
+
;; (delete-if! pred l)
|
39 |
+
;; (delete-if-not! pred l)
|
40 |
+
;; (butlast lst n)
|
41 |
+
;; (and? . args)
|
42 |
+
;; (or? . args)
|
43 |
+
;; (has-duplicates? lst)
|
44 |
+
;; (pick p l)
|
45 |
+
;; (pick-mappings p l)
|
46 |
+
;; (uniq l)
|
47 |
+
;;
|
48 |
+
;; See docstrings for each procedure for more info. See also module
|
49 |
+
;; `(srfi srfi-1)' for a complete list handling library.
|
50 |
+
|
51 |
+
;;; Code:
|
52 |
+
|
53 |
+
(define-module (ice-9 common-list)
|
54 |
+
:export (adjoin union intersection set-difference reduce-init reduce
|
55 |
+
some every notany notevery count-if find-if member-if remove-if
|
56 |
+
remove-if-not delete-if! delete-if-not! butlast and? or?
|
57 |
+
has-duplicates? pick pick-mappings uniq))
|
58 |
+
|
59 |
+
;;"comlist.scm" Implementation of COMMON LISP list functions for Scheme
|
60 |
+
; Copyright (C) 1991, 1993, 1995 Aubrey Jaffer.
|
61 |
+
;
|
62 |
+
;Permission to copy this software, to redistribute it, and to use it
|
63 |
+
;for any purpose is granted, subject to the following restrictions and
|
64 |
+
;understandings.
|
65 |
+
;
|
66 |
+
;1. Any copy made of this software must include this copyright notice
|
67 |
+
;in full.
|
68 |
+
;
|
69 |
+
;2. I have made no warrantee or representation that the operation of
|
70 |
+
;this software will be error-free, and I am under no obligation to
|
71 |
+
;provide any services, by way of maintenance, update, or otherwise.
|
72 |
+
;
|
73 |
+
;3. In conjunction with products arising from the use of this
|
74 |
+
;material, there shall be no use of my name in any advertising,
|
75 |
+
;promotional, or sales literature without prior written consent in
|
76 |
+
;each case.
|
77 |
+
|
78 |
+
(define (adjoin e l)
|
79 |
+
"Return list L, possibly with element E added if it is not already in L."
|
80 |
+
(if (memq e l) l (cons e l)))
|
81 |
+
|
82 |
+
(define (union l1 l2)
|
83 |
+
"Return a new list that is the union of L1 and L2.
|
84 |
+
Elements that occur in both lists occur only once in
|
85 |
+
the result list."
|
86 |
+
(cond ((null? l1) l2)
|
87 |
+
((null? l2) l1)
|
88 |
+
(else (union (cdr l1) (adjoin (car l1) l2)))))
|
89 |
+
|
90 |
+
(define (intersection l1 l2)
|
91 |
+
"Return a new list that is the intersection of L1 and L2.
|
92 |
+
Only elements that occur in both lists occur in the result list."
|
93 |
+
(if (null? l2) l2
|
94 |
+
(let loop ((l1 l1) (result '()))
|
95 |
+
(cond ((null? l1) (reverse! result))
|
96 |
+
((memv (car l1) l2) (loop (cdr l1) (cons (car l1) result)))
|
97 |
+
(else (loop (cdr l1) result))))))
|
98 |
+
|
99 |
+
(define (set-difference l1 l2)
|
100 |
+
"Return elements from list L1 that are not in list L2."
|
101 |
+
(let loop ((l1 l1) (result '()))
|
102 |
+
(cond ((null? l1) (reverse! result))
|
103 |
+
((memv (car l1) l2) (loop (cdr l1) result))
|
104 |
+
(else (loop (cdr l1) (cons (car l1) result))))))
|
105 |
+
|
106 |
+
(define (reduce-init p init l)
|
107 |
+
"Same as `reduce' except it implicitly inserts INIT at the start of L."
|
108 |
+
(if (null? l)
|
109 |
+
init
|
110 |
+
(reduce-init p (p init (car l)) (cdr l))))
|
111 |
+
|
112 |
+
(define (reduce p l)
|
113 |
+
"Combine all the elements of sequence L using a binary operation P.
|
114 |
+
The combination is left-associative. For example, using +, one can
|
115 |
+
add up all the elements. `reduce' allows you to apply a function which
|
116 |
+
accepts only two arguments to more than 2 objects. Functional
|
117 |
+
programmers usually refer to this as foldl."
|
118 |
+
(cond ((null? l) l)
|
119 |
+
((null? (cdr l)) (car l))
|
120 |
+
(else (reduce-init p (car l) (cdr l)))))
|
121 |
+
|
122 |
+
(define (some pred l . rest)
|
123 |
+
"PRED is a boolean function of as many arguments as there are list
|
124 |
+
arguments to `some', i.e., L plus any optional arguments. PRED is
|
125 |
+
applied to successive elements of the list arguments in order. As soon
|
126 |
+
as one of these applications returns a true value, return that value.
|
127 |
+
If no application returns a true value, return #f.
|
128 |
+
All the lists should have the same length."
|
129 |
+
(cond ((null? rest)
|
130 |
+
(let mapf ((l l))
|
131 |
+
(and (not (null? l))
|
132 |
+
(or (pred (car l)) (mapf (cdr l))))))
|
133 |
+
(else (let mapf ((l l) (rest rest))
|
134 |
+
(and (not (null? l))
|
135 |
+
(or (apply pred (car l) (map car rest))
|
136 |
+
(mapf (cdr l) (map cdr rest))))))))
|
137 |
+
|
138 |
+
(define (every pred l . rest)
|
139 |
+
"Return #t iff every application of PRED to L, etc., returns #t.
|
140 |
+
Analogous to `some' except it returns #t if every application of
|
141 |
+
PRED is #t and #f otherwise."
|
142 |
+
(cond ((null? rest)
|
143 |
+
(let mapf ((l l))
|
144 |
+
(or (null? l)
|
145 |
+
(and (pred (car l)) (mapf (cdr l))))))
|
146 |
+
(else (let mapf ((l l) (rest rest))
|
147 |
+
(or (null? l)
|
148 |
+
(and (apply pred (car l) (map car rest))
|
149 |
+
(mapf (cdr l) (map cdr rest))))))))
|
150 |
+
|
151 |
+
(define (notany pred . ls)
|
152 |
+
"Return #t iff every application of PRED to L, etc., returns #f.
|
153 |
+
Analogous to some but returns #t if no application of PRED returns a
|
154 |
+
true value or #f as soon as any one does."
|
155 |
+
(not (apply some pred ls)))
|
156 |
+
|
157 |
+
(define (notevery pred . ls)
|
158 |
+
"Return #t iff there is an application of PRED to L, etc., that returns #f.
|
159 |
+
Analogous to some but returns #t as soon as an application of PRED returns #f,
|
160 |
+
or #f otherwise."
|
161 |
+
(not (apply every pred ls)))
|
162 |
+
|
163 |
+
(define (count-if pred l)
|
164 |
+
"Return the number of elements in L for which (PRED element) returns true."
|
165 |
+
(let loop ((n 0) (l l))
|
166 |
+
(cond ((null? l) n)
|
167 |
+
((pred (car l)) (loop (+ n 1) (cdr l)))
|
168 |
+
(else (loop n (cdr l))))))
|
169 |
+
|
170 |
+
(define (find-if pred l)
|
171 |
+
"Search for the first element in L for which (PRED element) returns true.
|
172 |
+
If found, return that element, otherwise return #f."
|
173 |
+
(cond ((null? l) #f)
|
174 |
+
((pred (car l)) (car l))
|
175 |
+
(else (find-if pred (cdr l)))))
|
176 |
+
|
177 |
+
(define (member-if pred l)
|
178 |
+
"Return the first sublist of L for whose car PRED is true."
|
179 |
+
(cond ((null? l) #f)
|
180 |
+
((pred (car l)) l)
|
181 |
+
(else (member-if pred (cdr l)))))
|
182 |
+
|
183 |
+
(define (remove-if pred l)
|
184 |
+
"Remove all elements from L where (PRED element) is true.
|
185 |
+
Return everything that's left."
|
186 |
+
(let loop ((l l) (result '()))
|
187 |
+
(cond ((null? l) (reverse! result))
|
188 |
+
((pred (car l)) (loop (cdr l) result))
|
189 |
+
(else (loop (cdr l) (cons (car l) result))))))
|
190 |
+
|
191 |
+
(define (remove-if-not pred l)
|
192 |
+
"Remove all elements from L where (PRED element) is #f.
|
193 |
+
Return everything that's left."
|
194 |
+
(let loop ((l l) (result '()))
|
195 |
+
(cond ((null? l) (reverse! result))
|
196 |
+
((not (pred (car l))) (loop (cdr l) result))
|
197 |
+
(else (loop (cdr l) (cons (car l) result))))))
|
198 |
+
|
199 |
+
(define (delete-if! pred l)
|
200 |
+
"Destructive version of `remove-if'."
|
201 |
+
(let delete-if ((l l))
|
202 |
+
(cond ((null? l) '())
|
203 |
+
((pred (car l)) (delete-if (cdr l)))
|
204 |
+
(else
|
205 |
+
(set-cdr! l (delete-if (cdr l)))
|
206 |
+
l))))
|
207 |
+
|
208 |
+
(define (delete-if-not! pred l)
|
209 |
+
"Destructive version of `remove-if-not'."
|
210 |
+
(let delete-if-not ((l l))
|
211 |
+
(cond ((null? l) '())
|
212 |
+
((not (pred (car l))) (delete-if-not (cdr l)))
|
213 |
+
(else
|
214 |
+
(set-cdr! l (delete-if-not (cdr l)))
|
215 |
+
l))))
|
216 |
+
|
217 |
+
(define (butlast lst n)
|
218 |
+
"Return all but the last N elements of LST."
|
219 |
+
(letrec ((l (- (length lst) n))
|
220 |
+
(bl (lambda (lst n)
|
221 |
+
(cond ((null? lst) lst)
|
222 |
+
((positive? n)
|
223 |
+
(cons (car lst) (bl (cdr lst) (+ -1 n))))
|
224 |
+
(else '())))))
|
225 |
+
(bl lst (if (negative? n)
|
226 |
+
(error "negative argument to butlast" n)
|
227 |
+
l))))
|
228 |
+
|
229 |
+
(define (and? . args)
|
230 |
+
"Return #t iff all of ARGS are true."
|
231 |
+
(cond ((null? args) #t)
|
232 |
+
((car args) (apply and? (cdr args)))
|
233 |
+
(else #f)))
|
234 |
+
|
235 |
+
(define (or? . args)
|
236 |
+
"Return #t iff any of ARGS is true."
|
237 |
+
(cond ((null? args) #f)
|
238 |
+
((car args) #t)
|
239 |
+
(else (apply or? (cdr args)))))
|
240 |
+
|
241 |
+
(define (has-duplicates? lst)
|
242 |
+
"Return #t iff 2 members of LST are equal?, else #f."
|
243 |
+
(cond ((null? lst) #f)
|
244 |
+
((member (car lst) (cdr lst)) #t)
|
245 |
+
(else (has-duplicates? (cdr lst)))))
|
246 |
+
|
247 |
+
(define (pick p l)
|
248 |
+
"Apply P to each element of L, returning a list of elts
|
249 |
+
for which P returns a non-#f value."
|
250 |
+
(let loop ((s '())
|
251 |
+
(l l))
|
252 |
+
(cond
|
253 |
+
((null? l) s)
|
254 |
+
((p (car l)) (loop (cons (car l) s) (cdr l)))
|
255 |
+
(else (loop s (cdr l))))))
|
256 |
+
|
257 |
+
(define (pick-mappings p l)
|
258 |
+
"Apply P to each element of L, returning a list of the
|
259 |
+
non-#f return values of P."
|
260 |
+
(let loop ((s '())
|
261 |
+
(l l))
|
262 |
+
(cond
|
263 |
+
((null? l) s)
|
264 |
+
((p (car l)) => (lambda (mapping) (loop (cons mapping s) (cdr l))))
|
265 |
+
(else (loop s (cdr l))))))
|
266 |
+
|
267 |
+
(define (uniq l)
|
268 |
+
"Return a list containing elements of L, with duplicates removed."
|
269 |
+
(let loop ((acc '())
|
270 |
+
(l l))
|
271 |
+
(if (null? l)
|
272 |
+
(reverse! acc)
|
273 |
+
(loop (if (memq (car l) acc)
|
274 |
+
acc
|
275 |
+
(cons (car l) acc))
|
276 |
+
(cdr l)))))
|
277 |
+
|
278 |
+
;;; common-list.scm ends here
|
node-addon-lilypond/output/share/guile/1.8/ice-9/debug.scm
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
;;;; Copyright (C) 1996, 1997, 1998, 1999, 2001, 2006 Free Software Foundation
|
2 |
+
;;;;
|
3 |
+
;;;; This library is free software; you can redistribute it and/or
|
4 |
+
;;;; modify it under the terms of the GNU Lesser General Public
|
5 |
+
;;;; License as published by the Free Software Foundation; either
|
6 |
+
;;;; version 2.1 of the License, or (at your option) any later version.
|
7 |
+
;;;;
|
8 |
+
;;;; This library is distributed in the hope that it will be useful,
|
9 |
+
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10 |
+
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11 |
+
;;;; Lesser General Public License for more details.
|
12 |
+
;;;;
|
13 |
+
;;;; You should have received a copy of the GNU Lesser General Public
|
14 |
+
;;;; License along with this library; if not, write to the Free Software
|
15 |
+
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16 |
+
;;;;
|
17 |
+
;;;; The author can be reached at djurfeldt@nada.kth.se
|
18 |
+
;;;; Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN
|
19 |
+
;;;;
|
20 |
+
|
21 |
+
|
22 |
+
(define-module (ice-9 debug)
|
23 |
+
:export (frame-number->index trace untrace trace-stack untrace-stack))
|
24 |
+
|
25 |
+
|
26 |
+
;;; {Misc}
|
27 |
+
;;;
|
28 |
+
(define (frame-number->index n . stack)
|
29 |
+
(let ((stack (if (null? stack)
|
30 |
+
(fluid-ref the-last-stack)
|
31 |
+
(car stack))))
|
32 |
+
(if (memq 'backwards (debug-options))
|
33 |
+
n
|
34 |
+
(- (stack-length stack) n 1))))
|
35 |
+
|
36 |
+
|
37 |
+
;;; {Trace}
|
38 |
+
;;;
|
39 |
+
;;; This code is just an experimental prototype (e. g., it is not
|
40 |
+
;;; thread safe), but since it's at the same time useful, it's
|
41 |
+
;;; included anyway.
|
42 |
+
;;;
|
43 |
+
(define traced-procedures '())
|
44 |
+
|
45 |
+
(define (trace . args)
|
46 |
+
(if (null? args)
|
47 |
+
(nameify traced-procedures)
|
48 |
+
(begin
|
49 |
+
(for-each (lambda (proc)
|
50 |
+
(if (not (procedure? proc))
|
51 |
+
(error "trace: Wrong type argument:" proc))
|
52 |
+
(set-procedure-property! proc 'trace #t)
|
53 |
+
(if (not (memq proc traced-procedures))
|
54 |
+
(set! traced-procedures
|
55 |
+
(cons proc traced-procedures))))
|
56 |
+
args)
|
57 |
+
(trap-set! apply-frame-handler trace-entry)
|
58 |
+
(trap-set! exit-frame-handler trace-exit)
|
59 |
+
;; We used to reset `trace-level' here to 0, but this is wrong
|
60 |
+
;; if `trace' itself is being traced, since `trace-exit' will
|
61 |
+
;; then decrement `trace-level' to -1! It shouldn't actually
|
62 |
+
;; be necessary to set `trace-level' here at all.
|
63 |
+
(debug-enable 'trace)
|
64 |
+
(nameify args))))
|
65 |
+
|
66 |
+
(define (untrace . args)
|
67 |
+
(if (and (null? args)
|
68 |
+
(not (null? traced-procedures)))
|
69 |
+
(apply untrace traced-procedures)
|
70 |
+
(begin
|
71 |
+
(for-each (lambda (proc)
|
72 |
+
(set-procedure-property! proc 'trace #f)
|
73 |
+
(set! traced-procedures (delq! proc traced-procedures)))
|
74 |
+
args)
|
75 |
+
(if (null? traced-procedures)
|
76 |
+
(debug-disable 'trace))
|
77 |
+
(nameify args))))
|
78 |
+
|
79 |
+
(define (nameify ls)
|
80 |
+
(map (lambda (proc)
|
81 |
+
(let ((name (procedure-name proc)))
|
82 |
+
(or name proc)))
|
83 |
+
ls))
|
84 |
+
|
85 |
+
(define trace-level 0)
|
86 |
+
(add-hook! abort-hook (lambda () (set! trace-level 0)))
|
87 |
+
|
88 |
+
(define traced-stack-ids (list 'repl-stack))
|
89 |
+
(define trace-all-stacks? #f)
|
90 |
+
|
91 |
+
(define (trace-stack id)
|
92 |
+
"Add ID to the set of stack ids for which tracing is active.
|
93 |
+
If `#t' is in this set, tracing is active regardless of stack context.
|
94 |
+
To remove ID again, use `untrace-stack'. If you add the same ID twice
|
95 |
+
using `trace-stack', you will need to remove it twice."
|
96 |
+
(set! traced-stack-ids (cons id traced-stack-ids))
|
97 |
+
(set! trace-all-stacks? (memq #t traced-stack-ids)))
|
98 |
+
|
99 |
+
(define (untrace-stack id)
|
100 |
+
"Remove ID from the set of stack ids for which tracing is active."
|
101 |
+
(set! traced-stack-ids (delq1! id traced-stack-ids))
|
102 |
+
(set! trace-all-stacks? (memq #t traced-stack-ids)))
|
103 |
+
|
104 |
+
(define (trace-entry key cont tail)
|
105 |
+
(if (or trace-all-stacks?
|
106 |
+
(memq (stack-id cont) traced-stack-ids))
|
107 |
+
(let ((cep (current-error-port))
|
108 |
+
(frame (last-stack-frame cont)))
|
109 |
+
(if (not tail)
|
110 |
+
(set! trace-level (+ trace-level 1)))
|
111 |
+
(let indent ((n trace-level))
|
112 |
+
(cond ((> n 1) (display "| " cep) (indent (- n 1)))))
|
113 |
+
(display-application frame cep)
|
114 |
+
(newline cep)))
|
115 |
+
;; It's not necessary to call the continuation since
|
116 |
+
;; execution will continue if the handler returns
|
117 |
+
;(cont #f)
|
118 |
+
)
|
119 |
+
|
120 |
+
(define (trace-exit key cont retval)
|
121 |
+
(if (or trace-all-stacks?
|
122 |
+
(memq (stack-id cont) traced-stack-ids))
|
123 |
+
(let ((cep (current-error-port)))
|
124 |
+
(set! trace-level (- trace-level 1))
|
125 |
+
(let indent ((n trace-level))
|
126 |
+
(cond ((> n 0) (display "| " cep) (indent (- n 1)))))
|
127 |
+
(write retval cep)
|
128 |
+
(newline cep))))
|
129 |
+
|
130 |
+
|
131 |
+
;;; A fix to get the error handling working together with the module system.
|
132 |
+
;;;
|
133 |
+
;;; XXX - Still needed?
|
134 |
+
(module-set! the-root-module 'debug-options debug-options)
|
node-addon-lilypond/output/share/guile/1.8/ice-9/debugger.scm
ADDED
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
;;;; Guile Debugger
|
2 |
+
|
3 |
+
;;; Copyright (C) 1999, 2001, 2002, 2006 Free Software Foundation, Inc.
|
4 |
+
;;;
|
5 |
+
;; This library is free software; you can redistribute it and/or
|
6 |
+
;; modify it under the terms of the GNU Lesser General Public
|
7 |
+
;; License as published by the Free Software Foundation; either
|
8 |
+
;; version 2.1 of the License, or (at your option) any later version.
|
9 |
+
;;
|
10 |
+
;; This library is distributed in the hope that it will be useful,
|
11 |
+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13 |
+
;; Lesser General Public License for more details.
|
14 |
+
;;
|
15 |
+
;; You should have received a copy of the GNU Lesser General Public
|
16 |
+
;; License along with this library; if not, write to the Free Software
|
17 |
+
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18 |
+
|
19 |
+
(define-module (ice-9 debugger)
|
20 |
+
#:use-module (ice-9 debugger command-loop)
|
21 |
+
#:use-module (ice-9 debugger state)
|
22 |
+
#:use-module (ice-9 debugger utils)
|
23 |
+
#:use-module (ice-9 format)
|
24 |
+
#:export (debug-stack
|
25 |
+
debug
|
26 |
+
debug-last-error
|
27 |
+
debugger-error
|
28 |
+
debugger-quit
|
29 |
+
debugger-input-port
|
30 |
+
debugger-output-port
|
31 |
+
debug-on-error)
|
32 |
+
#:no-backtrace)
|
33 |
+
|
34 |
+
;;; The old (ice-9 debugger) has been factored into its constituent
|
35 |
+
;;; parts:
|
36 |
+
;;;
|
37 |
+
;;; (ice-9 debugger) - public interface to all of the following
|
38 |
+
;;;
|
39 |
+
;;; (... commands) - procedures implementing the guts of the commands
|
40 |
+
;;; provided by the interactive debugger
|
41 |
+
;;;
|
42 |
+
;;; (... command-loop) - binding these commands into the interactive
|
43 |
+
;;; debugger command loop
|
44 |
+
;;;
|
45 |
+
;;; (... state) - implementation of an object that tracks current
|
46 |
+
;;; debugger state
|
47 |
+
;;;
|
48 |
+
;;; (... utils) - utilities for printing out frame and stack
|
49 |
+
;;; information in various formats
|
50 |
+
;;;
|
51 |
+
;;; The division between (... commands) and (... command-loop) exists
|
52 |
+
;;; because I (NJ) have another generic command loop implementation
|
53 |
+
;;; under development, and I want to be able to switch easily between
|
54 |
+
;;; that and the command loop implementation here. Thus the
|
55 |
+
;;; procedures in this file delegate to a debugger command loop
|
56 |
+
;;; implementation via the `debugger-command-loop-*' interface. The
|
57 |
+
;;; (ice-9 debugger command-loop) implementation can be replaced by
|
58 |
+
;;; any other that implements the `debugger-command-loop-*' interface
|
59 |
+
;;; simply by changing the relevant #:use-module line above.
|
60 |
+
;;;
|
61 |
+
;;; - Neil Jerram <neil@ossau.uklinux.net> 2002-10-26, updated 2005-07-09
|
62 |
+
|
63 |
+
(define *not-yet-introduced* #t)
|
64 |
+
|
65 |
+
(define (debug-stack stack . flags)
|
66 |
+
"Invoke the Guile debugger to explore the specified @var{stack}.
|
67 |
+
|
68 |
+
@var{flags}, if present, are keywords indicating characteristics of
|
69 |
+
the debugging session: the valid keywords are as follows.
|
70 |
+
|
71 |
+
@table @code
|
72 |
+
@item #:continuable
|
73 |
+
Indicates that the debugger is being invoked from a context (such as
|
74 |
+
an evaluator trap handler) where it is possible to return from the
|
75 |
+
debugger and continue normal code execution. This enables the
|
76 |
+
@dfn{continuing execution} commands, for example @code{continue} and
|
77 |
+
@code{step}.
|
78 |
+
|
79 |
+
@item #:with-introduction
|
80 |
+
Indicates that the debugger should display an introductory message.
|
81 |
+
@end table"
|
82 |
+
(start-stack 'debugger
|
83 |
+
(let ((state (apply make-state stack 0 flags)))
|
84 |
+
(with-input-from-port (debugger-input-port)
|
85 |
+
(lambda ()
|
86 |
+
(with-output-to-port (debugger-output-port)
|
87 |
+
(lambda ()
|
88 |
+
(if (or *not-yet-introduced*
|
89 |
+
(memq #:with-introduction flags))
|
90 |
+
(let ((ssize (stack-length stack)))
|
91 |
+
(display "This is the Guile debugger -- for help, type `help'.\n")
|
92 |
+
(set! *not-yet-introduced* #f)
|
93 |
+
(if (= ssize 1)
|
94 |
+
(display "There is 1 frame on the stack.\n\n")
|
95 |
+
(format #t "There are ~A frames on the stack.\n\n" ssize))))
|
96 |
+
(write-state-short state)
|
97 |
+
(debugger-command-loop state))))))))
|
98 |
+
|
99 |
+
(define (debug)
|
100 |
+
"Invoke the Guile debugger to explore the context of the last error."
|
101 |
+
(let ((stack (fluid-ref the-last-stack)))
|
102 |
+
(if stack
|
103 |
+
(debug-stack stack)
|
104 |
+
(display "Nothing to debug.\n"))))
|
105 |
+
|
106 |
+
(define debug-last-error debug)
|
107 |
+
|
108 |
+
(define (debugger-error message)
|
109 |
+
"Signal a debugger usage error with message @var{message}."
|
110 |
+
(debugger-command-loop-error message))
|
111 |
+
|
112 |
+
(define (debugger-quit)
|
113 |
+
"Exit the debugger."
|
114 |
+
(debugger-command-loop-quit))
|
115 |
+
|
116 |
+
;;; {Debugger Input and Output Ports}
|
117 |
+
|
118 |
+
(define debugger-input-port
|
119 |
+
(let ((input-port (current-input-port)))
|
120 |
+
(make-procedure-with-setter
|
121 |
+
(lambda () input-port)
|
122 |
+
(lambda (port) (set! input-port port)))))
|
123 |
+
|
124 |
+
(define debugger-output-port
|
125 |
+
(let ((output-port (current-output-port)))
|
126 |
+
(make-procedure-with-setter
|
127 |
+
(lambda () output-port)
|
128 |
+
(lambda (port) (set! output-port port)))))
|
129 |
+
|
130 |
+
;;; {Debug on Error}
|
131 |
+
|
132 |
+
(define (debug-on-error syms)
|
133 |
+
"Enable or disable debug on error."
|
134 |
+
(set! lazy-handler-dispatch
|
135 |
+
(if syms
|
136 |
+
(lambda (key . args)
|
137 |
+
(if (memq key syms)
|
138 |
+
(begin
|
139 |
+
(debug-stack (make-stack #t lazy-handler-dispatch)
|
140 |
+
#:with-introduction
|
141 |
+
#:continuable)
|
142 |
+
(throw 'abort key)))
|
143 |
+
(apply default-lazy-handler key args))
|
144 |
+
default-lazy-handler)))
|
145 |
+
|
146 |
+
;;; (ice-9 debugger) ends here.
|
node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/command-loop.scm
ADDED
@@ -0,0 +1,542 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
;;;; Guile Debugger command loop
|
2 |
+
|
3 |
+
;;; Copyright (C) 1999, 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
|
4 |
+
;;;
|
5 |
+
;; This library is free software; you can redistribute it and/or
|
6 |
+
;; modify it under the terms of the GNU Lesser General Public
|
7 |
+
;; License as published by the Free Software Foundation; either
|
8 |
+
;; version 2.1 of the License, or (at your option) any later version.
|
9 |
+
;;
|
10 |
+
;; This library is distributed in the hope that it will be useful,
|
11 |
+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13 |
+
;; Lesser General Public License for more details.
|
14 |
+
;;
|
15 |
+
;; You should have received a copy of the GNU Lesser General Public
|
16 |
+
;; License along with this library; if not, write to the Free Software
|
17 |
+
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18 |
+
|
19 |
+
(define-module (ice-9 debugger command-loop)
|
20 |
+
#:use-module ((ice-9 debugger commands) :prefix debugger:)
|
21 |
+
#:export (debugger-command-loop
|
22 |
+
debugger-command-loop-error
|
23 |
+
debugger-command-loop-quit)
|
24 |
+
#:no-backtrace)
|
25 |
+
|
26 |
+
;;; {Interface used by (ice-9 debugger).}
|
27 |
+
|
28 |
+
(define (debugger-command-loop state)
|
29 |
+
(read-and-dispatch-commands state (current-input-port)))
|
30 |
+
|
31 |
+
(define (debugger-command-loop-error message)
|
32 |
+
(user-error message))
|
33 |
+
|
34 |
+
(define (debugger-command-loop-quit)
|
35 |
+
(throw 'exit-debugger))
|
36 |
+
|
37 |
+
;;; {Implementation.}
|
38 |
+
|
39 |
+
(define debugger-prompt "debug> ")
|
40 |
+
|
41 |
+
(define (debugger-handler key . args)
|
42 |
+
(case key
|
43 |
+
((exit-debugger) #f)
|
44 |
+
((signal)
|
45 |
+
;; Restore stack
|
46 |
+
(fluid-set! the-last-stack (fluid-ref before-signal-stack))
|
47 |
+
(apply display-error #f (current-error-port) args))
|
48 |
+
(else
|
49 |
+
(display "Internal debugger error:\n")
|
50 |
+
(save-stack debugger-handler)
|
51 |
+
(apply throw key args)))
|
52 |
+
(throw 'exit-debugger)) ;Pop the stack
|
53 |
+
|
54 |
+
(define (read-and-dispatch-commands state port)
|
55 |
+
(catch 'exit-debugger
|
56 |
+
(lambda ()
|
57 |
+
(lazy-catch #t
|
58 |
+
(lambda ()
|
59 |
+
(with-fluids ((last-command #f))
|
60 |
+
(let loop ()
|
61 |
+
(read-and-dispatch-command state port)
|
62 |
+
(loop))))
|
63 |
+
debugger-handler))
|
64 |
+
(lambda args
|
65 |
+
*unspecified*)))
|
66 |
+
|
67 |
+
(define set-readline-prompt! #f)
|
68 |
+
|
69 |
+
(define (read-and-dispatch-command state port)
|
70 |
+
(if (using-readline?)
|
71 |
+
(begin
|
72 |
+
;; Import set-readline-prompt! if we haven't already.
|
73 |
+
(or set-readline-prompt!
|
74 |
+
(set! set-readline-prompt!
|
75 |
+
(module-ref (resolve-module '(ice-9 readline))
|
76 |
+
'set-readline-prompt!)))
|
77 |
+
(set-readline-prompt! debugger-prompt debugger-prompt))
|
78 |
+
(display debugger-prompt))
|
79 |
+
(force-output) ;This should not be necessary...
|
80 |
+
(let ((token (read-token port)))
|
81 |
+
(cond ((eof-object? token)
|
82 |
+
(throw 'exit-debugger))
|
83 |
+
((not token)
|
84 |
+
(discard-rest-of-line port)
|
85 |
+
(catch-user-errors port (lambda () (run-last-command state))))
|
86 |
+
(else
|
87 |
+
(catch-user-errors port
|
88 |
+
(lambda ()
|
89 |
+
(dispatch-command token command-table state port)))))))
|
90 |
+
|
91 |
+
(define (run-last-command state)
|
92 |
+
(let ((procedure (fluid-ref last-command)))
|
93 |
+
(if procedure
|
94 |
+
(procedure state))))
|
95 |
+
|
96 |
+
(define (catch-user-errors port thunk)
|
97 |
+
(catch 'debugger-user-error
|
98 |
+
thunk
|
99 |
+
(lambda (key . objects)
|
100 |
+
(apply user-warning objects)
|
101 |
+
(discard-rest-of-line port))))
|
102 |
+
|
103 |
+
(define last-command (make-fluid))
|
104 |
+
|
105 |
+
(define (user-warning . objects)
|
106 |
+
(for-each (lambda (object)
|
107 |
+
(display object))
|
108 |
+
objects)
|
109 |
+
(newline))
|
110 |
+
|
111 |
+
(define (user-error . objects)
|
112 |
+
(apply throw 'debugger-user-error objects))
|
113 |
+
|
114 |
+
;;;; Command dispatch
|
115 |
+
|
116 |
+
(define (dispatch-command string table state port)
|
117 |
+
(let ((value (command-table-value table string)))
|
118 |
+
(if value
|
119 |
+
(dispatch-command/value value state port)
|
120 |
+
(user-error "Unknown command: " string))))
|
121 |
+
|
122 |
+
(define (dispatch-command/value value state port)
|
123 |
+
(cond ((command? value)
|
124 |
+
(dispatch-command/command value state port))
|
125 |
+
((command-table? value)
|
126 |
+
(dispatch-command/table value state port))
|
127 |
+
((list? value)
|
128 |
+
(dispatch-command/name value state port))
|
129 |
+
(else
|
130 |
+
(error "Unrecognized command-table value: " value))))
|
131 |
+
|
132 |
+
(define (dispatch-command/command command state port)
|
133 |
+
(let ((procedure (command-procedure command))
|
134 |
+
(arguments ((command-parser command) port)))
|
135 |
+
(let ((procedure (lambda (state) (apply procedure state arguments))))
|
136 |
+
(warn-about-extra-args port)
|
137 |
+
(fluid-set! last-command procedure)
|
138 |
+
(procedure state))))
|
139 |
+
|
140 |
+
(define (warn-about-extra-args port)
|
141 |
+
;; **** modify this to show the arguments.
|
142 |
+
(let ((char (skip-whitespace port)))
|
143 |
+
(cond ((eof-object? char) #f)
|
144 |
+
((char=? #\newline char) (read-char port))
|
145 |
+
(else
|
146 |
+
(user-warning "Extra arguments at end of line: "
|
147 |
+
(read-rest-of-line port))))))
|
148 |
+
|
149 |
+
(define (dispatch-command/table table state port)
|
150 |
+
(let ((token (read-token port)))
|
151 |
+
(if (or (eof-object? token)
|
152 |
+
(not token))
|
153 |
+
(user-error "Command name too short.")
|
154 |
+
(dispatch-command token table state port))))
|
155 |
+
|
156 |
+
(define (dispatch-command/name name state port)
|
157 |
+
(let ((value (lookup-command name)))
|
158 |
+
(cond ((not value)
|
159 |
+
(apply user-error "Unknown command name: " name))
|
160 |
+
((command-table? value)
|
161 |
+
(apply user-error "Partial command name: " name))
|
162 |
+
(else
|
163 |
+
(dispatch-command/value value state port)))))
|
164 |
+
|
165 |
+
;;;; Command definition
|
166 |
+
|
167 |
+
(define (define-command name argument-template procedure)
|
168 |
+
(let ((name (canonicalize-command-name name)))
|
169 |
+
(add-command name
|
170 |
+
(make-command name
|
171 |
+
(argument-template->parser argument-template)
|
172 |
+
(procedure-documentation procedure)
|
173 |
+
procedure)
|
174 |
+
command-table)
|
175 |
+
name))
|
176 |
+
|
177 |
+
(define (define-command-alias name1 name2)
|
178 |
+
(let ((name1 (canonicalize-command-name name1)))
|
179 |
+
(add-command name1 (canonicalize-command-name name2) command-table)
|
180 |
+
name1))
|
181 |
+
|
182 |
+
(define (argument-template->parser template)
|
183 |
+
;; Deliberately handles only cases that occur in "commands.scm".
|
184 |
+
(cond ((eq? 'tokens template)
|
185 |
+
(lambda (port)
|
186 |
+
(let loop ((tokens '()))
|
187 |
+
(let ((token (read-token port)))
|
188 |
+
(if (or (eof-object? token)
|
189 |
+
(not token))
|
190 |
+
(list (reverse! tokens))
|
191 |
+
(loop (cons token tokens)))))))
|
192 |
+
((null? template)
|
193 |
+
(lambda (port)
|
194 |
+
'()))
|
195 |
+
((and (pair? template)
|
196 |
+
(null? (cdr template))
|
197 |
+
(eq? 'object (car template)))
|
198 |
+
(lambda (port)
|
199 |
+
(list (read port))))
|
200 |
+
((and (pair? template)
|
201 |
+
(equal? ''optional (car template))
|
202 |
+
(pair? (cdr template))
|
203 |
+
(null? (cddr template)))
|
204 |
+
(case (cadr template)
|
205 |
+
((token)
|
206 |
+
(lambda (port)
|
207 |
+
(let ((token (read-token port)))
|
208 |
+
(if (or (eof-object? token)
|
209 |
+
(not token))
|
210 |
+
(list #f)
|
211 |
+
(list token)))))
|
212 |
+
((exact-integer)
|
213 |
+
(lambda (port)
|
214 |
+
(list (parse-optional-exact-integer port))))
|
215 |
+
((exact-nonnegative-integer)
|
216 |
+
(lambda (port)
|
217 |
+
(list (parse-optional-exact-nonnegative-integer port))))
|
218 |
+
((object)
|
219 |
+
(lambda (port)
|
220 |
+
(list (parse-optional-object port))))
|
221 |
+
(else
|
222 |
+
(error "Malformed argument template: " template))))
|
223 |
+
(else
|
224 |
+
(error "Malformed argument template: " template))))
|
225 |
+
|
226 |
+
(define (parse-optional-exact-integer port)
|
227 |
+
(let ((object (parse-optional-object port)))
|
228 |
+
(if (or (not object)
|
229 |
+
(and (integer? object)
|
230 |
+
(exact? object)))
|
231 |
+
object
|
232 |
+
(user-error "Argument not an exact integer: " object))))
|
233 |
+
|
234 |
+
(define (parse-optional-exact-nonnegative-integer port)
|
235 |
+
(let ((object (parse-optional-object port)))
|
236 |
+
(if (or (not object)
|
237 |
+
(and (integer? object)
|
238 |
+
(exact? object)
|
239 |
+
(not (negative? object))))
|
240 |
+
object
|
241 |
+
(user-error "Argument not an exact non-negative integer: " object))))
|
242 |
+
|
243 |
+
(define (parse-optional-object port)
|
244 |
+
(let ((terminator (skip-whitespace port)))
|
245 |
+
(if (or (eof-object? terminator)
|
246 |
+
(eq? #\newline terminator))
|
247 |
+
#f
|
248 |
+
(let ((object (read port)))
|
249 |
+
(if (eof-object? object)
|
250 |
+
#f
|
251 |
+
object)))))
|
252 |
+
|
253 |
+
;;;; Command tables
|
254 |
+
|
255 |
+
(define (lookup-command name)
|
256 |
+
(let loop ((table command-table) (strings name))
|
257 |
+
(let ((value (command-table-value table (car strings))))
|
258 |
+
(cond ((or (not value) (null? (cdr strings))) value)
|
259 |
+
((command-table? value) (loop value (cdr strings)))
|
260 |
+
(else #f)))))
|
261 |
+
|
262 |
+
(define (command-table-value table string)
|
263 |
+
(let ((entry (command-table-entry table string)))
|
264 |
+
(and entry
|
265 |
+
(caddr entry))))
|
266 |
+
|
267 |
+
(define (command-table-entry table string)
|
268 |
+
(let loop ((entries (command-table-entries table)))
|
269 |
+
(and (not (null? entries))
|
270 |
+
(let ((entry (car entries)))
|
271 |
+
(if (and (<= (cadr entry)
|
272 |
+
(string-length string)
|
273 |
+
(string-length (car entry)))
|
274 |
+
(= (string-length string)
|
275 |
+
(match-strings (car entry) string)))
|
276 |
+
entry
|
277 |
+
(loop (cdr entries)))))))
|
278 |
+
|
279 |
+
(define (match-strings s1 s2)
|
280 |
+
(let ((n (min (string-length s1) (string-length s2))))
|
281 |
+
(let loop ((i 0))
|
282 |
+
(cond ((= i n) i)
|
283 |
+
((char=? (string-ref s1 i) (string-ref s2 i)) (loop (+ i 1)))
|
284 |
+
(else i)))))
|
285 |
+
|
286 |
+
(define (write-command-name name)
|
287 |
+
(display (car name))
|
288 |
+
(for-each (lambda (string)
|
289 |
+
(write-char #\space)
|
290 |
+
(display string))
|
291 |
+
(cdr name)))
|
292 |
+
|
293 |
+
(define (add-command name value table)
|
294 |
+
(let loop ((strings name) (table table))
|
295 |
+
(let ((entry
|
296 |
+
(or (let loop ((entries (command-table-entries table)))
|
297 |
+
(and (not (null? entries))
|
298 |
+
(if (string=? (car strings) (caar entries))
|
299 |
+
(car entries)
|
300 |
+
(loop (cdr entries)))))
|
301 |
+
(let ((entry (list (car strings) #f #f)))
|
302 |
+
(let ((entries
|
303 |
+
(let ((entries (command-table-entries table)))
|
304 |
+
(if (or (null? entries)
|
305 |
+
(string<? (car strings) (caar entries)))
|
306 |
+
(cons entry entries)
|
307 |
+
(begin
|
308 |
+
(let loop ((prev entries) (this (cdr entries)))
|
309 |
+
(if (or (null? this)
|
310 |
+
(string<? (car strings) (caar this)))
|
311 |
+
(set-cdr! prev (cons entry this))
|
312 |
+
(loop this (cdr this))))
|
313 |
+
entries)))))
|
314 |
+
(compute-string-abbreviations! entries)
|
315 |
+
(set-command-table-entries! table entries))
|
316 |
+
entry))))
|
317 |
+
(if (null? (cdr strings))
|
318 |
+
(set-car! (cddr entry) value)
|
319 |
+
(loop (cdr strings)
|
320 |
+
(if (command-table? (caddr entry))
|
321 |
+
(caddr entry)
|
322 |
+
(let ((table (make-command-table '())))
|
323 |
+
(set-car! (cddr entry) table)
|
324 |
+
table)))))))
|
325 |
+
|
326 |
+
(define (canonicalize-command-name name)
|
327 |
+
(cond ((and (string? name)
|
328 |
+
(not (string-null? name)))
|
329 |
+
(list name))
|
330 |
+
((let loop ((name name))
|
331 |
+
(and (pair? name)
|
332 |
+
(string? (car name))
|
333 |
+
(not (string-null? (car name)))
|
334 |
+
(or (null? (cdr name))
|
335 |
+
(loop (cdr name)))))
|
336 |
+
name)
|
337 |
+
(else
|
338 |
+
(error "Illegal command name: " name))))
|
339 |
+
|
340 |
+
(define (compute-string-abbreviations! entries)
|
341 |
+
(let loop ((entries entries) (index 0))
|
342 |
+
(let ((groups '()))
|
343 |
+
(for-each
|
344 |
+
(lambda (entry)
|
345 |
+
(let* ((char (string-ref (car entry) index))
|
346 |
+
(group (assv char groups)))
|
347 |
+
(if group
|
348 |
+
(set-cdr! group (cons entry (cdr group)))
|
349 |
+
(set! groups
|
350 |
+
(cons (list char entry)
|
351 |
+
groups)))))
|
352 |
+
entries)
|
353 |
+
(for-each
|
354 |
+
(lambda (group)
|
355 |
+
(let ((index (+ index 1)))
|
356 |
+
(if (null? (cddr group))
|
357 |
+
(set-car! (cdadr group) index)
|
358 |
+
(loop (let ((entry
|
359 |
+
(let loop ((entries (cdr group)))
|
360 |
+
(and (not (null? entries))
|
361 |
+
(if (= index (string-length (caar entries)))
|
362 |
+
(car entries)
|
363 |
+
(loop (cdr entries)))))))
|
364 |
+
(if entry
|
365 |
+
(begin
|
366 |
+
(set-car! (cdr entry) index)
|
367 |
+
(delq entry (cdr group)))
|
368 |
+
(cdr group)))
|
369 |
+
index))))
|
370 |
+
groups))))
|
371 |
+
|
372 |
+
;;;; Data structures
|
373 |
+
|
374 |
+
(define command-table-rtd (make-record-type "command-table" '(entries)))
|
375 |
+
(define make-command-table (record-constructor command-table-rtd '(entries)))
|
376 |
+
(define command-table? (record-predicate command-table-rtd))
|
377 |
+
(define command-table-entries (record-accessor command-table-rtd 'entries))
|
378 |
+
(define set-command-table-entries!
|
379 |
+
(record-modifier command-table-rtd 'entries))
|
380 |
+
|
381 |
+
(define command-rtd
|
382 |
+
(make-record-type "command"
|
383 |
+
'(name parser documentation procedure)))
|
384 |
+
|
385 |
+
(define make-command
|
386 |
+
(record-constructor command-rtd
|
387 |
+
'(name parser documentation procedure)))
|
388 |
+
|
389 |
+
(define command? (record-predicate command-rtd))
|
390 |
+
(define command-name (record-accessor command-rtd 'name))
|
391 |
+
(define command-parser (record-accessor command-rtd 'parser))
|
392 |
+
(define command-documentation (record-accessor command-rtd 'documentation))
|
393 |
+
(define command-procedure (record-accessor command-rtd 'procedure))
|
394 |
+
|
395 |
+
;;;; Character parsing
|
396 |
+
|
397 |
+
(define (read-token port)
|
398 |
+
(letrec
|
399 |
+
((loop
|
400 |
+
(lambda (chars)
|
401 |
+
(let ((char (peek-char port)))
|
402 |
+
(cond ((eof-object? char)
|
403 |
+
(do-eof char chars))
|
404 |
+
((char=? #\newline char)
|
405 |
+
(do-eot chars))
|
406 |
+
((char-whitespace? char)
|
407 |
+
(do-eot chars))
|
408 |
+
((char=? #\# char)
|
409 |
+
(read-char port)
|
410 |
+
(let ((terminator (skip-comment port)))
|
411 |
+
(if (eof-object? char)
|
412 |
+
(do-eof char chars)
|
413 |
+
(do-eot chars))))
|
414 |
+
(else
|
415 |
+
(read-char port)
|
416 |
+
(loop (cons char chars)))))))
|
417 |
+
(do-eof
|
418 |
+
(lambda (eof chars)
|
419 |
+
(if (null? chars)
|
420 |
+
eof
|
421 |
+
(do-eot chars))))
|
422 |
+
(do-eot
|
423 |
+
(lambda (chars)
|
424 |
+
(if (null? chars)
|
425 |
+
#f
|
426 |
+
(list->string (reverse! chars))))))
|
427 |
+
(skip-whitespace port)
|
428 |
+
(loop '())))
|
429 |
+
|
430 |
+
(define (skip-whitespace port)
|
431 |
+
(let ((char (peek-char port)))
|
432 |
+
(cond ((or (eof-object? char)
|
433 |
+
(char=? #\newline char))
|
434 |
+
char)
|
435 |
+
((char-whitespace? char)
|
436 |
+
(read-char port)
|
437 |
+
(skip-whitespace port))
|
438 |
+
((char=? #\# char)
|
439 |
+
(read-char port)
|
440 |
+
(skip-comment port))
|
441 |
+
(else char))))
|
442 |
+
|
443 |
+
(define (skip-comment port)
|
444 |
+
(let ((char (peek-char port)))
|
445 |
+
(if (or (eof-object? char)
|
446 |
+
(char=? #\newline char))
|
447 |
+
char
|
448 |
+
(begin
|
449 |
+
(read-char port)
|
450 |
+
(skip-comment port)))))
|
451 |
+
|
452 |
+
(define (read-rest-of-line port)
|
453 |
+
(let loop ((chars '()))
|
454 |
+
(let ((char (read-char port)))
|
455 |
+
(if (or (eof-object? char)
|
456 |
+
(char=? #\newline char))
|
457 |
+
(list->string (reverse! chars))
|
458 |
+
(loop (cons char chars))))))
|
459 |
+
|
460 |
+
(define (discard-rest-of-line port)
|
461 |
+
(let loop ()
|
462 |
+
(if (not (let ((char (read-char port)))
|
463 |
+
(or (eof-object? char)
|
464 |
+
(char=? #\newline char))))
|
465 |
+
(loop))))
|
466 |
+
|
467 |
+
;;;; Commands
|
468 |
+
|
469 |
+
(define command-table (make-command-table '()))
|
470 |
+
|
471 |
+
(define-command "help" 'tokens
|
472 |
+
(lambda (state tokens)
|
473 |
+
"Type \"help\" followed by a command name for full documentation."
|
474 |
+
(let loop ((name (if (null? tokens) '("help") tokens)))
|
475 |
+
(let ((value (lookup-command name)))
|
476 |
+
(cond ((not value)
|
477 |
+
(write-command-name name)
|
478 |
+
(display " is not a known command name.")
|
479 |
+
(newline))
|
480 |
+
((command? value)
|
481 |
+
(display (command-documentation value))
|
482 |
+
(newline)
|
483 |
+
(if (equal? '("help") (command-name value))
|
484 |
+
(begin
|
485 |
+
(display "Available commands are:")
|
486 |
+
(newline)
|
487 |
+
(for-each (lambda (entry)
|
488 |
+
(if (not (list? (caddr entry)))
|
489 |
+
(begin
|
490 |
+
(display " ")
|
491 |
+
(display (car entry))
|
492 |
+
(newline))))
|
493 |
+
(command-table-entries command-table)))))
|
494 |
+
((command-table? value)
|
495 |
+
(display "The \"")
|
496 |
+
(write-command-name name)
|
497 |
+
(display "\" command requires a subcommand.")
|
498 |
+
(newline)
|
499 |
+
(display "Available subcommands are:")
|
500 |
+
(newline)
|
501 |
+
(for-each (lambda (entry)
|
502 |
+
(if (not (list? (caddr entry)))
|
503 |
+
(begin
|
504 |
+
(display " ")
|
505 |
+
(write-command-name name)
|
506 |
+
(write-char #\space)
|
507 |
+
(display (car entry))
|
508 |
+
(newline))))
|
509 |
+
(command-table-entries value)))
|
510 |
+
((list? value)
|
511 |
+
(loop value))
|
512 |
+
(else
|
513 |
+
(error "Unknown value from lookup-command:" value)))))
|
514 |
+
state))
|
515 |
+
|
516 |
+
(define-command "frame" '('optional exact-nonnegative-integer) debugger:frame)
|
517 |
+
|
518 |
+
(define-command "position" '() debugger:position)
|
519 |
+
|
520 |
+
(define-command "up" '('optional exact-integer) debugger:up)
|
521 |
+
|
522 |
+
(define-command "down" '('optional exact-integer) debugger:down)
|
523 |
+
|
524 |
+
(define-command "backtrace" '('optional exact-integer) debugger:backtrace)
|
525 |
+
|
526 |
+
(define-command "evaluate" '(object) debugger:evaluate)
|
527 |
+
|
528 |
+
(define-command '("info" "args") '() debugger:info-args)
|
529 |
+
|
530 |
+
(define-command '("info" "frame") '() debugger:info-frame)
|
531 |
+
|
532 |
+
(define-command "quit" '()
|
533 |
+
(lambda (state)
|
534 |
+
"Exit the debugger."
|
535 |
+
(debugger-command-loop-quit)))
|
536 |
+
|
537 |
+
(define-command-alias "f" "frame")
|
538 |
+
(define-command-alias '("info" "f") '("info" "frame"))
|
539 |
+
(define-command-alias "bt" "backtrace")
|
540 |
+
(define-command-alias "where" "backtrace")
|
541 |
+
(define-command-alias "p" "evaluate")
|
542 |
+
(define-command-alias '("info" "stack") "backtrace")
|
node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/commands.scm
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
;;;; (ice-9 debugger commands) -- debugger commands
|
2 |
+
|
3 |
+
;;; Copyright (C) 2002, 2006 Free Software Foundation, Inc.
|
4 |
+
;;;
|
5 |
+
;; This library is free software; you can redistribute it and/or
|
6 |
+
;; modify it under the terms of the GNU Lesser General Public
|
7 |
+
;; License as published by the Free Software Foundation; either
|
8 |
+
;; version 2.1 of the License, or (at your option) any later version.
|
9 |
+
;;
|
10 |
+
;; This library is distributed in the hope that it will be useful,
|
11 |
+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13 |
+
;; Lesser General Public License for more details.
|
14 |
+
;;
|
15 |
+
;; You should have received a copy of the GNU Lesser General Public
|
16 |
+
;; License along with this library; if not, write to the Free Software
|
17 |
+
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18 |
+
|
19 |
+
(define-module (ice-9 debugger commands)
|
20 |
+
#:use-module (ice-9 debug)
|
21 |
+
#:use-module (ice-9 debugger)
|
22 |
+
#:use-module (ice-9 debugger state)
|
23 |
+
#:use-module (ice-9 debugger utils)
|
24 |
+
#:export (backtrace
|
25 |
+
evaluate
|
26 |
+
info-args
|
27 |
+
info-frame
|
28 |
+
position
|
29 |
+
up
|
30 |
+
down
|
31 |
+
frame))
|
32 |
+
|
33 |
+
(define (backtrace state n-frames)
|
34 |
+
"Print backtrace of all stack frames, or innermost COUNT frames.
|
35 |
+
With a negative argument, print outermost -COUNT frames.
|
36 |
+
If the number of frames isn't explicitly given, the debug option
|
37 |
+
`depth' determines the maximum number of frames printed."
|
38 |
+
(let ((stack (state-stack state)))
|
39 |
+
;; Kludge around lack of call-with-values.
|
40 |
+
(let ((values
|
41 |
+
(lambda (start end)
|
42 |
+
(display-backtrace stack
|
43 |
+
(current-output-port)
|
44 |
+
(if (memq 'backwards (debug-options))
|
45 |
+
start
|
46 |
+
(- end 1))
|
47 |
+
(- end start))
|
48 |
+
)))
|
49 |
+
(let ((end (stack-length stack)))
|
50 |
+
(cond ((not n-frames) ;(>= (abs n-frames) end))
|
51 |
+
(values 0 (min end (cadr (memq 'depth (debug-options))))))
|
52 |
+
((>= n-frames 0)
|
53 |
+
(values 0 n-frames))
|
54 |
+
(else
|
55 |
+
(values (+ end n-frames) end)))))))
|
56 |
+
|
57 |
+
(define (eval-handler key . args)
|
58 |
+
(let ((stack (make-stack #t eval-handler)))
|
59 |
+
(if (= (length args) 4)
|
60 |
+
(apply display-error stack (current-error-port) args)
|
61 |
+
;; We want display-error to be the "final common pathway"
|
62 |
+
(catch #t
|
63 |
+
(lambda ()
|
64 |
+
(apply bad-throw key args))
|
65 |
+
(lambda (key . args)
|
66 |
+
(apply display-error stack (current-error-port) args)))))
|
67 |
+
(throw 'continue))
|
68 |
+
|
69 |
+
(define (evaluate state expression)
|
70 |
+
"Evaluate an expression in the environment of the selected stack frame.
|
71 |
+
The expression must appear on the same line as the command, however it
|
72 |
+
may be continued over multiple lines."
|
73 |
+
(let ((source (frame-source (stack-ref (state-stack state)
|
74 |
+
(state-index state)))))
|
75 |
+
(if (not source)
|
76 |
+
(display "No environment for this frame.\n")
|
77 |
+
(catch 'continue
|
78 |
+
(lambda ()
|
79 |
+
(lazy-catch #t
|
80 |
+
(lambda ()
|
81 |
+
(let* ((expr
|
82 |
+
;; We assume that no one will
|
83 |
+
;; really want to evaluate a
|
84 |
+
;; string (since it is
|
85 |
+
;; self-evaluating); so if we
|
86 |
+
;; have a string here, read the
|
87 |
+
;; expression to evaluate from
|
88 |
+
;; it.
|
89 |
+
(if (string? expression)
|
90 |
+
(with-input-from-string expression
|
91 |
+
read)
|
92 |
+
expression))
|
93 |
+
(env (memoized-environment source))
|
94 |
+
(value (local-eval expr env)))
|
95 |
+
(write expr)
|
96 |
+
(display " => ")
|
97 |
+
(write value)
|
98 |
+
(newline)))
|
99 |
+
eval-handler))
|
100 |
+
(lambda args args)))))
|
101 |
+
|
102 |
+
(define (info-args state)
|
103 |
+
"Display the argument variables of the current stack frame.
|
104 |
+
Arguments can also be seen in the backtrace, but are presented more
|
105 |
+
clearly by this command."
|
106 |
+
(let ((index (state-index state)))
|
107 |
+
(let ((frame (stack-ref (state-stack state) index)))
|
108 |
+
(write-frame-index-long frame)
|
109 |
+
(write-frame-args-long frame))))
|
110 |
+
|
111 |
+
(define (info-frame state)
|
112 |
+
"Display a verbose description of the selected frame. The
|
113 |
+
information that this command provides is equivalent to what can be
|
114 |
+
deduced from the one line summary for the frame that appears in a
|
115 |
+
backtrace, but is presented and explained more clearly."
|
116 |
+
(write-state-long state))
|
117 |
+
|
118 |
+
(define (position state)
|
119 |
+
"Display the name of the source file that the current expression
|
120 |
+
comes from, and the line and column number of the expression's opening
|
121 |
+
parenthesis within that file. This information is only available when
|
122 |
+
the 'positions read option is enabled."
|
123 |
+
(let* ((frame (stack-ref (state-stack state) (state-index state)))
|
124 |
+
(source (frame-source frame)))
|
125 |
+
(if (not source)
|
126 |
+
(display "No source available for this frame.")
|
127 |
+
(let ((position (source-position source)))
|
128 |
+
(if (not position)
|
129 |
+
(display "No position information available for this frame.")
|
130 |
+
(display-position position)))))
|
131 |
+
(newline))
|
132 |
+
|
133 |
+
(define (up state n)
|
134 |
+
"Move @var{n} frames up the stack. For positive @var{n}, this
|
135 |
+
advances toward the outermost frame, to lower frame numbers, to
|
136 |
+
frames that have existed longer. @var{n} defaults to one."
|
137 |
+
(set-stack-index! state (+ (state-index state) (or n 1)))
|
138 |
+
(write-state-short state))
|
139 |
+
|
140 |
+
(define (down state n)
|
141 |
+
"Move @var{n} frames down the stack. For positive @var{n}, this
|
142 |
+
advances toward the innermost frame, to higher frame numbers, to frames
|
143 |
+
that were created more recently. @var{n} defaults to one."
|
144 |
+
(set-stack-index! state (- (state-index state) (or n 1)))
|
145 |
+
(write-state-short state))
|
146 |
+
|
147 |
+
(define (frame state n)
|
148 |
+
"Select and print a stack frame.
|
149 |
+
With no argument, print the selected stack frame. (See also \"info frame\").
|
150 |
+
An argument specifies the frame to select; it must be a stack-frame number."
|
151 |
+
(if n (set-stack-index! state (frame-number->index n (state-stack state))))
|
152 |
+
(write-state-short state))
|
153 |
+
|
154 |
+
;;; (ice-9 debugger commands) ends here.
|
node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/state.scm
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
;;;; (ice-9 debugger state) -- debugger state representation
|
2 |
+
|
3 |
+
;;; Copyright (C) 2002, 2006 Free Software Foundation, Inc.
|
4 |
+
;;;
|
5 |
+
;; This library is free software; you can redistribute it and/or
|
6 |
+
;; modify it under the terms of the GNU Lesser General Public
|
7 |
+
;; License as published by the Free Software Foundation; either
|
8 |
+
;; version 2.1 of the License, or (at your option) any later version.
|
9 |
+
;;
|
10 |
+
;; This library is distributed in the hope that it will be useful,
|
11 |
+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13 |
+
;; Lesser General Public License for more details.
|
14 |
+
;;
|
15 |
+
;; You should have received a copy of the GNU Lesser General Public
|
16 |
+
;; License along with this library; if not, write to the Free Software
|
17 |
+
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18 |
+
|
19 |
+
(define-module (ice-9 debugger state)
|
20 |
+
#:export (make-state
|
21 |
+
state-stack
|
22 |
+
state-index
|
23 |
+
state-flags
|
24 |
+
set-stack-index!))
|
25 |
+
|
26 |
+
(define state-rtd (make-record-type "debugger-state" '(stack index flags)))
|
27 |
+
(define state? (record-predicate state-rtd))
|
28 |
+
(define make-state
|
29 |
+
(let ((make-state-internal (record-constructor state-rtd
|
30 |
+
'(stack index flags))))
|
31 |
+
(lambda (stack index . flags)
|
32 |
+
(make-state-internal stack index flags))))
|
33 |
+
(define state-stack (record-accessor state-rtd 'stack))
|
34 |
+
(define state-index (record-accessor state-rtd 'index))
|
35 |
+
(define state-flags (record-accessor state-rtd 'flags))
|
36 |
+
|
37 |
+
(define set-state-index! (record-modifier state-rtd 'index))
|
38 |
+
|
39 |
+
(define (set-stack-index! state index)
|
40 |
+
(let* ((stack (state-stack state))
|
41 |
+
(ssize (stack-length stack)))
|
42 |
+
(set-state-index! state
|
43 |
+
(cond ((< index 0) 0)
|
44 |
+
((>= index ssize) (- ssize 1))
|
45 |
+
(else index)))))
|
46 |
+
|
47 |
+
;;; (ice-9 debugger state) ends here.
|
node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/trc.scm
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
;;;; (ice-9 debugger trc) -- tracing for Guile debugger code
|
2 |
+
|
3 |
+
;;; Copyright (C) 2002, 2006 Free Software Foundation, Inc.
|
4 |
+
;;;
|
5 |
+
;; This library is free software; you can redistribute it and/or
|
6 |
+
;; modify it under the terms of the GNU Lesser General Public
|
7 |
+
;; License as published by the Free Software Foundation; either
|
8 |
+
;; version 2.1 of the License, or (at your option) any later version.
|
9 |
+
;;
|
10 |
+
;; This library is distributed in the hope that it will be useful,
|
11 |
+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13 |
+
;; Lesser General Public License for more details.
|
14 |
+
;;
|
15 |
+
;; You should have received a copy of the GNU Lesser General Public
|
16 |
+
;; License along with this library; if not, write to the Free Software
|
17 |
+
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18 |
+
|
19 |
+
(define-module (ice-9 debugger trc)
|
20 |
+
#:export (trc trc-syms trc-all trc-none trc-add trc-remove trc-port))
|
21 |
+
|
22 |
+
(define *syms* #f)
|
23 |
+
|
24 |
+
(define (trc-set! syms)
|
25 |
+
(set! *syms* syms))
|
26 |
+
|
27 |
+
(define (trc-syms . syms)
|
28 |
+
(trc-set! syms))
|
29 |
+
|
30 |
+
(define (trc-all)
|
31 |
+
(trc-set! #f))
|
32 |
+
|
33 |
+
(define (trc-none)
|
34 |
+
(trc-set! '()))
|
35 |
+
|
36 |
+
(define (trc-add sym)
|
37 |
+
(trc-set! (cons sym *syms*)))
|
38 |
+
|
39 |
+
(define (trc-remove sym)
|
40 |
+
(trc-set! (delq1! sym *syms*)))
|
41 |
+
|
42 |
+
(define (trc sym . args)
|
43 |
+
(if (or (not *syms*)
|
44 |
+
(memq sym *syms*))
|
45 |
+
(let ((port (trc-port)))
|
46 |
+
(write sym port)
|
47 |
+
(display ":" port)
|
48 |
+
(for-each (lambda (arg)
|
49 |
+
(display " " port)
|
50 |
+
(write arg port))
|
51 |
+
args)
|
52 |
+
(newline port))))
|
53 |
+
|
54 |
+
(define trc-port
|
55 |
+
(let ((port (current-error-port)))
|
56 |
+
(make-procedure-with-setter
|
57 |
+
(lambda () port)
|
58 |
+
(lambda (p) (set! port p)))))
|
59 |
+
|
60 |
+
;; Default to no tracing.
|
61 |
+
(trc-none)
|
62 |
+
|
63 |
+
;;; (ice-9 debugger trc) ends here.
|
node-addon-lilypond/output/share/guile/1.8/ice-9/debugger/utils.scm
ADDED
@@ -0,0 +1,203 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
(define-module (ice-9 debugger utils)
|
3 |
+
#:use-module (ice-9 debugger state)
|
4 |
+
#:export (display-position
|
5 |
+
source-position
|
6 |
+
write-frame-args-long
|
7 |
+
write-frame-index-long
|
8 |
+
write-frame-short/expression
|
9 |
+
write-frame-short/application
|
10 |
+
write-frame-long
|
11 |
+
write-state-long
|
12 |
+
write-state-short))
|
13 |
+
|
14 |
+
;;; Procedures in this module print information about a stack frame.
|
15 |
+
;;; The available information is as follows.
|
16 |
+
;;;
|
17 |
+
;;; * Source code location.
|
18 |
+
;;;
|
19 |
+
;;; For an evaluation frame, this is the location recorded at the time
|
20 |
+
;;; that the expression being evaluated was read, if the 'positions
|
21 |
+
;;; read option was enabled at that time.
|
22 |
+
;;;
|
23 |
+
;;; For an application frame, I'm not yet sure. Some applications
|
24 |
+
;;; seem to have associated source expressions.
|
25 |
+
;;;
|
26 |
+
;;; * Whether frame is still evaluating its arguments.
|
27 |
+
;;;
|
28 |
+
;;; Only applies to an application frame. For example, an expression
|
29 |
+
;;; like `(+ (* 2 3) 4)' goes through the following stages of
|
30 |
+
;;; evaluation.
|
31 |
+
;;;
|
32 |
+
;;; (+ (* 2 3) 4) -- evaluation
|
33 |
+
;;; [+ ... -- application; the car of the evaluation
|
34 |
+
;;; has been evaluated and found to be a
|
35 |
+
;;; procedure; before this procedure can
|
36 |
+
;;; be applied, its arguments must be evaluated
|
37 |
+
;;; [+ 6 ... -- same application after evaluating the
|
38 |
+
;;; first argument
|
39 |
+
;;; [+ 6 4] -- same application after evaluating all
|
40 |
+
;;; arguments
|
41 |
+
;;; 10 -- result
|
42 |
+
;;;
|
43 |
+
;;; * Whether frame is real or tail-recursive.
|
44 |
+
;;;
|
45 |
+
;;; If a frame is tail-recursive, its containing frame as shown by the
|
46 |
+
;;; debugger backtrace doesn't really exist as far as the Guile
|
47 |
+
;;; evaluator is concerned. The effect of this is that when a
|
48 |
+
;;; tail-recursive frame returns, it looks as though its containing
|
49 |
+
;;; frame returns at the same time. (And if the containing frame is
|
50 |
+
;;; also tail-recursive, _its_ containing frame returns at that time
|
51 |
+
;;; also, and so on ...)
|
52 |
+
;;;
|
53 |
+
;;; A `real' frame is one that is not tail-recursive.
|
54 |
+
|
55 |
+
|
56 |
+
(define (write-state-short state)
|
57 |
+
(let* ((frame (stack-ref (state-stack state) (state-index state)))
|
58 |
+
(source (frame-source frame))
|
59 |
+
(position (and source (source-position source))))
|
60 |
+
(format #t "Frame ~A at " (frame-number frame))
|
61 |
+
(if position
|
62 |
+
(display-position position)
|
63 |
+
(display "unknown source location"))
|
64 |
+
(newline)
|
65 |
+
(write-char #\tab)
|
66 |
+
(write-frame-short frame)
|
67 |
+
(newline)))
|
68 |
+
|
69 |
+
(define (write-state-short* stack index)
|
70 |
+
(write-frame-index-short stack index)
|
71 |
+
(write-char #\space)
|
72 |
+
(write-frame-short (stack-ref stack index))
|
73 |
+
(newline))
|
74 |
+
|
75 |
+
(define (write-frame-index-short stack index)
|
76 |
+
(let ((s (number->string (frame-number (stack-ref stack index)))))
|
77 |
+
(display s)
|
78 |
+
(write-char #\:)
|
79 |
+
(write-chars #\space (- 4 (string-length s)))))
|
80 |
+
|
81 |
+
(define (write-frame-short frame)
|
82 |
+
(if (frame-procedure? frame)
|
83 |
+
(write-frame-short/application frame)
|
84 |
+
(write-frame-short/expression frame)))
|
85 |
+
|
86 |
+
(define (write-frame-short/application frame)
|
87 |
+
(write-char #\[)
|
88 |
+
(write (let ((procedure (frame-procedure frame)))
|
89 |
+
(or (and (procedure? procedure)
|
90 |
+
(procedure-name procedure))
|
91 |
+
procedure)))
|
92 |
+
(if (frame-evaluating-args? frame)
|
93 |
+
(display " ...")
|
94 |
+
(begin
|
95 |
+
(for-each (lambda (argument)
|
96 |
+
(write-char #\space)
|
97 |
+
(write argument))
|
98 |
+
(frame-arguments frame))
|
99 |
+
(write-char #\]))))
|
100 |
+
|
101 |
+
;;; Use builtin function instead:
|
102 |
+
(set! write-frame-short/application
|
103 |
+
(lambda (frame)
|
104 |
+
(display-application frame (current-output-port) 12)))
|
105 |
+
|
106 |
+
(define (write-frame-short/expression frame)
|
107 |
+
(write (let* ((source (frame-source frame))
|
108 |
+
(copy (source-property source 'copy)))
|
109 |
+
(if (pair? copy)
|
110 |
+
copy
|
111 |
+
(unmemoize-expr source)))))
|
112 |
+
|
113 |
+
(define (write-state-long state)
|
114 |
+
(let ((index (state-index state)))
|
115 |
+
(let ((frame (stack-ref (state-stack state) index)))
|
116 |
+
(write-frame-index-long frame)
|
117 |
+
(write-frame-long frame))))
|
118 |
+
|
119 |
+
(define (write-frame-index-long frame)
|
120 |
+
(display "Stack frame: ")
|
121 |
+
(write (frame-number frame))
|
122 |
+
(if (frame-real? frame)
|
123 |
+
(display " (real)"))
|
124 |
+
(newline))
|
125 |
+
|
126 |
+
(define (write-frame-long frame)
|
127 |
+
(if (frame-procedure? frame)
|
128 |
+
(write-frame-long/application frame)
|
129 |
+
(write-frame-long/expression frame)))
|
130 |
+
|
131 |
+
(define (write-frame-long/application frame)
|
132 |
+
(display "This frame is an application.")
|
133 |
+
(newline)
|
134 |
+
(if (frame-source frame)
|
135 |
+
(begin
|
136 |
+
(display "The corresponding expression is:")
|
137 |
+
(newline)
|
138 |
+
(display-source frame)
|
139 |
+
(newline)))
|
140 |
+
(display "The procedure being applied is: ")
|
141 |
+
(write (let ((procedure (frame-procedure frame)))
|
142 |
+
(or (and (procedure? procedure)
|
143 |
+
(procedure-name procedure))
|
144 |
+
procedure)))
|
145 |
+
(newline)
|
146 |
+
(display "The procedure's arguments are")
|
147 |
+
(if (frame-evaluating-args? frame)
|
148 |
+
(display " being evaluated.")
|
149 |
+
(begin
|
150 |
+
(display ": ")
|
151 |
+
(write (frame-arguments frame))))
|
152 |
+
(newline))
|
153 |
+
|
154 |
+
(define (display-source frame)
|
155 |
+
(let* ((source (frame-source frame))
|
156 |
+
(copy (source-property source 'copy)))
|
157 |
+
(cond ((source-position source)
|
158 |
+
=> (lambda (p) (display-position p) (display ":\n"))))
|
159 |
+
(display " ")
|
160 |
+
(write (or copy (unmemoize-expr source)))))
|
161 |
+
|
162 |
+
(define (source-position source)
|
163 |
+
(let ((fname (source-property source 'filename))
|
164 |
+
(line (source-property source 'line))
|
165 |
+
(column (source-property source 'column)))
|
166 |
+
(and fname
|
167 |
+
(list fname line column))))
|
168 |
+
|
169 |
+
(define (display-position pos)
|
170 |
+
(format #t "~A:~D:~D" (car pos) (+ 1 (cadr pos)) (+ 1 (caddr pos))))
|
171 |
+
|
172 |
+
(define (write-frame-long/expression frame)
|
173 |
+
(display "This frame is an evaluation.")
|
174 |
+
(newline)
|
175 |
+
(display "The expression being evaluated is:")
|
176 |
+
(newline)
|
177 |
+
(display-source frame)
|
178 |
+
(newline))
|
179 |
+
|
180 |
+
(define (write-frame-args-long frame)
|
181 |
+
(if (frame-procedure? frame)
|
182 |
+
(let ((arguments (frame-arguments frame)))
|
183 |
+
(let ((n (length arguments)))
|
184 |
+
(display "This frame has ")
|
185 |
+
(write n)
|
186 |
+
(display " argument")
|
187 |
+
(if (not (= n 1))
|
188 |
+
(display "s"))
|
189 |
+
(write-char (if (null? arguments) #\. #\:))
|
190 |
+
(newline))
|
191 |
+
(for-each (lambda (argument)
|
192 |
+
(display " ")
|
193 |
+
(write argument)
|
194 |
+
(newline))
|
195 |
+
arguments))
|
196 |
+
(begin
|
197 |
+
(display "This frame is an evaluation frame; it has no arguments.")
|
198 |
+
(newline))))
|
199 |
+
|
200 |
+
(define (write-chars char n)
|
201 |
+
(do ((i 0 (+ i 1)))
|
202 |
+
((>= i n))
|
203 |
+
(write-char char)))
|
node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/example-fns.scm
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(define-module (ice-9 debugging example-fns)
|
2 |
+
#:export (fact1 fact2 facti))
|
3 |
+
|
4 |
+
(define (fact1 n)
|
5 |
+
(if (= n 0)
|
6 |
+
1
|
7 |
+
(* n (fact1 (- n 1)))))
|
8 |
+
|
9 |
+
(define (facti n a)
|
10 |
+
(if (= n 0)
|
11 |
+
a
|
12 |
+
(facti (- n 1) (* a n))))
|
13 |
+
|
14 |
+
(define (fact2 n)
|
15 |
+
(facti n 1))
|
16 |
+
|
17 |
+
; Test: (fact2 3)
|
node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/ice-9-debugger-extensions.scm
ADDED
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
(define-module (ice-9 debugging ice-9-debugger-extensions)
|
3 |
+
#:use-module (ice-9 debugger))
|
4 |
+
|
5 |
+
;;; Upgrade the debugger state object so that it can carry a flag
|
6 |
+
;;; indicating whether the debugging session is continuable.
|
7 |
+
|
8 |
+
(cond ((string>=? (version) "1.7")
|
9 |
+
(use-modules (ice-9 debugger state))
|
10 |
+
(define-module (ice-9 debugger state)))
|
11 |
+
(else
|
12 |
+
(define-module (ice-9 debugger))))
|
13 |
+
|
14 |
+
(set! state-rtd (make-record-type "debugger-state" '(stack index flags)))
|
15 |
+
(set! state? (record-predicate state-rtd))
|
16 |
+
(set! make-state
|
17 |
+
(let ((make-state-internal (record-constructor state-rtd
|
18 |
+
'(stack index flags))))
|
19 |
+
(lambda (stack index . flags)
|
20 |
+
(make-state-internal stack index flags))))
|
21 |
+
(set! state-stack (record-accessor state-rtd 'stack))
|
22 |
+
(set! state-index (record-accessor state-rtd 'index))
|
23 |
+
|
24 |
+
(define state-flags (record-accessor state-rtd 'flags))
|
25 |
+
|
26 |
+
;;; Add commands that (ice-9 debugger) doesn't currently have, for
|
27 |
+
;;; continuing or single stepping program execution.
|
28 |
+
|
29 |
+
(cond ((string>=? (version) "1.7")
|
30 |
+
(use-modules (ice-9 debugger command-loop))
|
31 |
+
(define-module (ice-9 debugger command-loop)
|
32 |
+
#:use-module (ice-9 debugger)
|
33 |
+
#:use-module (ice-9 debugger state)
|
34 |
+
#:use-module (ice-9 debugging traps))
|
35 |
+
(define new-define-command define-command)
|
36 |
+
(set! define-command
|
37 |
+
(lambda (name argument-template documentation procedure)
|
38 |
+
(new-define-command name argument-template procedure))))
|
39 |
+
(else
|
40 |
+
(define-module (ice-9 debugger))))
|
41 |
+
|
42 |
+
(use-modules (ice-9 debugging steps)
|
43 |
+
(ice-9 debugging trace))
|
44 |
+
|
45 |
+
(define (assert-continuable state)
|
46 |
+
;; Check that debugger is in a state where `continuing' makes sense.
|
47 |
+
;; If not, signal an error.
|
48 |
+
(or (memq #:continuable (state-flags state))
|
49 |
+
(user-error "This debug session is not continuable.")))
|
50 |
+
|
51 |
+
(define (debugger:continue state)
|
52 |
+
"Tell the program being debugged to continue running. (In fact this is
|
53 |
+
the same as the @code{quit} command, because it exits the debugger
|
54 |
+
command loop and so allows whatever code it was that invoked the
|
55 |
+
debugger to continue.)"
|
56 |
+
(assert-continuable state)
|
57 |
+
(throw 'exit-debugger))
|
58 |
+
|
59 |
+
(define (debugger:finish state)
|
60 |
+
"Continue until evaluation of the current frame is complete, and
|
61 |
+
print the result obtained."
|
62 |
+
(assert-continuable state)
|
63 |
+
(at-exit (- (stack-length (state-stack state))
|
64 |
+
(state-index state))
|
65 |
+
(list trace-trap debug-trap))
|
66 |
+
(debugger:continue state))
|
67 |
+
|
68 |
+
(define (debugger:step state n)
|
69 |
+
"Tell the debugged program to do @var{n} more steps from its current
|
70 |
+
position. One @dfn{step} means executing until the next frame entry
|
71 |
+
or exit of any kind. @var{n} defaults to 1."
|
72 |
+
(assert-continuable state)
|
73 |
+
(at-step debug-trap (or n 1))
|
74 |
+
(debugger:continue state))
|
75 |
+
|
76 |
+
(define (debugger:next state n)
|
77 |
+
"Tell the debugged program to do @var{n} more steps from its current
|
78 |
+
position, but only counting frame entries and exits where the
|
79 |
+
corresponding source code comes from the same file as the current
|
80 |
+
stack frame. (See @ref{Step Traps} for the details of how this
|
81 |
+
works.) If the current stack frame has no source code, the effect of
|
82 |
+
this command is the same as of @code{step}. @var{n} defaults to 1."
|
83 |
+
(assert-continuable state)
|
84 |
+
(at-step debug-trap
|
85 |
+
(or n 1)
|
86 |
+
(frame-file-name (stack-ref (state-stack state)
|
87 |
+
(state-index state)))
|
88 |
+
(if (memq #:return (state-flags state))
|
89 |
+
#f
|
90 |
+
(- (stack-length (state-stack state)) (state-index state))))
|
91 |
+
(debugger:continue state))
|
92 |
+
|
93 |
+
(define-command "continue" '()
|
94 |
+
"Continue program execution."
|
95 |
+
debugger:continue)
|
96 |
+
|
97 |
+
(define-command "finish" '()
|
98 |
+
"Continue until evaluation of the current frame is complete, and
|
99 |
+
print the result obtained."
|
100 |
+
debugger:finish)
|
101 |
+
|
102 |
+
(define-command "step" '('optional exact-integer)
|
103 |
+
"Continue until entry to @var{n}th next frame."
|
104 |
+
debugger:step)
|
105 |
+
|
106 |
+
(define-command "next" '('optional exact-integer)
|
107 |
+
"Continue until entry to @var{n}th next frame in same file."
|
108 |
+
debugger:next)
|
109 |
+
|
110 |
+
;;; Export a couple of procedures for use by (ice-9 debugging trace).
|
111 |
+
|
112 |
+
(cond ((string>=? (version) "1.7"))
|
113 |
+
(else
|
114 |
+
(define-module (ice-9 debugger))
|
115 |
+
(export write-frame-short/expression
|
116 |
+
write-frame-short/application)))
|
117 |
+
|
118 |
+
;;; Provide a `debug-trap' entry point in (ice-9 debugger). This is
|
119 |
+
;;; designed so that it can be called to explore the stack at a
|
120 |
+
;;; breakpoint, and to single step from the breakpoint.
|
121 |
+
|
122 |
+
(define-module (ice-9 debugger))
|
123 |
+
|
124 |
+
(use-modules (ice-9 debugging traps))
|
125 |
+
|
126 |
+
(define *not-yet-introduced* #t)
|
127 |
+
|
128 |
+
(cond ((string>=? (version) "1.7"))
|
129 |
+
(else
|
130 |
+
(define (debugger-command-loop state)
|
131 |
+
(read-and-dispatch-commands state (current-input-port)))))
|
132 |
+
|
133 |
+
(define-public (debug-trap trap-context)
|
134 |
+
"Invoke the Guile debugger to explore the stack at the specified @var{trap}."
|
135 |
+
(start-stack 'debugger
|
136 |
+
(let* ((stack (tc:stack trap-context))
|
137 |
+
(flags1 (let ((trap-type (tc:type trap-context)))
|
138 |
+
(case trap-type
|
139 |
+
((#:return #:error)
|
140 |
+
(list trap-type
|
141 |
+
(tc:return-value trap-context)))
|
142 |
+
(else
|
143 |
+
(list trap-type)))))
|
144 |
+
(flags (if (tc:continuation trap-context)
|
145 |
+
(cons #:continuable flags1)
|
146 |
+
flags1))
|
147 |
+
(state (apply make-state stack 0 flags)))
|
148 |
+
(if *not-yet-introduced*
|
149 |
+
(let ((ssize (stack-length stack)))
|
150 |
+
(display "This is the Guile debugger -- for help, type `help'.\n")
|
151 |
+
(set! *not-yet-introduced* #f)
|
152 |
+
(if (= ssize 1)
|
153 |
+
(display "There is 1 frame on the stack.\n\n")
|
154 |
+
(format #t "There are ~A frames on the stack.\n\n" ssize))))
|
155 |
+
(write-state-short-with-source-location state)
|
156 |
+
(debugger-command-loop state))))
|
157 |
+
|
158 |
+
(define write-state-short-with-source-location
|
159 |
+
(cond ((string>=? (version) "1.7")
|
160 |
+
write-state-short)
|
161 |
+
(else
|
162 |
+
(lambda (state)
|
163 |
+
(let* ((frame (stack-ref (state-stack state) (state-index state)))
|
164 |
+
(source (frame-source frame))
|
165 |
+
(position (and source (source-position source))))
|
166 |
+
(format #t "Frame ~A at " (frame-number frame))
|
167 |
+
(if position
|
168 |
+
(display-position position)
|
169 |
+
(display "unknown source location"))
|
170 |
+
(newline)
|
171 |
+
(write-char #\tab)
|
172 |
+
(write-frame-short frame)
|
173 |
+
(newline))))))
|
node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/steps.scm
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
;;;; (ice-9 debugging steps) -- stepping through code from the debugger
|
2 |
+
|
3 |
+
;;; Copyright (C) 2002, 2004 Free Software Foundation, Inc.
|
4 |
+
;;;
|
5 |
+
;; This library is free software; you can redistribute it and/or
|
6 |
+
;; modify it under the terms of the GNU Lesser General Public
|
7 |
+
;; License as published by the Free Software Foundation; either
|
8 |
+
;; version 2.1 of the License, or (at your option) any later version.
|
9 |
+
;;
|
10 |
+
;; This library is distributed in the hope that it will be useful,
|
11 |
+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13 |
+
;; Lesser General Public License for more details.
|
14 |
+
;;
|
15 |
+
;; You should have received a copy of the GNU Lesser General Public
|
16 |
+
;; License along with this library; if not, write to the Free Software
|
17 |
+
;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18 |
+
|
19 |
+
(define-module (ice-9 debugging steps)
|
20 |
+
#:use-module (ice-9 debugging traps)
|
21 |
+
#:use-module (ice-9 and-let-star)
|
22 |
+
#:use-module (ice-9 debugger)
|
23 |
+
#:use-module (ice-9 optargs)
|
24 |
+
#:export (at-exit
|
25 |
+
at-entry
|
26 |
+
at-apply
|
27 |
+
at-step
|
28 |
+
at-next))
|
29 |
+
|
30 |
+
;;; at-exit DEPTH BEHAVIOUR
|
31 |
+
;;;
|
32 |
+
;;; Install a behaviour to run when we exit the current frame.
|
33 |
+
|
34 |
+
(define (at-exit depth behaviour)
|
35 |
+
(install-trap (make <exit-trap>
|
36 |
+
#:depth depth
|
37 |
+
#:single-shot #t
|
38 |
+
#:behaviour behaviour)))
|
39 |
+
|
40 |
+
;;; at-entry BEHAVIOUR [COUNT]
|
41 |
+
;;;
|
42 |
+
;;; Install a behaviour to run when we get to the COUNT'th next frame
|
43 |
+
;;; entry. COUNT defaults to 1.
|
44 |
+
|
45 |
+
(define* (at-entry behaviour #:optional (count 1))
|
46 |
+
(install-trap (make <entry-trap>
|
47 |
+
#:skip-count (- count 1)
|
48 |
+
#:single-shot #t
|
49 |
+
#:behaviour behaviour)))
|
50 |
+
|
51 |
+
;;; at-apply BEHAVIOUR [COUNT]
|
52 |
+
;;;
|
53 |
+
;;; Install a behaviour to run when we get to the COUNT'th next
|
54 |
+
;;; application. COUNT defaults to 1.
|
55 |
+
|
56 |
+
(define* (at-apply behaviour #:optional (count 1))
|
57 |
+
(install-trap (make <apply-trap>
|
58 |
+
#:skip-count (- count 1)
|
59 |
+
#:single-shot #t
|
60 |
+
#:behaviour behaviour)))
|
61 |
+
|
62 |
+
;;; at-step BEHAVIOUR [COUNT [FILENAME [DEPTH]]
|
63 |
+
;;;
|
64 |
+
;;; Install BEHAVIOUR to run on the COUNT'th next application, frame
|
65 |
+
;;; entry or frame exit. COUNT defaults to 1. If FILENAME is
|
66 |
+
;;; specified and not #f, only frames that begin in the named file are
|
67 |
+
;;; counted.
|
68 |
+
|
69 |
+
(define* (at-step behaviour #:optional (count 1) filename (depth 1000))
|
70 |
+
(install-trap (make <step-trap>
|
71 |
+
#:file-name filename
|
72 |
+
#:exit-depth depth
|
73 |
+
#:skip-count (- count 1)
|
74 |
+
#:single-shot #t
|
75 |
+
#:behaviour behaviour)))
|
76 |
+
|
77 |
+
;; (or count (set! count 1))
|
78 |
+
;; (letrec ((proc (lambda (trap-context)
|
79 |
+
;; ;; Behaviour whenever we enter or exit a frame.
|
80 |
+
;; (set! count (- count 1))
|
81 |
+
;; (if (= count 0)
|
82 |
+
;; (begin
|
83 |
+
;; (remove-enter-frame-hook! step)
|
84 |
+
;; (remove-apply-frame-hook! step)
|
85 |
+
;; (behaviour trap-context)))))
|
86 |
+
;; (step (lambda (trap-context)
|
87 |
+
;; ;; Behaviour on frame entry: both execute the above
|
88 |
+
;; ;; and install it as an exit hook.
|
89 |
+
;; (if (or (not filename)
|
90 |
+
;; (equal? (frame-file-name (tc:frame trap-context))
|
91 |
+
;; filename))
|
92 |
+
;; (begin
|
93 |
+
;; (proc trap-context)
|
94 |
+
;; (at-exit (tc:depth trap-context) proc))))))
|
95 |
+
;; (at-exit depth proc)
|
96 |
+
;; (add-enter-frame-hook! step)
|
97 |
+
;; (add-apply-frame-hook! step)))
|
98 |
+
|
99 |
+
;;; at-next BEHAVIOUR [COUNT]
|
100 |
+
;;;
|
101 |
+
;;; Install a behaviour to run when we get to the COUNT'th next frame
|
102 |
+
;;; entry in the same source file as the current location. COUNT
|
103 |
+
;;; defaults to 1. If the current location has no filename, fall back
|
104 |
+
;;; silently to `at-entry' behaviour.
|
105 |
+
|
106 |
+
;;; (ice-9 debugging steps) ends here.
|
node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/trace.scm
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
;;;; (ice-9 debugging trace) -- breakpoint trace behaviour
|
2 |
+
|
3 |
+
;;; Copyright (C) 2002 Free Software Foundation, Inc.
|
4 |
+
;;;
|
5 |
+
;; This library is free software; you can redistribute it and/or
|
6 |
+
;; modify it under the terms of the GNU Lesser General Public
|
7 |
+
;; License as published by the Free Software Foundation; either
|
8 |
+
;; version 2.1 of the License, or (at your option) any later version.
|
9 |
+
;;
|
10 |
+
;; This library is distributed in the hope that it will be useful,
|
11 |
+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13 |
+
;; Lesser General Public License for more details.
|
14 |
+
;;
|
15 |
+
;; You should have received a copy of the GNU Lesser General Public
|
16 |
+
;; License along with this library; if not, write to the Free Software
|
17 |
+
;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18 |
+
|
19 |
+
(define-module (ice-9 debugging trace)
|
20 |
+
#:use-module (ice-9 debug)
|
21 |
+
#:use-module (ice-9 debugger)
|
22 |
+
#:use-module (ice-9 debugging ice-9-debugger-extensions)
|
23 |
+
#:use-module (ice-9 debugging steps)
|
24 |
+
#:use-module (ice-9 debugging traps)
|
25 |
+
#:export (trace-trap
|
26 |
+
trace-port
|
27 |
+
set-trace-layout
|
28 |
+
trace/pid
|
29 |
+
trace/stack-id
|
30 |
+
trace/stack-depth
|
31 |
+
trace/stack-real-depth
|
32 |
+
trace/stack
|
33 |
+
trace/source-file-name
|
34 |
+
trace/source-line
|
35 |
+
trace/source-column
|
36 |
+
trace/source
|
37 |
+
trace/type
|
38 |
+
trace/real?
|
39 |
+
trace/info
|
40 |
+
trace-at-exit
|
41 |
+
trace-until-exit))
|
42 |
+
|
43 |
+
(cond ((string>=? (version) "1.7")
|
44 |
+
(use-modules (ice-9 debugger utils))))
|
45 |
+
|
46 |
+
(define trace-format-string #f)
|
47 |
+
(define trace-arg-procs #f)
|
48 |
+
|
49 |
+
(define (set-trace-layout format-string . arg-procs)
|
50 |
+
(set! trace-format-string format-string)
|
51 |
+
(set! trace-arg-procs arg-procs))
|
52 |
+
|
53 |
+
(define (trace/pid trap-context)
|
54 |
+
(getpid))
|
55 |
+
|
56 |
+
(define (trace/stack-id trap-context)
|
57 |
+
(stack-id (tc:stack trap-context)))
|
58 |
+
|
59 |
+
(define (trace/stack-depth trap-context)
|
60 |
+
(tc:depth trap-context))
|
61 |
+
|
62 |
+
(define (trace/stack-real-depth trap-context)
|
63 |
+
(tc:real-depth trap-context))
|
64 |
+
|
65 |
+
(define (trace/stack trap-context)
|
66 |
+
(format #f "~a:~a+~a"
|
67 |
+
(stack-id (tc:stack trap-context))
|
68 |
+
(tc:real-depth trap-context)
|
69 |
+
(- (tc:depth trap-context) (tc:real-depth trap-context))))
|
70 |
+
|
71 |
+
(define (trace/source-file-name trap-context)
|
72 |
+
(cond ((frame->source-position (tc:frame trap-context)) => car)
|
73 |
+
(else "")))
|
74 |
+
|
75 |
+
(define (trace/source-line trap-context)
|
76 |
+
(cond ((frame->source-position (tc:frame trap-context)) => cadr)
|
77 |
+
(else 0)))
|
78 |
+
|
79 |
+
(define (trace/source-column trap-context)
|
80 |
+
(cond ((frame->source-position (tc:frame trap-context)) => caddr)
|
81 |
+
(else 0)))
|
82 |
+
|
83 |
+
(define (trace/source trap-context)
|
84 |
+
(cond ((frame->source-position (tc:frame trap-context))
|
85 |
+
=>
|
86 |
+
(lambda (pos)
|
87 |
+
(format #f "~a:~a:~a" (car pos) (cadr pos) (caddr pos))))
|
88 |
+
(else "")))
|
89 |
+
|
90 |
+
(define (trace/type trap-context)
|
91 |
+
(case (tc:type trap-context)
|
92 |
+
((#:application) "APP")
|
93 |
+
((#:evaluation) "EVA")
|
94 |
+
((#:return) "RET")
|
95 |
+
((#:error) "ERR")
|
96 |
+
(else "???")))
|
97 |
+
|
98 |
+
(define (trace/real? trap-context)
|
99 |
+
(if (frame-real? (tc:frame trap-context)) " " "t"))
|
100 |
+
|
101 |
+
(define (trace/info trap-context)
|
102 |
+
(with-output-to-string
|
103 |
+
(lambda ()
|
104 |
+
(if (memq (tc:type trap-context) '(#:application #:evaluation))
|
105 |
+
((if (tc:expression trap-context)
|
106 |
+
write-frame-short/expression
|
107 |
+
write-frame-short/application) (tc:frame trap-context))
|
108 |
+
(begin
|
109 |
+
(display "=>")
|
110 |
+
(write (tc:return-value trap-context)))))))
|
111 |
+
|
112 |
+
(set-trace-layout "|~3@a: ~a\n" trace/stack-real-depth trace/info)
|
113 |
+
|
114 |
+
;;; trace-trap
|
115 |
+
;;;
|
116 |
+
;;; Trace the current location, and install a hook to trace the return
|
117 |
+
;;; value when we exit the current frame.
|
118 |
+
|
119 |
+
(define (trace-trap trap-context)
|
120 |
+
(apply format
|
121 |
+
(trace-port)
|
122 |
+
trace-format-string
|
123 |
+
(map (lambda (arg-proc)
|
124 |
+
(arg-proc trap-context))
|
125 |
+
trace-arg-procs)))
|
126 |
+
|
127 |
+
(set! (behaviour-ordering trace-trap) 50)
|
128 |
+
|
129 |
+
;;; trace-port
|
130 |
+
;;;
|
131 |
+
;;; The port to which trace information is printed.
|
132 |
+
|
133 |
+
(define trace-port
|
134 |
+
(let ((port (current-output-port)))
|
135 |
+
(make-procedure-with-setter
|
136 |
+
(lambda () port)
|
137 |
+
(lambda (new) (set! port new)))))
|
138 |
+
|
139 |
+
;;; trace-at-exit
|
140 |
+
;;;
|
141 |
+
;;; Trace return value on exit from the current frame.
|
142 |
+
|
143 |
+
(define (trace-at-exit trap-context)
|
144 |
+
(at-exit (tc:depth trap-context) trace-trap))
|
145 |
+
|
146 |
+
;;; trace-until-exit
|
147 |
+
;;;
|
148 |
+
;;; Trace absolutely everything until exit from the current frame.
|
149 |
+
|
150 |
+
(define (trace-until-exit trap-context)
|
151 |
+
(let ((step-trap (make <step-trap> #:behaviour trace-trap)))
|
152 |
+
(install-trap step-trap)
|
153 |
+
(at-exit (tc:depth trap-context)
|
154 |
+
(lambda (trap-context)
|
155 |
+
(uninstall-trap step-trap)))))
|
156 |
+
|
157 |
+
;;; (ice-9 debugging trace) ends here.
|
node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/traps.scm
ADDED
@@ -0,0 +1,1037 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
;;;; (ice-9 debugging traps) -- abstraction of libguile's traps interface
|
2 |
+
|
3 |
+
;;; Copyright (C) 2002, 2004 Free Software Foundation, Inc.
|
4 |
+
;;; Copyright (C) 2005 Neil Jerram
|
5 |
+
;;;
|
6 |
+
;; This library is free software; you can redistribute it and/or
|
7 |
+
;; modify it under the terms of the GNU Lesser General Public
|
8 |
+
;; License as published by the Free Software Foundation; either
|
9 |
+
;; version 2.1 of the License, or (at your option) any later version.
|
10 |
+
;;
|
11 |
+
;; This library is distributed in the hope that it will be useful,
|
12 |
+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
+
;; Lesser General Public License for more details.
|
15 |
+
;;
|
16 |
+
;; You should have received a copy of the GNU Lesser General Public
|
17 |
+
;; License along with this library; if not, write to the Free Software
|
18 |
+
;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19 |
+
|
20 |
+
;;; This module provides an abstraction around Guile's low level trap
|
21 |
+
;;; handler interface; its aim is to make the low level trap mechanism
|
22 |
+
;;; shareable between the debugger and other applications, and to
|
23 |
+
;;; insulate the rest of the debugger code a bit from changes that may
|
24 |
+
;;; occur in the low level trap interface in future.
|
25 |
+
|
26 |
+
(define-module (ice-9 debugging traps)
|
27 |
+
#:use-module (ice-9 regex)
|
28 |
+
#:use-module (oop goops)
|
29 |
+
#:use-module (oop goops describe)
|
30 |
+
#:use-module (ice-9 debugging trc)
|
31 |
+
#:use-module (srfi srfi-1)
|
32 |
+
#:use-module (srfi srfi-2)
|
33 |
+
#:export (tc:type
|
34 |
+
tc:continuation
|
35 |
+
tc:expression
|
36 |
+
tc:return-value
|
37 |
+
tc:stack
|
38 |
+
tc:frame
|
39 |
+
tc:depth
|
40 |
+
tc:real-depth
|
41 |
+
tc:exit-depth
|
42 |
+
tc:fired-traps
|
43 |
+
;; Interface for users of <trap> subclasses defined in
|
44 |
+
;; this module.
|
45 |
+
add-trapped-stack-id!
|
46 |
+
remove-trapped-stack-id!
|
47 |
+
<procedure-trap>
|
48 |
+
<exit-trap>
|
49 |
+
<entry-trap>
|
50 |
+
<apply-trap>
|
51 |
+
<step-trap>
|
52 |
+
<source-trap>
|
53 |
+
<location-trap>
|
54 |
+
install-trap
|
55 |
+
uninstall-trap
|
56 |
+
all-traps
|
57 |
+
get-trap
|
58 |
+
list-traps
|
59 |
+
trap-ordering
|
60 |
+
behaviour-ordering
|
61 |
+
throw->trap-context
|
62 |
+
on-lazy-handler-dispatch
|
63 |
+
;; Interface for authors of new <trap> subclasses.
|
64 |
+
<trap-context>
|
65 |
+
<trap>
|
66 |
+
trap->behaviour
|
67 |
+
trap-runnable?
|
68 |
+
install-apply-frame-trap
|
69 |
+
install-breakpoint-trap
|
70 |
+
install-enter-frame-trap
|
71 |
+
install-exit-frame-trap
|
72 |
+
install-trace-trap
|
73 |
+
uninstall-apply-frame-trap
|
74 |
+
uninstall-breakpoint-trap
|
75 |
+
uninstall-enter-frame-trap
|
76 |
+
uninstall-exit-frame-trap
|
77 |
+
uninstall-trace-trap
|
78 |
+
frame->source-position
|
79 |
+
frame-file-name
|
80 |
+
without-traps
|
81 |
+
guile-trap-features)
|
82 |
+
#:re-export (make)
|
83 |
+
#:export-syntax (trap-here))
|
84 |
+
|
85 |
+
;; How to debug the debugging infrastructure, when needed. Grep for
|
86 |
+
;; "(trc " to find other symbols that can be passed to trc-add.
|
87 |
+
;; (trc-add 'after-gc-hook)
|
88 |
+
|
89 |
+
;; In Guile 1.7 onwards, weak-vector and friends are provided by the
|
90 |
+
;; (ice-9 weak-vector) module.
|
91 |
+
(cond ((string>=? (version) "1.7")
|
92 |
+
(use-modules (ice-9 weak-vector))))
|
93 |
+
|
94 |
+
;;; The current low level traps interface is as follows.
|
95 |
+
;;;
|
96 |
+
;;; All trap handlers are subject to SCM_TRAPS_P, which is controlled
|
97 |
+
;;; by the `traps' setting of `(evaluator-traps-interface)' but also
|
98 |
+
;;; (and more relevant in most cases) by the `with-traps' procedure.
|
99 |
+
;;; Basically, `with-traps' sets SCM_TRAPS_P to 1 during execution of
|
100 |
+
;;; its thunk parameter.
|
101 |
+
;;;
|
102 |
+
;;; Note that all trap handlers are called with SCM_TRAPS_P set to 0
|
103 |
+
;;; for the duration of the call, to avoid nasty recursive trapping
|
104 |
+
;;; loops. If a trap handler knows what it is doing, it can override
|
105 |
+
;;; this by `(trap-enable traps)'.
|
106 |
+
;;;
|
107 |
+
;;; The apply-frame handler is called when Guile is about to perform
|
108 |
+
;;; an application if EITHER the `apply-frame' evaluator trap option
|
109 |
+
;;; is set, OR the `trace' debug option is set and the procedure to
|
110 |
+
;;; apply has its `trace' procedure property set. The arguments
|
111 |
+
;;; passed are:
|
112 |
+
;;;
|
113 |
+
;;; - the symbol 'apply-frame
|
114 |
+
;;;
|
115 |
+
;;; - a continuation or debug object describing the current stack
|
116 |
+
;;;
|
117 |
+
;;; - a boolean indicating whether the application is tail-recursive.
|
118 |
+
;;;
|
119 |
+
;;; The enter-frame handler is called when the evaluator begins a new
|
120 |
+
;;; evaluation frame if EITHER the `enter-frame' evaluator trap option
|
121 |
+
;;; is set, OR the `breakpoints' debug option is set and the code to
|
122 |
+
;;; be evaluated has its `breakpoint' source property set. The
|
123 |
+
;;; arguments passed are:
|
124 |
+
;;;
|
125 |
+
;;; - the symbol 'enter-frame
|
126 |
+
;;;
|
127 |
+
;;; - a continuation or debug object describing the current stack
|
128 |
+
;;;
|
129 |
+
;;; - a boolean indicating whether the application is tail-recursive.
|
130 |
+
;;;
|
131 |
+
;;; - an unmemoized copy of the expression to be evaluated.
|
132 |
+
;;;
|
133 |
+
;;; If the `enter-frame' evaluator trap option is set, the enter-frame
|
134 |
+
;;; handler is also called when about to perform an application in
|
135 |
+
;;; SCM_APPLY, immediately before possibly calling the apply-frame
|
136 |
+
;;; handler. (I don't totally understand this.) In this case, the
|
137 |
+
;;; arguments passed are:
|
138 |
+
;;;
|
139 |
+
;;; - the symbol 'enter-frame
|
140 |
+
;;;
|
141 |
+
;;; - a continuation or debug object describing the current stack.
|
142 |
+
;;;
|
143 |
+
;;; The exit-frame handler is called when Guile exits an evaluation
|
144 |
+
;;; frame (in SCM_CEVAL) or an application frame (in SCM_APPLY), if
|
145 |
+
;;; EITHER the `exit-frame' evaluator trap option is set, OR the
|
146 |
+
;;; `trace' debug option is set and the frame is marked as having been
|
147 |
+
;;; traced. The frame will be marked as having been traced if the
|
148 |
+
;;; apply-frame handler was called for this frame. (This is trickier
|
149 |
+
;;; than it sounds because of tail recursion: the same debug frame
|
150 |
+
;;; could have been used for multiple applications, only some of which
|
151 |
+
;;; were traced - I think.) The arguments passed are:
|
152 |
+
;;;
|
153 |
+
;;; - the symbol 'exit-frame
|
154 |
+
;;;
|
155 |
+
;;; - a continuation or debug object describing the current stack
|
156 |
+
;;;
|
157 |
+
;;; - the result of the evaluation or application.
|
158 |
+
|
159 |
+
;;; {Trap Context}
|
160 |
+
;;;
|
161 |
+
;;; A trap context is a GOOPS object that encapsulates all the useful
|
162 |
+
;;; information about a particular trap. Encapsulating this
|
163 |
+
;;; information in a single object also allows us:
|
164 |
+
;;;
|
165 |
+
;;; - to defer the calculation of information that is time-consuming
|
166 |
+
;;; to calculate, such as the stack, and to cache such information so
|
167 |
+
;;; that it is only ever calculated once per trap
|
168 |
+
;;;
|
169 |
+
;;; - to pass all interesting information to trap behaviour procedures
|
170 |
+
;;; in a single parameter, which (i) is convenient and (ii) makes for
|
171 |
+
;;; a more future-proof interface.
|
172 |
+
;;;
|
173 |
+
;;; It also allows us - where very carefully documented! - to pass
|
174 |
+
;;; information from one behaviour procedure to another.
|
175 |
+
|
176 |
+
(define-class <trap-context> ()
|
177 |
+
;; Information provided directly by the trap calls from the
|
178 |
+
;; evaluator. The "type" slot holds a keyword indicating the type
|
179 |
+
;; of the trap: one of #:evaluation, #:application, #:return,
|
180 |
+
;; #:error.
|
181 |
+
(type #:getter tc:type
|
182 |
+
#:init-keyword #:type)
|
183 |
+
;; The "continuation" slot holds the continuation (or debug object,
|
184 |
+
;; if "cheap" traps are enabled, which is the default) at the point
|
185 |
+
;; of the trap. For an error trap it is #f.
|
186 |
+
(continuation #:getter tc:continuation
|
187 |
+
#:init-keyword #:continuation)
|
188 |
+
;; The "expression" slot holds the source code expression, for an
|
189 |
+
;; evaluation trap.
|
190 |
+
(expression #:getter tc:expression
|
191 |
+
#:init-keyword #:expression
|
192 |
+
#:init-value #f)
|
193 |
+
;; The "return-value" slot holds the return value, for a return
|
194 |
+
;; trap, or the error args, for an error trap.
|
195 |
+
(return-value #:getter tc:return-value
|
196 |
+
#:init-keyword #:return-value
|
197 |
+
#:init-value #f)
|
198 |
+
;; The list of trap objects which fired in this trap context.
|
199 |
+
(fired-traps #:getter tc:fired-traps
|
200 |
+
#:init-value '())
|
201 |
+
;; The set of symbols which, if one of them is set in the CAR of the
|
202 |
+
;; handler-return-value slot, will cause the CDR of that slot to
|
203 |
+
;; have an effect.
|
204 |
+
(handler-return-syms #:init-value '())
|
205 |
+
;; The value which the trap handler should return to the evaluator.
|
206 |
+
(handler-return-value #:init-value #f)
|
207 |
+
;; Calculated and cached information. "stack" is the stack
|
208 |
+
;; (computed from the continuation (or debug object) by make-stack,
|
209 |
+
;; or else (in the case of an error trap) by (make-stack #t ...).
|
210 |
+
(stack #:init-value #f)
|
211 |
+
(frame #:init-value #f)
|
212 |
+
(depth #:init-value #f)
|
213 |
+
(real-depth #:init-value #f)
|
214 |
+
(exit-depth #:init-value #f))
|
215 |
+
|
216 |
+
(define-method (tc:stack (ctx <trap-context>))
|
217 |
+
(or (slot-ref ctx 'stack)
|
218 |
+
(let ((stack (make-stack (tc:continuation ctx))))
|
219 |
+
(slot-set! ctx 'stack stack)
|
220 |
+
stack)))
|
221 |
+
|
222 |
+
(define-method (tc:frame (ctx <trap-context>))
|
223 |
+
(or (slot-ref ctx 'frame)
|
224 |
+
(let ((frame (cond ((tc:continuation ctx) => last-stack-frame)
|
225 |
+
(else (stack-ref (tc:stack ctx) 0)))))
|
226 |
+
(slot-set! ctx 'frame frame)
|
227 |
+
frame)))
|
228 |
+
|
229 |
+
(define-method (tc:depth (ctx <trap-context>))
|
230 |
+
(or (slot-ref ctx 'depth)
|
231 |
+
(let ((depth (stack-length (tc:stack ctx))))
|
232 |
+
(slot-set! ctx 'depth depth)
|
233 |
+
depth)))
|
234 |
+
|
235 |
+
(define-method (tc:real-depth (ctx <trap-context>))
|
236 |
+
(or (slot-ref ctx 'real-depth)
|
237 |
+
(let* ((stack (tc:stack ctx))
|
238 |
+
(real-depth (apply +
|
239 |
+
(map (lambda (i)
|
240 |
+
(if (frame-real? (stack-ref stack i))
|
241 |
+
1
|
242 |
+
0))
|
243 |
+
(iota (tc:depth ctx))))))
|
244 |
+
(slot-set! ctx 'real-depth real-depth)
|
245 |
+
real-depth)))
|
246 |
+
|
247 |
+
(define-method (tc:exit-depth (ctx <trap-context>))
|
248 |
+
(or (slot-ref ctx 'exit-depth)
|
249 |
+
(let* ((stack (tc:stack ctx))
|
250 |
+
(depth (tc:depth ctx))
|
251 |
+
(exit-depth (let loop ((exit-depth depth))
|
252 |
+
(if (or (zero? exit-depth)
|
253 |
+
(frame-real? (stack-ref stack
|
254 |
+
(- depth
|
255 |
+
exit-depth))))
|
256 |
+
exit-depth
|
257 |
+
(loop (- exit-depth 1))))))
|
258 |
+
(slot-set! ctx 'exit-depth exit-depth)
|
259 |
+
exit-depth)))
|
260 |
+
|
261 |
+
;;; {Stack IDs}
|
262 |
+
;;;
|
263 |
+
;;; Mechanism for limiting trapping to contexts whose stack ID matches
|
264 |
+
;;; one of a registered set. The default is for traps to fire
|
265 |
+
;;; regardless of stack ID.
|
266 |
+
|
267 |
+
(define trapped-stack-ids (list #t))
|
268 |
+
(define all-stack-ids-trapped? #t)
|
269 |
+
|
270 |
+
(define (add-trapped-stack-id! id)
|
271 |
+
"Add ID to the set of stack ids for which traps are active.
|
272 |
+
If `#t' is in this set, traps are active regardless of stack context.
|
273 |
+
To remove ID again, use `remove-trapped-stack-id!'. If you add the
|
274 |
+
same ID twice using `add-trapped-stack-id!', you will need to remove
|
275 |
+
it twice."
|
276 |
+
(set! trapped-stack-ids (cons id trapped-stack-ids))
|
277 |
+
(set! all-stack-ids-trapped? (memq #t trapped-stack-ids)))
|
278 |
+
|
279 |
+
(define (remove-trapped-stack-id! id)
|
280 |
+
"Remove ID from the set of stack ids for which traps are active."
|
281 |
+
(set! trapped-stack-ids (delq1! id trapped-stack-ids))
|
282 |
+
(set! all-stack-ids-trapped? (memq #t trapped-stack-ids)))
|
283 |
+
|
284 |
+
(define (trap-here? cont)
|
285 |
+
;; Return true if the stack id of the specified continuation (or
|
286 |
+
;; debug object) is in the set that we should trap for; otherwise
|
287 |
+
;; false.
|
288 |
+
(or all-stack-ids-trapped?
|
289 |
+
(memq (stack-id cont) trapped-stack-ids)))
|
290 |
+
|
291 |
+
;;; {Global State}
|
292 |
+
;;;
|
293 |
+
;;; Variables tracking registered handlers, relevant procedures, and
|
294 |
+
;;; what's turned on as regards the evaluator's debugging options.
|
295 |
+
|
296 |
+
(define enter-frame-traps '())
|
297 |
+
(define apply-frame-traps '())
|
298 |
+
(define exit-frame-traps '())
|
299 |
+
(define breakpoint-traps '())
|
300 |
+
(define trace-traps '())
|
301 |
+
|
302 |
+
(define (non-null? hook)
|
303 |
+
(not (null? hook)))
|
304 |
+
|
305 |
+
;; The low level frame handlers must all be initialized to something
|
306 |
+
;; harmless. Otherwise we hit a problem immediately when trying to
|
307 |
+
;; enable one of these handlers.
|
308 |
+
(trap-set! enter-frame-handler noop)
|
309 |
+
(trap-set! apply-frame-handler noop)
|
310 |
+
(trap-set! exit-frame-handler noop)
|
311 |
+
|
312 |
+
(define set-debug-and-trap-options
|
313 |
+
(let ((dopts (debug-options))
|
314 |
+
(topts (evaluator-traps-interface))
|
315 |
+
(setting (lambda (key opts)
|
316 |
+
(let ((l (memq key opts)))
|
317 |
+
(and l
|
318 |
+
(not (null? (cdr l)))
|
319 |
+
(cadr l)))))
|
320 |
+
(debug-set-boolean! (lambda (key value)
|
321 |
+
((if value debug-enable debug-disable) key)))
|
322 |
+
(trap-set-boolean! (lambda (key value)
|
323 |
+
((if value trap-enable trap-disable) key))))
|
324 |
+
(let ((save-debug (memq 'debug dopts))
|
325 |
+
(save-trace (memq 'trace dopts))
|
326 |
+
(save-breakpoints (memq 'breakpoints dopts))
|
327 |
+
(save-enter-frame (memq 'enter-frame topts))
|
328 |
+
(save-apply-frame (memq 'apply-frame topts))
|
329 |
+
(save-exit-frame (memq 'exit-frame topts))
|
330 |
+
(save-enter-frame-handler (setting 'enter-frame-handler topts))
|
331 |
+
(save-apply-frame-handler (setting 'apply-frame-handler topts))
|
332 |
+
(save-exit-frame-handler (setting 'exit-frame-handler topts)))
|
333 |
+
(lambda ()
|
334 |
+
(let ((need-trace (non-null? trace-traps))
|
335 |
+
(need-breakpoints (non-null? breakpoint-traps))
|
336 |
+
(need-enter-frame (non-null? enter-frame-traps))
|
337 |
+
(need-apply-frame (non-null? apply-frame-traps))
|
338 |
+
(need-exit-frame (non-null? exit-frame-traps)))
|
339 |
+
(debug-set-boolean! 'debug
|
340 |
+
(or need-trace
|
341 |
+
need-breakpoints
|
342 |
+
need-enter-frame
|
343 |
+
need-apply-frame
|
344 |
+
need-exit-frame
|
345 |
+
save-debug))
|
346 |
+
(debug-set-boolean! 'trace
|
347 |
+
(or need-trace
|
348 |
+
save-trace))
|
349 |
+
(debug-set-boolean! 'breakpoints
|
350 |
+
(or need-breakpoints
|
351 |
+
save-breakpoints))
|
352 |
+
(trap-set-boolean! 'enter-frame
|
353 |
+
(or need-enter-frame
|
354 |
+
save-enter-frame))
|
355 |
+
(trap-set-boolean! 'apply-frame
|
356 |
+
(or need-apply-frame
|
357 |
+
save-apply-frame))
|
358 |
+
(trap-set-boolean! 'exit-frame
|
359 |
+
(or need-exit-frame
|
360 |
+
save-exit-frame))
|
361 |
+
(trap-set! enter-frame-handler
|
362 |
+
(cond ((or need-breakpoints
|
363 |
+
need-enter-frame)
|
364 |
+
enter-frame-handler)
|
365 |
+
(else save-enter-frame-handler)))
|
366 |
+
(trap-set! apply-frame-handler
|
367 |
+
(cond ((or need-trace
|
368 |
+
need-apply-frame)
|
369 |
+
apply-frame-handler)
|
370 |
+
(else save-apply-frame-handler)))
|
371 |
+
(trap-set! exit-frame-handler
|
372 |
+
(cond ((or need-exit-frame)
|
373 |
+
exit-frame-handler)
|
374 |
+
(else save-exit-frame-handler))))
|
375 |
+
;;(write (evaluator-traps-interface))
|
376 |
+
*unspecified*))))
|
377 |
+
|
378 |
+
(define (enter-frame-handler key cont . args)
|
379 |
+
;; For a non-application entry, ARGS is (TAIL? EXP), where EXP is an
|
380 |
+
;; unmemoized copy of the source expression. For an application
|
381 |
+
;; entry, ARGS is empty.
|
382 |
+
(if (trap-here? cont)
|
383 |
+
(let* ((application-entry? (null? args))
|
384 |
+
(trap-context (make <trap-context>
|
385 |
+
#:type #:evaluation
|
386 |
+
#:continuation cont
|
387 |
+
#:expression (if application-entry?
|
388 |
+
#f
|
389 |
+
(cadr args)))))
|
390 |
+
(trc 'enter-frame-handler)
|
391 |
+
(if (and (not application-entry?)
|
392 |
+
(memq 'tweaking guile-trap-features))
|
393 |
+
(slot-set! trap-context 'handler-return-syms '(instead)))
|
394 |
+
(run-traps (if application-entry?
|
395 |
+
enter-frame-traps
|
396 |
+
(append enter-frame-traps breakpoint-traps))
|
397 |
+
trap-context)
|
398 |
+
(slot-ref trap-context 'handler-return-value))))
|
399 |
+
|
400 |
+
(define (apply-frame-handler key cont tail?)
|
401 |
+
(if (trap-here? cont)
|
402 |
+
(let ((trap-context (make <trap-context>
|
403 |
+
#:type #:application
|
404 |
+
#:continuation cont)))
|
405 |
+
(trc 'apply-frame-handler tail?)
|
406 |
+
(run-traps (append apply-frame-traps trace-traps) trap-context)
|
407 |
+
(slot-ref trap-context 'handler-return-value))))
|
408 |
+
|
409 |
+
(define (exit-frame-handler key cont retval)
|
410 |
+
(if (trap-here? cont)
|
411 |
+
(let ((trap-context (make <trap-context>
|
412 |
+
#:type #:return
|
413 |
+
#:continuation cont
|
414 |
+
#:return-value retval)))
|
415 |
+
(trc 'exit-frame-handler retval (tc:depth trap-context))
|
416 |
+
(if (memq 'tweaking guile-trap-features)
|
417 |
+
(slot-set! trap-context 'handler-return-syms '(instead)))
|
418 |
+
(run-traps exit-frame-traps trap-context)
|
419 |
+
(slot-ref trap-context 'handler-return-value))))
|
420 |
+
|
421 |
+
(define-macro (trap-installer trap-list)
|
422 |
+
`(lambda (trap)
|
423 |
+
(set! ,trap-list (cons trap ,trap-list))
|
424 |
+
(set-debug-and-trap-options)))
|
425 |
+
|
426 |
+
(define install-enter-frame-trap (trap-installer enter-frame-traps))
|
427 |
+
(define install-apply-frame-trap (trap-installer apply-frame-traps))
|
428 |
+
(define install-exit-frame-trap (trap-installer exit-frame-traps))
|
429 |
+
(define install-breakpoint-trap (trap-installer breakpoint-traps))
|
430 |
+
(define install-trace-trap (trap-installer trace-traps))
|
431 |
+
|
432 |
+
(define-macro (trap-uninstaller trap-list)
|
433 |
+
`(lambda (trap)
|
434 |
+
(or (memq trap ,trap-list)
|
435 |
+
(error "Trap list does not include the specified trap"))
|
436 |
+
(set! ,trap-list (delq1! trap ,trap-list))
|
437 |
+
(set-debug-and-trap-options)))
|
438 |
+
|
439 |
+
(define uninstall-enter-frame-trap (trap-uninstaller enter-frame-traps))
|
440 |
+
(define uninstall-apply-frame-trap (trap-uninstaller apply-frame-traps))
|
441 |
+
(define uninstall-exit-frame-trap (trap-uninstaller exit-frame-traps))
|
442 |
+
(define uninstall-breakpoint-trap (trap-uninstaller breakpoint-traps))
|
443 |
+
(define uninstall-trace-trap (trap-uninstaller trace-traps))
|
444 |
+
|
445 |
+
(define trap-ordering (make-object-property))
|
446 |
+
(define behaviour-ordering (make-object-property))
|
447 |
+
|
448 |
+
(define (run-traps traps trap-context)
|
449 |
+
(let ((behaviours (apply append
|
450 |
+
(map (lambda (trap)
|
451 |
+
(trap->behaviour trap trap-context))
|
452 |
+
(sort traps
|
453 |
+
(lambda (t1 t2)
|
454 |
+
(< (or (trap-ordering t1) 0)
|
455 |
+
(or (trap-ordering t2) 0))))))))
|
456 |
+
(for-each (lambda (proc)
|
457 |
+
(proc trap-context))
|
458 |
+
(sort (delete-duplicates behaviours)
|
459 |
+
(lambda (b1 b2)
|
460 |
+
(< (or (behaviour-ordering b1) 0)
|
461 |
+
(or (behaviour-ordering b2) 0)))))))
|
462 |
+
|
463 |
+
;;; {Pseudo-Traps for Non-Trap Events}
|
464 |
+
|
465 |
+
;;; Once there is a body of code to do with responding to (debugging,
|
466 |
+
;;; tracing, etc.) traps, it makes sense to be able to leverage that
|
467 |
+
;;; same code for certain events that are trap-like, but not actually
|
468 |
+
;;; traps in the sense of the calls made by libguile's evaluator.
|
469 |
+
|
470 |
+
;;; The main example of this is when an error is signalled. Guile
|
471 |
+
;;; doesn't yet have a 100% reliable way of hooking into errors, but
|
472 |
+
;;; in practice most errors go through a lazy-catch whose handler is
|
473 |
+
;;; lazy-handler-dispatch (defined in ice-9/boot-9.scm), which in turn
|
474 |
+
;;; calls default-lazy-handler. So we can present most errors as
|
475 |
+
;;; pseudo-traps by modifying default-lazy-handler.
|
476 |
+
|
477 |
+
(define default-default-lazy-handler default-lazy-handler)
|
478 |
+
|
479 |
+
(define (throw->trap-context key args . stack-args)
|
480 |
+
(let ((ctx (make <trap-context>
|
481 |
+
#:type #:error
|
482 |
+
#:continuation #f
|
483 |
+
#:return-value (cons key args))))
|
484 |
+
(slot-set! ctx 'stack
|
485 |
+
(let ((caller-stack (and (= (length stack-args) 1)
|
486 |
+
(car stack-args))))
|
487 |
+
(if (stack? caller-stack)
|
488 |
+
caller-stack
|
489 |
+
(apply make-stack #t stack-args))))
|
490 |
+
ctx))
|
491 |
+
|
492 |
+
(define (on-lazy-handler-dispatch behaviour . ignored-keys)
|
493 |
+
(set! default-lazy-handler
|
494 |
+
(if behaviour
|
495 |
+
(lambda (key . args)
|
496 |
+
(or (memq key ignored-keys)
|
497 |
+
(behaviour (throw->trap-context key
|
498 |
+
args
|
499 |
+
lazy-handler-dispatch)))
|
500 |
+
(apply default-default-lazy-handler key args))
|
501 |
+
default-default-lazy-handler)))
|
502 |
+
|
503 |
+
;;; {Trap Classes}
|
504 |
+
|
505 |
+
;;; Class: <trap>
|
506 |
+
;;;
|
507 |
+
;;; <trap> is the base class for traps. Any actual trap should be an
|
508 |
+
;;; instance of a class derived from <trap>, not of <trap> itself,
|
509 |
+
;;; because there is no base class method for the install-trap,
|
510 |
+
;;; trap-runnable? and uninstall-trap GFs.
|
511 |
+
(define-class <trap> ()
|
512 |
+
;; "number" slot: the number of this trap (assigned automatically).
|
513 |
+
(number)
|
514 |
+
;; "installed" slot: whether this trap is installed.
|
515 |
+
(installed #:init-value #f)
|
516 |
+
;; "condition" slot: if non-#f, this is a thunk which is called when
|
517 |
+
;; the trap fires, to determine whether trap processing should
|
518 |
+
;; proceed any further.
|
519 |
+
(condition #:init-value #f #:init-keyword #:condition)
|
520 |
+
;; "skip-count" slot: a count of valid (after "condition"
|
521 |
+
;; processing) firings of this trap to skip.
|
522 |
+
(skip-count #:init-value 0 #:init-keyword #:skip-count)
|
523 |
+
;; "single-shot" slot: if non-#f, this trap is removed after it has
|
524 |
+
;; successfully fired (after "condition" and "skip-count"
|
525 |
+
;; processing) for the first time.
|
526 |
+
(single-shot #:init-value #f #:init-keyword #:single-shot)
|
527 |
+
;; "behaviour" slot: procedure or list of procedures to call
|
528 |
+
;; (passing the trap context as parameter) if we finally decide
|
529 |
+
;; (after "condition" and "skip-count" processing) to run this
|
530 |
+
;; trap's behaviour.
|
531 |
+
(behaviour #:init-value '() #:init-keyword #:behaviour)
|
532 |
+
;; "repeat-identical-behaviour" slot: normally, if multiple <trap>
|
533 |
+
;; objects are triggered by the same low level trap, and they
|
534 |
+
;; request the same behaviour, it's only useful to do that behaviour
|
535 |
+
;; once (per low level trap); so by default multiple requests for
|
536 |
+
;; the same behaviour are coalesced. If this slot is non-#f, the
|
537 |
+
;; contents of the "behaviour" slot are uniquified so that they
|
538 |
+
;; avoid being coalesced in this way.
|
539 |
+
(repeat-identical-behaviour #:init-value #f
|
540 |
+
#:init-keyword #:repeat-identical-behaviour)
|
541 |
+
;; "observer" slot: this is a procedure that is called with one
|
542 |
+
;; EVENT argument when the trap status changes in certain
|
543 |
+
;; interesting ways, currently the following. (1) When the trap is
|
544 |
+
;; uninstalled because of the target becoming inaccessible; EVENT in
|
545 |
+
;; this case is 'target-gone.
|
546 |
+
(observer #:init-value #f #:init-keyword #:observer))
|
547 |
+
|
548 |
+
(define last-assigned-trap-number 0)
|
549 |
+
(define all-traps (make-weak-value-hash-table 7))
|
550 |
+
|
551 |
+
(define-method (initialize (trap <trap>) initargs)
|
552 |
+
(next-method)
|
553 |
+
;; Assign a trap number, and store in the hash of all traps.
|
554 |
+
(set! last-assigned-trap-number (+ last-assigned-trap-number 1))
|
555 |
+
(slot-set! trap 'number last-assigned-trap-number)
|
556 |
+
(hash-set! all-traps last-assigned-trap-number trap)
|
557 |
+
;; Listify the behaviour slot, if not a list already.
|
558 |
+
(let ((behaviour (slot-ref trap 'behaviour)))
|
559 |
+
(if (procedure? behaviour)
|
560 |
+
(slot-set! trap 'behaviour (list behaviour)))))
|
561 |
+
|
562 |
+
(define-generic install-trap) ; provided mostly by subclasses
|
563 |
+
(define-generic uninstall-trap) ; provided mostly by subclasses
|
564 |
+
(define-generic trap->behaviour) ; provided by <trap>
|
565 |
+
(define-generic trap-runnable?) ; provided by subclasses
|
566 |
+
|
567 |
+
(define-method (install-trap (trap <trap>))
|
568 |
+
(if (slot-ref trap 'installed)
|
569 |
+
(error "Trap is already installed"))
|
570 |
+
(slot-set! trap 'installed #t))
|
571 |
+
|
572 |
+
(define-method (uninstall-trap (trap <trap>))
|
573 |
+
(or (slot-ref trap 'installed)
|
574 |
+
(error "Trap is not installed"))
|
575 |
+
(slot-set! trap 'installed #f))
|
576 |
+
|
577 |
+
;;; uniquify-behaviour
|
578 |
+
;;;
|
579 |
+
;;; Uniquify BEHAVIOUR by wrapping it in a new lambda.
|
580 |
+
(define (uniquify-behaviour behaviour)
|
581 |
+
(lambda (trap-context)
|
582 |
+
(behaviour trap-context)))
|
583 |
+
|
584 |
+
;;; trap->behaviour
|
585 |
+
;;;
|
586 |
+
;;; If TRAP is runnable, given TRAP-CONTEXT, return a list of
|
587 |
+
;;; behaviour procs to call with TRAP-CONTEXT as a parameter.
|
588 |
+
;;; Otherwise return the empty list.
|
589 |
+
(define-method (trap->behaviour (trap <trap>) (trap-context <trap-context>))
|
590 |
+
(if (and
|
591 |
+
;; Check that the trap is runnable. Runnability is implemented
|
592 |
+
;; by the subclass and allows us to check, for example, that
|
593 |
+
;; the procedure being applied in an apply-frame trap matches
|
594 |
+
;; this trap's procedure.
|
595 |
+
(trap-runnable? trap trap-context)
|
596 |
+
;; Check the additional condition, if specified.
|
597 |
+
(let ((condition (slot-ref trap 'condition)))
|
598 |
+
(or (not condition)
|
599 |
+
((condition))))
|
600 |
+
;; Check for a skip count.
|
601 |
+
(let ((skip-count (slot-ref trap 'skip-count)))
|
602 |
+
(if (zero? skip-count)
|
603 |
+
#t
|
604 |
+
(begin
|
605 |
+
(slot-set! trap 'skip-count (- skip-count 1))
|
606 |
+
#f))))
|
607 |
+
;; All checks passed, so we will return the contents of this
|
608 |
+
;; trap's behaviour slot.
|
609 |
+
(begin
|
610 |
+
;; First, though, remove this trap if its single-shot slot
|
611 |
+
;; indicates that it should fire only once.
|
612 |
+
(if (slot-ref trap 'single-shot)
|
613 |
+
(uninstall-trap trap))
|
614 |
+
;; Add this trap object to the context's list of traps which
|
615 |
+
;; fired here.
|
616 |
+
(slot-set! trap-context 'fired-traps
|
617 |
+
(cons trap (tc:fired-traps trap-context)))
|
618 |
+
;; Return trap behaviour, uniquified if necessary.
|
619 |
+
(if (slot-ref trap 'repeat-identical-behaviour)
|
620 |
+
(map uniquify-behaviour (slot-ref trap 'behaviour))
|
621 |
+
(slot-ref trap 'behaviour)))
|
622 |
+
'()))
|
623 |
+
|
624 |
+
;;; Class: <procedure-trap>
|
625 |
+
;;;
|
626 |
+
;;; An installed instance of <procedure-trap> triggers on invocation
|
627 |
+
;;; of a specific procedure.
|
628 |
+
(define-class <procedure-trap> (<trap>)
|
629 |
+
;; "procedure" slot: the procedure to trap on. This is implemented
|
630 |
+
;; virtually, using the following weak vector slot, so as to avoid
|
631 |
+
;; this trap preventing the GC of the target procedure.
|
632 |
+
(procedure #:init-keyword #:procedure
|
633 |
+
#:allocation #:virtual
|
634 |
+
#:slot-ref
|
635 |
+
(lambda (trap)
|
636 |
+
(vector-ref (slot-ref trap 'procedure-wv) 0))
|
637 |
+
#:slot-set!
|
638 |
+
(lambda (trap proc)
|
639 |
+
(if (slot-bound? trap 'procedure-wv)
|
640 |
+
(vector-set! (slot-ref trap 'procedure-wv) 0 proc)
|
641 |
+
(slot-set! trap 'procedure-wv (weak-vector proc)))))
|
642 |
+
(procedure-wv))
|
643 |
+
|
644 |
+
;; Customization of the initialize method: set up to handle what
|
645 |
+
;; should happen when the procedure is GC'd.
|
646 |
+
(define-method (initialize (trap <procedure-trap>) initargs)
|
647 |
+
(next-method)
|
648 |
+
(let* ((proc (slot-ref trap 'procedure))
|
649 |
+
(existing-traps (volatile-target-traps proc)))
|
650 |
+
;; If this is the target's first trap, give the target procedure
|
651 |
+
;; to the volatile-target-guardian, so we can find out if it
|
652 |
+
;; becomes inaccessible.
|
653 |
+
(or existing-traps (volatile-target-guardian proc))
|
654 |
+
;; Add this trap to the target procedure's list of traps.
|
655 |
+
(set! (volatile-target-traps proc)
|
656 |
+
(cons trap (or existing-traps '())))))
|
657 |
+
|
658 |
+
(define procedure-trace-count (make-object-property))
|
659 |
+
|
660 |
+
(define-method (install-trap (trap <procedure-trap>))
|
661 |
+
(next-method)
|
662 |
+
(let* ((proc (slot-ref trap 'procedure))
|
663 |
+
(trace-count (or (procedure-trace-count proc) 0)))
|
664 |
+
(set-procedure-property! proc 'trace #t)
|
665 |
+
(set! (procedure-trace-count proc) (+ trace-count 1)))
|
666 |
+
(install-trace-trap trap))
|
667 |
+
|
668 |
+
(define-method (uninstall-trap (trap <procedure-trap>))
|
669 |
+
(next-method)
|
670 |
+
(let* ((proc (slot-ref trap 'procedure))
|
671 |
+
(trace-count (or (procedure-trace-count proc) 0)))
|
672 |
+
(if (= trace-count 1)
|
673 |
+
(set-procedure-property! proc 'trace #f))
|
674 |
+
(set! (procedure-trace-count proc) (- trace-count 1)))
|
675 |
+
(uninstall-trace-trap trap))
|
676 |
+
|
677 |
+
(define-method (trap-runnable? (trap <procedure-trap>)
|
678 |
+
(trap-context <trap-context>))
|
679 |
+
(eq? (slot-ref trap 'procedure)
|
680 |
+
(frame-procedure (tc:frame trap-context))))
|
681 |
+
|
682 |
+
;;; Class: <exit-trap>
|
683 |
+
;;;
|
684 |
+
;;; An installed instance of <exit-trap> triggers on stack frame exit
|
685 |
+
;;; past a specified stack depth.
|
686 |
+
(define-class <exit-trap> (<trap>)
|
687 |
+
;; "depth" slot: the reference depth for the trap.
|
688 |
+
(depth #:init-keyword #:depth))
|
689 |
+
|
690 |
+
(define-method (install-trap (trap <exit-trap>))
|
691 |
+
(next-method)
|
692 |
+
(install-exit-frame-trap trap))
|
693 |
+
|
694 |
+
(define-method (uninstall-trap (trap <exit-trap>))
|
695 |
+
(next-method)
|
696 |
+
(uninstall-exit-frame-trap trap))
|
697 |
+
|
698 |
+
(define-method (trap-runnable? (trap <exit-trap>)
|
699 |
+
(trap-context <trap-context>))
|
700 |
+
(<= (tc:exit-depth trap-context)
|
701 |
+
(slot-ref trap 'depth)))
|
702 |
+
|
703 |
+
;;; Class: <entry-trap>
|
704 |
+
;;;
|
705 |
+
;;; An installed instance of <entry-trap> triggers on any frame entry.
|
706 |
+
(define-class <entry-trap> (<trap>))
|
707 |
+
|
708 |
+
(define-method (install-trap (trap <entry-trap>))
|
709 |
+
(next-method)
|
710 |
+
(install-enter-frame-trap trap))
|
711 |
+
|
712 |
+
(define-method (uninstall-trap (trap <entry-trap>))
|
713 |
+
(next-method)
|
714 |
+
(uninstall-enter-frame-trap trap))
|
715 |
+
|
716 |
+
(define-method (trap-runnable? (trap <entry-trap>)
|
717 |
+
(trap-context <trap-context>))
|
718 |
+
#t)
|
719 |
+
|
720 |
+
;;; Class: <apply-trap>
|
721 |
+
;;;
|
722 |
+
;;; An installed instance of <apply-trap> triggers on any procedure
|
723 |
+
;;; application.
|
724 |
+
(define-class <apply-trap> (<trap>))
|
725 |
+
|
726 |
+
(define-method (install-trap (trap <apply-trap>))
|
727 |
+
(next-method)
|
728 |
+
(install-apply-frame-trap trap))
|
729 |
+
|
730 |
+
(define-method (uninstall-trap (trap <apply-trap>))
|
731 |
+
(next-method)
|
732 |
+
(uninstall-apply-frame-trap trap))
|
733 |
+
|
734 |
+
(define-method (trap-runnable? (trap <apply-trap>)
|
735 |
+
(trap-context <trap-context>))
|
736 |
+
#t)
|
737 |
+
|
738 |
+
;;; Class: <step-trap>
|
739 |
+
;;;
|
740 |
+
;;; An installed instance of <step-trap> triggers on the next frame
|
741 |
+
;;; entry, exit or application, optionally with source location inside
|
742 |
+
;;; a specified file.
|
743 |
+
(define-class <step-trap> (<exit-trap>)
|
744 |
+
;; "file-name" slot: if non-#f, indicates that this trap should
|
745 |
+
;; trigger only for steps in source code from the specified file.
|
746 |
+
(file-name #:init-value #f #:init-keyword #:file-name)
|
747 |
+
;; "exit-depth" slot: when non-#f, indicates that the next step may
|
748 |
+
;; be a frame exit past this depth; otherwise, indicates that the
|
749 |
+
;; next step must be an application or a frame entry.
|
750 |
+
(exit-depth #:init-value #f #:init-keyword #:exit-depth))
|
751 |
+
|
752 |
+
(define-method (initialize (trap <step-trap>) initargs)
|
753 |
+
(next-method)
|
754 |
+
(slot-set! trap 'depth (slot-ref trap 'exit-depth)))
|
755 |
+
|
756 |
+
(define-method (install-trap (trap <step-trap>))
|
757 |
+
(next-method)
|
758 |
+
(install-enter-frame-trap trap)
|
759 |
+
(install-apply-frame-trap trap))
|
760 |
+
|
761 |
+
(define-method (uninstall-trap (trap <step-trap>))
|
762 |
+
(next-method)
|
763 |
+
(uninstall-enter-frame-trap trap)
|
764 |
+
(uninstall-apply-frame-trap trap))
|
765 |
+
|
766 |
+
(define-method (trap-runnable? (trap <step-trap>)
|
767 |
+
(trap-context <trap-context>))
|
768 |
+
(if (eq? (tc:type trap-context) #:return)
|
769 |
+
;; We're in the context of an exit-frame trap. Trap should only
|
770 |
+
;; be run if exit-depth is set and this exit-frame has returned
|
771 |
+
;; past the set depth.
|
772 |
+
(and (slot-ref trap 'exit-depth)
|
773 |
+
(next-method)
|
774 |
+
;; OK to run the trap here, but we should first reset the
|
775 |
+
;; exit-depth slot to indicate that the step after this one
|
776 |
+
;; must be an application or frame entry.
|
777 |
+
(begin
|
778 |
+
(slot-set! trap 'exit-depth #f)
|
779 |
+
#t))
|
780 |
+
;; We're in the context of an application or frame entry trap.
|
781 |
+
;; Check whether trap is limited to a specified file.
|
782 |
+
(let ((file-name (slot-ref trap 'file-name)))
|
783 |
+
(and (or (not file-name)
|
784 |
+
(equal? (frame-file-name (tc:frame trap-context)) file-name))
|
785 |
+
;; Trap should run here, but we should also set exit-depth to
|
786 |
+
;; the current stack length, so that - if we don't stop at any
|
787 |
+
;; other steps first - the next step shows the return value of
|
788 |
+
;; the current application or evaluation.
|
789 |
+
(begin
|
790 |
+
(slot-set! trap 'exit-depth (tc:depth trap-context))
|
791 |
+
(slot-set! trap 'depth (tc:depth trap-context))
|
792 |
+
#t)))))
|
793 |
+
|
794 |
+
(define (frame->source-position frame)
|
795 |
+
(let ((source (if (frame-procedure? frame)
|
796 |
+
(or (frame-source frame)
|
797 |
+
(let ((proc (frame-procedure frame)))
|
798 |
+
(and proc
|
799 |
+
(procedure? proc)
|
800 |
+
(procedure-source proc))))
|
801 |
+
(frame-source frame))))
|
802 |
+
(and source
|
803 |
+
(string? (source-property source 'filename))
|
804 |
+
(list (source-property source 'filename)
|
805 |
+
(source-property source 'line)
|
806 |
+
(source-property source 'column)))))
|
807 |
+
|
808 |
+
(define (frame-file-name frame)
|
809 |
+
(cond ((frame->source-position frame) => car)
|
810 |
+
(else #f)))
|
811 |
+
|
812 |
+
;;; Class: <source-trap>
|
813 |
+
;;;
|
814 |
+
;;; An installed instance of <source-trap> triggers upon evaluation of
|
815 |
+
;;; a specified source expression.
|
816 |
+
(define-class <source-trap> (<trap>)
|
817 |
+
;; "expression" slot: the expression to trap on. This is
|
818 |
+
;; implemented virtually, using the following weak vector slot, so
|
819 |
+
;; as to avoid this trap preventing the GC of the target source
|
820 |
+
;; code.
|
821 |
+
(expression #:init-keyword #:expression
|
822 |
+
#:allocation #:virtual
|
823 |
+
#:slot-ref
|
824 |
+
(lambda (trap)
|
825 |
+
(vector-ref (slot-ref trap 'expression-wv) 0))
|
826 |
+
#:slot-set!
|
827 |
+
(lambda (trap expr)
|
828 |
+
(if (slot-bound? trap 'expression-wv)
|
829 |
+
(vector-set! (slot-ref trap 'expression-wv) 0 expr)
|
830 |
+
(slot-set! trap 'expression-wv (weak-vector expr)))))
|
831 |
+
(expression-wv)
|
832 |
+
;; source property slots - for internal use only
|
833 |
+
(filename)
|
834 |
+
(line)
|
835 |
+
(column))
|
836 |
+
|
837 |
+
;; Customization of the initialize method: get and save the
|
838 |
+
;; expression's source properties, or signal an error if it doesn't
|
839 |
+
;; have the necessary properties.
|
840 |
+
(define-method (initialize (trap <source-trap>) initargs)
|
841 |
+
(next-method)
|
842 |
+
(let* ((expr (slot-ref trap 'expression))
|
843 |
+
(filename (source-property expr 'filename))
|
844 |
+
(line (source-property expr 'line))
|
845 |
+
(column (source-property expr 'column))
|
846 |
+
(existing-traps (volatile-target-traps expr)))
|
847 |
+
(or (and filename line column)
|
848 |
+
(error "Specified source does not have the necessary properties"
|
849 |
+
filename line column))
|
850 |
+
(slot-set! trap 'filename filename)
|
851 |
+
(slot-set! trap 'line line)
|
852 |
+
(slot-set! trap 'column column)
|
853 |
+
;; If this is the target's first trap, give the target expression
|
854 |
+
;; to the volatile-target-guardian, so we can find out if it
|
855 |
+
;; becomes inaccessible.
|
856 |
+
(or existing-traps (volatile-target-guardian expr))
|
857 |
+
;; Add this trap to the target expression's list of traps.
|
858 |
+
(set! (volatile-target-traps expr)
|
859 |
+
(cons trap (or existing-traps '())))))
|
860 |
+
|
861 |
+
;; Just in case more than one trap is installed on the same source
|
862 |
+
;; expression ... so that we can still get the setting and resetting
|
863 |
+
;; of the 'breakpoint source property correct.
|
864 |
+
(define source-breakpoint-count (make-object-property))
|
865 |
+
|
866 |
+
(define-method (install-trap (trap <source-trap>))
|
867 |
+
(next-method)
|
868 |
+
(let* ((expr (slot-ref trap 'expression))
|
869 |
+
(breakpoint-count (or (source-breakpoint-count expr) 0)))
|
870 |
+
(set-source-property! expr 'breakpoint #t)
|
871 |
+
(set! (source-breakpoint-count expr) (+ breakpoint-count 1)))
|
872 |
+
(install-breakpoint-trap trap))
|
873 |
+
|
874 |
+
(define-method (uninstall-trap (trap <source-trap>))
|
875 |
+
(next-method)
|
876 |
+
(let* ((expr (slot-ref trap 'expression))
|
877 |
+
(breakpoint-count (or (source-breakpoint-count expr) 0)))
|
878 |
+
(if (= breakpoint-count 1)
|
879 |
+
(set-source-property! expr 'breakpoint #f))
|
880 |
+
(set! (source-breakpoint-count expr) (- breakpoint-count 1)))
|
881 |
+
(uninstall-breakpoint-trap trap))
|
882 |
+
|
883 |
+
(define-method (trap-runnable? (trap <source-trap>)
|
884 |
+
(trap-context <trap-context>))
|
885 |
+
(or (eq? (slot-ref trap 'expression)
|
886 |
+
(tc:expression trap-context))
|
887 |
+
(let ((trap-location (frame->source-position (tc:frame trap-context))))
|
888 |
+
(and trap-location
|
889 |
+
(string=? (car trap-location) (slot-ref trap 'filename))
|
890 |
+
(= (cadr trap-location) (slot-ref trap 'line))
|
891 |
+
(= (caddr trap-location) (slot-ref trap 'column))))))
|
892 |
+
|
893 |
+
;; (trap-here EXPRESSION . OPTIONS)
|
894 |
+
(define trap-here
|
895 |
+
(procedure->memoizing-macro
|
896 |
+
(lambda (expr env)
|
897 |
+
(let ((trap (apply make
|
898 |
+
<source-trap>
|
899 |
+
#:expression expr
|
900 |
+
(local-eval `(list ,@(cddr expr))
|
901 |
+
env))))
|
902 |
+
(install-trap trap)
|
903 |
+
(set-car! expr 'begin)
|
904 |
+
(set-cdr! (cdr expr) '())
|
905 |
+
expr))))
|
906 |
+
|
907 |
+
;;; Class: <location-trap>
|
908 |
+
;;;
|
909 |
+
;;; An installed instance of <location-trap> triggers on entry to a
|
910 |
+
;;; frame with a more-or-less precisely specified source location.
|
911 |
+
(define-class <location-trap> (<trap>)
|
912 |
+
;; "file-regexp" slot: regexp matching the name(s) of the file(s) to
|
913 |
+
;; trap in.
|
914 |
+
(file-regexp #:init-keyword #:file-regexp)
|
915 |
+
;; "line" and "column" slots: position to trap at (0-based).
|
916 |
+
(line #:init-value #f #:init-keyword #:line)
|
917 |
+
(column #:init-value #f #:init-keyword #:column)
|
918 |
+
;; "compiled-regexp" slot - self explanatory, internal use only
|
919 |
+
(compiled-regexp))
|
920 |
+
|
921 |
+
(define-method (initialize (trap <location-trap>) initargs)
|
922 |
+
(next-method)
|
923 |
+
(slot-set! trap 'compiled-regexp
|
924 |
+
(make-regexp (slot-ref trap 'file-regexp))))
|
925 |
+
|
926 |
+
(define-method (install-trap (trap <location-trap>))
|
927 |
+
(next-method)
|
928 |
+
(install-enter-frame-trap trap))
|
929 |
+
|
930 |
+
(define-method (uninstall-trap (trap <location-trap>))
|
931 |
+
(next-method)
|
932 |
+
(uninstall-enter-frame-trap trap))
|
933 |
+
|
934 |
+
(define-method (trap-runnable? (trap <location-trap>)
|
935 |
+
(trap-context <trap-context>))
|
936 |
+
(and-let* ((trap-location (frame->source-position (tc:frame trap-context)))
|
937 |
+
(tcline (cadr trap-location))
|
938 |
+
(tccolumn (caddr trap-location)))
|
939 |
+
(and (= tcline (slot-ref trap 'line))
|
940 |
+
(= tccolumn (slot-ref trap 'column))
|
941 |
+
(regexp-exec (slot-ref trap 'compiled-regexp)
|
942 |
+
(car trap-location) 0))))
|
943 |
+
|
944 |
+
;;; {Misc Trap Utilities}
|
945 |
+
|
946 |
+
(define (get-trap number)
|
947 |
+
(hash-ref all-traps number))
|
948 |
+
|
949 |
+
(define (list-traps)
|
950 |
+
(for-each describe
|
951 |
+
(map cdr (sort (hash-fold acons '() all-traps)
|
952 |
+
(lambda (x y) (< (car x) (car y)))))))
|
953 |
+
|
954 |
+
;;; {Volatile Traps}
|
955 |
+
;;;
|
956 |
+
;;; Some traps are associated with Scheme objects that are likely to
|
957 |
+
;;; be GC'd, such as procedures and read expressions. When those
|
958 |
+
;;; objects are GC'd, we want to allow their traps to evaporate as
|
959 |
+
;;; well, or at least not to prevent them from doing so because they
|
960 |
+
;;; are (now pointlessly) included on the various installed trap
|
961 |
+
;;; lists.
|
962 |
+
|
963 |
+
;; An object property that maps each volatile target to the list of
|
964 |
+
;; traps that are installed on it.
|
965 |
+
(define volatile-target-traps (make-object-property))
|
966 |
+
|
967 |
+
;; A guardian that tells us when a volatile target is no longer
|
968 |
+
;; accessible.
|
969 |
+
(define volatile-target-guardian (make-guardian))
|
970 |
+
|
971 |
+
;; An after GC hook that checks for newly inaccessible targets.
|
972 |
+
(add-hook! after-gc-hook
|
973 |
+
(lambda ()
|
974 |
+
(trc 'after-gc-hook)
|
975 |
+
(let loop ((target (volatile-target-guardian)))
|
976 |
+
(if target
|
977 |
+
;; We have a target which is now inaccessible. Get
|
978 |
+
;; the list of traps installed on it.
|
979 |
+
(begin
|
980 |
+
(trc 'after-gc-hook "got target")
|
981 |
+
;; Uninstall all the traps that are installed on
|
982 |
+
;; this target.
|
983 |
+
(for-each (lambda (trap)
|
984 |
+
(trc 'after-gc-hook "got trap")
|
985 |
+
;; If the trap is still installed,
|
986 |
+
;; uninstall it.
|
987 |
+
(if (slot-ref trap 'installed)
|
988 |
+
(uninstall-trap trap))
|
989 |
+
;; If the trap has an observer, tell
|
990 |
+
;; it that the target has gone.
|
991 |
+
(cond ((slot-ref trap 'observer)
|
992 |
+
=>
|
993 |
+
(lambda (proc)
|
994 |
+
(trc 'after-gc-hook "call obs")
|
995 |
+
(proc 'target-gone)))))
|
996 |
+
(or (volatile-target-traps target) '()))
|
997 |
+
;; Check for any more inaccessible targets.
|
998 |
+
(loop (volatile-target-guardian)))))))
|
999 |
+
|
1000 |
+
(define (without-traps thunk)
|
1001 |
+
(with-traps (lambda ()
|
1002 |
+
(trap-disable 'traps)
|
1003 |
+
(thunk))))
|
1004 |
+
|
1005 |
+
(define guile-trap-features
|
1006 |
+
;; Helper procedure, to test whether a specific possible Guile
|
1007 |
+
;; feature is supported.
|
1008 |
+
(let ((supported?
|
1009 |
+
(lambda (test-feature)
|
1010 |
+
(case test-feature
|
1011 |
+
((tweaking)
|
1012 |
+
;; Tweaking is supported if the description of the cheap
|
1013 |
+
;; traps option includes the word "obsolete", or if the
|
1014 |
+
;; option isn't there any more.
|
1015 |
+
(and (string>=? (version) "1.7")
|
1016 |
+
(let ((cheap-opt-desc
|
1017 |
+
(assq 'cheap (debug-options-interface 'help))))
|
1018 |
+
(or (not cheap-opt-desc)
|
1019 |
+
(string-match "obsolete" (caddr cheap-opt-desc))))))
|
1020 |
+
(else
|
1021 |
+
(error "Unexpected feature name:" test-feature))))))
|
1022 |
+
;; Compile the list of actually supported features from all
|
1023 |
+
;; possible features.
|
1024 |
+
(let loop ((possible-features '(tweaking))
|
1025 |
+
(actual-features '()))
|
1026 |
+
(if (null? possible-features)
|
1027 |
+
(reverse! actual-features)
|
1028 |
+
(let ((test-feature (car possible-features)))
|
1029 |
+
(loop (cdr possible-features)
|
1030 |
+
(if (supported? test-feature)
|
1031 |
+
(cons test-feature actual-features)
|
1032 |
+
actual-features)))))))
|
1033 |
+
|
1034 |
+
;; Make sure that traps are enabled.
|
1035 |
+
(trap-enable 'traps)
|
1036 |
+
|
1037 |
+
;;; (ice-9 debugging traps) ends here.
|
node-addon-lilypond/output/share/guile/1.8/ice-9/debugging/trc.scm
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
;;;; (ice-9 debugging trc) -- tracing for Guile debugger code
|
2 |
+
|
3 |
+
;;; Copyright (C) 2002, 2004 Free Software Foundation, Inc.
|
4 |
+
;;;
|
5 |
+
;; This library is free software; you can redistribute it and/or
|
6 |
+
;; modify it under the terms of the GNU Lesser General Public
|
7 |
+
;; License as published by the Free Software Foundation; either
|
8 |
+
;; version 2.1 of the License, or (at your option) any later version.
|
9 |
+
;;
|
10 |
+
;; This library is distributed in the hope that it will be useful,
|
11 |
+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13 |
+
;; Lesser General Public License for more details.
|
14 |
+
;;
|
15 |
+
;; You should have received a copy of the GNU Lesser General Public
|
16 |
+
;; License along with this library; if not, write to the Free Software
|
17 |
+
;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18 |
+
|
19 |
+
(define-module (ice-9 debugging trc)
|
20 |
+
#:export (trc trc-syms trc-all trc-none trc-add trc-remove trc-port))
|
21 |
+
|
22 |
+
(define *syms* #f)
|
23 |
+
|
24 |
+
(define (trc-set! syms)
|
25 |
+
(set! *syms* syms))
|
26 |
+
|
27 |
+
(define (trc-syms . syms)
|
28 |
+
(trc-set! syms))
|
29 |
+
|
30 |
+
(define (trc-all)
|
31 |
+
(trc-set! #f))
|
32 |
+
|
33 |
+
(define (trc-none)
|
34 |
+
(trc-set! '()))
|
35 |
+
|
36 |
+
(define (trc-add sym)
|
37 |
+
(trc-set! (cons sym *syms*)))
|
38 |
+
|
39 |
+
(define (trc-remove sym)
|
40 |
+
(trc-set! (delq1! sym *syms*)))
|
41 |
+
|
42 |
+
(define (trc sym . args)
|
43 |
+
(if (or (not *syms*)
|
44 |
+
(memq sym *syms*))
|
45 |
+
(let ((port (trc-port)))
|
46 |
+
(write sym port)
|
47 |
+
(display ":" port)
|
48 |
+
(for-each (lambda (arg)
|
49 |
+
(display " " port)
|
50 |
+
(write arg port))
|
51 |
+
args)
|
52 |
+
(newline port))))
|
53 |
+
|
54 |
+
(define trc-port
|
55 |
+
(let ((port (current-error-port)))
|
56 |
+
(make-procedure-with-setter
|
57 |
+
(lambda () port)
|
58 |
+
(lambda (p) (set! port p)))))
|
59 |
+
|
60 |
+
;; Default to no tracing.
|
61 |
+
(trc-none)
|
62 |
+
|
63 |
+
;;; (ice-9 debugging trc) ends here.
|
node-addon-lilypond/output/share/guile/1.8/ice-9/deprecated.scm
ADDED
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
;;;; Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
|
2 |
+
;;;;
|
3 |
+
;;;; This library is free software; you can redistribute it and/or
|
4 |
+
;;;; modify it under the terms of the GNU Lesser General Public
|
5 |
+
;;;; License as published by the Free Software Foundation; either
|
6 |
+
;;;; version 2.1 of the License, or (at your option) any later version.
|
7 |
+
;;;;
|
8 |
+
;;;; This library is distributed in the hope that it will be useful,
|
9 |
+
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10 |
+
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11 |
+
;;;; Lesser General Public License for more details.
|
12 |
+
;;;;
|
13 |
+
;;;; You should have received a copy of the GNU Lesser General Public
|
14 |
+
;;;; License along with this library; if not, write to the Free Software
|
15 |
+
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16 |
+
;;;;
|
17 |
+
|
18 |
+
;;;; Deprecated definitions.
|
19 |
+
|
20 |
+
(define substring-move-left! substring-move!)
|
21 |
+
(define substring-move-right! substring-move!)
|
22 |
+
|
23 |
+
;; This method of dynamically linking Guile Extensions is deprecated.
|
24 |
+
;; Use `load-extension' explicitly from Scheme code instead.
|
25 |
+
|
26 |
+
(define (split-c-module-name str)
|
27 |
+
(let loop ((rev '())
|
28 |
+
(start 0)
|
29 |
+
(pos 0)
|
30 |
+
(end (string-length str)))
|
31 |
+
(cond
|
32 |
+
((= pos end)
|
33 |
+
(reverse (cons (string->symbol (substring str start pos)) rev)))
|
34 |
+
((eq? (string-ref str pos) #\space)
|
35 |
+
(loop (cons (string->symbol (substring str start pos)) rev)
|
36 |
+
(+ pos 1)
|
37 |
+
(+ pos 1)
|
38 |
+
end))
|
39 |
+
(else
|
40 |
+
(loop rev start (+ pos 1) end)))))
|
41 |
+
|
42 |
+
(define (convert-c-registered-modules dynobj)
|
43 |
+
(let ((res (map (lambda (c)
|
44 |
+
(list (split-c-module-name (car c)) (cdr c) dynobj))
|
45 |
+
(c-registered-modules))))
|
46 |
+
(c-clear-registered-modules)
|
47 |
+
res))
|
48 |
+
|
49 |
+
(define registered-modules '())
|
50 |
+
|
51 |
+
(define (register-modules dynobj)
|
52 |
+
(set! registered-modules
|
53 |
+
(append! (convert-c-registered-modules dynobj)
|
54 |
+
registered-modules)))
|
55 |
+
|
56 |
+
(define (warn-autoload-deprecation modname)
|
57 |
+
(issue-deprecation-warning
|
58 |
+
"Autoloading of compiled code modules is deprecated."
|
59 |
+
"Write a Scheme file instead that uses `load-extension'.")
|
60 |
+
(issue-deprecation-warning
|
61 |
+
(simple-format #f "(You just autoloaded module ~S.)" modname)))
|
62 |
+
|
63 |
+
(define (init-dynamic-module modname)
|
64 |
+
;; Register any linked modules which have been registered on the C level
|
65 |
+
(register-modules #f)
|
66 |
+
(or-map (lambda (modinfo)
|
67 |
+
(if (equal? (car modinfo) modname)
|
68 |
+
(begin
|
69 |
+
(warn-autoload-deprecation modname)
|
70 |
+
(set! registered-modules (delq! modinfo registered-modules))
|
71 |
+
(let ((mod (resolve-module modname #f)))
|
72 |
+
(save-module-excursion
|
73 |
+
(lambda ()
|
74 |
+
(set-current-module mod)
|
75 |
+
(set-module-public-interface! mod mod)
|
76 |
+
(dynamic-call (cadr modinfo) (caddr modinfo))
|
77 |
+
))
|
78 |
+
#t))
|
79 |
+
#f))
|
80 |
+
registered-modules))
|
81 |
+
|
82 |
+
(define (dynamic-maybe-call name dynobj)
|
83 |
+
(catch #t ; could use false-if-exception here
|
84 |
+
(lambda ()
|
85 |
+
(dynamic-call name dynobj))
|
86 |
+
(lambda args
|
87 |
+
#f)))
|
88 |
+
|
89 |
+
(define (dynamic-maybe-link filename)
|
90 |
+
(catch #t ; could use false-if-exception here
|
91 |
+
(lambda ()
|
92 |
+
(dynamic-link filename))
|
93 |
+
(lambda args
|
94 |
+
#f)))
|
95 |
+
|
96 |
+
(define (find-and-link-dynamic-module module-name)
|
97 |
+
(define (make-init-name mod-name)
|
98 |
+
(string-append "scm_init"
|
99 |
+
(list->string (map (lambda (c)
|
100 |
+
(if (or (char-alphabetic? c)
|
101 |
+
(char-numeric? c))
|
102 |
+
c
|
103 |
+
#\_))
|
104 |
+
(string->list mod-name)))
|
105 |
+
"_module"))
|
106 |
+
|
107 |
+
;; Put the subdirectory for this module in the car of SUBDIR-AND-LIBNAME,
|
108 |
+
;; and the `libname' (the name of the module prepended by `lib') in the cdr
|
109 |
+
;; field. For example, if MODULE-NAME is the list (inet tcp-ip udp), then
|
110 |
+
;; SUBDIR-AND-LIBNAME will be the pair ("inet/tcp-ip" . "libudp").
|
111 |
+
(let ((subdir-and-libname
|
112 |
+
(let loop ((dirs "")
|
113 |
+
(syms module-name))
|
114 |
+
(if (null? (cdr syms))
|
115 |
+
(cons dirs (string-append "lib" (symbol->string (car syms))))
|
116 |
+
(loop (string-append dirs (symbol->string (car syms)) "/")
|
117 |
+
(cdr syms)))))
|
118 |
+
(init (make-init-name (apply string-append
|
119 |
+
(map (lambda (s)
|
120 |
+
(string-append "_"
|
121 |
+
(symbol->string s)))
|
122 |
+
module-name)))))
|
123 |
+
(let ((subdir (car subdir-and-libname))
|
124 |
+
(libname (cdr subdir-and-libname)))
|
125 |
+
|
126 |
+
;; Now look in each dir in %LOAD-PATH for `subdir/libfoo.la'. If that
|
127 |
+
;; file exists, fetch the dlname from that file and attempt to link
|
128 |
+
;; against it. If `subdir/libfoo.la' does not exist, or does not seem
|
129 |
+
;; to name any shared library, look for `subdir/libfoo.so' instead and
|
130 |
+
;; link against that.
|
131 |
+
(let check-dirs ((dir-list %load-path))
|
132 |
+
(if (null? dir-list)
|
133 |
+
#f
|
134 |
+
(let* ((dir (in-vicinity (car dir-list) subdir))
|
135 |
+
(sharlib-full
|
136 |
+
(or (try-using-libtool-name dir libname)
|
137 |
+
(try-using-sharlib-name dir libname))))
|
138 |
+
(if (and sharlib-full (file-exists? sharlib-full))
|
139 |
+
(link-dynamic-module sharlib-full init)
|
140 |
+
(check-dirs (cdr dir-list)))))))))
|
141 |
+
|
142 |
+
(define (try-using-libtool-name libdir libname)
|
143 |
+
(let ((libtool-filename (in-vicinity libdir
|
144 |
+
(string-append libname ".la"))))
|
145 |
+
(and (file-exists? libtool-filename)
|
146 |
+
libtool-filename)))
|
147 |
+
|
148 |
+
(define (try-using-sharlib-name libdir libname)
|
149 |
+
(in-vicinity libdir (string-append libname ".so")))
|
150 |
+
|
151 |
+
(define (link-dynamic-module filename initname)
|
152 |
+
;; Register any linked modules which have been registered on the C level
|
153 |
+
(register-modules #f)
|
154 |
+
(let ((dynobj (dynamic-link filename)))
|
155 |
+
(dynamic-call initname dynobj)
|
156 |
+
(register-modules dynobj)))
|
157 |
+
|
158 |
+
(define (try-module-linked module-name)
|
159 |
+
(init-dynamic-module module-name))
|
160 |
+
|
161 |
+
(define (try-module-dynamic-link module-name)
|
162 |
+
(and (find-and-link-dynamic-module module-name)
|
163 |
+
(init-dynamic-module module-name)))
|
164 |
+
|
165 |
+
(define (list* . args)
|
166 |
+
(issue-deprecation-warning "'list*' is deprecated. Use 'cons*' instead.")
|
167 |
+
(apply cons* args))
|
168 |
+
|
169 |
+
;; The strange prototype system for uniform arrays has been
|
170 |
+
;; deprecated.
|
171 |
+
|
172 |
+
(define uniform-vector-fill! array-fill!)
|
173 |
+
|
174 |
+
(define make-uniform-vector dimensions->uniform-array)
|
175 |
+
|
176 |
+
(define (make-uniform-array prot . bounds)
|
177 |
+
(dimensions->uniform-array bounds prot))
|
178 |
+
|
179 |
+
(define (list->uniform-vector prot lst)
|
180 |
+
(list->uniform-array 1 prot lst))
|
node-addon-lilypond/output/share/guile/1.8/ice-9/documentation.scm
ADDED
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
;;;; Copyright (C) 2000,2001, 2002, 2003, 2006 Free Software Foundation, Inc.
|
2 |
+
;;;;
|
3 |
+
;;;; This library is free software; you can redistribute it and/or
|
4 |
+
;;;; modify it under the terms of the GNU Lesser General Public
|
5 |
+
;;;; License as published by the Free Software Foundation; either
|
6 |
+
;;;; version 2.1 of the License, or (at your option) any later version.
|
7 |
+
;;;;
|
8 |
+
;;;; This library is distributed in the hope that it will be useful,
|
9 |
+
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10 |
+
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11 |
+
;;;; Lesser General Public License for more details.
|
12 |
+
;;;;
|
13 |
+
;;;; You should have received a copy of the GNU Lesser General Public
|
14 |
+
;;;; License along with this library; if not, write to the Free Software
|
15 |
+
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16 |
+
;;;;
|
17 |
+
|
18 |
+
;;; Commentary:
|
19 |
+
|
20 |
+
;; * This module exports:
|
21 |
+
;;
|
22 |
+
;; file-commentary -- a procedure that returns a file's "commentary"
|
23 |
+
;;
|
24 |
+
;; documentation-files -- a search-list of files using the Guile
|
25 |
+
;; Documentation Format Version 2.
|
26 |
+
;;
|
27 |
+
;; search-documentation-files -- a procedure that takes NAME (a symbol)
|
28 |
+
;; and searches `documentation-files' for
|
29 |
+
;; associated documentation. optional
|
30 |
+
;; arg FILES is a list of filenames to use
|
31 |
+
;; instead of `documentation-files'.
|
32 |
+
;;
|
33 |
+
;; object-documentation -- a procedure that returns its arg's docstring
|
34 |
+
;;
|
35 |
+
;; * Guile Documentation Format
|
36 |
+
;;
|
37 |
+
;; Here is the complete and authoritative documentation for the Guile
|
38 |
+
;; Documentation Format Version 2:
|
39 |
+
;;
|
40 |
+
;; HEADER
|
41 |
+
;; ^LPROC1
|
42 |
+
;; DOCUMENTATION1
|
43 |
+
;;
|
44 |
+
;; ^LPROC2
|
45 |
+
;; DOCUMENTATION2
|
46 |
+
;;
|
47 |
+
;; ^L...
|
48 |
+
;;
|
49 |
+
;; The HEADER is completely ignored. The "^L" are formfeeds. PROC1, PROC2
|
50 |
+
;; and so on are symbols that name the element documented. DOCUMENTATION1,
|
51 |
+
;; DOCUMENTATION2 and so on are the related documentation, w/o any further
|
52 |
+
;; formatting. Note that there are two newlines before the next formfeed;
|
53 |
+
;; these are discarded when the documentation is read in.
|
54 |
+
;;
|
55 |
+
;; (Version 1, corresponding to guile-1.4 and prior, is documented as being
|
56 |
+
;; not documented anywhere except by this embarrassingly circular comment.)
|
57 |
+
;;
|
58 |
+
;; * File Commentary
|
59 |
+
;;
|
60 |
+
;; A file's commentary is the body of text found between comments
|
61 |
+
;; ;;; Commentary:
|
62 |
+
;; and
|
63 |
+
;; ;;; Code:
|
64 |
+
;; both of which must be at the beginning of the line. In the result string,
|
65 |
+
;; semicolons at the beginning of each line are discarded.
|
66 |
+
;;
|
67 |
+
;; You can specify to `file-commentary' alternate begin and end strings, and
|
68 |
+
;; scrub procedure. Use #t to get default values. For example:
|
69 |
+
;;
|
70 |
+
;; (file-commentary "documentation.scm")
|
71 |
+
;; You should see this text!
|
72 |
+
;;
|
73 |
+
;; (file-commentary "documentation.scm" "^;;; Code:" "ends here$")
|
74 |
+
;; You should see the rest of this file.
|
75 |
+
;;
|
76 |
+
;; (file-commentary "documentation.scm" #t #t string-upcase)
|
77 |
+
;; You should see this text very loudly (note semicolons untouched).
|
78 |
+
|
79 |
+
;;; Code:
|
80 |
+
|
81 |
+
(define-module (ice-9 documentation)
|
82 |
+
:use-module (ice-9 rdelim)
|
83 |
+
:export (file-commentary
|
84 |
+
documentation-files search-documentation-files
|
85 |
+
object-documentation)
|
86 |
+
:autoload (ice-9 regex) (match:suffix)
|
87 |
+
:no-backtrace)
|
88 |
+
|
89 |
+
|
90 |
+
;;
|
91 |
+
;; commentary extraction
|
92 |
+
;;
|
93 |
+
|
94 |
+
(define (file-commentary filename . cust) ; (IN-LINE-RE AFTER-LINE-RE SCRUB)
|
95 |
+
|
96 |
+
;; These are constants but are not at the top level because the repl in
|
97 |
+
;; boot-9.scm loads session.scm which in turn loads this file, and we want
|
98 |
+
;; that to work even even when regexps are not available (ie. make-regexp
|
99 |
+
;; doesn't exist), as for instance is the case on mingw.
|
100 |
+
;;
|
101 |
+
(define default-in-line-re (make-regexp "^;;; Commentary:"))
|
102 |
+
(define default-after-line-re (make-regexp "^;;; Code:"))
|
103 |
+
(define default-scrub (let ((dirt (make-regexp "^;+")))
|
104 |
+
(lambda (line)
|
105 |
+
(let ((m (regexp-exec dirt line)))
|
106 |
+
(if m (match:suffix m) line)))))
|
107 |
+
|
108 |
+
;; fixme: might be cleaner to use optargs here...
|
109 |
+
(let ((in-line-re (if (> 1 (length cust))
|
110 |
+
default-in-line-re
|
111 |
+
(let ((v (car cust)))
|
112 |
+
(cond ((regexp? v) v)
|
113 |
+
((string? v) (make-regexp v))
|
114 |
+
(else default-in-line-re)))))
|
115 |
+
(after-line-re (if (> 2 (length cust))
|
116 |
+
default-after-line-re
|
117 |
+
(let ((v (cadr cust)))
|
118 |
+
(cond ((regexp? v) v)
|
119 |
+
((string? v) (make-regexp v))
|
120 |
+
(else default-after-line-re)))))
|
121 |
+
(scrub (if (> 3 (length cust))
|
122 |
+
default-scrub
|
123 |
+
(let ((v (caddr cust)))
|
124 |
+
(cond ((procedure? v) v)
|
125 |
+
(else default-scrub))))))
|
126 |
+
(call-with-input-file filename
|
127 |
+
(lambda (port)
|
128 |
+
(let loop ((line (read-delimited "\n" port))
|
129 |
+
(doc "")
|
130 |
+
(parse-state 'before))
|
131 |
+
(if (or (eof-object? line) (eq? 'after parse-state))
|
132 |
+
doc
|
133 |
+
(let ((new-state
|
134 |
+
(cond ((regexp-exec in-line-re line) 'in)
|
135 |
+
((regexp-exec after-line-re line) 'after)
|
136 |
+
(else parse-state))))
|
137 |
+
(if (eq? 'after new-state)
|
138 |
+
doc
|
139 |
+
(loop (read-delimited "\n" port)
|
140 |
+
(if (and (eq? 'in new-state) (eq? 'in parse-state))
|
141 |
+
(string-append doc (scrub line) "\n")
|
142 |
+
doc)
|
143 |
+
new-state)))))))))
|
144 |
+
|
145 |
+
|
146 |
+
|
147 |
+
;;
|
148 |
+
;; documentation-files is the list of places to look for documentation
|
149 |
+
;;
|
150 |
+
(define documentation-files
|
151 |
+
(map (lambda (vicinity)
|
152 |
+
(in-vicinity (vicinity) "guile-procedures.txt"))
|
153 |
+
(list %library-dir
|
154 |
+
%package-data-dir
|
155 |
+
%site-dir
|
156 |
+
(lambda () "."))))
|
157 |
+
|
158 |
+
(define entry-delimiter "\f")
|
159 |
+
|
160 |
+
(define (find-documentation-in-file name file)
|
161 |
+
(and (file-exists? file)
|
162 |
+
(call-with-input-file file
|
163 |
+
(lambda (port)
|
164 |
+
(let ((name (symbol->string name)))
|
165 |
+
(let ((len (string-length name)))
|
166 |
+
(read-delimited entry-delimiter port) ;skip to first entry
|
167 |
+
(let loop ((entry (read-delimited entry-delimiter port)))
|
168 |
+
(cond ((eof-object? entry) #f)
|
169 |
+
;; match?
|
170 |
+
((and ;; large enough?
|
171 |
+
(>= (string-length entry) len)
|
172 |
+
;; matching name?
|
173 |
+
(string=? (substring entry 0 len) name)
|
174 |
+
;; terminated?
|
175 |
+
(memq (string-ref entry len) '(#\newline)))
|
176 |
+
;; cut away name tag and extra surrounding newlines
|
177 |
+
(substring entry (+ len 2) (- (string-length entry) 2)))
|
178 |
+
(else (loop (read-delimited entry-delimiter port)))))))))))
|
179 |
+
|
180 |
+
(define (search-documentation-files name . files)
|
181 |
+
(or-map (lambda (file)
|
182 |
+
(find-documentation-in-file name file))
|
183 |
+
(cond ((null? files) documentation-files)
|
184 |
+
(else files))))
|
185 |
+
|
186 |
+
;; helper until the procedure documentation property is cleaned up
|
187 |
+
(define (proc-doc proc)
|
188 |
+
(or (procedure-documentation proc)
|
189 |
+
(procedure-property proc 'documentation)))
|
190 |
+
|
191 |
+
(define (object-documentation object)
|
192 |
+
"Return the docstring for OBJECT.
|
193 |
+
OBJECT can be a procedure, macro or any object that has its
|
194 |
+
`documentation' property set."
|
195 |
+
(or (and (procedure? object)
|
196 |
+
(proc-doc object))
|
197 |
+
(and (defmacro? object)
|
198 |
+
(proc-doc (defmacro-transformer object)))
|
199 |
+
(and (macro? object)
|
200 |
+
(let ((transformer (macro-transformer object)))
|
201 |
+
(and transformer
|
202 |
+
(proc-doc transformer))))
|
203 |
+
(object-property object 'documentation)
|
204 |
+
(and (procedure? object)
|
205 |
+
(not (closure? object))
|
206 |
+
(procedure-name object)
|
207 |
+
(let ((docstring (search-documentation-files
|
208 |
+
(procedure-name object))))
|
209 |
+
(if docstring
|
210 |
+
(set-procedure-property! object 'documentation docstring))
|
211 |
+
docstring))))
|
212 |
+
|
213 |
+
;;; documentation.scm ends here
|
node-addon-lilypond/output/share/guile/1.8/ice-9/emacs.scm
ADDED
@@ -0,0 +1,276 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
;;;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2006 Free Software Foundation, Inc.
|
2 |
+
;;;;
|
3 |
+
;;;; This library is free software; you can redistribute it and/or
|
4 |
+
;;;; modify it under the terms of the GNU Lesser General Public
|
5 |
+
;;;; License as published by the Free Software Foundation; either
|
6 |
+
;;;; version 2.1 of the License, or (at your option) any later version.
|
7 |
+
;;;;
|
8 |
+
;;;; This library is distributed in the hope that it will be useful,
|
9 |
+
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10 |
+
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11 |
+
;;;; Lesser General Public License for more details.
|
12 |
+
;;;;
|
13 |
+
;;;; You should have received a copy of the GNU Lesser General Public
|
14 |
+
;;;; License along with this library; if not, write to the Free Software
|
15 |
+
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16 |
+
;;;;
|
17 |
+
;;;; The author can be reached at djurfeldt@nada.kth.se
|
18 |
+
;;;; Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN
|
19 |
+
;;;; (I didn't write this!)
|
20 |
+
;;;;
|
21 |
+
|
22 |
+
|
23 |
+
;;; *********************************************************************
|
24 |
+
;;; * This is the Guile side of the Emacs interface *
|
25 |
+
;;; * Experimental hACK---the real version will be coming soon (almost) *
|
26 |
+
;;; *********************************************************************
|
27 |
+
|
28 |
+
;;; {Session support for Emacs}
|
29 |
+
;;;
|
30 |
+
|
31 |
+
(define-module (ice-9 emacs)
|
32 |
+
:use-module (ice-9 debug)
|
33 |
+
:use-module (ice-9 threads)
|
34 |
+
:use-module (ice-9 session)
|
35 |
+
:no-backtrace)
|
36 |
+
|
37 |
+
(define emacs-escape-character #\sub)
|
38 |
+
|
39 |
+
(define emacs-output-port (current-output-port))
|
40 |
+
|
41 |
+
(define (make-emacs-command char)
|
42 |
+
(let ((cmd (list->string (list emacs-escape-character char))))
|
43 |
+
(lambda ()
|
44 |
+
(display cmd emacs-output-port))))
|
45 |
+
|
46 |
+
(define enter-input-wait (make-emacs-command #\s))
|
47 |
+
(define exit-input-wait (make-emacs-command #\f))
|
48 |
+
(define enter-read-character #\r)
|
49 |
+
(define sending-error (make-emacs-command #\F))
|
50 |
+
(define sending-backtrace (make-emacs-command #\B))
|
51 |
+
(define sending-result (make-emacs-command #\x))
|
52 |
+
(define end-of-text (make-emacs-command #\.))
|
53 |
+
(define no-stack (make-emacs-command #\S))
|
54 |
+
(define no-source (make-emacs-command #\R))
|
55 |
+
|
56 |
+
;; {Error handling}
|
57 |
+
;;
|
58 |
+
|
59 |
+
(add-hook! before-backtrace-hook sending-backtrace)
|
60 |
+
(add-hook! after-backtrace-hook end-of-text)
|
61 |
+
(add-hook! before-error-hook sending-error)
|
62 |
+
(add-hook! after-error-hook end-of-text)
|
63 |
+
|
64 |
+
;; {Repl}
|
65 |
+
;;
|
66 |
+
|
67 |
+
(set-current-error-port emacs-output-port)
|
68 |
+
|
69 |
+
(add-hook! before-read-hook
|
70 |
+
(lambda ()
|
71 |
+
(enter-input-wait)
|
72 |
+
(force-output emacs-output-port)))
|
73 |
+
|
74 |
+
(add-hook! after-read-hook
|
75 |
+
(lambda ()
|
76 |
+
(exit-input-wait)
|
77 |
+
(force-output emacs-output-port)))
|
78 |
+
|
79 |
+
;;; {Misc.}
|
80 |
+
|
81 |
+
(define (make-emacs-load-port orig-port)
|
82 |
+
(letrec ((read-char-fn (lambda args
|
83 |
+
(let ((c (read-char orig-port)))
|
84 |
+
(if (eq? c #\soh)
|
85 |
+
(throw 'end-of-chunk)
|
86 |
+
c)))))
|
87 |
+
|
88 |
+
(make-soft-port
|
89 |
+
(vector #f #f #f
|
90 |
+
read-char-fn
|
91 |
+
(lambda () (close-port orig-port)))
|
92 |
+
"r")))
|
93 |
+
|
94 |
+
(set-current-input-port (make-emacs-load-port (current-input-port)))
|
95 |
+
|
96 |
+
(define (result-to-emacs exp)
|
97 |
+
(sending-result)
|
98 |
+
(write exp emacs-output-port)
|
99 |
+
(end-of-text)
|
100 |
+
(force-output emacs-output-port))
|
101 |
+
|
102 |
+
(define load-acknowledge (make-emacs-command #\l))
|
103 |
+
|
104 |
+
(define load-port (current-input-port))
|
105 |
+
|
106 |
+
(define (flush-line port)
|
107 |
+
(let loop ((c (read-char port)))
|
108 |
+
(if (not (eq? c #\nl))
|
109 |
+
(loop (read-char port)))))
|
110 |
+
|
111 |
+
(define whitespace-chars (list #\space #\tab #\nl #\np))
|
112 |
+
|
113 |
+
(define (flush-whitespace port)
|
114 |
+
(catch 'end-of-chunk
|
115 |
+
(lambda ()
|
116 |
+
(let loop ((c (read-char port)))
|
117 |
+
(cond ((eq? c the-eof-object)
|
118 |
+
(error "End of file while receiving Emacs data"))
|
119 |
+
((memq c whitespace-chars) (loop (read-char port)))
|
120 |
+
((eq? c #\;) (flush-line port) (loop (read-char port)))
|
121 |
+
(else (unread-char c port))))
|
122 |
+
#f)
|
123 |
+
(lambda args
|
124 |
+
(read-char port) ; Read final newline
|
125 |
+
#t)))
|
126 |
+
|
127 |
+
(define (emacs-load filename linum colnum module interactivep)
|
128 |
+
(define (read-and-eval! port)
|
129 |
+
(let ((x (read port)))
|
130 |
+
(if (eof-object? x)
|
131 |
+
(throw 'end-of-file)
|
132 |
+
(primitive-eval x))))
|
133 |
+
(set-port-filename! %%load-port filename)
|
134 |
+
(set-port-line! %%load-port linum)
|
135 |
+
(set-port-column! %%load-port colnum)
|
136 |
+
(lazy-catch #t
|
137 |
+
(lambda ()
|
138 |
+
(let loop ((endp (flush-whitespace %%load-port)))
|
139 |
+
(if (not endp)
|
140 |
+
(begin
|
141 |
+
(save-module-excursion
|
142 |
+
(lambda ()
|
143 |
+
(if module
|
144 |
+
(set-current-module (resolve-module module #f)))
|
145 |
+
(let ((result
|
146 |
+
(start-stack read-and-eval!
|
147 |
+
(read-and-eval! %%load-port))))
|
148 |
+
(if interactivep
|
149 |
+
(result-to-emacs result)))))
|
150 |
+
(loop (flush-whitespace %%load-port)))
|
151 |
+
(begin
|
152 |
+
(load-acknowledge)))
|
153 |
+
(set-port-filename! %%load-port #f))) ;reset port filename
|
154 |
+
(lambda (key . args)
|
155 |
+
(set-port-filename! %%load-port #f)
|
156 |
+
(cond ((eq? key 'end-of-chunk)
|
157 |
+
(fluid-set! the-last-stack #f)
|
158 |
+
(set! stack-saved? #t)
|
159 |
+
(scm-error 'misc-error
|
160 |
+
#f
|
161 |
+
"Incomplete expression"
|
162 |
+
'()
|
163 |
+
'()))
|
164 |
+
((eq? key 'exit))
|
165 |
+
(else
|
166 |
+
(save-stack 2)
|
167 |
+
(catch 'end-of-chunk
|
168 |
+
(lambda ()
|
169 |
+
(let loop ()
|
170 |
+
(read-char %%load-port)
|
171 |
+
(loop)))
|
172 |
+
(lambda args
|
173 |
+
#f))
|
174 |
+
(apply throw key args))))))
|
175 |
+
|
176 |
+
(define (emacs-eval-request form)
|
177 |
+
(result-to-emacs (eval form (interaction-environment))))
|
178 |
+
|
179 |
+
;;*fixme* Not necessary to use flags no-stack and no-source
|
180 |
+
(define (get-frame-source frame)
|
181 |
+
(if (or (not (fluid-ref the-last-stack))
|
182 |
+
(>= frame (stack-length (fluid-ref the-last-stack))))
|
183 |
+
(begin
|
184 |
+
(no-stack)
|
185 |
+
#f)
|
186 |
+
(let* ((frame (stack-ref (fluid-ref the-last-stack)
|
187 |
+
(frame-number->index frame)))
|
188 |
+
(source (frame-source frame)))
|
189 |
+
(or source
|
190 |
+
(begin (no-source)
|
191 |
+
#f)))))
|
192 |
+
|
193 |
+
(define (emacs-select-frame frame)
|
194 |
+
(let ((source (get-frame-source frame)))
|
195 |
+
(if source
|
196 |
+
(let ((fname (source-property source 'filename))
|
197 |
+
(line (source-property source 'line))
|
198 |
+
(column (source-property source 'column)))
|
199 |
+
(if (and fname line column)
|
200 |
+
(list fname line column)
|
201 |
+
(begin (no-source)
|
202 |
+
'())))
|
203 |
+
'())))
|
204 |
+
|
205 |
+
(define (object->string x . method)
|
206 |
+
(with-output-to-string
|
207 |
+
(lambda ()
|
208 |
+
((if (null? method)
|
209 |
+
write
|
210 |
+
(car method))
|
211 |
+
x))))
|
212 |
+
|
213 |
+
(define (format template . rest)
|
214 |
+
(let loop ((chars (string->list template))
|
215 |
+
(result '())
|
216 |
+
(rest rest))
|
217 |
+
(cond ((null? chars) (list->string (reverse result)))
|
218 |
+
((char=? (car chars) #\%)
|
219 |
+
(loop (cddr chars)
|
220 |
+
(append (reverse
|
221 |
+
(string->list
|
222 |
+
(case (cadr chars)
|
223 |
+
((#\S) (object->string (car rest)))
|
224 |
+
((#\s) (object->string (car rest) display)))))
|
225 |
+
result)
|
226 |
+
(cdr rest)))
|
227 |
+
(else (loop (cdr chars) (cons (car chars) result) rest)))))
|
228 |
+
|
229 |
+
(define (error-args->string args)
|
230 |
+
(let ((msg (apply format (caddr args) (cadddr args))))
|
231 |
+
(if (symbol? (cadr args))
|
232 |
+
(string-append (symbol->string (cadr args))
|
233 |
+
": "
|
234 |
+
msg)
|
235 |
+
msg)))
|
236 |
+
|
237 |
+
(define (emacs-frame-eval frame form)
|
238 |
+
(let ((source (get-frame-source frame)))
|
239 |
+
(if source
|
240 |
+
(catch #t
|
241 |
+
(lambda ()
|
242 |
+
(list 'result
|
243 |
+
(object->string
|
244 |
+
(local-eval (with-input-from-string form read)
|
245 |
+
(memoized-environment source)))))
|
246 |
+
(lambda args
|
247 |
+
(list (car args)
|
248 |
+
(error-args->string args))))
|
249 |
+
(begin
|
250 |
+
(no-source)
|
251 |
+
'()))))
|
252 |
+
|
253 |
+
(define (emacs-symdoc symbol)
|
254 |
+
(if (or (not (module-bound? (current-module) symbol))
|
255 |
+
(not (procedure? (eval symbol (interaction-environment)))))
|
256 |
+
'nil
|
257 |
+
(procedure-documentation (eval symbol (interaction-environment)))))
|
258 |
+
|
259 |
+
;;; A fix to get the emacs interface to work together with the module system.
|
260 |
+
;;;
|
261 |
+
(for-each (lambda (name value)
|
262 |
+
(module-define! the-root-module name value))
|
263 |
+
'(%%load-port
|
264 |
+
%%emacs-load
|
265 |
+
%%emacs-eval-request
|
266 |
+
%%emacs-select-frame
|
267 |
+
%%emacs-frame-eval
|
268 |
+
%%emacs-symdoc
|
269 |
+
%%apropos-internal)
|
270 |
+
(list load-port
|
271 |
+
emacs-load
|
272 |
+
emacs-eval-request
|
273 |
+
emacs-select-frame
|
274 |
+
emacs-frame-eval
|
275 |
+
emacs-symdoc
|
276 |
+
apropos-internal))
|
node-addon-lilypond/output/share/guile/1.8/ice-9/expect.scm
ADDED
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
;;;; Copyright (C) 1996, 1998, 1999, 2001, 2006 Free Software Foundation, Inc.
|
2 |
+
;;;;
|
3 |
+
;;;; This library is free software; you can redistribute it and/or
|
4 |
+
;;;; modify it under the terms of the GNU Lesser General Public
|
5 |
+
;;;; License as published by the Free Software Foundation; either
|
6 |
+
;;;; version 2.1 of the License, or (at your option) any later version.
|
7 |
+
;;;;
|
8 |
+
;;;; This library is distributed in the hope that it will be useful,
|
9 |
+
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10 |
+
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11 |
+
;;;; Lesser General Public License for more details.
|
12 |
+
;;;;
|
13 |
+
;;;; You should have received a copy of the GNU Lesser General Public
|
14 |
+
;;;; License along with this library; if not, write to the Free Software
|
15 |
+
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16 |
+
;;;;
|
17 |
+
|
18 |
+
;;; Commentary:
|
19 |
+
|
20 |
+
;; This module is documented in the Guile Reference Manual.
|
21 |
+
;; Briefly, these are exported:
|
22 |
+
;; procedures: expect-select, expect-regexec
|
23 |
+
;; variables: expect-port, expect-timeout, expect-timeout-proc,
|
24 |
+
;; expect-eof-proc, expect-char-proc,
|
25 |
+
;; expect-strings-compile-flags, expect-strings-exec-flags,
|
26 |
+
;; macros: expect, expect-strings
|
27 |
+
|
28 |
+
;;; Code:
|
29 |
+
|
30 |
+
(define-module (ice-9 expect)
|
31 |
+
:use-module (ice-9 regex)
|
32 |
+
:export-syntax (expect expect-strings)
|
33 |
+
:export (expect-port expect-timeout expect-timeout-proc
|
34 |
+
expect-eof-proc expect-char-proc expect-strings-compile-flags
|
35 |
+
expect-strings-exec-flags expect-select expect-regexec))
|
36 |
+
|
37 |
+
;;; Expect: a macro for selecting actions based on what it reads from a port.
|
38 |
+
;;; The idea is from Don Libes' expect based on Tcl.
|
39 |
+
;;; This version by Gary Houston incorporating ideas from Aubrey Jaffer.
|
40 |
+
|
41 |
+
|
42 |
+
(define expect-port #f)
|
43 |
+
(define expect-timeout #f)
|
44 |
+
(define expect-timeout-proc #f)
|
45 |
+
(define expect-eof-proc #f)
|
46 |
+
(define expect-char-proc #f)
|
47 |
+
|
48 |
+
;;; expect: each test is a procedure which is applied to the accumulating
|
49 |
+
;;; string.
|
50 |
+
(defmacro expect clauses
|
51 |
+
(let ((s (gensym))
|
52 |
+
(c (gensym))
|
53 |
+
(port (gensym))
|
54 |
+
(timeout (gensym)))
|
55 |
+
`(let ((,s "")
|
56 |
+
(,port (or expect-port (current-input-port)))
|
57 |
+
;; when timeout occurs, in floating point seconds.
|
58 |
+
(,timeout (if expect-timeout
|
59 |
+
(let* ((secs-usecs (gettimeofday)))
|
60 |
+
(+ (car secs-usecs)
|
61 |
+
expect-timeout
|
62 |
+
(/ (cdr secs-usecs)
|
63 |
+
1000000))) ; one million.
|
64 |
+
#f)))
|
65 |
+
(let next-char ()
|
66 |
+
(if (and expect-timeout
|
67 |
+
(not (expect-select ,port ,timeout)))
|
68 |
+
(if expect-timeout-proc
|
69 |
+
(expect-timeout-proc ,s)
|
70 |
+
#f)
|
71 |
+
(let ((,c (read-char ,port)))
|
72 |
+
(if expect-char-proc
|
73 |
+
(expect-char-proc ,c))
|
74 |
+
(if (not (eof-object? ,c))
|
75 |
+
(set! ,s (string-append ,s (string ,c))))
|
76 |
+
(cond
|
77 |
+
;; this expands to clauses where the car invokes the
|
78 |
+
;; match proc and the cdr is the return value from expect
|
79 |
+
;; if the proc matched.
|
80 |
+
,@(let next-expr ((tests (map car clauses))
|
81 |
+
(exprs (map cdr clauses))
|
82 |
+
(body '()))
|
83 |
+
(cond
|
84 |
+
((null? tests)
|
85 |
+
(reverse body))
|
86 |
+
(else
|
87 |
+
(next-expr
|
88 |
+
(cdr tests)
|
89 |
+
(cdr exprs)
|
90 |
+
(cons
|
91 |
+
`((,(car tests) ,s (eof-object? ,c))
|
92 |
+
,@(cond ((null? (car exprs))
|
93 |
+
'())
|
94 |
+
((eq? (caar exprs) '=>)
|
95 |
+
(if (not (= (length (car exprs))
|
96 |
+
2))
|
97 |
+
(scm-error 'misc-error
|
98 |
+
"expect"
|
99 |
+
"bad recipient: ~S"
|
100 |
+
(list (car exprs))
|
101 |
+
#f)
|
102 |
+
`((apply ,(cadar exprs)
|
103 |
+
(,(car tests) ,s ,port)))))
|
104 |
+
(else
|
105 |
+
(car exprs))))
|
106 |
+
body)))))
|
107 |
+
;; if none of the clauses matched the current string.
|
108 |
+
(else (cond ((eof-object? ,c)
|
109 |
+
(if expect-eof-proc
|
110 |
+
(expect-eof-proc ,s)
|
111 |
+
#f))
|
112 |
+
(else
|
113 |
+
(next-char)))))))))))
|
114 |
+
|
115 |
+
|
116 |
+
(define expect-strings-compile-flags regexp/newline)
|
117 |
+
(define expect-strings-exec-flags regexp/noteol)
|
118 |
+
|
119 |
+
;;; the regexec front-end to expect:
|
120 |
+
;;; each test must evaluate to a regular expression.
|
121 |
+
(defmacro expect-strings clauses
|
122 |
+
`(let ,@(let next-test ((tests (map car clauses))
|
123 |
+
(exprs (map cdr clauses))
|
124 |
+
(defs '())
|
125 |
+
(body '()))
|
126 |
+
(cond ((null? tests)
|
127 |
+
(list (reverse defs) `(expect ,@(reverse body))))
|
128 |
+
(else
|
129 |
+
(let ((rxname (gensym)))
|
130 |
+
(next-test (cdr tests)
|
131 |
+
(cdr exprs)
|
132 |
+
(cons `(,rxname (make-regexp
|
133 |
+
,(car tests)
|
134 |
+
expect-strings-compile-flags))
|
135 |
+
defs)
|
136 |
+
(cons `((lambda (s eof?)
|
137 |
+
(expect-regexec ,rxname s eof?))
|
138 |
+
,@(car exprs))
|
139 |
+
body))))))))
|
140 |
+
|
141 |
+
;;; simplified select: returns #t if input is waiting or #f if timed out or
|
142 |
+
;;; select was interrupted by a signal.
|
143 |
+
;;; timeout is an absolute time in floating point seconds.
|
144 |
+
(define (expect-select port timeout)
|
145 |
+
(let* ((secs-usecs (gettimeofday))
|
146 |
+
(relative (- timeout
|
147 |
+
(car secs-usecs)
|
148 |
+
(/ (cdr secs-usecs)
|
149 |
+
1000000)))) ; one million.
|
150 |
+
(and (> relative 0)
|
151 |
+
(pair? (car (select (list port) '() '()
|
152 |
+
relative))))))
|
153 |
+
|
154 |
+
;;; match a string against a regexp, returning a list of strings (required
|
155 |
+
;;; by the => syntax) or #f. called once each time a character is added
|
156 |
+
;;; to s (eof? will be #f), and once when eof is reached (with eof? #t).
|
157 |
+
(define (expect-regexec rx s eof?)
|
158 |
+
;; if expect-strings-exec-flags contains regexp/noteol,
|
159 |
+
;; remove it for the eof test.
|
160 |
+
(let* ((flags (if (and eof?
|
161 |
+
(logand expect-strings-exec-flags regexp/noteol))
|
162 |
+
(logxor expect-strings-exec-flags regexp/noteol)
|
163 |
+
expect-strings-exec-flags))
|
164 |
+
(match (regexp-exec rx s 0 flags)))
|
165 |
+
(if match
|
166 |
+
(do ((i (- (match:count match) 1) (- i 1))
|
167 |
+
(result '() (cons (match:substring match i) result)))
|
168 |
+
((< i 0) result))
|
169 |
+
#f)))
|
170 |
+
|
171 |
+
;;; expect.scm ends here
|