env-packages.scm 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. ; Part of Scheme 48 1.9. See file COPYING for notices and license.
  2. ; Authors: Richard Kelsey, Jonathan Rees, Mike Sperber, Marcel Turino,
  3. ; Marcus Crestani, Robert Ransom, Martin Gasbichler, Sebastian Rheinnecker
  4. ; Packages for the programming environment: the command processor, inspector,
  5. ; and disassembler and assembler.
  6. ; Command processor
  7. (define-structures ((command-processor command-processor-interface)
  8. (command (export command-processor)))
  9. (open scheme ;;-level-2 ; eval, interaction-environment
  10. tables fluids cells
  11. conditions
  12. os-strings
  13. define-record-types
  14. handle
  15. command-levels
  16. command-state
  17. menus
  18. reading ; gobble-line, with-sharp-sharp
  19. i/o ; current-error-port
  20. display-conditions ; display-condition
  21. methods
  22. util ; unspecific
  23. undefined ; $note-undefined
  24. features ; force-output
  25. interrupts ; set-enabled-interrupts!, all-interrupts
  26. vm-exposure ; primitive-catch
  27. fluids-internal ; get-dynamic-env, set-dynamic-env!
  28. nodes ; for ## kludge
  29. exceptions signal-conditions
  30. debug-messages ; for debugging
  31. (subset silly (reverse-list->string))
  32. (subset evaluation (load-script-into))
  33. (subset packages-internal (package-reader))
  34. (subset environments (environment-ref))
  35. (subset shared-bindings (shared-binding-ref lookup-imported-binding))
  36. (subset root-scheduler (scheme-exit-now))
  37. (subset threads (thread? thread-uid))
  38. (subset threads-internal (thread-continuation))
  39. (subset continuations (continuation?)))
  40. (files (env version-info)
  41. (env command)
  42. (env read-command)))
  43. (define-structures ((command-levels command-levels-interface)
  44. (command-state command-state-interface))
  45. (open scheme
  46. enumerated enum-case
  47. os-strings
  48. tables queues
  49. session-data
  50. define-record-types
  51. threads threads-internal
  52. scheduler
  53. interrupts
  54. handle
  55. display-conditions ; display-condition
  56. weak
  57. debug-messages ; for debugging
  58. exceptions signal-conditions
  59. i/o ; current-error-port
  60. (subset filenames (with-translations make-translations))
  61. util ; unspecific
  62. channel-i/o ; steal-channel-port
  63. fluids
  64. fluids-internal ; get-dynamic-env, set-dynamic-env!
  65. environments ; with-interaction-environment,
  66. ; interaction-environment
  67. root-scheduler ; call-when-deadlocked!
  68. conditions)
  69. (files (env user)
  70. (env command-level)))
  71. (define-structure basic-commands basic-commands-interface
  72. (open scheme-level-2
  73. command-processor
  74. command-levels
  75. command-state
  76. undefined ; noting-undefined-variables
  77. environments ; with-interaction-environment
  78. (modify evaluation (hide load)) ; eval, load-into
  79. ;; packages ; package?
  80. root-scheduler ; scheme-exit-now
  81. i/o ; silently
  82. )
  83. (files (env basic-command)))
  84. ; Usual command set
  85. (define-structure usual-commands usual-commands-interface
  86. (open basic-commands
  87. build-commands
  88. package-commands
  89. debug-commands
  90. inspect-commands
  91. disassemble-commands
  92. ))
  93. ; Image builder.
  94. (define-structures ((build (export build-image stand-alone-resumer))
  95. (build-commands build-commands-interface))
  96. (open scheme-level-2
  97. command-processor
  98. command-levels
  99. command-state
  100. menus ; write-line
  101. conditions
  102. exceptions signal-conditions
  103. handle
  104. usual-resumer
  105. filenames ; translate
  106. display-conditions ; display-condition
  107. evaluation ; package-for-load, eval
  108. environments ; with-interaction-environment
  109. i/o ; current-error-port
  110. write-images
  111. os-strings)
  112. (files (env build)))
  113. ; Package commands.
  114. (define-structures ((package-commands package-commands-interface)
  115. (package-commands-internal
  116. package-commands-internal-interface))
  117. (open scheme
  118. command-processor
  119. command-levels
  120. command-state
  121. methods
  122. undefined ; noting-undefined-variables
  123. packages ; for creating a user package
  124. packages-internal ; set-package-integrate?!, etc.
  125. package-mutation ; package-system-sentinel
  126. environments ; *structure-ref, etc.
  127. compiler-envs ; syntactic-tower
  128. ensures-loaded ; ensure-loaded
  129. debug-messages
  130. interfaces
  131. ascii
  132. i/o ; force-output, current-error-port, silently
  133. exceptions
  134. util ; every
  135. tables ; table->entry-list
  136. meta-types ; type->sexp
  137. os-strings
  138. fluids)
  139. (files (env pacman)))
  140. ; Debugging aids.
  141. ; Disclosers: this makes objects and conditions print nicely.
  142. (define-structure disclosers disclosers-interface
  143. (open scheme-level-1
  144. methods more-types
  145. tables
  146. conditions
  147. display-conditions
  148. locations
  149. code-vectors
  150. closures
  151. packages-internal ; location-info-tables
  152. debug-data
  153. segments ; get-debug-data
  154. enumerated ; enumerand->name
  155. weak ; weak-pointer?
  156. cells
  157. (subset i/o-internal (disclose-port))
  158. low-level ; cell-unassigned?
  159. templates continuations channels
  160. architecture)
  161. (files (env disclosers)))
  162. (define-structure more-vm-exceptions (export construct-vm-exception)
  163. (open scheme
  164. conditions
  165. signal-conditions
  166. enumerated enum-case
  167. vm-exceptions
  168. architecture
  169. disclosers
  170. (subset primitives (os-error-message))
  171. os-strings)
  172. (files (env vm-exception)))
  173. ; For printing procedures with their names, etc.
  174. (define-structure debuginfo debuginfo-interface
  175. (open scheme-level-2
  176. tables
  177. debug-data
  178. debug-data-internal ; debug-data-table make-debug-data
  179. ;; packages
  180. packages-internal ; package-name-table
  181. names ; generated?
  182. features
  183. weak)
  184. (files (env debuginfo)))
  185. ; Utility for displaying error messages
  186. (define-structure display-conditions display-conditions-interface
  187. (open scheme-level-2
  188. writing
  189. methods
  190. conditions
  191. handle) ;ignore-errors
  192. (files (env dispcond)))
  193. ; Most of the debugging commands.
  194. (define-structures ((debugging ;additional exports in future
  195. (export breakpoint))
  196. (previews
  197. (export display-preview))
  198. (debug-commands debug-commands-interface))
  199. (open scheme-level-2
  200. command-processor ; define-command, etc.
  201. command-levels
  202. command-state
  203. menus ; write-carefully, with-limited-output
  204. fluids
  205. tables
  206. weak
  207. exceptions
  208. util ; filter
  209. evaluation ; eval-from-file, eval
  210. environments ; environment-define! (for ,trace)
  211. ;; debug.scm has a procedure called condition, and it has to be called that
  212. (modify conditions (prefix conditions:)
  213. (expose condition))
  214. (modify conditions (hide condition))
  215. display-conditions ; for setting writing length and depth
  216. (subset filenames (set-translation!))
  217. disclosers ; template-name, debug-data-names
  218. packages ; flush-location-names, package-integrate?
  219. packages-internal ; [set-]package-integrate?[!], flush-location-names
  220. bindings
  221. meta-types
  222. (subset transforms (transform?))
  223. (subset primops (primop?))
  224. undefined ; noting-undefined-variables
  225. continuations ; continuation-template, continuation-preview
  226. architecture ; op/global, etc.
  227. interrupts ; all-interrupts, set-enabled-interrupts!
  228. vm-exposure ; fluid-let suppression kludge - fix later
  229. (subset nodes (schemify))
  230. (subset reading-forms ($note-file-package))
  231. (subset handle (with-handler))
  232. debug-data ; yucko
  233. debug-data-internal ; yucko
  234. (modify filenames (prefix filenames:)
  235. (expose translate))
  236. (modify syntactic (prefix syntactic:)
  237. (expose expand expand-form))
  238. (modify primitives (prefix primitives:)
  239. (expose collect time memory-status)))
  240. (files (env debug)))
  241. (define-structure menus menus-interface
  242. (open scheme-level-2
  243. command-levels
  244. command-state
  245. fluids
  246. display-conditions ; limited-write
  247. util ; sublist
  248. exceptions
  249. handle ; ignore-errors
  250. conditions ; error?
  251. ; the rest are for looking inside various types of objects
  252. closures ; closure-template
  253. disclosers ; template-debug-data, etc.
  254. debug-data
  255. segments ; get-debug-data
  256. templates
  257. continuations
  258. records
  259. record-types
  260. low-level ; vector-unassigned?
  261. locations
  262. cells
  263. weak
  264. (subset primitives (transport-link-cell?
  265. transport-link-cell-key
  266. transport-link-cell-value
  267. transport-link-cell-tconc
  268. transport-link-cell-next)))
  269. (files (env menu)))
  270. ; Inspector
  271. (define-structure inspect-commands inspect-commands-interface
  272. (open scheme-level-2
  273. command-processor ; define-command, etc.
  274. command-levels
  275. command-state
  276. menus
  277. exceptions
  278. ; The following two structures are for ,where
  279. debug-data
  280. disclosers ; template-debug-data
  281. closures
  282. templates
  283. continuations
  284. debug-messages ; for debugging
  285. debugging ; command-loop-continuation
  286. evaluation) ; eval
  287. (files (env inspect)))
  288. ; Package and interface mutation.
  289. (define-structure package-mutation package-mutation-interface
  290. (open scheme-level-2 cells
  291. shadowing ; shadow-location!
  292. packages
  293. interfaces
  294. bindings
  295. packages-internal
  296. defpackage ; set-verify-later!
  297. locations
  298. disclosers ; location-info
  299. handle
  300. debug-messages
  301. tables fluids weak exceptions)
  302. (files (env pedit)))
  303. ; The following hooks the compiler up with a VM exception handler for
  304. ; unbound variables.
  305. (define-structure shadowing (export shadow-location!)
  306. (open scheme-level-1
  307. vm-exposure ;primitive-catch
  308. continuations templates locations code-vectors
  309. vm-exceptions more-vm-exceptions exceptions
  310. signal-conditions
  311. enumerated
  312. disclosers
  313. conditions
  314. debug-messages
  315. architecture) ;(enum op global)
  316. (files (env shadow))) ;Exception handler to support package system
  317. (define-structure parse-bytecode parse-bytecode-interface
  318. (open scheme
  319. (subset util (receive))
  320. bitwise
  321. templates
  322. code-vectors byte-vectors
  323. architecture
  324. enumerated
  325. exceptions
  326. fluids
  327. closures
  328. debug-data
  329. (subset disclosers (template-debug-data))
  330. continuations
  331. define-record-types)
  332. (files (env parse-bytecode)))
  333. ; Disassembler
  334. (define-structures ((disassembler
  335. (export disassemble write-instruction))
  336. (disassemble-commands disassemble-commands-interface))
  337. (open scheme-level-2
  338. command-processor ; define-command
  339. command-state ; focus-object
  340. disclosers ; template-name
  341. enumerated ; enumerand->name
  342. disclosers ; location-name
  343. parse-bytecode
  344. evaluation ; eval
  345. templates
  346. continuations
  347. locations
  348. define-record-types
  349. bitwise
  350. closures
  351. architecture
  352. exceptions)
  353. (files (env disasm)))
  354. ; Assembler.
  355. (define-structure assembling (export) ; No exports, this defines a compilator.
  356. (open scheme-level-2
  357. compiler ;define-compilator
  358. segments
  359. frames
  360. architecture
  361. bc-generation
  362. nodes ;node-form node-ref
  363. bindings ;binding? binding-place
  364. meta-types ;value-type
  365. templates ; for Richard's version
  366. exceptions
  367. enumerated ;name->enumerand
  368. code-vectors)
  369. (files (env assem)))
  370. ; Foo
  371. (define-structure assembler (export (lap :syntax))
  372. (open scheme-level-2)
  373. (for-syntax (open scheme-level-2 nodes meta-types assembling))
  374. (begin
  375. (define-syntax lap
  376. (lambda (e r c)
  377. (make-node (get-operator 'lap syntax-type) e)))))