adjust sandbox to give S-expression input "original" status

This commit is contained in:
Matthew Flatt 2011-08-17 06:18:22 -06:00
parent a221e4bba2
commit dfd58a2cdd
2 changed files with 21 additions and 3 deletions

View File

@ -474,11 +474,24 @@
(loop (cdr inps) (and n (add1 n))
;; 1st at line#1, pos#1, 2nd at line#2, pos#2 etc
;; (starting from the `n' argument)
(cons (datum->syntax
#f (car inps)
(list source n (and n 0) n (and n 1)))
(cons (add-location (car inps)
(list source n (and n 0) n (and n 1)))
r))))]))))
(define orig-stx (read-syntax 'src (open-input-string "0"))) ; for "is original?" property
(define (make-orig x loc) (datum->syntax #f x loc orig-stx))
(define (add-location x loc)
(cond
[(null? x) null]
[(pair? x) (make-orig (cons (add-location (car x) loc)
(add-location (cdr x) loc))
loc)]
[(vector? x) (make-orig (for/vector ([i (in-vector x)])
(add-location i loc))
loc)]
[else (make-orig x loc)]))
(define ((init-hook-for-language language))
(cond [(or (not (pair? language))
(not (eq? 'special (car language))))

View File

@ -493,6 +493,11 @@
=err> "out of mem+o(?:ry)"
b => 1))
--top--
(make-base-evaluator!)
--eval--
(syntax-original? #'x) => #t
))
(report-errs)