3
$Id: stackp.scm,v 1.7 1999/01/02 06:06:43 cph Exp $
5
Copyright (c) 1987-8, 1991, 1999 Massachusetts Institute of Technology
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or (at
10
your option) any later version.
12
This program is distributed in the hope that it will be useful, but
13
WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
;;;; Primitive Stack Parser
24
(declare (usual-integrations))
26
(define (rcd #!optional filename continuation)
30
(if (default-object? continuation)
33
(if (or (default-object? filename) (not filename))
35
(with-output-to-file filename do-it))))
37
(define (rcr n #!optional continuation)
38
(continuation-ref (if (default-object? continuation)
43
(define (error-continuation)
44
(let ((condition (nearest-repl/condition)))
46
(error "no error continuation"))
47
(condition/continuation condition)))
49
(define (write-continuation continuation)
50
(let write-stack-stream
51
((stream (continuation->stream continuation)) (n 0))
52
(if (not (stream-null? stream))
53
(begin (if (let ((object (stream-car stream)))
54
(or (return-address? object)
55
(compiled-return-address? object)))
60
(let ((string (write-to-string (stream-car stream) 68)))
61
(write-string (cdr string))
63
(write-string "...")))
64
(write-stack-stream (tail stream) (1+ n)))))
67
(define (continuation-ref continuation n)
68
(stream-ref (continuation->stream continuation) n))
70
(define (continuation->stream continuation)
71
(let stack-frame->stream ((frame (continuation->stack-frame continuation)))
72
(let ((length (stack-frame/length frame)))
75
(cons-stream (stack-frame/ref frame n) (loop (1+ n)))
76
(let ((next (stack-frame/next frame)))
78
(stack-frame->stream next)
b'\\ No newline at end of file'