start.scm 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. ; Part of Scheme 48 1.9. See file COPYING for notices and license.
  2. ; Authors: Richard Kelsey, Jonathan Rees
  3. (define (start structs-to-open)
  4. (lambda (structs-thunk)
  5. (usual-resumer
  6. (lambda (arg)
  7. (let* ((structs (structs-thunk))
  8. (b (make-built-in-structures structs)))
  9. (initialize-interaction-environment! b)
  10. (with-interaction-environment
  11. (make-initial-package b structs-to-open)
  12. (lambda ()
  13. (command-processor (cond ((assq 'usual-commands structs)
  14. => (lambda (z)
  15. (structure-package (cdr z))))
  16. (else #f))
  17. arg))))))))
  18. ; The structs argument is an a-list of (name . structure), as computed
  19. ; by the expression returned by reify-structures.
  20. (define (make-built-in-structures structs)
  21. (let* ((p (make-simple-package '() #f #f 'built-in-structures))
  22. (s (make-structure p
  23. (lambda ()
  24. (make-simple-interface
  25. #f ;name
  26. (cons 'built-in-structures (map car structs))))
  27. 'built-in-structures)))
  28. (for-each (lambda (name+struct)
  29. (environment-define! p
  30. (car name+struct)
  31. (cdr name+struct)))
  32. structs)
  33. (environment-define! p 'built-in-structures s)
  34. s))
  35. (define (initialize-interaction-environment! built-in-structures)
  36. (let ((scheme (*structure-ref built-in-structures 'scheme))
  37. (tower (make-tower built-in-structures 'interaction)))
  38. (set-interaction-environment!
  39. (make-simple-package (list scheme) #t tower 'interaction))
  40. (set-scheme-report-environment!
  41. 5
  42. (make-simple-package (list scheme) #t tower 'r5rs))))
  43. ; Intended for bootstrapping the command processor.
  44. (define (make-initial-package built-in-structures structs-to-open)
  45. (let ((p (make-simple-package
  46. (cons built-in-structures
  47. (map (lambda (name)
  48. (*structure-ref built-in-structures name))
  49. structs-to-open))
  50. eval
  51. (make-tower built-in-structures 'initial)
  52. 'initial)))
  53. (environment-define! p 'built-in-structures built-in-structures)
  54. p))
  55. (define (make-tower built-in-structures id)
  56. (make-syntactic-tower eval
  57. (list (*structure-ref built-in-structures
  58. 'scheme))
  59. id))