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,16 +13,15 @@
(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
(in (if optimize? (let* ((prog (regexp-replace #rx"^#lang typed/(scheme|racket)(/base)?"
lines (file->string file) ""))
(cdr lines))) ;; drop the #:optimize (in (if optimize?
(evaluator prog
(make-evaluator 'typed/racket ;; drop the #:optimize
(foldl (lambda (acc new) (regexp-replace #rx"#:optimize" prog "")))
(string-append new "\n" acc)) (evaluator (make-evaluator 'typed/racket in))
"" in))) (out (get-output evaluator)))
(out (get-output evaluator)))
(kill-evaluator evaluator) (kill-evaluator evaluator)
out))))) out)))))