interfaces.scm 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560
  1. ; Part of Scheme 48 1.9. See file COPYING for notices and license.
  2. ; Authors: Richard Kelsey, Jonathan Rees, Mike Sperber, Marcus Crestani,
  3. ; Robert Ransom, Marcel Turino, Ivan Shmakov, Harald Glab-Phlak
  4. ; Some interfaces. Order of presentation is a bit random.
  5. (define-interface scheme-level-0-interface
  6. (export ((if begin lambda letrec letrec* quote set!
  7. define define-syntax let-syntax letrec-syntax)
  8. :syntax)
  9. ;; The basic derived expression types.
  10. ((and cond do let let* or) :syntax)
  11. apply
  12. ;; Scalar primitives
  13. eq?
  14. number? integer? rational? real? complex?
  15. exact? exact->inexact inexact->exact
  16. + - * / = < > <= >=
  17. quotient remainder
  18. floor numerator denominator
  19. real-part imag-part
  20. exp log sin cos tan asin acos atan sqrt
  21. angle magnitude make-polar make-rectangular
  22. char?
  23. char=? char<?
  24. eof-object?
  25. input-port? output-port?
  26. ;; Data manipulation
  27. pair? cons car cdr set-car! set-cdr!
  28. symbol? symbol->string
  29. string? make-string string-length string-ref string-set!
  30. vector? make-vector vector-length vector-ref vector-set!
  31. ;; Unnecessarily primitive
  32. string=?
  33. vector
  34. assq
  35. ;; New in Revised^5 Scheme
  36. values call-with-values
  37. ;; Things that aren't primitive at the VM level, but have
  38. ;; to be defined using VM primitives.
  39. string-copy
  40. string->symbol
  41. procedure?
  42. integer->char char->integer))
  43. ; Miscellaneous primitives.
  44. (define-interface primitives-interface
  45. (export add-finalizer!
  46. call-external-value
  47. call-external-value-2
  48. channel-parameter
  49. checked-record-ref
  50. checked-record-set!
  51. collect ;,collect command
  52. continuation-length
  53. continuation-ref
  54. continuation-set!
  55. continuation?
  56. copy-bytes!
  57. copy-string-chars!
  58. current-thread ;fluids threads
  59. double?
  60. eof-object ;i/o-internal re-exports this
  61. extended-number-length
  62. extended-number-ref
  63. extended-number-set!
  64. extended-number?
  65. new-external-event-uid
  66. unregister-external-event-uid!
  67. find-all ;externals, command-levels
  68. find-all-records ;threads
  69. immutable?
  70. make-continuation
  71. make-double
  72. make-extended-number
  73. make-immutable!
  74. make-record
  75. make-template
  76. make-weak-pointer
  77. memory-status ;interrupts
  78. os-error-message
  79. peek-byte
  80. peek-char
  81. read-byte
  82. read-char
  83. record
  84. record-length
  85. record-ref
  86. record-set!
  87. record?
  88. record-type<=?
  89. return-from-callback
  90. schedule-interrupt ;interrupts re-exports this
  91. session-data ;channels
  92. set-current-thread! ;fluids threads
  93. set-enabled-interrupts! ;interrupts
  94. set-exception-handlers!
  95. set-interrupt-handlers! ;interrupts
  96. set-session-data! ;channels
  97. string-hash
  98. system-parameter
  99. template-length
  100. template-ref
  101. template-set!
  102. template?
  103. time
  104. unspecific ;record
  105. vm-extension
  106. wait
  107. weak-pointer-ref
  108. weak-pointer?
  109. make-transport-link-cell
  110. transport-link-cell?
  111. transport-link-cell-key
  112. transport-link-cell-value
  113. set-transport-link-cell-value!
  114. transport-link-cell-tconc
  115. set-transport-link-cell-tconc!
  116. transport-link-cell-next
  117. set-transport-link-cell-next!
  118. write-byte
  119. write-char
  120. char->utf
  121. utf->char))
  122. (define-interface syntax-transformers-interface
  123. (export make-explicit-renaming-transformer/4
  124. explicit-renaming-transformer/4?
  125. explicit-renaming-transformer/4-proc))
  126. (define-interface bitwise-interface
  127. (export arithmetic-shift
  128. bitwise-not
  129. bit-count
  130. ((bitwise-and bitwise-ior bitwise-xor)
  131. (proc (&rest :exact-integer) :exact-integer))))
  132. (define-interface cells-interface
  133. (export cell?
  134. make-cell
  135. cell-ref
  136. cell-set!))
  137. (define-interface records-interface
  138. (export make-record
  139. record
  140. record?
  141. record-type
  142. record-length
  143. record-ref
  144. record-set!))
  145. (define-interface locations-interface
  146. (export location?
  147. location-defined?
  148. location-assigned?
  149. location-id
  150. set-location-id!
  151. make-undefined-location
  152. set-location-defined?!
  153. contents
  154. set-contents!))
  155. (define-interface closures-interface
  156. (export closure?
  157. make-closure
  158. closure-env set-closure-env!
  159. closure-template set-closure-template!))
  160. (define-interface byte-vectors-interface
  161. (export byte-vector?
  162. byte-vector-length
  163. byte-vector-ref
  164. byte-vector-set!
  165. make-byte-vector
  166. ;; creates a byte-vector that will never be moved in a
  167. ;; garbage collection or raises an exception if the GC does
  168. ;; not support this feature.
  169. make-unmovable-byte-vector
  170. byte-vector=?
  171. byte-vector))
  172. ; Same again, but with old names for compatibility.
  173. (define-interface code-vectors-interface
  174. (export code-vector?
  175. code-vector-length
  176. code-vector-ref
  177. code-vector-set!
  178. make-code-vector))
  179. (define-interface channels-interface
  180. (export channel?
  181. channel-id
  182. channel-status
  183. channel-os-index
  184. open-channel
  185. close-channel
  186. channel-ready?
  187. channel-maybe-read
  188. channel-maybe-write
  189. channel-abort
  190. open-channels-list))
  191. (define-interface ports-interface
  192. (export port?
  193. make-port
  194. port-handler
  195. port-text-codec-spec set-port-text-codec-spec!
  196. port-crlf? set-port-crlf?!
  197. port-buffer
  198. port-lock set-port-lock!
  199. port-status set-port-status!
  200. port-data set-port-data!
  201. port-index set-port-index!
  202. port-limit set-port-limit!
  203. port-pending-cr? set-port-pending-cr?!
  204. port-pending-eof? set-port-pending-eof?!
  205. provisional-port-status provisional-set-port-status!
  206. provisional-port-index provisional-set-port-index!
  207. provisional-port-limit provisional-set-port-limit!
  208. provisional-port-lock provisional-set-port-lock!
  209. provisional-port-pending-cr?
  210. provisional-set-port-pending-cr?!
  211. provisional-port-pending-eof?
  212. provisional-set-port-pending-eof?!))
  213. (define-interface condvars-interface
  214. (export make-condvar
  215. condvar?
  216. maybe-commit-and-wait-for-condvar
  217. maybe-commit-and-set-condvar!
  218. condvar-value set-condvar-value!
  219. condvar-has-value? set-condvar-has-value?!))
  220. (define-interface shared-bindings-interface
  221. (export shared-binding?
  222. shared-binding-is-import?
  223. shared-binding-name
  224. shared-binding-ref
  225. shared-binding-set!
  226. lookup-imported-binding
  227. define-imported-binding
  228. undefine-imported-binding
  229. lookup-exported-binding
  230. define-exported-binding
  231. undefine-exported-binding
  232. find-undefined-imported-bindings))
  233. (define-interface low-proposals-interface
  234. (export make-proposal
  235. current-proposal
  236. set-current-proposal!
  237. maybe-commit
  238. provisional-car
  239. provisional-cdr
  240. provisional-set-car!
  241. provisional-set-cdr!
  242. provisional-cell-ref
  243. provisional-cell-set!
  244. provisional-vector-ref
  245. provisional-vector-set!
  246. provisional-byte-vector-ref
  247. provisional-byte-vector-set!
  248. provisional-checked-record-ref
  249. provisional-checked-record-set!
  250. attempt-copy-bytes!))
  251. (define-interface proposals-interface
  252. (export ((ensure-atomicity
  253. ensure-atomicity!
  254. atomically
  255. atomically!
  256. with-new-proposal) :syntax)
  257. maybe-commit
  258. proposal-active?
  259. remove-current-proposal!
  260. invalidate-current-proposal!
  261. call-ensuring-atomicity
  262. call-ensuring-atomicity!
  263. call-atomically
  264. call-atomically!
  265. provisional-car
  266. provisional-cdr
  267. provisional-set-car!
  268. provisional-set-cdr!
  269. provisional-cell-ref
  270. provisional-cell-set!
  271. provisional-vector-ref
  272. provisional-vector-set!
  273. provisional-byte-vector-ref
  274. provisional-byte-vector-set!
  275. (define-synchronized-record-type :syntax)
  276. define-record-discloser ;users are likely to want it
  277. attempt-copy-bytes!))
  278. ; Miscellaneous useful procedures used in various random places.
  279. ; These are used in the byte-code compiler and the linker and so have
  280. ; alternative implementations in alt/...
  281. (define-interface features-interface
  282. (export immutable?
  283. make-immutable!
  284. string-hash
  285. force-output
  286. current-noise-port))
  287. ; Another hodge-podge.
  288. (define-interface low-level-interface
  289. (export vector-unassigned? ;inspector
  290. cell-unassigned?)) ;disclosers
  291. (define-interface vm-exposure-interface
  292. (export invoke-closure ;eval
  293. primitive-catch)) ;shadowing, start, command
  294. (define-interface escapes-interface
  295. (export primitive-cwcc
  296. with-continuation))
  297. (define-interface ascii-interface
  298. (export ascii->char
  299. char->ascii
  300. ascii-limit
  301. ascii-whitespaces))
  302. (define-interface unicode-interface
  303. (export scalar-value->char
  304. char->scalar-value
  305. scalar-value?))
  306. ; Level 1: The rest of Scheme except for I/O.
  307. (define-interface scheme-level-1-adds-interface
  308. (export ((case delay quasiquote syntax-rules) :syntax)
  309. abs
  310. append assoc assv
  311. boolean?
  312. caaaar caaadr caadar caaddr caaar caadr caar
  313. cadaar cadadr caddar cadddr cadar caddr cadr
  314. cdaaar cdaadr cdadar cdaddr cdaar cdadr cdar
  315. cddaar cddadr cdddar cddddr cddar cdddr cddr
  316. char-alphabetic?
  317. ceiling
  318. char-ci<=? char-ci<? char-ci=? char-ci>=? char-ci>?
  319. char-downcase char-lower-case? char-numeric?
  320. char-upcase
  321. char-upper-case? char-whitespace? char<=?
  322. char>=? char>?
  323. equal? eqv? even? expt
  324. for-each force
  325. gcd
  326. inexact?
  327. lcm length list list->string list->vector
  328. list? ;New in R4RS
  329. list-ref list-tail
  330. map max member memq memv min modulo
  331. negative? not null?
  332. odd?
  333. positive?
  334. rationalize
  335. reverse
  336. round
  337. string string->list
  338. string-append
  339. string-ci<=? string-ci<? string-ci=? string-ci>=? string-ci>?
  340. string-fill!
  341. string<=? string<? string=? string>=? string>?
  342. substring
  343. truncate
  344. vector->list vector-fill!
  345. zero?))
  346. (define-interface scheme-level-1-interface
  347. (compound-interface scheme-level-1-adds-interface
  348. scheme-level-0-interface))
  349. (define-interface util-interface
  350. (export any
  351. every
  352. filter
  353. fold fold->2 fold->3
  354. last
  355. posq
  356. posv
  357. posqual
  358. reduce
  359. sublist
  360. insert
  361. unspecific
  362. symbol-append
  363. x->boolean
  364. (receive :syntax)))
  365. ; Level 2 consists of harder things built on level 1.
  366. (define-interface records-internal-interface
  367. (export :record-type
  368. disclose-record
  369. initialize-records!))
  370. (define-interface record-types-interface
  371. (export make-record-type
  372. record-constructor
  373. record-standard-constructor
  374. record-accessor
  375. record-modifier
  376. record-predicate
  377. define-record-discloser
  378. define-record-resumer
  379. record-type?
  380. record-type<=?
  381. record-type-field-names
  382. record-type-name
  383. record-type-parent
  384. record-type-data
  385. record-type-size
  386. set-record-type-data!
  387. ))
  388. (define-interface define-record-types-interface
  389. (export (define-record-type :syntax)
  390. define-record-discloser))
  391. (define-interface methods-interface
  392. (export (define-generic :syntax)
  393. (define-method :syntax)
  394. (define-simple-type :syntax)
  395. <values>
  396. <value>
  397. <number>
  398. <complex>
  399. <real>
  400. <rational>
  401. <integer>
  402. <exact-integer>
  403. <boolean>
  404. <symbol>
  405. <char>
  406. <null>
  407. <pair>
  408. <vector>
  409. <string>
  410. <procedure>
  411. <input-port>
  412. <output-port>
  413. <eof-object>
  414. <record>
  415. :record-type
  416. <zero>
  417. singleton
  418. disclose &disclose))
  419. (define-interface meta-methods-interface
  420. (export type-predicate &type-predicate
  421. type-priority &type-priority
  422. type-superiors &type-superiors
  423. same-type? &same-type?
  424. add-method! &add-method!
  425. set-final-method!
  426. make-method-table
  427. method-table-get-perform
  428. make-simple-type
  429. ;; Hooks for DOODL or other future extension
  430. :simple-type :method-info :method-table :singleton
  431. make-generic
  432. (method-info :syntax)
  433. methods->perform))
  434. (define-interface number-i/o-interface
  435. (export number->string &number->string
  436. string->number
  437. really-string->number &really-string->number ;exactness argument
  438. string->integer))
  439. (define-interface fluids-interface
  440. (export make-fluid
  441. let-fluid
  442. let-fluids
  443. fluid
  444. fluid-cell-ref
  445. fluid-cell-set!
  446. set-fluid!)) ; deprecated
  447. (define-interface fluids-internal-interface
  448. (export initialize-dynamic-state!
  449. current-thread
  450. set-current-thread!
  451. get-dynamic-env ; wind.scm, env/command-level.scm
  452. set-dynamic-env! ; wind.scm, env/command-level.scm
  453. get-dynamic-point ; wind.scm
  454. set-dynamic-point!)) ; wind.scm
  455. (define-interface enumerated-interface
  456. (export (define-enumeration :syntax)
  457. (enum :syntax)
  458. (enumerand->name :syntax)
  459. (name->enumerand :syntax)))
  460. (define :enumeration :syntax)
  461. (define-interface low-exceptions-interface
  462. (export ((error
  463. assertion-violation
  464. implementation-restriction-violation
  465. warning note
  466. syntax-violation)
  467. (proc (:value :string &rest :value) :values))))
  468. (define-interface low-exceptions-internal-interface
  469. (export initialize-low-exception-procedures!))
  470. (define-interface handle-interface
  471. (export ignore-errors report-errors-as-warnings with-handler))
  472. (define-interface conditions-interface
  473. (export condition
  474. condition?
  475. simple-conditions
  476. condition-predicate
  477. condition-accessor
  478. define-condition-type
  479. &condition
  480. &message
  481. make-message-condition
  482. message-condition?
  483. condition-message
  484. &warning
  485. make-warning
  486. warning?
  487. &serious
  488. make-serious-condition
  489. serious-condition?
  490. &error
  491. make-error
  492. error?
  493. &violation
  494. make-violation
  495. violation?
  496. &non-continuable
  497. make-noncontinuable-violation
  498. non-continuable-violation?
  499. &implementation-restriction
  500. make-implementation-restriction-violation
  501. implementation-restriction-violation?
  502. &lexical
  503. make-lexical-violation
  504. lexical-violation?
  505. &syntax
  506. make-syntax-violation
  507. syntax-violation?
  508. &undefined
  509. make-undefined-violation
  510. undefined-violation?
  511. &assertion
  512. make-assertion-violation
  513. assertion-violation?
  514. &irritants
  515. make-irritants-condition
  516. irritants-condition?
  517. condition-irritants
  518. &who
  519. make-who-condition
  520. who-condition?
  521. condition-who
  522. &vm-exception make-vm-exception vm-exception?
  523. vm-exception-opcode vm-exception-reason
  524. &os-error make-os-error os-error?
  525. os-error-code
  526. &i/o-error make-i/o-error i/o-error?
  527. &i/o-port-error make-i/o-port-error i/o-port-error? i/o-error-port
  528. &decoding-error make-decoding-error decoding-error?
  529. decoding-error-encoding-name
  530. decoding-error-bytes decoding-error-start
  531. &note make-note note?
  532. &interrupt make-interrupt-condition interrupt-condition?
  533. interrupt-source
  534. decode-condition
  535. ))
  536. (define-interface wind-interface
  537. (export call-with-current-continuation
  538. dynamic-wind))
  539. (define-interface i/o-interface
  540. (export current-input-port current-output-port
  541. close-output-port close-input-port
  542. read-byte peek-byte write-byte byte-ready?
  543. read-char peek-char
  544. char-ready?
  545. write-char
  546. read-block write-block
  547. newline
  548. write-string ;write.scm
  549. with-current-ports
  550. current-error-port
  551. current-noise-port
  552. force-output ;xport.scm
  553. port-text-codec set-port-text-codec!
  554. output-port-ready?
  555. input-port?
  556. output-port?
  557. silently
  558. make-null-output-port))
  559. (define-interface text-codecs-interface
  560. (export spec->text-codec text-codec->spec
  561. text-codec? make-text-codec
  562. text-codec-names
  563. text-codec-decode-char-proc
  564. text-codec-encode-char-proc
  565. (define-text-codec :syntax)
  566. find-text-codec
  567. null-text-codec
  568. us-ascii-codec
  569. latin-1-codec
  570. utf-8-codec
  571. utf-16le-codec utf-16be-codec
  572. utf-32le-codec utf-32be-codec))
  573. (define-interface encodings-interface
  574. (export char-encoding-length
  575. string-encoding-length
  576. encode-char
  577. encode-string
  578. string->bytes-n
  579. string->bytes
  580. bytes-string-size
  581. decode-char
  582. decode-string
  583. bytes->string bytes->string-n
  584. char-encoding-length/utf-8
  585. string-encoding-length/utf-8
  586. encode-char/utf-8
  587. encode-string/utf-8
  588. string->utf-8-n
  589. string->utf-8
  590. bytes-string-size/utf-8
  591. decode-char/utf-8
  592. decode-string/utf-8
  593. utf-8->string utf-8->string-n
  594. (encoding-status :enumeration)
  595. (decoding-status :enumeration)))
  596. (define-interface os-strings-interface
  597. (export os-string?
  598. make-os-string
  599. string->os-string byte-vector->os-string x->os-string
  600. string->os-byte-vector x->os-byte-vector
  601. os-string->string os-string->byte-vector
  602. os-string-text-codec
  603. os-string=?
  604. call-with-os-string-text-codec
  605. current-os-string-text-codec))
  606. (define-interface i/o-internal-interface
  607. (export input-port-option ;read.scm
  608. output-port-option ;write.scm
  609. initialize-i/o ;init.scm
  610. initialize-i/o-handlers! ;init.scm
  611. disclose-port
  612. make-buffered-input-port
  613. make-buffered-output-port make-unbuffered-output-port
  614. make-port-handler
  615. port-handler-discloser port-handler-close
  616. port-handler-byte port-handler-char port-handler-block
  617. port-handler-ready? port-handler-force
  618. make-buffered-input-port-handler
  619. make-buffered-output-port-handler
  620. make-unbuffered-output-port-handler
  621. ;port-handler-buffer-proc ; extended-ports
  622. default-buffer-size
  623. open-input-port?
  624. open-input-port-status
  625. make-input-port-closed!
  626. open-output-port?
  627. open-output-port-status
  628. make-output-port-closed!
  629. eof-object ; users will probably want this
  630. note-buffer-reuse!
  631. check-buffer-timestamp!
  632. force-output-if-open
  633. periodically-force-output!
  634. periodically-flushed-ports
  635. output-port-forcers
  636. call-with-current-input-port
  637. call-with-current-output-port
  638. call-with-current-noise-port))
  639. (define-interface channel-i/o-interface
  640. (export channel-maybe-commit-and-read
  641. channel-maybe-commit-and-write
  642. channel-maybe-commit-and-close
  643. channel-write
  644. initialize-channel-i/o! ;scheduler
  645. zap-i/o-orphans! ;root-scheduler
  646. ; call this with interrupts disabled
  647. wait-for-channel)) ;big/socket.scm
  648. (define-interface channel-ports-interface
  649. (export call-with-input-file call-with-output-file
  650. with-input-from-file with-output-to-file
  651. open-input-file open-output-file
  652. input-channel->port ;usual-resumer, posix
  653. output-channel->port ;usual-resumer, posix
  654. input-channel+closer->port ;big/socket.scm
  655. output-channel+closer->port ;big/socket.scm
  656. port->channel ;posix
  657. force-channel-output-ports!)) ;posix
  658. (define-interface threads-interface
  659. (export thread?
  660. thread-name thread-uid ;for debugging
  661. current-thread
  662. spawn
  663. relinquish-timeslice
  664. sleep
  665. terminate-current-thread))
  666. (define-interface threads-internal-interface
  667. (export make-thread
  668. thread-data set-thread-data!
  669. thread-continuation ;debugger
  670. thread-uid->thread ;expensive!
  671. thread-scheduler set-thread-scheduler!
  672. thread-dynamic-env set-thread-dynamic-env!
  673. set-thread-arguments!
  674. event-pending?
  675. get-next-event!
  676. schedule-event
  677. (event-type :syntax)
  678. run
  679. running?
  680. maybe-commit-and-block
  681. maybe-commit-and-block-on-queue
  682. maybe-commit-and-make-ready
  683. maybe-commit-no-interrupts
  684. threads-not-deadlocked-count
  685. spawn-on-scheduler spawn-on-root
  686. wait-for-event
  687. upcall propogate-upcall
  688. interrupt-thread
  689. kill-thread!
  690. terminate-thread!
  691. make-deadlock-condition deadlock-condition?
  692. thread-queue-empty?
  693. maybe-dequeue-thread!
  694. register-dozer!
  695. wake-some-threads
  696. all-threads ; for command-levels
  697. with-threads)) ; rts/init.scm
  698. (define-interface scheduler-interface
  699. (export run-threads
  700. run-threads-with-housekeeper
  701. round-robin-event-handler
  702. make-counter ; for thread counts
  703. counter-value set-counter!
  704. increment-counter!
  705. decrement-counter!))
  706. (define-interface queues-interface
  707. (export queue?
  708. ;; Constructors.
  709. make-queue
  710. list->queue
  711. ;; Queue operations.
  712. queue-empty?
  713. enqueue!
  714. enqueue-many!
  715. queue-head-or-thunk
  716. queue-head-or-value
  717. queue-head
  718. maybe-queue-head
  719. dequeue-or-thunk!
  720. dequeue-or-value!
  721. dequeue!
  722. maybe-dequeue!
  723. empty-queue!
  724. ;; The following operations are *very* slow, and may be
  725. ;; removed in a future revision.
  726. queue->list
  727. queue-length
  728. on-queue?
  729. delete-from-queue!))
  730. (define-interface queues-internal-interface
  731. ;; Exported for testing.
  732. (export list->queue-list))
  733. (define-interface exceptions-interface
  734. (compound-interface (export with-exception-handler
  735. raise raise-continuable
  736. (guard :syntax)
  737. (assert :syntax))
  738. low-exceptions-interface))
  739. (define-interface exceptions-internal-interface
  740. (export initialize-exceptions!
  741. really-signal-condition))
  742. (define-interface signal-conditions-interface
  743. (export signal-condition))
  744. (define-interface vm-exceptions-interface
  745. (export define-vm-exception-handler
  746. initialize-vm-exceptions!
  747. extend-opcode!
  748. signal-vm-exception
  749. vm-exception-reason->message))
  750. (define-interface interrupts-interface
  751. (export initialize-interrupts! ;init.scm
  752. all-interrupts
  753. no-interrupts
  754. ;reset-timer-interrupts!
  755. set-interrupt-handler!
  756. get-interrupt-handler
  757. interrupt-condition?
  758. ;set-timer-interrupt!
  759. schedule-interrupt
  760. set-enabled-interrupts! ;command.scm
  761. enabled-interrupts
  762. enable-interrupts!
  763. disable-interrupts!
  764. with-interrupts-allowed
  765. with-interrupts-inhibited
  766. call-after-gc!
  767. call-before-heap-overflow!
  768. (interrupt :syntax)))
  769. (define-interface external-events-interface
  770. (export initialize-external-events! ;init.scm
  771. zap-external-event-orphans! ;root-scheduler.scm
  772. register-condvar-for-external-event!
  773. wait-for-external-event
  774. new-external-event-uid
  775. new-external-event
  776. unregister-external-event-uid!))
  777. (define-interface writing-interface
  778. (export write
  779. display
  780. recurring-write))
  781. (define-interface reading-interface
  782. (export read
  783. define-sharp-macro ;command.scm
  784. reading-error
  785. gobble-line
  786. sub-read sub-read-carefully))
  787. ; Level 2: the harder stuff.
  788. ; Various primitives get numeric types and promoted to n-ary at this point.
  789. (define-interface scheme-level-2-adds-interface
  790. (export (char-ready? (proc (&opt :input-port) :boolean))
  791. call-with-current-continuation
  792. call-with-input-file call-with-output-file
  793. current-input-port current-output-port
  794. dynamic-wind ;New in R5RS
  795. close-input-port close-output-port
  796. open-input-file open-output-file
  797. with-input-from-file with-output-to-file
  798. number->string string->number
  799. read-char peek-char write-char
  800. newline display write
  801. read))
  802. (define-interface scheme-level-2-interface
  803. (compound-interface scheme-level-2-adds-interface
  804. scheme-level-1-interface))
  805. (define-interface scheme-adds-interface
  806. (export eval load
  807. interaction-environment
  808. scheme-report-environment
  809. null-environment))
  810. (define-interface scheme-interface
  811. (compound-interface scheme-adds-interface
  812. scheme-level-2-interface))
  813. (define-interface continuations-interface
  814. (export continuation-arg
  815. continuation-arg-count
  816. continuation-cont
  817. continuation-pc
  818. continuation-code
  819. continuation-template
  820. continuation?
  821. <continuation>
  822. vm-exception-continuation?
  823. vm-exception-continuation-exception
  824. continuation-preview)) ; env/debug.scm
  825. (define-interface templates-interface
  826. (export make-template
  827. template-code
  828. template-byte-code
  829. template-info
  830. template-package-id
  831. template-length
  832. template-ref
  833. template-overhead
  834. set-template-code!
  835. set-template-byte-code!
  836. set-template-info!
  837. set-template-package-id!
  838. template-set!
  839. template?))
  840. (define-interface weak-interface
  841. (export weak-pointer? ;disclosers.scm
  842. weak-pointer-ref
  843. make-weak-pointer
  844. make-population
  845. add-to-population!
  846. population->list
  847. walk-population))
  848. (define-interface filenames-interface
  849. (export namestring *scheme-file-type* *load-file-type*
  850. file-name-directory
  851. file-name-nondirectory
  852. translate
  853. set-global-translation!
  854. set-translation!
  855. make-translations with-translations
  856. current-translations))
  857. ; Things for the compiler.
  858. (define-interface general-tables-interface
  859. (export make-table
  860. make-string-table
  861. make-symbol-table
  862. make-integer-table
  863. make-datum-table
  864. make-table-maker
  865. table?
  866. table-size
  867. table-ref
  868. table-set!
  869. table-walk table->entry-list
  870. make-table-immutable!
  871. table-string-hash table-symbol-hash
  872. number-hash
  873. string-hash symbol-hash datum-hash
  874. default-hash-function))
  875. ;----------------
  876. ; Beginning of compiler interfaces
  877. (define-interface usual-macros-interface
  878. (export usual-transform))
  879. (define-interface meta-types-interface
  880. (export ; same-type? ; conflicts with `same-type?' from methods
  881. subtype?
  882. meet?
  883. join-type
  884. meet-type
  885. sexp->type type->sexp rail-type->sexp
  886. syntax-type
  887. any-values-type
  888. any-arguments-type
  889. value-type value-type?
  890. error-type
  891. make-some-values-type
  892. empty-rail-type
  893. rail-type
  894. make-optional-type
  895. make-rest-type
  896. empty-rail-type?
  897. rest-type?
  898. head-type
  899. tail-type
  900. procedure-type
  901. procedure-type-domain
  902. procedure-type-codomain
  903. restrictive?
  904. procedure-type?
  905. fixed-arity-procedure-type?
  906. procedure-type-argument-types
  907. procedure-type-arity
  908. any-procedure-type
  909. (proc :syntax)
  910. boolean-type
  911. char-type
  912. null-type
  913. unspecific-type
  914. exact-integer-type
  915. integer-type
  916. rational-type
  917. real-type
  918. complex-type
  919. number-type
  920. exact-type
  921. inexact-type
  922. pair-type
  923. string-type
  924. symbol-type
  925. vector-type
  926. escape-type
  927. structure-type
  928. ;; Stuff moved back from syntactic - why was it moved there?
  929. variable-type
  930. variable-type?
  931. variable-value-type
  932. usual-variable-type
  933. undeclared-type
  934. compatible-types?))
  935. (define-interface names-interface
  936. (export name?
  937. name->symbol
  938. make-name-generator
  939. generate-name ;qualified->name in opt/inline.scm
  940. generated?
  941. generated-name
  942. generated-token
  943. generated-env
  944. generated-parent-name
  945. generated-uid
  946. make-name-table
  947. make-qualified
  948. qualified?
  949. qualified-parent-name
  950. qualified-symbol
  951. qualified-uid
  952. desyntaxify
  953. ))
  954. (define-interface transforms-interface
  955. (export make-transform/macro
  956. make-transform/inline
  957. maybe-apply-macro-transform
  958. apply-inline-transform
  959. transform?
  960. transform-kind
  961. transform-type
  962. transform-env ; These are used to reify transforms.
  963. transform-aux-names
  964. transform-source
  965. transform-id
  966. make-transform)) ; backwards compatibility
  967. (define-interface bindings-interface
  968. (export binding?
  969. make-binding
  970. binding-place
  971. set-binding-place! ;for package mutation, used in package.scm
  972. binding-static
  973. set-binding-static! ; for letrec-syntax
  974. binding-type
  975. clobber-binding!
  976. maybe-fix-place!
  977. forget-integration
  978. impose-type
  979. same-denotation?
  980. ))
  981. ;----------------
  982. ; Syntactic interfaces
  983. (define-interface compiler-envs-interface
  984. (export make-compiler-env ; re-exported by syntactic
  985. compiler-env?
  986. lookup
  987. bind1 bind
  988. bind-source-file-name ; re-exported by syntactic
  989. source-file-name
  990. comp-env-macro-eval
  991. comp-env-define!
  992. extract-package-from-comp-env)) ; temporary
  993. (define-interface syntactic-interface
  994. (export expand
  995. expand-form
  996. scan-forms
  997. expand-scanned-form
  998. syntax?
  999. static-value
  1000. make-compiler-env
  1001. bind-source-file-name))
  1002. (define-interface syntax-rules-data-interface
  1003. (export make-pattern-variable
  1004. pattern-variable?
  1005. pattern-variable-name
  1006. pattern-variable-rank
  1007. make-ellipsis-form
  1008. ellipsis-form?
  1009. ellipsis-form-body
  1010. ellipsis-form-vars
  1011. make-vector-marker
  1012. vector-marker?
  1013. vector-marker-contents))
  1014. (define-interface syntax-rules-apply-interface
  1015. (export apply-rules))
  1016. (define-interface nodes-interface
  1017. (export make-node
  1018. node?
  1019. node-operator
  1020. node-operator-id
  1021. node-form
  1022. node-ref
  1023. node-set!
  1024. node-predicate
  1025. make-similar-node
  1026. force-node
  1027. schemify
  1028. name->qualified
  1029. get-operator
  1030. make-operator-table
  1031. operator-name
  1032. operator-nargs
  1033. operator-table-ref
  1034. operator-define!
  1035. operator-lookup
  1036. operator-type
  1037. operator-uid
  1038. operator?
  1039. operators-table ;config.scm comp-package.scm
  1040. lambda-node?
  1041. flat-lambda-node?
  1042. name-node?
  1043. call-node?
  1044. literal-node?
  1045. quote-node?
  1046. define-node?
  1047. loophole-node?
  1048. operator/flat-lambda
  1049. operator/lambda
  1050. operator/set!
  1051. operator/call
  1052. operator/begin
  1053. operator/name
  1054. operator/letrec
  1055. operator/letrec*
  1056. operator/pure-letrec
  1057. operator/literal
  1058. operator/quote
  1059. operator/unassigned
  1060. operator/unspecific
  1061. operator/define
  1062. operator/define-syntax
  1063. operator/primitive-procedure
  1064. operator/structure-ref
  1065. ))
  1066. ;----------------
  1067. ; Compiler interfaces
  1068. (define-interface segments-interface
  1069. (export attach-label
  1070. byte-limit two-byte-limit
  1071. high-byte low-byte
  1072. empty-segment
  1073. instruction
  1074. instruction-using-label
  1075. using-optional-label
  1076. jump-instruction
  1077. computed-goto-instruction
  1078. stack-shuffle-instruction
  1079. continuation-data
  1080. lambda-protocol nary-lambda-protocol
  1081. nary-primitive-protocol continuation-protocol
  1082. cwv-continuation-protocol
  1083. make-dispatch-protocol
  1084. make-label label?
  1085. label-reference
  1086. note-environment
  1087. note-source-code
  1088. segment->cv segment->template
  1089. segment-size
  1090. sequentially
  1091. with-package-key))
  1092. (define-interface compiler-interface
  1093. (export compile-forms
  1094. make-startup-procedure ;link/link.scm
  1095. set-type-check?! ; for timings
  1096. define-compilator ;assem.scm
  1097. deliver-value ;assem.scm
  1098. ))
  1099. (define-interface bc-generation-interface
  1100. (export call-instruction
  1101. stack-ref-instruction
  1102. stack-set!-instruction
  1103. stack-indirect-instruction
  1104. integer-literal-instruction
  1105. push+stack-ref-instruction
  1106. push+stack-indirect-instruction
  1107. push-instruction))
  1108. (define-interface frames-interface
  1109. (export make-frame
  1110. frame-size
  1111. frame-literals
  1112. frame-debug-data
  1113. template-offset
  1114. environment-offset
  1115. depth-check!
  1116. index->offset
  1117. literal->index
  1118. binding->index))
  1119. (define-interface primops-interface
  1120. (export define-compiler-primitive
  1121. primop?
  1122. primop-name
  1123. primop-type
  1124. primop-closed
  1125. primop-compilator
  1126. get-primop
  1127. walk-primops ;comp-package.scm
  1128. ))
  1129. (define-interface debug-data-interface
  1130. (export debug-data-env-maps
  1131. debug-data-env-shape
  1132. debug-data-name
  1133. debug-data-parent
  1134. debug-data-jump-back-dests
  1135. debug-data-source
  1136. debug-data-uid
  1137. debug-data?
  1138. get-debug-data))
  1139. (define-interface debug-data-internal-interface
  1140. (export make-debug-data
  1141. set-debug-data-source!
  1142. set-debug-data-env-maps!
  1143. set-debug-data-jump-back-dests!
  1144. debug-flag-names ; keep and flush commands
  1145. debug-flag-accessor
  1146. debug-flag-modifier
  1147. debug-data-table
  1148. with-fresh-compiler-state ;for linker
  1149. keep-source-code? ;for bcomp
  1150. keep-environment-maps?
  1151. keep-file-names?
  1152. keep-procedure-names?
  1153. new-debug-data
  1154. debug-data->info))
  1155. ;----------------
  1156. ; Module interfaces
  1157. ; Interfaces.
  1158. (define-interface interfaces-interface
  1159. (export make-simple-interface
  1160. make-compound-interface
  1161. make-modified-interface-maker
  1162. note-reference-to-interface!
  1163. interface-ref
  1164. interface-member?
  1165. interface?
  1166. interface-clients
  1167. for-each-declaration
  1168. note-interface-name!))
  1169. ; Packages.
  1170. (define-interface packages-interface
  1171. (export make-package
  1172. make-simple-package ;start.scm
  1173. make-structure
  1174. make-modified-structure
  1175. package-define!
  1176. package-lookup
  1177. package? ;command.scm
  1178. structure-lookup ;env.scm
  1179. generic-lookup ;inline.scm
  1180. structure-interface ;config.scm
  1181. package->environment
  1182. link!
  1183. structure?
  1184. package-uid ;reifier
  1185. make-new-location ;ctop.scm
  1186. structure-package
  1187. note-structure-name!
  1188. (:package :type)))
  1189. (define-interface packages-internal-interface
  1190. (export package-loaded? ;env/load-package.scm
  1191. set-package-loaded?! ;env/load-package.scm
  1192. package-name
  1193. flush-location-names
  1194. package-name-table ;debuginfo
  1195. location-info-table ;debuginfo, disclosers
  1196. package-definition
  1197. package-unstable? ;env/pacman.scm
  1198. environment-stable? ;comp/schemify.scm
  1199. package-integrate? ;env/debug.scm
  1200. package-add-static! ;opt/analyze.scm
  1201. package-refine-type! ;opt/usage.scm
  1202. ;; For scanner
  1203. for-each-export
  1204. package-accesses
  1205. package-clauses
  1206. package-file-name
  1207. package-reader set-package-reader!
  1208. package-opens
  1209. set-package-integrate?!
  1210. structure-name
  1211. ;; For package mutation
  1212. for-each-definition
  1213. set-package-opens!
  1214. set-structure-interface!
  1215. set-package-opens-thunk!
  1216. structure-clients
  1217. package-opens-thunk
  1218. package-opens-really
  1219. package-undefineds
  1220. package-undefined-but-assigneds
  1221. package-note-caching!
  1222. structure-interface-really
  1223. make-new-location
  1224. $get-location
  1225. set-package-get-location!
  1226. initialize-structure!
  1227. initialize-package!
  1228. location-for-reference
  1229. package-cached
  1230. package-definitions
  1231. package-clients))
  1232. (define-interface scan-package-interface
  1233. (export collect-packages
  1234. package-source
  1235. package-optimizer-names
  1236. check-structure))
  1237. (define-interface optimizer-interface
  1238. (export set-optimizer!
  1239. get-optimizer))
  1240. (define-interface undefined-interface
  1241. (export noting-undefined-variables
  1242. $note-undefined ;env/command.scm
  1243. ))
  1244. ;----------------
  1245. ; Inlining
  1246. (define-interface inline-interface
  1247. (export make-inline-transform
  1248. inline-transform ;bcomp/for-reify.scm
  1249. qualified->name))
  1250. (define-interface usages-interface
  1251. (export find-usages
  1252. find-node-usages
  1253. usage-name-node
  1254. usage-reference-count
  1255. usage-operator-count
  1256. usage-assignment-count))
  1257. ; End of compiler interfaces
  1258. ;----------------
  1259. (define-interface environments-interface ;cheesy
  1260. (export *structure-ref
  1261. environment-define!
  1262. environment-ref
  1263. environment-set!
  1264. interaction-environment
  1265. make-syntactic-tower
  1266. make-reflective-tower ; backwards compatibility for PreScheme compiler
  1267. scheme-report-environment
  1268. null-environment
  1269. set-interaction-environment!
  1270. set-scheme-report-environment!
  1271. with-interaction-environment
  1272. set-syntactic-tower-maker!
  1273. set-reflective-tower-maker! ; backwards compatibility for PreScheme compiler
  1274. set-reader!))
  1275. (define-interface defpackage-interface
  1276. (export ((def ;Formerly define-structure
  1277. define-interface ;Formerly define-signature
  1278. define-structures ;Formerly define-package
  1279. define-structure
  1280. define-module
  1281. define-syntax
  1282. define-reader
  1283. define-syntactic-tower-maker
  1284. export-syntactic-tower-maker
  1285. export-reflective-tower-maker ; backwards compatibility for PreScheme compiler
  1286. compound-interface
  1287. modify subset with-prefix
  1288. export
  1289. structure structures let ; New
  1290. begin ; mostly for macros
  1291. define ; for compatibility?
  1292. a-package) ; cf. env/init-defpackage.scm
  1293. :syntax)
  1294. values
  1295. interface-of
  1296. set-verify-later!))
  1297. (define-interface types-interface
  1298. (export ((:syntax :values :arguments :value) :type)
  1299. (procedure (proc (:type :type) :type)) ; (procedure T1 T2)
  1300. (proc :syntax) ; (proc (T1 ... Tn) T)
  1301. ((:boolean
  1302. :char
  1303. :number
  1304. :complex :real :rational :integer :exact-integer
  1305. :null
  1306. :unspecific
  1307. :pair
  1308. :string
  1309. :symbol
  1310. :vector
  1311. :procedure
  1312. :input-port :output-port
  1313. :error
  1314. :escape)
  1315. :type)
  1316. (:structure :type)
  1317. :type)) ;Holy stratification, Batman!
  1318. (define-interface evaluation-interface
  1319. (export eval load load-into load-script-into eval-from-file
  1320. ; eval-scanned-forms
  1321. ))
  1322. (define-interface load-filenames-interface
  1323. (export with-load-filename
  1324. current-load-filename))
  1325. ; Bindings needed by the form composed by REIFY-STRUCTURES.
  1326. (define-interface for-reification-interface
  1327. (export operator
  1328. simple-interface
  1329. package
  1330. transform
  1331. primop
  1332. ;; From usual-macros
  1333. usual-transform
  1334. ;; From inline
  1335. inline-transform
  1336. ;; From packages
  1337. package-define-static!
  1338. ;; From primops
  1339. make-structure
  1340. ))
  1341. ;(define-interface command-interface ...) -- moved to more-interfaces.scm