comp-packages.scm 9.3 KB

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