comp-packages.scm 8.8 KB

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