More fixes to support r7rs import sets

This commit is contained in:
Justin Ethier 2016-10-07 22:34:46 -04:00
parent c5f9ffb5dd
commit 8f7a56a3ef

View file

@ -53,11 +53,14 @@
(tagged-list? 'define-library ast)) (tagged-list? 'define-library ast))
;; Convert a raw list to an import set. For example, a list might be ;; Convert a raw list to an import set. For example, a list might be
;; (srfi 18) containing the number 18. An import set contains only symbols. ;; (srfi 18) containing the number 18. An import set contains only symbols
;; or sub-lists.
(define (lib:list->import-set lis) (define (lib:list->import-set lis)
(map (map
(lambda (atom) (lambda (atom)
(cond (cond
((pair? atom)
(lib:list->import-set atom))
((number? atom) ((number? atom)
(string->symbol (number->string atom))) (string->symbol (number->string atom)))
(else atom))) (else atom)))
@ -243,15 +246,15 @@
(apply (apply
append append
(map (map
(lambda (import) (lambda (import-set)
(foldr (let ((lib-name (lib:import->library-name import-set)))
(lambda (id ids) (foldr
(cons (lambda (id ids)
(cons id import) (cons
ids)) (cons id lib-name)
'() ids))
(lib:import->export-list import)) '()
) (lib:import->export-list import-set))))
(map lib:list->import-set imports)))) (map lib:list->import-set imports))))
;; Convert from the import DB to a list of identifiers that are imported. ;; Convert from the import DB to a list of identifiers that are imported.
@ -303,8 +306,9 @@
;; Prevent cycles by only processing new libraries ;; Prevent cycles by only processing new libraries
((not (assoc import-set libraries/deps)) ((not (assoc import-set libraries/deps))
;; Find all dependencies of i (IE, libraries it imports) ;; Find all dependencies of i (IE, libraries it imports)
(let ((deps (lib:read-imports import-set))) (let ((deps (lib:read-imports import-set))
(set! libraries/deps (cons (cons import-set deps) libraries/deps)) (lib-name (lib:import->library-name import-set)))
(set! libraries/deps (cons (cons lib-name deps) libraries/deps))
(find-deps! deps) (find-deps! deps)
))))) )))))
import-sets)))) import-sets))))