updated pconvert to use the new arguments to make-hash and friends

svn: r18128
This commit is contained in:
Robby Findler 2010-02-17 21:20:39 +00:00
parent 746b85fa6b
commit 66e329c21b
2 changed files with 18 additions and 12 deletions

View File

@ -357,15 +357,21 @@
`(mcons ,(recur (mcar expr)) ,(recur (mcdr expr))))]
[(weak-box? expr) `(make-weak-box ,(recur (weak-box-value expr)))]
[(box? expr) `(box ,(recur (unbox expr)))]
[(hash-table? expr) `(,(cond
[(hash-table? expr 'weak 'equal) 'weak-hash]
[(hash-table? expr 'equal) 'hash]
[(hash-table? expr 'weak) 'weak-hasheq]
[else 'hasheq])
,@(hash-table-map
expr
(lambda (k v)
`(,(recur k) ,(recur v)))))]
[(hash-table? expr)
(let ([contents
(hash-table-map
expr
(lambda (k v)
`(cons ,(recur k) ,(recur v))))]
[constructor
(cond
[(hash-table? expr 'weak 'equal) 'weak-hash]
[(hash-table? expr 'equal) 'make-hash]
[(hash-table? expr 'weak) 'weak-hasheq]
[else 'hasheq])])
(if (null? contents)
`(,constructor)
`(,constructor (list ,@contents))))]
[(vector? expr) `(vector ,@(map recur (vector->list expr)))]
[(symbol? expr) `',expr]
[(keyword? expr) `',expr]

View File

@ -207,13 +207,13 @@
(make-same-test (make-weak-hasheq)
'(weak-hasheq))
(make-same-test (make-hash)
'(hash))
'(make-hash))
(make-same-test (make-weak-hash)
'(weak-hash))
(make-same-test (let ([ht (make-hash)])
(hash-set! ht 'x 1)
ht)
'(hash ('x 1)))
'(make-hash (list (cons 'x 1))))
(make-pctest (list 'a (box (list '())) (cons 1 '()))
'(list (quote a) (box (list empty)) (list 1))
'(list (quote a) (box (list empty)) (list 1))
@ -356,7 +356,7 @@
(test-shared (vector 1 2 3) '(vector 1 2 3))
(let () (define-struct a () #:inspector (make-inspector)) (test-shared (make-a) '(make-a)))
(test-shared (box 1) '(box 1))
(test-shared (make-hash) '(hash)))
(test-shared (make-hash) '(make-hash)))
(arity-test print-convert 1 2)
(arity-test build-share 1 1)