for-reify.scm 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ; Part of Scheme 48 1.9. See file COPYING for notices and license.
  2. ; Authors: Richard Kelsey, Jonathan Rees, Mike Sperber
  3. ; Things used by the expression returned by REIFY-STRUCTURES.
  4. ; Cf. link/reify.scm.
  5. (define (operator name type-exp)
  6. (get-operator name (sexp->type type-exp #t)))
  7. (define (primop name)
  8. (get-primop name))
  9. (define (simple-interface names types)
  10. (make-simple-interface #f
  11. (map (lambda (name type)
  12. (list name (sexp->type type #t)))
  13. (vector->list names)
  14. (vector->list types))))
  15. (define (package names locs get-location uid)
  16. (let ((end (vector-length names))
  17. (p (make-package list list ;(lambda () '())
  18. #f #f "" '()
  19. uid #f)))
  20. (set-package-loaded?! p #t)
  21. (do ((i 0 (+ i 1)))
  22. ((= i end))
  23. (let* ((name (vector-ref names i))
  24. (probe (package-lookup p name)))
  25. (if (not (binding? probe))
  26. (package-define! p
  27. name
  28. usual-variable-type
  29. (get-location (vector-ref locs i))
  30. #f))))
  31. (make-table-immutable! (package-definitions p))
  32. p))
  33. (define (transform kind names+proc env type-exp source name)
  34. (cond
  35. ((eq? kind 'macro)
  36. (make-transform/macro names+proc env (sexp->type type-exp #t) source name))
  37. ((eq? kind 'inline)
  38. (make-transform/inline names+proc env (sexp->type type-exp #t) source name))
  39. (else
  40. (assertion-violation 'transform
  41. "unknown transform kind" kind))))
  42. (define (package-define-static! package name static)
  43. (package-define! package
  44. name
  45. (cond ((transform? static)
  46. (transform-type static))
  47. ((primop? static)
  48. (primop-type static))
  49. ((operator? static)
  50. (operator-type static))
  51. ((structure? static)
  52. structure-type)
  53. (else
  54. (assertion-violation 'package-define-static!
  55. "unknown kind of static value" static)))
  56. #f
  57. static))