Better way to setup the sandbox input.

This commit is contained in:
Vincent St-Amour 2010-08-27 13:59:39 -04:00
parent 9884663697
commit 9f540bce01

View File

@ -13,15 +13,14 @@
(list (car (sandbox-namespace-specs)) (list (car (sandbox-namespace-specs))
'typed/racket 'typed/racket
'typed/scheme)]) 'typed/scheme)])
(let* ((lines (cdr (file->lines file))) ;; drop the #lang line ;; drop the #lang line
(let* ((prog (regexp-replace #rx"^#lang typed/(scheme|racket)(/base)?"
(file->string file) ""))
(in (if optimize? (in (if optimize?
lines prog
(cdr lines))) ;; drop the #:optimize ;; drop the #:optimize
(evaluator (regexp-replace #rx"#:optimize" prog "")))
(make-evaluator 'typed/racket (evaluator (make-evaluator 'typed/racket in))
(foldl (lambda (acc new)
(string-append new "\n" acc))
"" in)))
(out (get-output evaluator))) (out (get-output evaluator)))
(kill-evaluator evaluator) (kill-evaluator evaluator)
out))))) out)))))