mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-24 04:25:06 +02:00
Cut over to (lib:import-set/exports->imports)
This commit is contained in:
parent
d4486696b2
commit
5b75a48eac
1 changed files with 8 additions and 43 deletions
|
@ -40,7 +40,6 @@
|
||||||
lib:read-imports
|
lib:read-imports
|
||||||
lib:import->export-list
|
lib:import->export-list
|
||||||
lib:import-set/exports->imports
|
lib:import-set/exports->imports
|
||||||
;lib:member:direct-or-car
|
|
||||||
;lib:resolve-imports
|
;lib:resolve-imports
|
||||||
lib:resolve-meta
|
lib:resolve-meta
|
||||||
lib:get-all
|
lib:get-all
|
||||||
|
@ -244,56 +243,22 @@
|
||||||
(lib (read-all fp))
|
(lib (read-all fp))
|
||||||
(exports (lib:exports (car lib))))
|
(exports (lib:exports (car lib))))
|
||||||
(close-input-port fp)
|
(close-input-port fp)
|
||||||
;; TODO: don't even both with below and call this instead:
|
(lib:import-set/exports->imports import exports)))
|
||||||
;;(define (lib:import-set/exports->imports import-set exports)
|
|
||||||
(cond
|
|
||||||
;; TODO: how to handle these recursively? IE: import set could be
|
|
||||||
;; a rename that has a prefix that has a library name
|
|
||||||
((tagged-list? 'only import)
|
|
||||||
;; Filter to symbols from "only" that appear in export list
|
|
||||||
(filter
|
|
||||||
(lambda (sym)
|
|
||||||
(member sym exports))
|
|
||||||
(cddr import)))
|
|
||||||
((tagged-list? 'except import)
|
|
||||||
(filter
|
|
||||||
(lambda (sym)
|
|
||||||
(not (member sym (cddr import))))
|
|
||||||
exports))
|
|
||||||
|
|
||||||
;; TODO: if prefix or rename, can resolve to original lib identifier.
|
|
||||||
;; would need another function somewhere to compute the renames though.
|
|
||||||
;; maybe compute both and return a list of both???
|
|
||||||
(else
|
|
||||||
exports))))
|
|
||||||
|
|
||||||
;; Determine if given value is a member of the given list, either directly
|
|
||||||
;; or as the car of a pair in the list
|
|
||||||
#;(define (lib:member:direct-or-car val lis)
|
|
||||||
(call/cc
|
|
||||||
(lambda (return)
|
|
||||||
(for-each
|
|
||||||
(lambda (elem)
|
|
||||||
(if (or (equal? elem val)
|
|
||||||
(and (pair? elem) (equal? (car elem) val)))
|
|
||||||
(return #t)))
|
|
||||||
lis)
|
|
||||||
(return #f))))
|
|
||||||
|
|
||||||
;; Take an import set and the corresponding list of exports. Process all of the
|
;; Take an import set and the corresponding list of exports. Process all of the
|
||||||
;; import set directives (only, except, rename, prefix) and return a list of:
|
;; import set directives (only, except, rename, prefix) and return a list of identifiers to import based on the export list.
|
||||||
;; - identifiers to import
|
;;
|
||||||
;; - renames: identifiers that will be imported using a different name
|
;; Any identifiers renamed in the export list will be returned as a pair
|
||||||
|
;; of the form (renamed-ident . original-ident)
|
||||||
|
;;
|
||||||
(define (lib:import-set/exports->imports import-set exports)
|
(define (lib:import-set/exports->imports import-set exports)
|
||||||
;; TODO: how to handle if a var is renamed more than once? really just want one mapping from lib-var-name => renamed-var-name
|
;; Handle import set that contains another import set
|
||||||
|
|
||||||
;; TODO: if import-set is not library name, recursively process it, then deal with results here
|
|
||||||
(unless (lib:import-set:library-name? import-set)
|
(unless (lib:import-set:library-name? import-set)
|
||||||
(let ((result (lib:import-set/exports->imports
|
(let ((result (lib:import-set/exports->imports
|
||||||
(lib:import-set->import-set import-set)
|
(lib:import-set->import-set import-set)
|
||||||
exports)))
|
exports)))
|
||||||
(set! exports result)))
|
(set! exports result)))
|
||||||
|
;; Process the current import set
|
||||||
(cond
|
(cond
|
||||||
((tagged-list? 'only import-set)
|
((tagged-list? 'only import-set)
|
||||||
;; Filter to symbols from "only" that appear in export list
|
;; Filter to symbols from "only" that appear in export list
|
||||||
|
|
Loading…
Add table
Reference in a new issue