start.scm 2.1 KB

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