summaryrefslogtreecommitdiff
path: root/scheme/guile/geiser
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-09-07 00:22:52 +0200
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-09-07 00:22:52 +0200
commit34cfc967b6d377c4c2a795aba692a3652f21bb49 (patch)
treecdb966c8fa8651ec23f8662c71fe951771371124 /scheme/guile/geiser
parent911a1fc178d9399a62b3742bffb992a41a7a197a (diff)
downloadgeiser-chez-34cfc967b6d377c4c2a795aba692a3652f21bb49.tar.gz
geiser-chez-34cfc967b6d377c4c2a795aba692a3652f21bb49.tar.bz2
Guile: evaluation warnings
Diffstat (limited to 'scheme/guile/geiser')
-rw-r--r--scheme/guile/geiser/evaluation.scm49
1 files changed, 31 insertions, 18 deletions
diff --git a/scheme/guile/geiser/evaluation.scm b/scheme/guile/geiser/evaluation.scm
index a0007c4..aba0cfe 100644
--- a/scheme/guile/geiser/evaluation.scm
+++ b/scheme/guile/geiser/evaluation.scm
@@ -19,6 +19,7 @@
#:use-module (srfi srfi-1)
#:use-module (language tree-il)
#:use-module (system base compile)
+ #:use-module (system base message)
#:use-module (system base pmatch)
#:use-module (system vm program)
#:use-module (ice-9 pretty-print))
@@ -38,31 +39,43 @@
(write (list (cons 'result result) (cons 'output output)))
(newline))
+(define compile-opts '(#:warnings (arity-mismatch unbound-variable)))
+
+(define (call-with-result thunk)
+ (letrec* ((result #f)
+ (output
+ (with-output-to-string
+ (lambda ()
+ (with-fluids ((*current-warning-port* (current-output-port)))
+ (set! result (thunk)))))))
+ (write-result result output)))
+
(define (ge:compile form module-name)
(let* ((module (or (find-module module-name) (current-module)))
- (result #f)
(ev (lambda ()
- (set! result
- (call-with-values
- (lambda ()
- (let* ((o (compile form
- #:to 'objcode #:env module))
- (thunk (make-program o)))
- (start-stack 'geiser-evaluation-stack
- (eval `(,thunk) module))))
- (lambda vs (map object->string vs)))))))
- (let ((output (with-output-to-string ev)))
- (write-result result output))))
+ (call-with-values
+ (lambda ()
+ (let* ((o (compile form
+ #:to 'objcode
+ #:env module
+ #:opts compile-opts))
+ (thunk (make-program o)))
+ (start-stack 'geiser-evaluation-stack
+ (eval `(,thunk) module))))
+ (lambda vs (map object->string vs))))))
+ (call-with-result ev)))
(define ge:eval ge:compile)
(define (ge:compile-file path)
- (write-result
- (let ((cr (compile-file path #:canonicalization 'absolute)))
- (and cr
- (list (object->string (save-module-excursion
- (lambda () (load-compiled cr)))))))
- ""))
+ (call-with-result
+ (lambda ()
+ (let ((cr (compile-file path
+ #:canonicalization 'absolute
+ #:opts compile-opts)))
+ (and cr
+ (list (object->string (save-module-excursion
+ (lambda () (load-compiled cr))))))))))
(define ge:load-file ge:compile-file)