>From d43d075da57da72522a9db088ae904569df0d795 Mon Sep 17 00:00:00 2001
From: Peter Bex
Date: Sun, 20 Jul 2014 15:50:02 +0200
Subject: [PATCH] Get rid of explicit marking of primitives re-exported by
modules.
When importing a module, its dependencies always *must* be imported,
because a re-export could involve a macro which is defined by another
module, and the definitions of macros are handled through the import
library.
Because this is happening anyway, any module re-exporting a primitive
will end up importing the core module which exports it. This import
will execute ##sys#register-primitive-module which causes the primitives
to be marked though ##sys#primitive-alias.
Because of this recursive module loading, it's unnecessary to detect
primitives at module registration time. This simplifies the module
registration code a little (which is already hairy enough of itself).
---
expand.scm | 5 ----
modules.scm | 96 ++++++++++++++++++++++++++---------------------------------
2 files changed, 43 insertions(+), 58 deletions(-)
diff --git a/expand.scm b/expand.scm
index f14c79f..8f922db 100644
--- a/expand.scm
+++ b/expand.scm
@@ -921,11 +921,6 @@
;;; Macro definitions:
-(define (##sys#mark-primitive prims)
- (for-each
- (lambda (a) (putp (cdr a) '##core#primitive (car a)))
- prims))
-
(##sys#extend-macro-environment
'import '()
(##sys#er-transformer
diff --git a/modules.scm b/modules.scm
index e102b9d..a59aa5b 100644
--- a/modules.scm
+++ b/modules.scm
@@ -681,59 +681,49 @@
(for-each
(lambda (spec)
(let-values (((vsv vss vsi) (import-spec spec)))
- (let ((prims '()))
- (dd `(IMPORT: ,loc))
- (dd `(V: ,(if cm (module-name cm) ') ,(map-se vsv)))
- (dd `(S: ,(if cm (module-name cm) ') ,(map-se vss)))
- (##sys#mark-imported-symbols vsv) ; mark imports as ##core#aliased
- (for-each
- (lambda (imp)
- (let* ((id (car imp))
- (aid (cdr imp))
- (prim (getp aid '##core#primitive)))
- (when prim
- (set! prims (cons imp prims)))
- (and-let* ((a (assq id (import-env)))
- ((not (eq? aid (cdr a)))))
- (##sys#notice "re-importing already imported identifier" id))))
- vsv)
- (for-each
- (lambda (imp)
- (and-let* ((a (assq (car imp) (macro-env)))
- ((not (eq? (cdr imp) (cdr a)))))
- (##sys#notice "re-importing already imported syntax" (car imp))) )
- vss)
- (when reexp?
- (unless cm
- (##sys#syntax-error-hook loc "`reexport' only valid inside a module"))
- (let ((el (module-export-list cm)))
- (cond ((eq? #t el)
- (set-module-sexports! cm (append vss (module-sexports cm)))
- (set-module-exist-list!
- cm
- (append (module-exist-list cm)
- (map car vsv)
- (map car vss))))
- (else
- (set-module-export-list!
- cm
- (append
- (let ((xl (module-export-list cm)))
- (if (eq? #t xl) '() xl))
- (map car vsv)
- (map car vss))))))
- (set-module-iexports!
- cm
- (merge-se (module-iexports cm) vsi))
- (when (pair? prims)
- (set-module-meta-expressions!
- cm
- (append
- (module-meta-expressions cm)
- `((##sys#mark-primitive ',prims)))))
- (dm "export-list: " (module-export-list cm)))
- (import-env (append vsv (import-env)))
- (macro-env (append vss (macro-env))))))
+ (dd `(IMPORT: ,loc))
+ (dd `(V: ,(if cm (module-name cm) ') ,(map-se vsv)))
+ (dd `(S: ,(if cm (module-name cm) ') ,(map-se vss)))
+ (##sys#mark-imported-symbols vsv) ; mark imports as ##core#aliased
+ (for-each
+ (lambda (imp)
+ (and-let* ((id (car imp))
+ (a (assq id (import-env)))
+ (aid (cdr imp))
+ ((not (eq? aid (cdr a)))))
+ (##sys#notice "re-importing already imported identifier" id)))
+ vsv)
+ (for-each
+ (lambda (imp)
+ (and-let* ((a (assq (car imp) (macro-env)))
+ ((not (eq? (cdr imp) (cdr a)))))
+ (##sys#notice "re-importing already imported syntax" (car imp))) )
+ vss)
+ (when reexp?
+ (unless cm
+ (##sys#syntax-error-hook loc "`reexport' only valid inside a module"))
+ (let ((el (module-export-list cm)))
+ (cond ((eq? #t el)
+ (set-module-sexports! cm (append vss (module-sexports cm)))
+ (set-module-exist-list!
+ cm
+ (append (module-exist-list cm)
+ (map car vsv)
+ (map car vss))))
+ (else
+ (set-module-export-list!
+ cm
+ (append
+ (let ((xl (module-export-list cm)))
+ (if (eq? #t xl) '() xl))
+ (map car vsv)
+ (map car vss))))))
+ (set-module-iexports!
+ cm
+ (merge-se (module-iexports cm) vsi))
+ (dm "export-list: " (module-export-list cm)))
+ (import-env (append vsv (import-env)))
+ (macro-env (append vss (macro-env)))))
(cdr x))
'(##core#undefined))))
--
1.7.10.4