diff --git a/sex-modules.scm b/sex-modules.scm index 7a68e917..f2f3a3c7 100644 --- a/sex-modules.scm +++ b/sex-modules.scm @@ -290,10 +290,23 @@ (let ((path (locate-module (symbol->string (car modules))))) (if (or (not path) (member path seen)) (next (cdr modules) seen acc) - (let ((forms (interface-forms (read-module path)))) - (next (append (cdr modules) (imported-modules forms #f)) + (let ((exports (module-exports path))) + (next (append (cdr modules) (cdr exports)) (cons path seen) - (cons (declared-types forms) acc)))))))) + (cons (car exports) acc)))))))) + +;;; The types the module at PATH declares to its importers, and the +;;; modules its interface imports; worked out once, though the check of +;;; every module above it on a pub import chain walks there +(define +module-exports+ (list)) + +(define (module-exports path) + (cond ((assoc path +module-exports+) => cdr) + (else (let* ((forms (interface-forms (read-module path))) + (exports (cons (declared-types forms) + (imported-modules forms #f)))) + (set! +module-exports+ (cons (cons path exports) +module-exports+)) + exports)))) (define (public-fn-interface raw-form) ;; (pub fn name args ret . body) -> prototype, keeping a docstring so