env-packages.scm 12 KB

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