(module defun-state mzscheme
(require (lib "etc.ss")
(lib "unit-exptime.ss")
(lib "list.ss" "srfi" "1"))
(provide register-unit!
get-sigs
get-link-info
already-defined?)
(define-values (sigs names units) (values null null null))
(define (already-defined? id)
(s:member id (apply append names) module-identifier=?))
(define register-unit!
(opt-lambda (unit-id [sig-id #f])
(add-unit! unit-id)
(when sig-id
(add-sig! sig-id)
(let-values ([(_parent names _sig-defined sig-defsyntaxed)
(signature-members sig-id sig-id)])
(add-name! (append names sig-defsyntaxed))))))
(define (get-link-info)
(let ([rev-names (reverse names)])
(list (reverse sigs)
(reverse units)
rev-names
(map generate-temporaries rev-names))))
(define (get-sigs) sigs)
(define (add-sig! sig-id) (set! sigs (cons sig-id sigs)))
(define (add-name! id) (set! names (cons id names)))
(define (add-unit! u-id) (set! units (cons u-id units))))