* install-library now takes an extra visibility flag.

* installed-libraries now takes an optional "all?" flag:
  - if all? is true, it returns all libraries.
  - if all? is false, it returns only the visible libraries
  - all? defaults to #t.
This commit is contained in:
Abdulaziz Ghuloum 2007-05-07 04:52:22 -04:00
parent 4c8029ab3e
commit 8226619438
6 changed files with 69 additions and 47 deletions

Binary file not shown.

View File

@ -73,6 +73,7 @@ void ik_fasl_load(ikpcb* pcb, char* fasl_file){
bzero(p.marks, p.marks_size * sizeof(ikp*)); bzero(p.marks, p.marks_size * sizeof(ikp*));
} }
ikp val = ik_exec_code(pcb, v); ikp val = ik_exec_code(pcb, v);
val = void_object;
if(val != void_object){ if(val != void_object){
ik_print(val); ik_print(val);
} }

Binary file not shown.

View File

@ -30,7 +30,8 @@
x))) x)))
(define-record library (define-record library
(id name ver imp* vis* inv* subst env visit-state invoke-state)) (id name ver imp* vis* inv* subst env visit-state invoke-state
visible?))
(define (find-dependencies ls) (define (find-dependencies ls)
(cond (cond
@ -64,8 +65,14 @@
(define label->binding-table (make-hash-table)) (define label->binding-table (make-hash-table))
(define (install-library id name ver (define install-library
imp* vis* inv* exp-subst exp-env visit-code invoke-code) (case-lambda
; [(id name ver imp* vis* inv* exp-subst exp-env
; visit-code invoke-code)
; (install-library id name ver imp* vis* inv* exp-subst exp-env
; visit-code invoke-code #t)]
[(id name ver imp* vis* inv* exp-subst exp-env
visit-code invoke-code visible?)
(let ([imp-lib* (map find-library-by-spec/die imp*)] (let ([imp-lib* (map find-library-by-spec/die imp*)]
[vis-lib* (map find-library-by-spec/die vis*)] [vis-lib* (map find-library-by-spec/die vis*)]
[inv-lib* (map find-library-by-spec/die inv*)]) [inv-lib* (map find-library-by-spec/die inv*)])
@ -74,7 +81,8 @@
(when (library-exists? name) (when (library-exists? name)
(error 'install-library "~s is already installed" name)) (error 'install-library "~s is already installed" name))
(let ([lib (make-library id name ver imp-lib* vis-lib* inv-lib* (let ([lib (make-library id name ver imp-lib* vis-lib* inv-lib*
exp-subst exp-env visit-code invoke-code)]) exp-subst exp-env visit-code invoke-code
visible?)])
(for-each (for-each
(lambda (x) (lambda (x)
(let ([label (car x)] [binding (cdr x)]) (let ([label (car x)] [binding (cdr x)])
@ -85,7 +93,8 @@
[else binding])]) [else binding])])
(put-hash-table! label->binding-table label binding)))) (put-hash-table! label->binding-table label binding))))
exp-env) exp-env)
((current-library-collection) lib)))) ((current-library-collection) lib)
lib))]))
(define (imported-label->binding lab) (define (imported-label->binding lab)
(get-hash-table label->binding-table lab #f)) (get-hash-table label->binding-table lab #f))
@ -105,7 +114,16 @@
(invoke-library (find-library-by-spec/die spec))) (invoke-library (find-library-by-spec/die spec)))
(define installed-libraries (define installed-libraries
(lambda () ((current-library-collection)))) (case-lambda
[(all?)
(let f ([ls ((current-library-collection))])
(cond
[(null? ls) '()]
[(or all? (library-visible? (car ls)))
(cons (car ls) (f (cdr ls)))]
[else (f (cdr ls))]))]
[() (installed-libraries #f)]))
(define library-spec (define library-spec
(lambda (x) (lambda (x)
(unless (library? x) (unless (library? x)

View File

@ -2166,7 +2166,8 @@
(install-library id name ver (install-library id name ver
imp* vis* inv* export-subst export-env imp* vis* inv* export-subst export-env
void ;;; FIXME void ;;; FIXME
(lambda () (eval-core invoke-code))) (lambda () (eval-core invoke-code))
#t)
(values invoke-code export-subst export-env)))) (values invoke-code export-subst export-env))))
(define (boot-library-expand x) (define (boot-library-expand x)
(let-values ([(invoke-code export-subst export-env) (let-values ([(invoke-code export-subst export-env)

View File

@ -97,25 +97,25 @@
[or (macro . or)])) [or (macro . or)]))
(define library-legend (define library-legend
'([i (ikarus)] '([i (ikarus) #t]
[r (r6rs)] [r (r6rs) #t]
[$all (ikarus system $all)] [$all (ikarus system $all) #f]
[$pairs (ikarus system $pairs)] [$pairs (ikarus system $pairs) #f]
[$lists (ikarus system $lists)] [$lists (ikarus system $lists) #f]
[$chars (ikarus system $chars)] [$chars (ikarus system $chars) #f]
[$strings (ikarus system $strings)] [$strings (ikarus system $strings) #f]
[$vectors (ikarus system $vectors)] [$vectors (ikarus system $vectors) #f]
[$fx (ikarus system $fx)] [$fx (ikarus system $fx) #f]
[$symbols (ikarus system $symbols)] [$symbols (ikarus system $symbols) #f]
[$records (ikarus system $records)] [$records (ikarus system $records) #f]
[$ports (ikarus system $ports)] [$ports (ikarus system $ports) #f]
[$codes (ikarus system $codes)] [$codes (ikarus system $codes) #f]
[$tcbuckets (ikarus system $tcbuckets)] [$tcbuckets (ikarus system $tcbuckets) #f]
[$io (ikarus system $io)] [$io (ikarus system $io) #f]
[$arg-list (ikarus system $arg-list)] [$arg-list (ikarus system $arg-list) #f]
[$stack (ikarus system $stack)] [$stack (ikarus system $stack) #f]
[$interrupts (ikarus system $interrupts)] [$interrupts (ikarus system $interrupts) #f]
[$boot (ikarus system $bootstrap)] [$boot (ikarus system $bootstrap) #f]
)) ))
(define ikarus-macros-map (define ikarus-macros-map
@ -629,7 +629,9 @@
(define (build-system-library export-subst export-env primlocs) (define (build-system-library export-subst export-env primlocs)
(define (build-library legend-entry) (define (build-library legend-entry)
(let ([key (car legend-entry)] [name (cadr legend-entry)]) (let ([key (car legend-entry)]
[name (cadr legend-entry)]
[visible? (caddr legend-entry)])
(let ([id (gensym)] (let ([id (gensym)]
[name name] [name name]
[version '()] [version '()]
@ -644,7 +646,7 @@
'()))]) '()))])
`(install-library `(install-library
',id ',name ',version ',import-libs ',visit-libs ',invoke-libs ',id ',name ',version ',import-libs ',visit-libs ',invoke-libs
',subst ',env void void))))) ',subst ',env void void ',visible?)))))
(let ([code `(library (ikarus primlocs) (let ([code `(library (ikarus primlocs)
(export) ;;; must be empty (export) ;;; must be empty
(import (import