Fixing handling of multiple exports in a library. export-all now supported.

This commit is contained in:
Alex Shinn 2012-07-21 19:01:10 +09:00
parent a3daf9f728
commit cb4d0c77f6

View file

@ -217,14 +217,24 @@
(cons (car (cddr x)) (cadr x)) (cons (car (cddr x)) (cadr x))
(error "invalid module export" x)) (error "invalid module export" x))
x)) x))
(define (extract-exports)
(cond
((assq 'export-all ,this-module)
=> (lambda (x)
(if (pair? (cdr x))
(error "export-all takes no parameters" x))
#f))
(else
(let lp ((ls ,this-module) (res '()))
(cond
((null? ls) res)
((and (pair? (car ls)) (eq? 'export (caar ls)))
(lp (cdr ls) (append (map rewrite-export (cdar ls)) res)))
(else (lp (cdr ls) res)))))))
(set! ,this-module '()) (set! ,this-module '())
,@body ,@body
(set! ,this-module (reverse ,this-module)) (set! ,this-module (reverse ,this-module))
(let ((exports (,add-module! ',name (make-module (extract-exports) #f ,this-module))
(cond ((assq 'export ,this-module)
=> (lambda (x) (map rewrite-export (cdr x))))
(else '()))))
(,add-module! ',name (make-module exports #f ,this-module)))
(set! ,this-module ,tmp)))))) (set! ,this-module ,tmp))))))
(define-syntax define-library define-library-transformer) (define-syntax define-library define-library-transformer)
@ -243,6 +253,7 @@
(define-config-primitive import) (define-config-primitive import)
(define-config-primitive import-immutable) (define-config-primitive import-immutable)
(define-config-primitive export) (define-config-primitive export)
(define-config-primitive export-all)
(define-config-primitive include) (define-config-primitive include)
(define-config-primitive include-ci) (define-config-primitive include-ci)
(define-config-primitive include-shared) (define-config-primitive include-shared)