mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
allow tracing macros
This commit is contained in:
parent
68a81c8aff
commit
249f4f21ba
1 changed files with 19 additions and 7 deletions
|
@ -26,13 +26,25 @@
|
||||||
|
|
||||||
(define (make-tracer cell)
|
(define (make-tracer cell)
|
||||||
(let ((proc (cdr cell)))
|
(let ((proc (cdr cell)))
|
||||||
|
(if (macro? proc)
|
||||||
|
(make-macro
|
||||||
|
(lambda (expr use-env mac-env)
|
||||||
|
(show-trace cell (strip-syntactic-closures (cdr expr)))
|
||||||
|
(active-trace-depth (+ (active-trace-depth) 1))
|
||||||
|
(let ((res ((macro-procedure proc) expr use-env mac-env)))
|
||||||
|
(active-trace-depth (- (active-trace-depth) 1))
|
||||||
|
(show-trace-result cell
|
||||||
|
(strip-syntactic-closures (cdr expr))
|
||||||
|
(strip-syntactic-closures res))
|
||||||
|
res))
|
||||||
|
(macro-env proc))
|
||||||
(lambda args
|
(lambda args
|
||||||
(show-trace cell args)
|
(show-trace cell args)
|
||||||
(active-trace-depth (+ (active-trace-depth) 1))
|
(active-trace-depth (+ (active-trace-depth) 1))
|
||||||
(let ((res (apply proc args)))
|
(let ((res (apply proc args)))
|
||||||
(active-trace-depth (- (active-trace-depth) 1))
|
(active-trace-depth (- (active-trace-depth) 1))
|
||||||
(show-trace-result cell args res)
|
(show-trace-result cell args res)
|
||||||
res))))
|
res)))))
|
||||||
|
|
||||||
;;> Write a trace of all calls to the procedure \var{id} to
|
;;> Write a trace of all calls to the procedure \var{id} to
|
||||||
;;> \scheme{(current-error-port)}.
|
;;> \scheme{(current-error-port)}.
|
||||||
|
|
Loading…
Add table
Reference in a new issue