1
0
forked from alex-eg/sex

work out what a module exports once per unit

Every module's interface check walks the pub imports below it, so a
chain reduced each module's interface once per level above it.
This commit is contained in:
2026-10-19 18:21:02 +03:00
parent 62b1ead3eb
commit 64db505e6b

View File

@@ -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