package-defs.scm 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. ; Part of Scheme 48 1.9. See file COPYING for notices and license.
  2. ; Authors: Richard Kelsey, Mike Sperber, Marcus Crestani
  3. ; Pre-Scheme packages
  4. ; Everything else
  5. (define-structures ((prescheme-compiler (export)))
  6. (open scheme
  7. (modify big-scheme (hide table->entry-list))
  8. conditions comp-util structure-refs
  9. prescheme-front-end prescheme-display
  10. (subset parameters (determine-lambda-protocol))
  11. node
  12. front-debug forms
  13. ps-types
  14. type-variables
  15. c
  16. structure-refs
  17. primop-data
  18. c-primop-data
  19. jump ;find-jump-procs procs->jumps
  20. record-types ;reset-record-data!
  21. node-types
  22. front ;simplify-all
  23. simplify) ;simplify-node
  24. (files top))
  25. (define-structures ((prescheme-display (export display-forms-as-scheme)))
  26. (open scheme
  27. (modify big-scheme (hide table->entry-list))
  28. structure-refs
  29. (modify names (hide name->symbol))
  30. bindings ;binding-place
  31. ;; their literal-node? is equivalent, but wasn't exported until 2007
  32. (modify nodes (hide literal-node? schemify))
  33. variable primop external-values ps-primitives
  34. flatten-internal ;generated-top-variable?
  35. external-constants)
  36. (access forms) ;form-value form-var
  37. (files display))
  38. (define-structures ((protocol (export normal-protocol
  39. goto-protocol
  40. goto-protocol?)))
  41. (open scheme
  42. (modify big-scheme (hide table->entry-list))
  43. comp-util set-parameters ps-primops ps-types node)
  44. (files spec))
  45. (define-structures ((prescheme-front-end (export prescheme-front-end)))
  46. (open scheme
  47. (modify big-scheme (hide table->entry-list))
  48. comp-util structure-refs
  49. linking expand flatten forms
  50. ps-types inference
  51. variable
  52. primitive-data
  53. primop-data
  54. inference-internal ; unify!
  55. type-variables) ; reset-type-vars!
  56. (access nodes ; node? schemify
  57. node ; reset-node-id
  58. record-types) ; reset-record-types!
  59. (files front-end))
  60. (define-structures ((forms form-interface))
  61. (open scheme
  62. (modify big-scheme (hide table->entry-list))
  63. comp-util node expand defrecord
  64. node-vector queues to-cps
  65. structure-refs
  66. eval-node ; closure stuff
  67. ps-primops ; get-prescheme-primop
  68. simplify-internal ; simplify-node simplify-args
  69. front ; simplify-all
  70. ps-types ; type/undetermined
  71. type-variables ; maybe-follow-uvar
  72. node-types) ; instantiate-type&value
  73. (access nodes) ; node-predicate
  74. (files form))
  75. ; Translating Scheme into evaluated nodes
  76. (define-structures ((expand (export scan-packages)))
  77. (open scheme
  78. (modify big-scheme (hide table->entry-list))
  79. comp-util structure-refs
  80. variable
  81. bindings
  82. (modify nodes (hide define-node?)) ; we'd shadow this
  83. ps-primitives ;eval-primitive
  84. eval-node ;eval-node
  85. scan-package ;package-source
  86. locations
  87. (subset util (fold))
  88. syntactic)
  89. (access packages) ;package->environment
  90. (files expand))
  91. ; Eval and type information on Pre-Scheme primitives
  92. (define-structures ((ps-primitives (export primitive?
  93. make-primitive
  94. eval-primitive
  95. primitive-id
  96. primitive-source
  97. primitive-expander
  98. primitive-expands-in-place?
  99. primitive-inference-rule)))
  100. (open scheme
  101. (modify big-scheme (hide table->entry-list))
  102. comp-util defrecord)
  103. (files primitive))
  104. (define-structures ((primitive-data (export)))
  105. (open scheme
  106. (modify big-scheme (hide table->entry-list any?))
  107. comp-util ps-primitives
  108. bindings
  109. ;; ours is equivalent, but theirs wasn't exported until 2007
  110. (modify nodes (hide lambda-node?))
  111. ascii structure-refs
  112. ps-primops ;get-prescheme-primop
  113. linking ;define-prescheme!
  114. inference-internal ;check-arg-type
  115. type-variables ;make-arith-op-uvar
  116. record-types
  117. (modify prescheme (hide error
  118. peek-char read-char write-char newline
  119. open-input-file open-output-file
  120. close-input-port close-output-port))
  121. ps-memory
  122. ps-types external-constants external-values
  123. floatnums ;floatnum?
  124. locations
  125. eval-node) ; closure? (to keep them from being made immutable)
  126. (access variable) ; variable-name
  127. (files (primop scm-scheme)
  128. (primop scm-arith)
  129. (primop scm-memory)
  130. (primop scm-record)))
  131. (define-structures ((eval-node (export eval-node
  132. closure? closure-node closure-env
  133. make-top-level-closure
  134. closure-temp set-closure-temp!
  135. apply-closure
  136. unspecific? constant?)))
  137. (open (modify scheme (hide eval))
  138. define-record-types
  139. nodes
  140. ps-types ;expand-type-spec
  141. external-values
  142. external-constants ;external-constant?
  143. signals ;error
  144. util) ;unspecific
  145. (files eval))
  146. ; Reducing closures and data structures to simple definitions
  147. (define-structures ((flatten (export flatten-definitions))
  148. (flatten-internal (export generated-top-variable?)))
  149. (open scheme
  150. (modify big-scheme (hide table->entry-list))
  151. comp-util defrecord
  152. structure-refs
  153. bindings
  154. ;; ours are equivalent, but theirs weren't exported until 2007
  155. (modify nodes (hide name-node? lambda-node?
  156. make-similar-node)) ; ours is different
  157. variable
  158. eval-node ;closure stuff, constant?
  159. ps-primitives ;primitive stuff
  160. ps-types ;type/undetermined expand-type-spec
  161. linking ;prescheme-compiler-env
  162. syntactic ;expand
  163. strong
  164. external-values
  165. locations
  166. features) ;immutable?
  167. (access forms) ;avoid name conflict with NODE-FORM in nodes
  168. (files flatten substitute))
  169. (define-structures ((to-cps (export x->cps)))
  170. (open scheme
  171. (modify big-scheme (hide table->entry-list))
  172. comp-util
  173. variable
  174. names bindings
  175. ;; ours are equivalent, but theirs weren't exported until 2007
  176. (modify nodes (hide lambda-node?
  177. literal-node?))
  178. primop
  179. structure-refs
  180. cps-util enumerated
  181. ps-primops ;get-prescheme-primop
  182. ps-types ;type/unknown
  183. inference ;node-type lambda-node-return-type
  184. ps-primitives ;primitive-expander
  185. protocol) ;goto-protocol normal-protocol
  186. (access node)
  187. (files to-cps))
  188. ; Processing interface and package definitions
  189. (define-structures ((linking linking-interface))
  190. (open scheme
  191. (modify big-scheme (hide table->entry-list))
  192. structure-refs comp-util
  193. interfaces packages environments usual-macros
  194. defpackage types ;for making interfaces
  195. reflective-tower-maker
  196. fluids cells
  197. expand-define-record-type
  198. scan-package ;collect-packages
  199. bindings ;binding? binding-place
  200. nodes ;get-operator
  201. transforms ;make-transform
  202. locations) ;contents
  203. (access meta-types ;syntax-type usual-variable-type
  204. variable ;make-global-variable
  205. ps-types ;type/unknown
  206. reading-forms ;$note-file-package
  207. packages-internal ;$get-location
  208. package-commands-internal ;config-package
  209. prescheme ;we need this loaded
  210. built-in-structures) ;defpackage structure-refs
  211. (files linking))
  212. ;----------------------------------------------------------------
  213. ; Types and type inference
  214. (define-structures ((ps-types ps-type-interface)
  215. (type-variables type-variable-interface)
  216. (record-types record-type-interface)
  217. (expand-define-record-type
  218. (export expand-define-record-type)))
  219. (open scheme
  220. (modify big-scheme (hide table->entry-list))
  221. comp-util define-record-types)
  222. (files type
  223. type-scheme
  224. type-var
  225. record))
  226. (define-structures ((inference inference-interface)
  227. (inference-internal inference-internal-interface))
  228. (open scheme
  229. (modify big-scheme (hide table->entry-list))
  230. front variable comp-util transitive
  231. ps-types type-variables
  232. bindings
  233. ;; ours are equivalent, but theirs didn't exist until 2007
  234. (modify nodes (hide name-node?
  235. lambda-node?
  236. literal-node?))
  237. structure-refs
  238. ps-primitives
  239. ps-primops ; get-prescheme-primop
  240. external-values external-constants
  241. locations) ; for imported constants
  242. (access eval-node) ; unspecific?
  243. (for-syntax (open scheme big-scheme))
  244. (files inference infer-early))
  245. (define-structures ((node-types (export instantiate-type&value
  246. make-monomorphic!)))
  247. (open scheme
  248. (modify big-scheme (hide table->entry-list))
  249. front node comp-util
  250. ps-types type-variables
  251. inference-internal) ; unify!
  252. (files node-type))
  253. ;----------------------------------------------------------------
  254. ; Primops
  255. (define-structures ((ps-primops ps-primop-interface))
  256. (open scheme
  257. (modify big-scheme (hide table->entry-list))
  258. comp-util node simplify-internal
  259. linking ps-types front expand platform)
  260. (files (primop primop)))
  261. (define-structures ((ps-c-primops ps-c-primop-interface))
  262. (open scheme
  263. (modify big-scheme (hide table->entry-list))
  264. comp-util node simplify-internal
  265. define-record-types
  266. ps-types ps-primops)
  267. (for-syntax (open scheme big-scheme))
  268. (files (primop c-primop)))
  269. (define-structures ((primop-data (export)))
  270. (open scheme
  271. (modify big-scheme (hide table->entry-list))
  272. comp-util node
  273. (modify simplify-internal (hide simplify-unknown-call))
  274. simplify-let
  275. front expand type-variables inference-internal
  276. ps-types ps-primops record-types
  277. (subset parameters (determine-lambda-protocol))
  278. node-vector
  279. node-types) ; instantiate-type&value
  280. (files (primop base)
  281. (primop arith)
  282. (primop io)
  283. (primop vector)
  284. ))
  285. (define-structures ((c-primop-data (export)))
  286. (open scheme
  287. (modify big-scheme (hide table->entry-list))
  288. comp-util node simplify
  289. ps-types ps-primops ps-c-primops
  290. platform
  291. front
  292. structure-refs
  293. c-internal
  294. ps-types type-variables inference-internal
  295. (subset inference (get-variable-type))
  296. forms
  297. compiler-byte-vectors
  298. record-types
  299. eval-node) ; unspecific?
  300. (access ps-primitives prescheme)
  301. (files (primop c-base)
  302. (primop c-arith)
  303. (primop c-io)
  304. (primop c-vector)
  305. ))
  306. (define-structures ((external-values (export external-value?
  307. make-external-value
  308. external-value-type
  309. external-value-string)))
  310. (open scheme define-record-types)
  311. (begin
  312. (define-record-type external-value :external-value
  313. (make-external-value string type)
  314. external-value?
  315. (string external-value-string)
  316. (type external-value-type))))
  317. ;----------------------------------------------------------------
  318. ; Translating to C
  319. (define-structures ((c (export write-c-file hoist-nested-procedures))
  320. (c-internal c-internal-interface))
  321. (open scheme ascii
  322. (modify big-scheme (hide table->entry-list))
  323. comp-util strongly-connected node forms
  324. defrecord
  325. ps-primops ps-c-primops
  326. ps-types type-variables
  327. flatten-internal ; generated-top-variable?
  328. (subset inference (get-variable-type))
  329. inference-internal ; literal-value-type
  330. protocol ; goto-protocol?
  331. i/o ; force-output
  332. record-types
  333. external-values
  334. external-constants
  335. eval-node) ; unspecific?
  336. (files c
  337. c-decl
  338. c-call
  339. hoist
  340. merge))