2003-05-01 06:21:33 -04:00
|
|
|
; Copyright (c) 1993-2001 by Richard Kelsey and Jonathan Rees. See file COPYING.
|
1999-09-14 08:45:02 -04:00
|
|
|
|
|
|
|
|
|
|
|
; ,open interfaces packages meta-types sort syntactic
|
|
|
|
; ,config scheme
|
|
|
|
|
2003-05-01 06:21:33 -04:00
|
|
|
; Print out the names and types exported by THING, which is either a structure
|
|
|
|
; or an interface.
|
|
|
|
|
1999-09-14 08:45:02 -04:00
|
|
|
(define (list-interface thing)
|
|
|
|
(cond ((structure? thing)
|
|
|
|
(list-interface-1 (structure-interface thing)
|
2003-05-01 06:21:33 -04:00
|
|
|
(lambda (name type)
|
1999-09-14 08:45:02 -04:00
|
|
|
(let ((x (structure-lookup thing name #t)))
|
|
|
|
(if (binding? x)
|
|
|
|
(binding-type x)
|
|
|
|
#f)))))
|
|
|
|
((interface? thing)
|
2003-05-01 06:21:33 -04:00
|
|
|
(list-interface-1 thing
|
|
|
|
(lambda (name type)
|
|
|
|
type)))
|
1999-09-14 08:45:02 -04:00
|
|
|
(else '?)))
|
|
|
|
|
2003-05-01 06:21:33 -04:00
|
|
|
; LOOKUP is passed the package-name and the type from the interface and
|
|
|
|
; returns a (possibly different) type.
|
|
|
|
|
1999-09-14 08:45:02 -04:00
|
|
|
(define (list-interface-1 int lookup)
|
2003-05-01 06:21:33 -04:00
|
|
|
(let ((names '()))
|
|
|
|
(for-each-declaration (lambda (name package-name type)
|
|
|
|
(if (not (assq name names)) ;compound signatures...
|
|
|
|
(set! names
|
|
|
|
(cons (cons name
|
|
|
|
(lookup package-name type))
|
|
|
|
names))))
|
1999-09-14 08:45:02 -04:00
|
|
|
int)
|
2003-05-01 06:21:33 -04:00
|
|
|
(for-each (lambda (pair)
|
|
|
|
(let ((name (car pair))
|
|
|
|
(type (cdr pair)))
|
|
|
|
(write name)
|
|
|
|
(display (make-string
|
|
|
|
(max 0 (- 25 (string-length
|
|
|
|
(symbol->string name))))
|
|
|
|
#\space))
|
|
|
|
(write-char #\space)
|
|
|
|
(write (careful-type->sexp type)) ;( ...)
|
|
|
|
(newline)))
|
|
|
|
(sort-list names
|
|
|
|
(lambda (pair1 pair2)
|
|
|
|
(string<? (symbol->string (car pair1))
|
|
|
|
(symbol->string (car pair2))))))))
|
1999-09-14 08:45:02 -04:00
|
|
|
|
|
|
|
(define (careful-type->sexp thing)
|
|
|
|
(cond ((not thing) 'undefined)
|
2003-05-01 06:21:33 -04:00
|
|
|
((or (symbol? thing)
|
|
|
|
(null? thing)
|
|
|
|
(number? thing))
|
1999-09-14 08:45:02 -04:00
|
|
|
thing) ;?
|
|
|
|
((pair? thing) ;e.g. (variable #{Type :value})
|
|
|
|
(cons (careful-type->sexp (car thing))
|
|
|
|
(careful-type->sexp (cdr thing))))
|
2003-05-01 06:21:33 -04:00
|
|
|
(else
|
|
|
|
(type->sexp thing #t))))
|
|
|
|
|