diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-06-06 19:28:36 +0200 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-06-06 19:28:36 +0200 |
commit | 90835ae8e3ad9763e1a8d1135e337c0855ec3daf (patch) | |
tree | d01e229b9ba099eae8201e674196ff6225f54ded /geiser/evaluation.scm | |
parent | a57999c7da8747d031275e3167ed05bb01dbcdab (diff) | |
download | geiser-guile-90835ae8e3ad9763e1a8d1135e337c0855ec3daf.tar.gz geiser-guile-90835ae8e3ad9763e1a8d1135e337c0855ec3daf.tar.bz2 |
Guile: new evaluation strategy that really delimits stack frames.
Diffstat (limited to 'geiser/evaluation.scm')
-rw-r--r-- | geiser/evaluation.scm | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/geiser/evaluation.scm b/geiser/evaluation.scm index 7f2b8f7..179e425 100644 --- a/geiser/evaluation.scm +++ b/geiser/evaluation.scm @@ -16,10 +16,10 @@ ge:compile-file ge:load-file) #:use-module (srfi srfi-1) + #:use-module (language tree-il) #:use-module (system base compile) #:use-module (system base pmatch) #:use-module (system vm program) - #:use-module (language tree-il) #:use-module (ice-9 pretty-print)) (define (handle-error stack . args) @@ -40,25 +40,35 @@ (beautify-user-module! m) m)))) +(define (write-result result output) + (write (list (cons 'result result) (cons 'output output))) + (newline)) + (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 () - (start-stack 'geiser-evaluation-stack - (compile form #:env module))) - (lambda vs (map object->string vs))))))) + (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 `(,(cons 'result result) (output . ,output))) - (newline)))) + (write-result result output)))) (define ge:eval ge:compile) (define (ge:compile-file path) - (ge:compile `(load-compiled (compile-file ,path - #:canonicalization 'absolute)) - '(geiser evaluation))) + (write-result + (let ((cr (compile-file path #:canonicalization 'absolute))) + (and cr + (list (object->string (save-module-excursion + (lambda () (load-compiled cr))))))) + "")) (define ge:load-file ge:compile-file) |