* added an "imported-loc->library" procedure to the library manager

This commit is contained in:
Abdulaziz Ghuloum 2007-05-03 01:07:10 -04:00
parent d0c92ae99e
commit 86a75e8d54
3 changed files with 18 additions and 3 deletions

Binary file not shown.

View File

@ -490,6 +490,7 @@
[library-subst/env library-subst/env-label (core-prim . library-subst/env)]
[find-library-by-name find-library-by-name-label (core-prim . find-library-by-name)]
[imported-label->binding imported-label->binding-label (core-prim . imported-label->binding)]
[imported-loc->library imported-loc->library-label (core-prim . imported-loc->library)]
[library-spec library-spec-label (core-prim . library-spec)]
[invoke-library invoke-library-label (core-prim . invoke-library)]
))
@ -500,6 +501,20 @@
[(assq lab (library-env (car ls))) => cdr]
[else (f (cdr ls))])))
(define (lm:imported-loc->library loc)
(define (loc-in-env? ls)
(and (pair? ls)
(let ([a (car ls)])
(let ([binding (cdr a)])
(or (and (eq? (car binding) 'global)
(eq? (cdr binding) loc))
(loc-in-env? (cdr ls)))))))
(let f ([ls *all-libraries*])
(cond
[(null? ls) #f]
[(loc-in-env? (library-env (car ls))) (car ls)]
[else (f (cdr ls))])))
(define (lm:invoke-library lib)
(let ([invoke (library-invoke-state lib)])
(when (procedure? invoke)
@ -540,6 +555,7 @@
(list (library-id x) (library-name x) (library-ver x))))
(primitive-set! 'find-library-by-name lm:find-library-by-name)
(primitive-set! 'imported-label->binding lm:imported-label->binding)
(primitive-set! 'imported-loc->library lm:imported-loc->library)
(primitive-set! 'invoke-library lm:invoke-library)
(primitive-set! 'install-library lm:install-library))

View File

@ -308,7 +308,7 @@
(unless label
(stx-error e "unbound identifier"))
(case type
[(lexical core-prim macro)
[(lexical core-prim macro global)
(values type (binding-value b) id)]
[else (values 'other #f #f)])))]
[(syntax-pair? e)
@ -2022,8 +2022,7 @@
imp* vis* inv* exp-subst exp-env
void ;;; FIXME
(lambda () (eval-core invoke-code)))
(invoke-library (find-library-by-name name))
(build-void)))))
(invoke-library (find-library-by-name name))))))
(define boot-library-expander
(lambda (x)
(let-values ([(name imp* run* invoke-code exp*)