comp-packages.scm 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. ; Part of Scheme 48 1.9. See file COPYING for notices and license.
  2. ; Authors: Richard Kelsey, Jonathan Rees, Mike Sperber, Robert Ransom, Marcel Turino
  3. ; Various data structures used by the compiler, module system, etc.
  4. ; Type system
  5. (define-structure meta-types meta-types-interface
  6. (open scheme-level-2
  7. define-record-types tables bitwise
  8. features ;make-immutable!
  9. util low-exceptions)
  10. (files (bcomp mtype))
  11. (optimize auto-integrate))
  12. ; Bindings
  13. (define-structure bindings bindings-interface
  14. (open scheme-level-2
  15. define-record-types
  16. meta-types
  17. locations)
  18. (files (bcomp binding))
  19. (optimize auto-integrate))
  20. ; Names & Transforms
  21. (define-structures ((names names-interface)
  22. (transforms transforms-interface))
  23. (open scheme-level-2
  24. define-record-types tables
  25. low-exceptions
  26. meta-types ;sexp->type
  27. bindings ;same-denotation?
  28. features ;make-immutable! string-hash
  29. syntax-transformers
  30. compiler-envs)
  31. (files (bcomp name)
  32. (bcomp transform))
  33. (optimize auto-integrate))
  34. ; A thingie (placecard?) is used to hold a spot for a location that is to be
  35. ; found later. The compiler sticks them in templates and the module system
  36. ; later replaces them with locations.
  37. ;
  38. ; We can't use (BEGIN ...) for this trivial package because it is loaded
  39. ; by flatload, which can't handle them.
  40. (define-structure thingies (export make-thingie
  41. thingie?
  42. thingie-binding
  43. thingie-name
  44. thingie-assigned?
  45. set-thingie-assigned?!)
  46. (open scheme-level-2 define-record-types)
  47. (optimize auto-integrate)
  48. (files (bcomp thingie)))
  49. ; Nodes
  50. (define-structure compiler-envs compiler-envs-interface
  51. (open scheme-level-2 define-record-types
  52. meta-types bindings)
  53. (files (bcomp cenv))
  54. (optimize auto-integrate))
  55. (define-structure nodes nodes-interface
  56. (open scheme-level-2
  57. meta-types names packages packages-internal
  58. compiler-envs bindings transforms
  59. low-exceptions define-record-types tables
  60. util)
  61. (files (bcomp node)
  62. (bcomp schemify))
  63. (optimize auto-integrate))
  64. ;--------------------------------
  65. ; Macros
  66. (define-structure syntactic syntactic-interface
  67. (open scheme-level-2 util
  68. meta-types names bindings
  69. nodes compiler-envs
  70. low-exceptions tables fluids
  71. var-utilities
  72. transforms
  73. code-vectors
  74. features) ;make-immutable!
  75. (files (bcomp syntax))
  76. (optimize auto-integrate))
  77. (define-structure syntax-rules-compiler (export compile-rules)
  78. (open scheme-level-2 (subset util (receive)) names syntax-rules-data)
  79. (files (bcomp syntax-rules-compiler)))
  80. (define-structure usual-macros usual-macros-interface
  81. (open scheme-level-2
  82. names ;name?
  83. fluids ;used in definition of %file-name%
  84. code-quotation
  85. syntax-rules-compiler
  86. util
  87. tables
  88. low-exceptions
  89. syntax-transformers)
  90. (files (bcomp usual)
  91. (bcomp syntax-rules)))
  92. ; Little utilities to be phased out by changing the format of lambda var lists
  93. ; in nodes.
  94. (define-structure var-utilities (export n-ary?
  95. normalize-formals
  96. number-of-required-args)
  97. (open scheme-level-2)
  98. (files (bcomp var-util))) ; can't use (BEGIN ...) because this is flatloaded
  99. ;--------------------------------
  100. ; Byte-code compiler
  101. ; Lexical environment layout info for debugging
  102. (define-structures ((debug-data debug-data-interface)
  103. (debug-data-internal debug-data-internal-interface))
  104. (open scheme-level-2
  105. define-record-types
  106. tables
  107. fluids
  108. record-types ;for debug-flags randomness
  109. features) ;make-immutable!
  110. (files (bcomp ddata)
  111. (bcomp state))
  112. (optimize auto-integrate))
  113. ; Determining stack usage. No longer used.
  114. ;
  115. ;(define-structure stack-check (export maximum-stack-use)
  116. ; (open scheme-level-2 architecture code-vectors low-exceptions)
  117. ; (files (bcomp stack-check))
  118. ; (optimize auto-integrate))
  119. ; Compiler back end
  120. (define-structure segments segments-interface
  121. (open scheme-level-2 util tables low-exceptions fluids
  122. define-record-types
  123. bitwise vm-data
  124. code-vectors
  125. templates
  126. architecture
  127. features ;make-immutable!
  128. debug-data debug-data-internal
  129. frames)
  130. (files (bcomp segment))
  131. (optimize auto-integrate))
  132. ; Primops
  133. (define-structure primops primops-interface
  134. (open scheme-level-2 tables define-record-types
  135. meta-types
  136. low-exceptions)
  137. (files (bcomp primop))
  138. (optimize auto-integrate))
  139. ; Type reconstruction.
  140. (define-structure reconstruction (export node-type reconstruct-type)
  141. (open scheme-level-2 tables
  142. meta-types nodes names bindings
  143. primops
  144. var-utilities ;n-ary?
  145. util ;last
  146. low-exceptions)
  147. (files (bcomp recon)))
  148. ; The compiler itself.
  149. (define-structures ((compiler compiler-interface)
  150. (bc-generation bc-generation-interface))
  151. (open scheme-level-2 util low-exceptions
  152. features ;force-output
  153. enumerated ;enumerand->name
  154. ascii
  155. architecture
  156. meta-types names bindings
  157. transforms
  158. nodes var-utilities
  159. primops
  160. segments
  161. debug-data-internal ; keep-source-code?
  162. flat-environments
  163. frames
  164. reconstruction)
  165. (files (bcomp comp-exp)
  166. (bcomp comp-lambda)
  167. (bcomp comp-prim)
  168. (bcomp comp))
  169. (optimize auto-integrate))
  170. (define-structure frames frames-interface
  171. (open scheme-level-2
  172. define-record-types
  173. names
  174. architecture ; two-byte-limit
  175. templates ; template-overhead
  176. debug-data-internal ; new-debug-data
  177. low-exceptions ; error
  178. thingies)
  179. (files (bcomp frame))
  180. (optimize auto-integrate))
  181. ;----------------
  182. ; Reading the forms in a file.
  183. ; This is used by scan-package and rts/eval.scm.
  184. (define-structure reading-forms (export read-forms $note-file-package)
  185. (open scheme-level-2
  186. fluids filenames cells
  187. features ;current-noise-port force-output
  188. low-exceptions ;error
  189. (subset packages-internal (package-reader))
  190. )
  191. (files (bcomp read-form)))
  192. ;----------------
  193. ; Live-variable analysis for closures.
  194. (define-structure flat-environments (export flatten-form)
  195. (open scheme-level-2 nodes low-exceptions
  196. optimizer primops
  197. util ;every
  198. var-utilities)
  199. (files (bcomp flatten)))
  200. ;----------------
  201. ; Module system
  202. (define-structure interfaces interfaces-interface
  203. (open scheme-level-2
  204. define-record-types tables
  205. util ;filter every receive symbol-append
  206. low-exceptions ;error
  207. weak ;populations
  208. meta-types)
  209. (files (bcomp interface))
  210. (optimize auto-integrate))
  211. (define-structures ((packages packages-interface)
  212. (packages-internal packages-internal-interface)
  213. (undefined undefined-interface))
  214. (open scheme-level-2
  215. define-record-types tables fluids low-exceptions cells
  216. util features locations weak
  217. meta-types interfaces
  218. names bindings
  219. compiler-envs
  220. templates
  221. thingies)
  222. (files (bcomp package)
  223. (bcomp package-undef))
  224. (optimize auto-integrate))
  225. (define-structure scan-package scan-package-interface
  226. (open scheme-level-2 util
  227. packages packages-internal
  228. meta-types bindings
  229. compiler-envs
  230. reading-forms
  231. filenames
  232. low-exceptions
  233. features ;current-noise-port force-output
  234. )
  235. (files (bcomp scan-package)))
  236. (define-structure optimizer optimizer-interface
  237. (open scheme-level-2
  238. low-exceptions tables
  239. util)
  240. (files (bcomp optimize)))
  241. (define-structure compile-packages (export compile-package)
  242. (open scheme-level-2 util tables
  243. syntactic
  244. packages
  245. packages-internal ;package-name
  246. optimizer
  247. compiler
  248. primops ;walk-primops
  249. compiler-envs
  250. nodes
  251. scan-package
  252. usual-macros ;for usual-transforms
  253. transforms ;for usual-transforms
  254. meta-types) ;for usual-transforms and define-all-operators
  255. (files (bcomp comp-package)))
  256. ;----------------
  257. ; DEFINE-STRUCTURE and friends
  258. (define-structure defpackage defpackage-interface
  259. (open scheme-level-2
  260. packages
  261. (subset packages-internal (set-package-reader!))
  262. syntactic usual-macros types
  263. interfaces
  264. source-file-names ;%file-name%
  265. low-exceptions ;error
  266. tables)
  267. (files (bcomp module-language)
  268. (bcomp config)))
  269. (define-structure types types-interface ;Typing language
  270. (open scheme-level-2 meta-types syntactic loopholes)
  271. (files (bcomp type))
  272. ;; (optimize auto-integrate) - doesn't work
  273. )
  274. (define-structure module-system (compound-interface defpackage-interface
  275. types-interface)
  276. (open defpackage types))
  277. ;----------------
  278. ; Code analysis and inlining
  279. (define-structure usages usages-interface
  280. (open scheme-level-2
  281. meta-types names nodes
  282. packages
  283. packages-internal ;package-refine-type!
  284. reconstruction
  285. var-utilities
  286. define-record-types
  287. util low-exceptions tables strong)
  288. (files (opt usage)
  289. (opt sort)))
  290. (define-structure analysis (export analyze-forms)
  291. (open scheme-level-2
  292. meta-types bindings nodes primops
  293. packages-internal ;package-add-static!
  294. inline
  295. usages
  296. reconstruction
  297. var-utilities
  298. transforms
  299. syntactic ;static-value
  300. packages
  301. low-exceptions
  302. features ;force-output
  303. optimizer ;set-optimizer!
  304. util)
  305. (files (opt analyze)))
  306. (define-structure inline inline-interface
  307. (open scheme-level-2 util var-utilities
  308. meta-types names bindings nodes
  309. compiler-envs
  310. transforms
  311. packages
  312. usages
  313. low-exceptions)
  314. (files (opt inline)))
  315. (define-structure strong (export strongly-connected-components)
  316. (open scheme-level-2 define-record-types low-exceptions)
  317. (files (big strong))) ;!
  318. ;----------------
  319. ; Two basic structures needed to support the compiler.
  320. (define-structure tables general-tables-interface
  321. (open scheme-level-1
  322. define-record-types
  323. low-exceptions
  324. features) ; string-hash, make-immutable!
  325. (files (big general-table))
  326. (optimize auto-integrate))
  327. (define-structure filenames filenames-interface
  328. (open scheme-level-1 low-exceptions fluids cells)
  329. (files (big filename)))