Fixes bug 174594: Record read/write now terminate on cycles.

This commit is contained in:
Abdulaziz Ghuloum 2007-12-07 01:41:21 -05:00
parent 1f352825f5
commit c0191a8283
4 changed files with 41 additions and 5 deletions

View File

@ -160,7 +160,7 @@
(syntax-rules () (syntax-rules ()
[(_ name) [(_ name)
(define (name . args) (define (name . args)
(error 'name "not implemented" args))])) (apply error 'name "not implemented" args))]))
;;; ---------------------------------------------------------- ;;; ----------------------------------------------------------
(module (get-char lookahead-char) (module (get-char lookahead-char)

View File

@ -8,9 +8,9 @@
(syntax-rules () (syntax-rules ()
[(_ name body) [(_ name body)
(begin (begin
(printf "running ~s ..." 'name) (printf "running ~s ... " 'name)
body body
(printf " ok\n"))])) (printf "ok\n"))]))
(define (make-n-byte-custom-binary-input-port n) (define (make-n-byte-custom-binary-input-port n)
(assert (<= 0 n 256)) (assert (<= 0 n 256))

View File

@ -633,7 +633,23 @@
[(hashtable-ref h x #f) => [(hashtable-ref h x #f) =>
(lambda (n) (lambda (n)
(hashtable-set! h x (fxadd1 n)))])] (hashtable-set! h x (fxadd1 n)))])]
;;; FIXME: recursive records/structs [(struct? x)
(cond
[(hashtable-ref h x #f) =>
(lambda (n)
(hashtable-set! h x (fxadd1 n)))]
[else
(hashtable-set! h x 0)
(let ([rtd (struct-type-descriptor x)])
(unless
(and (record-type-descriptor? rtd)
(record-type-opaque? rtd))
(graph (struct-name x) h)
(let ([n (struct-length x)])
(let f ([idx 0])
(unless (fx= idx n)
(graph (struct-ref x idx) h)
(f (fxadd1 idx)))))))])]
)) ))
(define (dynamic x h) (define (dynamic x h)
(cond (cond
@ -660,6 +676,26 @@
(when (and (hashtable-ref h x #f) (when (and (hashtable-ref h x #f)
(fxzero? (hashtable-ref h x #f))) (fxzero? (hashtable-ref h x #f)))
(hashtable-set! h x #f))])] (hashtable-set! h x #f))])]
[(struct? x)
(cond
[(hashtable-ref h x #f) =>
(lambda (n)
(hashtable-set! h x (fxadd1 n)))]
[else
(hashtable-set! h x 0)
(let ([rtd (struct-type-descriptor x)])
(unless
(and (record-type-descriptor? rtd)
(record-type-opaque? rtd))
(dynamic (struct-name x) h)
(let ([n (struct-length x)])
(let f ([idx 0])
(unless (fx= idx n)
(dynamic (struct-ref x idx) h)
(f (fxadd1 idx)))))))
(when (and (hashtable-ref h x #f)
(fxzero? (hashtable-ref h x #f)))
(hashtable-set! h x #f))])]
;;; FIXME: recursive records/structs ;;; FIXME: recursive records/structs
)) ))
(if (print-graph) (if (print-graph)

View File

@ -1 +1 @@
1191 1192