Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Initial commit -- starting from RScheme 0.7.3.4b7

  • Loading branch information...
commit 9328bb97c8922c7a7faa39f23449478ba307fc7f 0 parents
authored October 04, 2009

Showing 301 changed files with 30,728 additions and 0 deletions. Show diff stats Hide diff stats

  1. 25  COPYING
  2. 138  INSTALL
  3. 212  Makefile
  4. 235  README
  5. 728  bytcodes/bcdefs.dat
  6. 118  bytcodes/bvecs.dat
  7. 53  bytcodes/check.dat
  8. 48  bytcodes/floatops.dat
  9. 38  bytcodes/loadbyt.scm
  10. 90  bytcodes/longint.dat
  11. 687  bytcodes/primops.dat
  12. 329  bytcodes/primtype.scm
  13. 27  bytcodes/setup.scm
  14. 113  cleanfiles
  15. 52  compiler/amlstubs.scm
  16. 99  compiler/boot/bindboot.scm
  17. 133  compiler/boot/bootable.scm
  18. 60  compiler/boot/handcraft.scm
  19. 287  compiler/boot/makeinit.scm
  20. 55  compiler/boot/replace.scm
  21. 177  compiler/c.scm
  22. 369  compiler/cgen/assem.scm
  23. 260  compiler/cgen/bldfiles.scm
  24. 43  compiler/cgen/estsize.scm
  25. 498  compiler/cgen/parts.scm
  26. 114  compiler/cgen/wrvinsn.scm
  27. 34  compiler/config.scm
  28. 115  compiler/configv.scm
  29. 40  compiler/misc.scm
  30. 43  compiler/mkcfg
  31. 159  compiler/mki.scm
  32. 53  compiler/mkrsc
  33. 124  compiler/modules/bldctx.scm
  34. 89  compiler/modules/def.scm
  35. 75  compiler/modules/deffull.scm
  36. 93  compiler/modules/defglue.scm
  37. 103  compiler/modules/defprim.scm
  38. 66  compiler/modules/defsyntx.scm
  39. 78  compiler/modules/document.scm
  40. 26  compiler/modules/expnvirt.scm
  41. 64  compiler/modules/findhier.scm
  42. 93  compiler/modules/findmodl.scm
  43. 117  compiler/modules/imported.scm
  44. 1,223  compiler/modules/mcfload.scm
  45. 635  compiler/modules/parseglue.scm
  46. 120  compiler/modules/use.scm
  47. 196  compiler/process.scm
  48. 118  compiler/resource/buildenv/postambl.mak
  49. 184  compiler/target.scm
  50. 30  compiler/toplevel/builtin.scm
  51. 504  compiler/toplevel/compileclass.scm
  52. 246  compiler/toplevel/make.scm
  53. 164  compiler/util/config-release.scm
  54. 477  compiler/util/genbcode.scm
  55. 95  compiler/util/resource.scm
  56. 21  compiler/util/util.scm
  57. 51  doc/Makefile
  58. 200  doc/articles/persistence/bibliography.xml
  59. 86  doc/articles/persistence/cloud.scm
  60. 49  doc/articles/persistence/extraheapptrs.scm
  61. 40  doc/articles/persistence/figures-util.scm
  62. 384  doc/articles/persistence/gc.xml
  63. 157  doc/articles/persistence/gcdiskusage.scm
  64. 37  doc/articles/persistence/gcfreeorder.scm
  65. 145  doc/articles/persistence/gcphases.scm
  66. 67  doc/articles/persistence/gcstart1.scm
  67. 71  doc/articles/persistence/graphic-styles.scm
  68. 119  doc/articles/persistence/heappic.scm
  69. 28  doc/articles/persistence/indirpod.scm
  70. 98  doc/articles/persistence/indirswiz.scm
  71. 56  doc/articles/persistence/intergen.scm
  72. 157  doc/articles/persistence/lsslayout.scm
  73. 51  doc/articles/persistence/lssrecord.scm
  74. 510  doc/articles/persistence/matrix-tool.scm
  75. 730  doc/articles/persistence/matrixpic.scm
  76. 81  doc/articles/persistence/mempic.scm
  77. 90  doc/articles/persistence/pagelist.scm
  78. 51  doc/articles/persistence/pagesinmem.scm
  79. 545  doc/articles/persistence/paper.tex
  80. 851  doc/articles/persistence/persistence.xml
  81. 73  doc/articles/persistence/ref-create.xml
  82. 105  doc/articles/persistence/ref-open.xml
  83. 2  doc/articles/persistence/ref.xml
  84. 66  doc/articles/persistence/serzpage.scm
  85. 94  doc/articles/persistence/serzstack.scm
  86. 36  doc/articles/persistence/symindirpp.scm
  87. 129  doc/articles/persistence/vmprlists.scm
  88. 62  doc/articles/persistence/wbmatrixactive.scm
  89. 21  doc/articles/persistence/wbmatrixgen.scm
  90. 57  doc/articles/tools/assign-ids.scm
  91. 107  doc/articles/tools/breakup.scm
  92. 23  doc/articles/tools/common.scm
  93. 115  doc/articles/tools/expand-entities.scm
  94. 240  doc/articles/tools/graphic-script.scm
  95. 68  doc/articles/tools/helloworld.scm
  96. 51  doc/articles/tools/main.scm
  97. 157  doc/articles/tools/make-article.scm
  98. 53  doc/articles/tools/numbering.scm
  99. 113  doc/articles/tools/style-driver.scm
  100. 47  doc/articles/tools/util.scm
  101. 91  doc/articles/tools/web-biblio.scm
  102. 90  doc/articles/tools/web-refentry.scm
  103. 255  doc/articles/tools/web-style.scm
  104. 39  doc/bookbody.sgml
  105. 48  doc/bookinfo.sgml
  106. 18  doc/chaps/calendar.sgml
  107. 255  doc/chaps/ccode.sgml
  108. 115  doc/chaps/cli.sgml
  109. 41  doc/chaps/control.sgml
  110. 79  doc/chaps/data.sgml
  111. 41  doc/chaps/debug.sgml
  112. 346  doc/chaps/debug2.sgml
  113. 14  doc/chaps/defmodule.sgml
  114. 391  doc/chaps/earley.sgml
  115. 74  doc/chaps/excepts.sgml
  116. 14  doc/chaps/glossary.sgml
  117. 233  doc/chaps/http.sgml
  118. 18  doc/chaps/inet.sgml
  119. 73  doc/chaps/intro.sgml
  120. 47  doc/chaps/io.sgml
  121. 98  doc/chaps/lists.sgml
  122. 146  doc/chaps/modules.sgml
  123. 86  doc/chaps/objsys.sgml
  124. 73  doc/chaps/paths.sgml
  125. 73  doc/chaps/pg95.sgml
  126. 106  doc/chaps/posix.sgml
  127. 31  doc/chaps/procs.sgml
  128. 360  doc/chaps/programs.sgml
  129. 136  doc/chaps/rstore.sgml
  130. 154  doc/chaps/string.sgml
  131. 36  doc/chaps/tables.sgml
  132. 120  doc/chaps/threads.sgml
  133. 32  doc/chaps/unix.sgml
  134. 45  doc/chaps/vectors.sgml
  135. 59  doc/decl.sgml
  136. 2,398  doc/docbook3.dsl
  137. 17  doc/figs/Makefile
  138. 17  doc/figs/list1.ofig
  139. 28  doc/figs/list2.ofig
  140. 18  doc/figs/list3.ofig
  141. 1  doc/figs/str1.strfig
  142. 247  doc/gen-ref-entry.scm
  143. 15  doc/obtain.sgml
  144. 20  doc/ref/abt.sgml
  145. 44  doc/ref/accept-client.sgml
  146. 47  doc/ref/accessmask.sgml
  147. 52  doc/ref/alloc-indirect-pages.sgml
  148. 55  doc/ref/appdirs.sgml
  149. 49  doc/ref/append.sgml
  150. 48  doc/ref/append1.sgml
  151. 54  doc/ref/apppath.sgml
  152. 31  doc/ref/bind.sgml
  153. 30  doc/ref/break.sgml
  154. 20  doc/ref/bt.sgml
  155. 43  doc/ref/car.sgml
  156. 43  doc/ref/cdr.sgml
  157. 45  doc/ref/char-ready.sgml
  158. 38  doc/ref/chmod.sgml
  159. 44  doc/ref/chown.sgml
  160. 32  doc/ref/clock.sgml
  161. 45  doc/ref/clockthunk.sgml
  162. 32  doc/ref/close-input-port.sgml
  163. 36  doc/ref/close-output-port.sgml
  164. 55  doc/ref/commit.sgml
  165. 51  doc/ref/cons.sgml
  166. 48  doc/ref/create-persistent-store.sgml
  167. 33  doc/ref/current-input-port.sgml
  168. 33  doc/ref/current-output-port.sgml
  169. 33  doc/ref/current-thread-group.sgml
  170. 32  doc/ref/current-thread.sgml
  171. 44  doc/ref/date-string.sgml
  172. 54  doc/ref/date-time.sgml
  173. 52  doc/ref/date-week.sgml
  174. 51  doc/ref/date-weekday.sgml
  175. 57  doc/ref/date-ymd.sgml
  176. 58  doc/ref/date.sgml
  177. 85  doc/ref/date1.sgml
  178. 51  doc/ref/daytime.sgml
  179. 52  doc/ref/define-class.sgml
  180. 39  doc/ref/define-module-extend.sgml
  181. 39  doc/ref/define-module.sgml
  182. 44  doc/ref/epochsecondstime.sgml
  183. 34  doc/ref/errno.sgml
  184. 54  doc/ref/error.sgml
  185. 49  doc/ref/exec.sgml
  186. 40  doc/ref/exec1.sgml
  187. 15  doc/ref/export.sgml
  188. 58  doc/ref/extrelated.sgml
  189. 43  doc/ref/fdclose.sgml
  190. 43  doc/ref/fddup.sgml
  191. 50  doc/ref/fddup2.sgml
  192. 56  doc/ref/fdlseek.sgml
  193. 56  doc/ref/fdopen.sgml
  194. 62  doc/ref/fdread.sgml
  195. 63  doc/ref/fdselect.sgml
  196. 43  doc/ref/fdstat.sgml
  197. 39  doc/ref/fdtruncate.sgml
  198. 62  doc/ref/fdwrite.sgml
  199. 49  doc/ref/file2str.sgml
  200. 50  doc/ref/fileaccess.sgml
  201. 44  doc/ref/filedir.sgml
  202. 47  doc/ref/fileindir.sgml
  203. 15  doc/ref/files.sgml
  204. 39  doc/ref/filetruncate.sgml
  205. 39  doc/ref/flushop.sgml
  206. 54  doc/ref/force.sgml
  207. 33  doc/ref/fork.sgml
  208. 136  doc/ref/format.sgml
  209. 45  doc/ref/future.sgml
  210. 44  doc/ref/get-env.sgml
  211. 51  doc/ref/get-next-client.sgml
  212. 32  doc/ref/geteuid.sgml
  213. 33  doc/ref/getlogin.sgml
  214. 32  doc/ref/getpgrp.sgml
  215. 32  doc/ref/getpid.sgml
  216. 32  doc/ref/getppid.sgml
  217. 54  doc/ref/getpw.sgml
  218. 38  doc/ref/getrusage.sgml
  219. 96  doc/ref/getsocketoption.sgml
  220. 32  doc/ref/getuid.sgml
  221. 68  doc/ref/handbind.sgml
  222. 73  doc/ref/handcase.sgml
  223. 50  doc/ref/hostaddressname.sgml
  224. 32  doc/ref/hostname.sgml
  225. 51  doc/ref/hostnameaddress.sgml
  226. 49  doc/ref/iiminus.sgml
  227. 49  doc/ref/iiplus.sgml
  228. 53  doc/ref/inet-client.sgml
  229. 54  doc/ref/inet-server.sgml
  230. 43  doc/ref/inetaddrstring.sgml
  231. 49  doc/ref/inetsocketaddrparts.sgml
  232. 45  doc/ref/input-port.sgml
  233. 43  doc/ref/intervalseconds.sgml
  234. 47  doc/ref/intervalstring.sgml
  235. 49  doc/ref/keyseq.sgml
  236. 49  doc/ref/kill.sgml
  237. 52  doc/ref/length.sgml
  238. 38  doc/ref/link.sgml
  239. 50  doc/ref/list-tail.sgml
  240. 49  doc/ref/list.sgml
  241. 44  doc/ref/lstat.sgml
  242. 64  doc/ref/make-extractor.sgml
  243. 35  doc/ref/make-mailbox.sgml
  244. 44  doc/ref/make-semaphore.sgml
  245. 55  doc/ref/make-send-rights.sgml
  246. 47  doc/ref/make-service.sgml
  247. 71  doc/ref/make-thread.sgml
  248. 57  doc/ref/makefdopenmode.sgml
  249. 57  doc/ref/makefdset.sgml
  250. 44  doc/ref/makeinetaddr.sgml
  251. 49  doc/ref/makeinetsocketaddr.sgml
  252. 32  doc/ref/mkdir.sgml
  253. 43  doc/ref/mkdirs.sgml
  254. 121  doc/ref/mktbl.sgml
  255. 49  doc/ref/modelistbits.sgml
  256. 43  doc/ref/negativeinterval.sgml
  257. 20  doc/ref/no-break.sgml
  258. 43  doc/ref/null.sgml
  259. 66  doc/ref/oid-instance.sgml
  260. 45  doc/ref/open-input-file.sgml
  261. 48  doc/ref/open-input-process.sgml
  262. 50  doc/ref/open-input-process1.sgml
  263. 45  doc/ref/open-output-file.sgml
  264. 47  doc/ref/open-output-process.sgml
  265. 49  doc/ref/open-persistent-store.sgml
  266. 16  doc/ref/open.sgml
  267. 46  doc/ref/opnappf.sgml
  268. 44  doc/ref/opnistr.sgml
  269. 39  doc/ref/opnostr.sgml
  270. 45  doc/ref/output-port.sgml
  271. 43  doc/ref/pair.sgml
  272. 51  doc/ref/path2os.sgml
  273. 59  doc/ref/path2str.sgml
  274. 51  doc/ref/peek-char.sgml
  275. 70  doc/ref/pg95-connect.sgml
  276. 53  doc/ref/pg95-exec-command.sgml
  277. 58  doc/ref/pg95-field-names.sgml
  278. 50  doc/ref/pg95-field-number.sgml
  279. 51  doc/ref/pg95-field-size.sgml
  280. 50  doc/ref/pg95-field-type.sgml
  281. 57  doc/ref/pg95-get-value.sgml
  282. 53  doc/ref/pg95-type.sgml
  283. 61  doc/ref/pg95-with-tuples.sgml
  284. 39  doc/ref/pipe.sgml
  285. 76  doc/ref/postgres-connect.sgml
  286. 52  doc/ref/rdline.sgml
  287. 50  doc/ref/read-char.sgml
  288. 50  doc/ref/read.sgml
  289. 45  doc/ref/receive-message.sgml
  290. 86  doc/ref/recvfrom.sgml
  291. 65  doc/ref/remote-port-owner.sgml
  292. 38  doc/ref/rename.sgml
  293. 33  doc/ref/reset-env.sgml
  294. 37  doc/ref/resume-thread.sgml
  295. 44  doc/ref/reverse.sgml
  296. 46  doc/ref/reverse1.sgml
  297. 32  doc/ref/rmdir.sgml
  298. 21  doc/ref/root-object.sgml
  299. 19  doc/ref/rsc.sgml
  300. 100  doc/ref/rx2proc.sgml
25  COPYING
... ...
@@ -0,0 +1,25 @@
  1
+
  2
+		      RScheme 0.7  Snapshot 3.2
  3
+
  4
+			 License For Free Use
  5
+			  January 3, 2002
  6
+
  7
+RScheme is free software.  It is not public domain -- I retain
  8
+copyright to all source code -- but it is free, and you have license
  9
+to use it as you desire.  This includes utilizing it as a complete
  10
+system, adapting it to your purposes, building new applications using
  11
+and incorporating it, etc.  This free license also includes the
  12
+ability to redistribute RScheme unmodified, or to redistribute derived
  13
+works.  These things and more you can do free of charge.
  14
+
  15
+Also, note that RScheme comes with ABSOLUTELY NO WARRANTY.  Because it
  16
+is free, and made available for your use with no compensation due, I
  17
+cannot warrant it to be suitable to any purpose, to be free of
  18
+defects, or to comply with any standard, etc.
  19
+
  20
+Given that, I hope you can enjoy and utilize it.  Certainly I do both.
  21
+
  22
+
  23
+-- Donovan Kolbly                       RScheme Development Group
  24
+   					d.kolbly@rscheme.org
  25
+					http://www.rscheme.org/~donovan/
138  INSTALL
... ...
@@ -0,0 +1,138 @@
  1
+INSTALL
  2
+
  3
+RScheme Install Notes
  4
+
  5
+RScheme 0.7.3.2
  6
+===============
  7
+
  8
+Building The Basic System
  9
+-------------------------
  10
+This distribution of RScheme includes both Scheme source and enough C
  11
+code to bootstrap into a fully functional RScheme system.
  12
+
  13
+The instructions in this section should get you up and running RScheme.
  14
+
  15
+The basic steps are
  16
+
  17
+    % cd .../rs-0.7.3.2
  18
+    % make stage1
  19
+    % cd src
  20
+    % ./configure
  21
+    % make all
  22
+
  23
+(Note: The stage1 build starts by running configure.  See "Stage1 Options"
  24
+below if configure needs help on your system.)
  25
+
  26
+This will get the base system library (librs.a) compiled and
  27
+installed, by default in /usr/local/lib/rs/0.7.3.2 (if you do not have
  28
+permissions to install in /usr/local/lib, or you want to install it
  29
+elsewhere, give the --prefix=PREFIX option to configure, where PREFIX
  30
+is the absolute directory name of the place to install RScheme)
  31
+
  32
+The executable "shell" program rs (ie, the normal interactive RScheme
  33
+program that comes up with a read-eval-print loop) is installed
  34
+in ${PREFIX}/bin/rs.  You can either link this executable into
  35
+a directory in your path, or add ${PREFIX}/bin to your path.
  36
+
  37
+Building the Off-line Module Compiler
  38
+-------------------------------------
  39
+
  40
+If you are doing module development (which includes building the optional
  41
+packages as mentioned in the next section), you should also build the 
  42
+off-line module compiler, `rsc':
  43
+
  44
+    src% make rsc
  45
+
  46
+This creates and installs `rsc' into $(PREFIX)/bin/rsc
  47
+
  48
+Building Optional Packages
  49
+--------------------------
  50
+[Note: Building packages as described here will implicity build
  51
+the offline compiler, rsc]
  52
+
  53
+After having installed the base system and basic interactive shell,
  54
+you can build and install the optional packages that you wish to use.
  55
+
  56
+The configuration script automatically chooses a default set of
  57
+optional packages to be built.  Usually, this default set is as
  58
+many packages as it expects to work.  In this case, you can
  59
+use:
  60
+
  61
+   % make packages
  62
+
  63
+Alternatively, if you want to build fewer packages, or think one
  64
+might work that the configuration script did not include in the
  65
+default set, you may override the PACKAGES make variable to supply
  66
+the set of packages to build:
  67
+
  68
+   % make PACKAGES="fasl syscalls unixm rstore x11" packages
  69
+
  70
+After having compiled all the packages of interest, you should
  71
+construct an executable which has all the corresponding code
  72
+linked in.  If you build the fasl package, this is as simple as:
  73
+
  74
+    % make fasl_shell
  75
+
  76
+which implicitly includes all the optional packages that have
  77
+been built and installed.
  78
+
  79
+This creates and installs an executable called "fshell" which is a
  80
+fast-loading shell (REPL) with the given modules linked into the image
  81
+with their corresponding C code.
  82
+
  83
+These are the packages you might find useful:
  84
+
  85
+	syscalls (basic system call interfaces)
  86
+	unixm    (unix-specific system call interfaces)
  87
+	rstore   (persistent store)
  88
+	calendar (date operations)
  89
+	sets     (set operations like 'union' and 'intersection')
  90
+	x11	 (simple Xlib interface; uses libgd for drawing to
  91
+		  in-memory images)
  92
+	db	 (Berkeley db interface)
  93
+	fasl	 (fasl-loading images)
  94
+	threads  (advanced thread support)
  95
+
  96
+The `fasl' and `rstore' packages have some fairly intense system
  97
+dependencies, so they may not work on your system.
  98
+
  99
+Additional modules (that are part of the base system and are not
  100
+packages) that you might want to link into your shell are:
  101
+
  102
+	debugger (procedure-level tracepoints and breakpoints)
  103
+
  104
+Recompiling from sources
  105
+------------------------
  106
+
  107
+As distributed, RScheme has already been compiled from its scheme sources
  108
+into C code.  However, many intermediate files are stripped out to reduce
  109
+the distribution size, so the system actually rebuilds itself at install
  110
+time (that is what the "make stage1" step does).
  111
+
  112
+If you feel like tweaking the scheme or C sources (mostly in modules/ and
  113
+handc/, respectively), you can do so, and use "make stage1" to rebuild 
  114
+src/ from those sources.
  115
+
  116
+(Appendix) Stage1 Options
  117
+-------------------------
  118
+
  119
+The stage1 build starts with a configuration step; if configure is
  120
+unable to determine the type of your system, or requires other flags,
  121
+you can set those options via the CONFIG_OPTS makefile flag.
  122
+
  123
+For example, in order to build on Windows NT with the GNU Win32 tools,
  124
+use:
  125
+
  126
+    % make CONFIG_OPTS="--host=i386-gnuwin32" stage1
  127
+
  128
+(which is not to imply that the WindowsNT build works, but it at
  129
+least gets most of the way :-))
  130
+
  131
+
  132
+For another example, Mac OS X wants:
  133
+
  134
+    % make CONFIG_OPTS="--host=ppc-rhapsody" stage1
  135
+
  136
+-- Donovan Kolbly                       RScheme Development Group
  137
+     			                d.kolbly@rscheme.org
  138
+					http://www.rscheme.org/~donovan/
212  Makefile
... ...
@@ -0,0 +1,212 @@
  1
+SHELL=/bin/sh
  2
+
  3
+TARGET_DIR=src
  4
+SRC_DIR=.
  5
+MODULES_DIR=$(TARGET_DIR)/install/resource/modules
  6
+
  7
+#
  8
+#  can set `RSC_FLAGS=-ccode' to build nearly entire system to C
  9
+#  instead of bytecodes
  10
+#
  11
+RSC_FLAGS=-pragma function-definitions-are-const \
  12
+	  -pragma slots-are-sealed
  13
+
  14
+#
  15
+#  `RSC_FLAGS2=-ccode' can be used to compile just certain modules to C
  16
+#  (ie: corelib lowscm objsys iolib highscm compiler codegen)
  17
+#  (by default -- most builds are development builds -- don't even set that)
  18
+#
  19
+#RSC_FLAGS2=-ccode
  20
+RSC_FLAGS2=
  21
+
  22
+RSC=$(TARGET_DIR)/tmp/rsc
  23
+RSC_F=$(RSC) $(RSC_FLAGS)
  24
+
  25
+RS=rs
  26
+
  27
+MODULES=$(MODULES_DIR)/primops.mif \
  28
+	$(MODULES_DIR)/precore.mif \
  29
+	$(MODULES_DIR)/corelib.mif \
  30
+	$(MODULES_DIR)/low_scheme.mif \
  31
+	$(MODULES_DIR)/objsys.mif \
  32
+	$(MODULES_DIR)/paths.mif \
  33
+	$(MODULES_DIR)/mathlib.mif \
  34
+	$(MODULES_DIR)/tables.mif \
  35
+	$(MODULES_DIR)/earley.mif \
  36
+	$(MODULES_DIR)/iolib.mif \
  37
+	$(MODULES_DIR)/high_scheme.mif \
  38
+	$(MODULES_DIR)/start.mif \
  39
+	$(MODULES_DIR)/sort.mif \
  40
+	$(MODULES_DIR)/imageio.mif \
  41
+	$(MODULES_DIR)/editinp.mif \
  42
+	$(MODULES_DIR)/mlink.mif \
  43
+	$(MODULES_DIR)/compiler.mif \
  44
+	$(MODULES_DIR)/codegen.mif \
  45
+	$(MODULES_DIR)/repl.mif \
  46
+	$(MODULES_DIR)/hacks.mif \
  47
+	$(MODULES_DIR)/regex.mif \
  48
+	$(MODULES_DIR)/debugger.mif \
  49
+	$(MODULES_DIR)/threads.mif
  50
+
  51
+base_system::  $(TARGET_DIR) rsc modules base_image configure_script
  52
+
  53
+rsc:: $(TARGET_DIR)/tmp/rsc.img
  54
+modules:: $(MODULES)
  55
+base_image:: $(TARGET_DIR)/tmp/system.bas
  56
+configure_script:: $(TARGET_DIR)/configure
  57
+
  58
+$(TARGET_DIR):
  59
+	rm -rf $(TARGET_DIR) ; mkdir $(TARGET_DIR)
  60
+	(cd ${SRC_DIR}/handc ; \
  61
+         find . \! \( -name CVS -prune \) -print) > .handc.list
  62
+	cat .handc.list | (cd ${SRC_DIR}/handc ; cpio -oc) \
  63
+	                | (cd ${TARGET_DIR} ; cpio -idc)
  64
+	if test -d $(TARGET_DIR)/tmp ; then : ; \
  65
+	else mkdir $(TARGET_DIR)/tmp ; fi
  66
+
  67
+$(TARGET_DIR)/tmp/buildcfg.scm:
  68
+	RS=$(RS) compiler/mkcfg $(TARGET_DIR) > $(TARGET_DIR)/tmp/buildcfg.scm
  69
+
  70
+$(TARGET_DIR)/tmp/rsc.img: $(TARGET_DIR)/tmp/buildcfg.scm
  71
+	RS=$(RS) compiler/mkrsc \
  72
+		./compiler \
  73
+		$(TARGET_DIR)/tmp \
  74
+		$(TARGET_DIR)/tmp \
  75
+		$(TARGET_DIR)/install \
  76
+		$(TARGET_DIR)/tmp/buildcfg.scm
  77
+
  78
+BCDEFS=$(TARGET_DIR)/install/resource/compiler/bytecode/bcgen.scm
  79
+
  80
+
  81
+$(MODULES_DIR)/primops.mif $(BCDEFS): $(TARGET_DIR)/tmp/rsc.img
  82
+	$(RS) -q -image $(TARGET_DIR)/tmp/rsc.img \
  83
+	  -e '(process-defs-file "$(SRC_DIR)/bytcodes/bcdefs.dat")' \
  84
+	  -e "(create-primop-module 'primops)" -exit
  85
+
  86
+#
  87
+#  linking
  88
+#
  89
+
  90
+$(TARGET_DIR)/tmp/system.bas: $(MODULES)
  91
+	$(RSC) -o $(TARGET_DIR)/tmp/system.bas
  92
+
  93
+#
  94
+#  autoconf
  95
+#
  96
+
  97
+$(TARGET_DIR)/configure: $(SRC_DIR)/handc/configure.in
  98
+	cd $(TARGET_DIR) ; autoconf
  99
+
  100
+#
  101
+#  building in stages...
  102
+#
  103
+#  `make ship' after a plain make will construct a tree appropriate
  104
+#  for distribution packaging such that `make stage1' is required
  105
+#  after unpacking on the target machine
  106
+#
  107
+
  108
+ship::
  109
+	mv src stage0
  110
+	cd stage0 ; rm -f tmp/rsc tmp/rsc.img
  111
+	cd stage0 ; rm -f install/resource/modules/*
  112
+	rm -rf stage0/pkg
  113
+
  114
+distclean::
  115
+	rm -rf src .handc.list
  116
+	-cd stage0 ; $(MAKE) clean
  117
+	-cd packages/lss ; $(MAKE) clean
  118
+	-cd packages/rstore ; $(MAKE) clean
  119
+	-cd packages/general ; $(MAKE) clean
  120
+	-cd packages/threads/shell ; $(MAKE) clean
  121
+	xargs rm -rf < cleanfiles
  122
+
  123
+#
  124
+#  this uses the stage0 C code set up by `ship' to build a
  125
+#  new src/ directory using an rsc running on top of the 
  126
+#  stage0 tree
  127
+#
  128
+
  129
+CONFIG_OPTS=
  130
+
  131
+stage1::
  132
+	cd stage0 ; ./configure --prefix=`pwd`/install $(CONFIG_OPTS)
  133
+	cd stage0 ; make
  134
+	mkdir -p stage0/install/bin
  135
+	cd stage0 ; make shell
  136
+	cd stage0 ; ln -fs ../../rshell/rs install/bin/rs
  137
+	cd stage0 ; ln -fs ../../system.img install/resource/system.img
  138
+	$(MAKE) RS=`pwd`/stage0/install/bin/rs RSC_FLAGS2=-ccode \
  139
+	    src src/tmp/rsc.img $(MODULES) src/tmp/system.bas
  140
+	# avoid the autoconf step ; don't want to depend on it
  141
+	cp -p stage0/configure src/configure
  142
+
  143
+#
  144
+#  all the modules
  145
+#
  146
+
  147
+precore $(MODULES_DIR)/precore.mif: $(BCDEFS)
  148
+	$(RSC) -precore $(RSC_FLAGS) modules/corelib/precore.mcf
  149
+
  150
+corelib $(MODULES_DIR)/corelib.mif: $(BCDEFS)
  151
+	$(RSC) -corelib $(RSC_FLAGS) $(RSC_FLAGS2) modules/corelib/corelib.mcf
  152
+
  153
+lowscm $(MODULES_DIR)/low_scheme.mif: $(BCDEFS)
  154
+	$(RSC) -lowscm $(RSC_FLAGS) $(RSC_FLAGS2) modules/lowscm/lowscm.mcf
  155
+
  156
+objsys $(MODULES_DIR)/objsys.mif: $(BCDEFS)
  157
+	$(RSC_F) $(RSC_FLAGS2) modules/objsys/objsys.mcf
  158
+
  159
+paths $(MODULES_DIR)/paths.mif: $(BCDEFS)
  160
+	$(RSC_F) modules/paths/paths.mcf
  161
+
  162
+tables $(MODULES_DIR)/tables.mif: $(BCDEFS)
  163
+	$(RSC_F) modules/tables/tables.mcf
  164
+
  165
+mathlib $(MODULES_DIR)/mathlib.mif: $(BCDEFS)
  166
+	$(RSC_F) modules/mathlib/mathlib.mcf
  167
+
  168
+iolib $(MODULES_DIR)/iolib.mif: $(BCDEFS)
  169
+	$(RSC_F) $(RSC_FLAGS2) modules/iolib/iolib.mcf
  170
+
  171
+highscm $(MODULES_DIR)/high_scheme.mif: $(BCDEFS)
  172
+	$(RSC_F) $(RSC_FLAGS2) modules/highscm/highscm.mcf
  173
+
  174
+start $(MODULES_DIR)/start.mif: $(BCDEFS)
  175
+	$(RSC_F) modules/start/start.mcf
  176
+
  177
+sort $(MODULES_DIR)/sort.mif: $(BCDEFS)
  178
+	$(RSC_F) modules/sort/sort.mcf
  179
+
  180
+imageio $(MODULES_DIR)/imageio.mif: $(BCDEFS)
  181
+	$(RSC_F) modules/imageio/imageio.mcf
  182
+
  183
+editinp $(MODULES_DIR)/editinp.mif: $(BCDEFS)
  184
+	$(RSC_F) modules/editinp/editinp.mcf
  185
+
  186
+compiler $(MODULES_DIR)/compiler.mif: $(BCDEFS)
  187
+	$(RSC_F) $(RSC_FLAGS2) modules/compiler/compiler.mcf
  188
+
  189
+codegen $(MODULES_DIR)/codegen.mif: $(BCDEFS)
  190
+	$(RSC_F) $(RSC_FLAGS2) modules/codegen/codegen.mcf
  191
+
  192
+mlink $(MODULES_DIR)/mlink.mif: $(BCDEFS)
  193
+	$(RSC_F) modules/mlink/mlink.mcf
  194
+
  195
+repl $(MODULES_DIR)/repl.mif: $(BCDEFS)
  196
+	$(RSC_F) modules/repl/repl.mcf
  197
+
  198
+debugger $(MODULES_DIR)/debugger.mif: $(BCDEFS)
  199
+	$(RSC_F) modules/debugger/debugger.mcf
  200
+
  201
+regex $(MODULES_DIR)/regex.mif: $(BCDEFS)
  202
+	$(RSC_F) modules/regex/regex.mcf
  203
+
  204
+earley $(MODULES_DIR)/earley.mif: $(BCDEFS)
  205
+	$(RSC_F) modules/earley/earley.mcf
  206
+
  207
+threads $(MODULES_DIR)/threads.mif: $(BCDEFS)
  208
+	$(RSC_F) modules/threads/threads.mcf
  209
+
  210
+hacks $(MODULES_DIR)/hacks.mif: $(BCDEFS)
  211
+	$(RSC_F) modules/hacks/hacks.mcf
  212
+
235  README
... ...
@@ -0,0 +1,235 @@
  1
+ ____  ____       _                            ___  _____ 
  2
+|  _ \/ ___|  ___| |__   ___ _ __ ___   ___   / _ \|___  |
  3
+| |_) \___ \ / __| '_ \ / _ \ '_ ` _ \ / _ \ | | | |  / / 
  4
+|  _ < ___) | (__| | | |  __/ | | | | |  __/ | |_| | / /  
  5
+|_| \_\____/ \___|_| |_|\___|_| |_| |_|\___|  \___(_)_/   
  6
+                                                          
  7
+================ RScheme (release 0.7.3.3) =================
  8
+
  9
+README
  10
+
  11
+This is the README file for RScheme release 0.7.3.3.
  12
+
  13
+What is RScheme?
  14
+
  15
+RScheme is an object-oriented, extended version of the Scheme dialect of
  16
+Lisp.  RScheme is freely redistributable, and offers reasonable performance
  17
+despite being extraordinarily portable.  RScheme can be compiled to C, and
  18
+the C can then compiled with a normal C compiler to generate machine code.
  19
+This can be done from a running system, and the resulting object code can be
  20
+dynamically linked into RScheme as a program executes.  By default,
  21
+however, RScheme compiles to bytecodes which are interpreted by
  22
+a (runtime) virtual machine.  This ensures that compilation is fast and
  23
+keeps code size down.  In general, we recommend using the (default) bytecode
  24
+code generation system, and only compiling your time-critical code to
  25
+machine code.  This allows a nice adjustment of space/time tradeoffs.
  26
+
  27
+To the casual user, RScheme appears to be an interpreter.  You
  28
+can type RScheme code at a read-eval-print loop, and it executes the
  29
+code and prints the result.  In reality, every expression you type to
  30
+the read-eval-print-loop is compiled and the resulting code is executed.
  31
+
  32
+Features of RScheme
  33
+
  34
+RScheme has a lot of useful features:
  35
+
  36
+  0. A very liberal license, similar to Tcl's, which allows RScheme to
  37
+     be used in commercial software with little burden on the user except
  38
+     to acknowledge the source.  See the COPYING file.
  39
+
  40
+  1. R4RS (Revised**4 Report on Scheme) compliant Scheme.  It's the
  41
+     full standard Scheme language, making it useful for writing portable
  42
+     programs, or using programs written for other Scheme dialects.
  43
+     Scheme is a small but powerful language with garbage
  44
+     collection, first-class procedures, list processing features,
  45
+     lexical scope, etc.  Various introductory texts on Scheme and
  46
+     Scheme programming are available.
  47
+
  48
+  2. Object system.  Everything in RScheme is an object in an object-oriented
  49
+     system.  That is, RScheme is "objects all the way down" rather than
  50
+     being a hybrid language like C++ or most Lisp object systems---the
  51
+     built-in R4RS Scheme data types are all classes in the class hierarchy,
  52
+     as they should be.  Currently, only a simple object system with
  53
+     single inheritance and single dispatching is supported.  Our object
  54
+     system is approximately a subset of TinyCLOS, with some Dylan-like
  55
+     extensions.
  56
+  
  57
+  3. Threads.  RScheme supports user-level threads portably, even on
  58
+     operating systems that don't have threads at all.  RScheme multiplexes
  59
+     several user threads onto one OS-level process.  These threads
  60
+     appear to be preemptive from the normal user's point of view.
  61
+     (For example, nonblocking I/O can be used automatically so that 
  62
+     one thread doing a read from a network socket doesn't block the
  63
+     whole system;
  64
+     the reading thread will actually issue a nonblocking read request
  65
+     and a thread switch will activate a waiting thread.  You don't
  66
+     have to schedule threads "cooperatively" --- just use threads
  67
+     and specify nonblocking i/o.  RScheme does the rest.)  [note: by
  68
+     default, the system uses stdio for input and output.  You will require
  69
+     the facilities of the syscalls package to have a useful threads system
  70
+     that does console or network I/O]
  71
+
  72
+  4. Sockets, globbing, etc.  Rscheme has several important features
  73
+     for writing serious programs, especially under UNIX.  It is suitable
  74
+     for writing networked servers, for example---that's one of the things
  75
+     it was designed for.  RScheme does not currently have as many shell
  76
+     programming features as Olin Shivers' scsh (the Scheme shell), but
  77
+     we will add more, and we may port full scsh to RScheme.
  78
+
  79
+  5. Separately-compilable and linkable modules.  The module system is
  80
+     pretty straightforward and simple, similar to Scheme-48's module
  81
+     system and a subset of Dylan's.  It makes development easy by
  82
+     supporting separate compilation and dynamic module linking.
  83
+
  84
+  6. Real-time garbage collection, using Wilson and Johnstone's algorithm.
  85
+     This is a hard real-time garbage collector, in principle, though
  86
+     the default configuration is only soft real time.  This is sufficient
  87
+     for most purposes, such as writing interactive applications and
  88
+     network servers---e.g., to avoid spurious network timeouts because
  89
+     a thread is delayed by a GC.
  90
+
  91
+     Unlike most language implementations that compile to C, RScheme does
  92
+     NOT use conservative pointer finding in its garbage collector.
  93
+     RScheme's strategy for compiling to C supports precise identification
  94
+     of root pointers, as well as pointers in heap-allocated objects,
  95
+     eliminating potential storage leaks and unreliability due to
  96
+     misidentification of pointers.  (We don't want to overstate our
  97
+     case here, however---conservative pointer finding works surprisingly
  98
+     well, and Hans Boehm et al. have done an amazing job on free conservative
  99
+     GC's for use with C, C++, etc.  We have avoided dependence on conservative
  100
+     pointer finding because we simply didn't need it, and the supprot for
  101
+     precise pointer identification can be helpful for a variety of other
  102
+     purposes.)
  103
+
  104
+     [For more on RTGC, see <http://www.cs.utexas.edu/users/oops> ]
  105
+
  106
+  7. Persistence, using the strategy described in Wilson and Kakkad's
  107
+     "pointer swizzling at page fault time".
  108
+
  109
+     Our persistent object store avoids the need to read and write data
  110
+     to files, for most purposes.  Data can simply be saved on disk as
  111
+     a special kind of virtual memory image, and processes can open
  112
+     a persistent store and start traversing its data structures in the
  113
+     usual way---pages of data are faulted into virtual memory as needed,
  114
+     on demand, with performance comparable to normal paging.
  115
+
  116
+  8. The ability to hand-code time-critical routines in C and plug them
  117
+     into applications written mostly in RScheme.  Since at the moment
  118
+     we can't claim to have a state-of-the-art compiler that generates
  119
+     awesome code for everything, we allow speed freaks to hand-code
  120
+     important things in C and integrate them into their programs.  (We
  121
+     discourage the overuse of this feature!  RScheme provides acceptable
  122
+     performance for most programs, and for most parts of most other
  123
+     programs, so if you overdo it, you're just making life harder for
  124
+     yourself.)
  125
+
  126
+  9. Big number support.  For this, you need to have the gmp libraries
  127
+     and the header file longlong.h from the gmp sources.
  128
+
  129
+Where to get RScheme
  130
+ 
  131
+If you have found this file on a web server, in a net announcement, or
  132
+whatever, and you want RScheme, you can ftp it from ftp.rscheme.org as
  133
+pub/rscheme/rs-0.7.3.3.tar.gz.
  134
+
  135
+What's in the Distribution
  136
+
  137
+If you have ftp'd and untar'd the distribution, you probably found
  138
+this file at the top level.  Also at this level are several subdirectories,
  139
+described below.
  140
+
  141
+  README  This file---the one you're reading.
  142
+
  143
+  INSTALL How to configure, compile, and install RScheme
  144
+
  145
+  COPYING License for free use
  146
+
  147
+  doc     This holds the documentation of the system.  Included are
  148
+          a user reference (user_ref.ps) and notes on the design
  149
+	  and implementation (design_and_impl.ps).  The documentation
  150
+	  source is not shipped in this distribution.
  151
+
  152
+  modules This is the source for the compiler and various other modules,
  153
+          in RScheme.  Most of the subdirectories hold the code for some
  154
+          particular module.
  155
+
  156
+  handc   This is miscellaneous handwritten C code, mostly runtime support
  157
+          code such as the GC and the low-level parts of the thread
  158
+          system.  This source gets copied into `src/' by the top-level
  159
+	  build process.
  160
+
  161
+  compiler This contains the "cross" compiler, which is written in the
  162
+	   language implemented by RScheme 0.6, but compiles code for 0.7.
  163
+	   (this is also the off-line module module, rsc, because it works
  164
+	   in 0.7 too)
  165
+
  166
+  test    This directory holds regression test files
  167
+
  168
+  src     The is is the C code generated automatically from RScheme code.
  169
+          The subdirectories correspond to the subdirectories
  170
+          of `modules/', and hold the C code generated from the RScheme code
  171
+          in those directories, plus copies of the subdirectories of `handc/'.
  172
+
  173
+  bytcodes This contains the definitions of the bytecode operations and
  174
+	   hooks for the bytecode compiler to make use of the low-level
  175
+	   type system.
  176
+
  177
+  packages This contains the standard, but optional, packages, such as
  178
+	   the persistent store (rstore) and posix interface package
  179
+	   (syscalls).
  180
+
  181
+
  182
+Goals of the RScheme project
  183
+============================
  184
+
  185
+We have two major goals for RScheme: building a very useful system, and
  186
+building a clean and powerful system that can be used to implement
  187
+a variety of langauge constructs, or even entirely different languages,
  188
+portably and with good performance.  
  189
+
  190
+In more detail, our goals are
  191
+
  192
+  1. To build a useful language that has all of the basic features that
  193
+     any good modern programming language should have, and which provides
  194
+     decent performance without being a big complicated monster.  To
  195
+     be useful, it should be extremely portable.  Nobody should have to
  196
+     worry that the vendor will go out of business and the software won't
  197
+     be ported to new platforms.  Hence, we compile to C.  As long as there
  198
+     are C compilers on new platforms, it should be very easy to port
  199
+     RScheme and get good performance.  We don't expect C to die in the
  200
+     next few decades---it's the FORTRAN of the next 30 years.
  201
+
  202
+     Compiling to C has its drawbacks.  C was not designed to be a compiler
  203
+     intermediate representation for other languages, so it is not the
  204
+     optimal backend.  On the other hand, we have found novel strategies
  205
+     for mapping RScheme onto C with surprisingly little degradation of
  206
+     performance.  (We don't just use C as a portable assembler, as some
  207
+     people do.  For example, in many cases, nested RScheme expressions
  208
+     can be compiled to nested C expressions, and the C compiler will do
  209
+     a good job of register allocation and instruction scheduling.)
  210
+
  211
+     GNU C provides several handy extensions, such as the ability to use
  212
+     hardware registers to hold important global variables.  RScheme
  213
+     will take advantage of these features if the configure process
  214
+     recognizes an opportunity.
  215
+
  216
+  2. To build a useful framework for research and development in programming
  217
+     language design and implementation.  RScheme was originally motivated
  218
+     by our frustration with existing language implementations, which are
  219
+     mostly very limited and very inefficient---or big, hairy, and nonnportable
  220
+     monsters.  Typically, implementors of interesting new languages write
  221
+     whole new compilers for them, because none of the existing compilers
  222
+     are flexible enough and understandable enough to make it worth reusing
  223
+     other people's code.  As a result, there are a whole lot of mediocre
  224
+     to bad langauge implementations out there, and that's a shame.  People
  225
+     keep using languages like C and C++ because they know there will be
  226
+     decent compilers for them everywhere.
  227
+
  228
+     We want to leverage C's momentum, and allow better languages to be easily
  229
+     implemented with reliably good performance on essentially all common
  230
+     platforms.
  231
+
  232
+
  233
+-- Donovan Kolbly                       RScheme Development Group
  234
+   			                d.kolbly@rscheme.org
  235
+					http://www.rscheme.org/~donovan/
728  bytcodes/bcdefs.dat
... ...
@@ -0,0 +1,728 @@
  1
+#|------------------------------------------------------------*-Scheme-*--|
  2
+ | File:    bytcodes/bcdefs.dat
  3
+ |
  4
+ |          Copyright (C)1995 Donovan Kolbly <donovan@tkg.com>
  5
+ |          as part of the RScheme project, licensed for free use
  6
+ |
  7
+ | Version: 1.18
  8
+ | Date:    2005-01-20 19:45:26
  9
+ | Build:   v0.7.3.4-b7u, 2007-05-30
  10
+ |
  11
+ `------------------------------------------------------------------------|#
  12
+
  13
+;; this definitions file is input to the
  14
+;; bytecode definition processor, which in
  15
+;; turn generates two outputs:
  16
+;;	the bytecode interpreter fragments file, bcfrags.ci
  17
+;;      the bytecode code generator file, bcgen.scm
  18
+
  19
+(bytecode (return n)
  20
+ (cond
  21
+  ((eq? n 0)
  22
+   (assign-code '(return 0) () "RETURN0();"))
  23
+  ((eq? n 1)
  24
+   (assign-code '(return 1) () "RETURN1();"))
  25
+  (else
  26
+   (assign-code (n) "RETURN(n);"))))
  27
+
  28
+#| generates:
  29
+	(define (emit-return n)
  30
+	    (cond ((eq? n 0) (emit-byte-code 37))
  31
+		    ((eq? n 1) (emit-byte-code 38))
  32
+		    (#t (emit-byte-code 39)
  33
+			(assert (byte-sized? n))
  34
+			(emit-byte-code n))))
  35
+   and:
  36
+   	case 37: RETURN0(); break;
  37
+	case 38: RETURN1(); break;
  38
+	case 39: { UINT_8 n; n = *pc++; RETURN(n); } break;
  39
+|#
  40
+
  41
+;; well, on to it...
  42
+
  43
+(bytecode (literal slot)
  44
+  ;; just add one to the literal slot, because bytecoded code
  45
+  ;; has the program in LITERAL(0) (LITERAL(0) ==> SLOT(2))
  46
+  (case slot
  47
+    ((0)  (assign-code '(literal 0) () "PUSH( LITERAL(0+1) );"))
  48
+    ((1)  (assign-code '(literal 1) () "PUSH( LITERAL(1+1) );"))
  49
+    ((2)  (assign-code '(literal 2) () "PUSH( LITERAL(2+1) );"))
  50
+    ((3)  (assign-code '(literal 3) () "PUSH( LITERAL(3+1) );"))
  51
+    ((4)  (assign-code '(literal 4) () "PUSH( LITERAL(4+1) );"))
  52
+    ((5)  (assign-code '(literal 5) () "PUSH( LITERAL(5+1) );"))
  53
+    (else 
  54
+     (if (> slot 255)
  55
+         (assign-code ((slot slot <uint-16>)) "PUSH( LITERAL(slot+1) );")
  56
+         (assign-code (slot) "PUSH( LITERAL(slot+1) );")))))
  57
+
  58
+(bytecode (closure slot)
  59
+  (if (> slot 255)
  60
+      (assign-code ((slot slot <uint-16>)) "PUSH( CLOSURE(slot+1) );")
  61
+      (assign-code (slot) "PUSH( CLOSURE(slot+1) );")))
  62
+
  63
+(bytecode (apply n)
  64
+  (case n
  65
+    ((0)  (assign-code '(apply 0) ()  "APPLY(0,POP());"))
  66
+    ((1)  (assign-code '(apply 1) ()  "APPLY(1,POP());"))
  67
+    ((2)  (assign-code '(apply 2) ()  "APPLY(2,POP());"))
  68
+    ((3)  (assign-code '(apply 3) ()  "APPLY(3,POP());"))
  69
+    ((4)  (assign-code '(apply 4) ()  "APPLY(4,POP());"))
  70
+    (else (assign-code (n) "APPLY(n,POP());"))))
  71
+
  72
+(bytecode (reg-set n)
  73
+  (case n
  74
+    ((0) (assign-code '(reg-set 0) () "REG0 = POP();"))
  75
+    ((1) (assign-code '(reg-set 1) () "REG1 = POP();"))
  76
+    ((2) (assign-code '(reg-set 2) () "REG2 = POP();"))
  77
+    (else
  78
+     ;; if the LHS is a low-numbered reg, we have to
  79
+     ;; use reg_set() because REG(n) only works for n>=10
  80
+     (if (< n 10)
  81
+	 (assign-code (n) "reg_set( n, POP() );")
  82
+         (if (> n 255)
  83
+             (assign-code ((n n <uint-16>)) "REG(n) = POP();")
  84
+             (assign-code (n) "REG(n) = POP();"))))))
  85
+
  86
+(bytecode (reg-ref n)
  87
+  (case n
  88
+    ((0) (assign-code '(reg-ref 0) () "PUSH( REG0 );"))
  89
+    ((1) (assign-code '(reg-ref 1) () "PUSH( REG1 );"))
  90
+    ((2) (assign-code '(reg-ref 2) () "PUSH( REG2 );"))
  91
+    (else
  92
+     ;; if the source is a low-numbered reg, we have to
  93
+     ;; use reg_ref() because REG(n) only works for n>=10
  94
+     (if (< n 10)
  95
+	 (assign-code (n) "PUSH( reg_ref(n) );")
  96
+         (if (> n 255)
  97
+             (assign-code ((n n <uint-16>)) "PUSH( REG(n) );")
  98
+             (assign-code (n) "PUSH( REG(n) );"))))))
  99
+
  100
+;; only called for from != to
  101
+(bytecode (reg-xfer from to)
  102
+  (case (if (<= to 255) from #f)
  103
+    ((0) (case to
  104
+	   ((1) (assign-code '(reg-xfer 0 1) () "REG1 = REG0;"))
  105
+	   ((2) (assign-code '(reg-xfer 0 2) () "REG2 = REG0;"))
  106
+	   ((3) (assign-code '(reg-xfer 0 3) () "REG3 = REG0;"))
  107
+	   (else (if (< to 10)
  108
+		     (assign-code '(reg-xfer 0 to) (to) "reg_set( to, REG0 );")
  109
+		     (assign-code '(reg-xfer 0 to) (to) "REG(to) = REG0;")))))
  110
+    ((1) (case to
  111
+	   ((0) (assign-code '(reg-xfer 1 0) () "REG0 = REG1;"))
  112
+	   ((2) (assign-code '(reg-xfer 1 2) () "REG2 = REG1;"))
  113
+	   ((3) (assign-code '(reg-xfer 1 3) () "REG3 = REG1;"))
  114
+	   (else (if (< to 10)
  115
+		     (assign-code '(reg-xfer 1 to) (to) "reg_set( to, REG1 );")
  116
+		     (assign-code '(reg-xfer 1 to) (to) "REG(to) = REG1;")))))
  117
+    ((2) (case to
  118
+	   ((0) (assign-code '(reg-xfer 2 0) () "REG0 = REG2;"))
  119
+	   ((1) (assign-code '(reg-xfer 2 1) () "REG1 = REG2;"))
  120
+	   ((3) (assign-code '(reg-xfer 2 3) () "REG3 = REG2;"))
  121
+	   (else (if (< to 10)
  122
+		     (assign-code '(reg-xfer 2 to) (to) "reg_set( to, REG2 );")
  123
+		     (assign-code '(reg-xfer 2 to) (to) "REG(to) = REG2;")))))
  124
+    ((3) (case to
  125
+	   ((0) (assign-code '(reg-xfer 3 0) () "REG0 = REG3;"))
  126
+	   ((1) (assign-code '(reg-xfer 3 1) () "REG1 = REG3;"))
  127
+	   ((2) (assign-code '(reg-xfer 3 2) () "REG2 = REG3;"))
  128
+	   (else (if (< to 10)
  129
+		     (assign-code '(reg-xfer 3 to) (to)
  130
+				  "reg_set( to, REG3 );")
  131
+		     (assign-code '(reg-xfer 3 to) (to)
  132
+				  "REG(to) = REG3;")))))
  133
+    (else (case (if (<= from 255) to #f)
  134
+	    ((0) (if (< from 10)
  135
+		     (assign-code '(reg-xfer from 0) (from)
  136
+				  "REG0 = reg_ref(from);")
  137
+		     (assign-code '(reg-xfer from 0) (from)
  138
+				  "REG0 = REG(from);")))
  139
+	    ((1) (if (< from 10)
  140
+		     (assign-code '(reg-xfer from 1) (from)
  141
+				  "REG1 = reg_ref(from);")
  142
+		     (assign-code '(reg-xfer from 1)(from)
  143
+				  "REG1 = REG(from);")))
  144
+	    ((2) (if (< from 10)
  145
+		     (assign-code '(reg-xfer from 2) (from)
  146
+				  "REG2 = reg_ref(from);")
  147
+		     (assign-code '(reg-xfer from 2) (from)
  148
+				  "REG2 = REG(from);")))
  149
+	    ((3) (if (< from 10)
  150
+		     (assign-code '(reg-xfer from 3) (from)
  151
+				  "REG3 = reg_ref(from);")
  152
+		     (assign-code '(reg-xfer from 3) (from)
  153
+				  "REG3 = REG(from);")))
  154
+	    (else
  155
+             (cond
  156
+              ((and (< from 10) (< to 10))
  157
+               (assign-code (from to) "reg_set( to, reg_ref( from ) );"))
  158
+              ((and (< from 10) (<= to 255))
  159
+               (assign-code (from to) "REG(to) = reg_ref( from );"))
  160
+              ((< from 10)
  161
+               (assign-code (from (to to <uint-16>))
  162
+                            "REG(to) = reg_ref( from );"))
  163
+              ((and (<= from 255) (< to 10))
  164
+               (assign-code (from to) "reg_set( to, REG(from) );"))
  165
+              ((and (<= from 255) (< to 255))
  166
+               (assign-code (from to) "REG(to) = REG(from);"))
  167
+              ((<= from 255)
  168
+               (assign-code (from (to to <uint-16>)) "REG(to) = REG(from);"))
  169
+              ((< to 10)
  170
+               (assign-code ((from from <uint-16>) to) "reg_set( to, REG(from) );"))
  171
+              ((<= to 255)
  172
+               (assign-code ((from from <uint-16>) to) "REG(to) = REG(from);"))
  173
+              (else
  174
+               (assign-code ((from from <uint-16>) 
  175
+                             (to to <uint-16>)) "REG(to) = REG(from);"))))))))
  176
+
  177
+(bytecode (pop)
  178
+  (assign-code () "POP();"))
  179
+
  180
+(bytecode (lex-ref frame slot)
  181
+  (case frame
  182
+    ((0)
  183
+     (case slot
  184
+       ((0)
  185
+	(assign-code '(lex-ref 0 0) ()
  186
+	   "PUSH( LEXREF0(0) );"))
  187
+       ((1)
  188
+	(assign-code '(lex-ref 0 1) ()
  189
+	   "PUSH( LEXREF0(1) );"))
  190
+       ((2)
  191
+	(assign-code '(lex-ref 0 2) ()
  192
+	   "PUSH( LEXREF0(2) );"))
  193
+       (else
  194
+	(assign-code '(lex-ref 0 slot) (slot)
  195
+	   "PUSH( LEXREF0(slot) );"))))
  196
+    ((1)
  197
+     (case slot
  198
+       ((0)
  199
+	(assign-code '(lex-ref 1 0) ()
  200
+	   "PUSH( LEXREF1(0) );"))
  201
+       ((1)
  202
+	(assign-code '(lex-ref 1 1) ()
  203
+	   "PUSH( LEXREF1(1) );"))
  204
+       ((2)
  205
+	(assign-code '(lex-ref 1 2) ()
  206
+	   "PUSH( LEXREF1(2) );"))
  207
+       (else
  208
+	(assign-code '(lex-ref 1 slot) (slot)
  209
+	   "PUSH( LEXREF1(slot) );"))))
  210
+    ((2)
  211
+     (case slot
  212
+       ((0)
  213
+	(assign-code '(lex-ref 2 0) ()
  214
+	   "PUSH( LEXREF2(0) );"))
  215
+       ((1)
  216
+	(assign-code '(lex-ref 2 1) ()
  217
+	   "PUSH( LEXREF2(1) );"))
  218
+       ((2)
  219
+	(assign-code '(lex-ref 2 2) ()
  220
+	   "PUSH( LEXREF2(2) );"))
  221
+       (else
  222
+	(assign-code '(lex-ref 2 slot) (slot)
  223
+	   "PUSH( LEXREF2(slot) );"))))
  224
+    (else
  225
+     (assign-code (frame slot)
  226
+        "PUSH( gvec_read( nth_enclosing_envt(frame), SLOT(slot+1) ) );"))))
  227
+
  228
+(bytecode (lex-set frame slot)
  229
+  (case frame
  230
+    ((0)
  231
+     (case slot
  232
+       ((0)
  233
+	(assign-code '(lex-set 0 0) ()
  234
+	   "LEXSET0(0,POP());"))
  235
+       ((1)
  236
+	(assign-code '(lex-set 0 1) ()
  237
+	   "LEXSET0(1,POP());"))
  238
+       ((2)
  239
+	(assign-code '(lex-set 0 2) ()
  240
+	   "LEXSET0(2,POP());"))
  241
+       (else
  242
+	(assign-code '(lex-set 0 slot) (slot)
  243
+	   "LEXSET0(slot,POP());"))))
  244
+    ((1)
  245
+     (case slot
  246
+       ((0)
  247
+	(assign-code '(lex-set 1 0) ()
  248
+	   "LEXSET1(0,POP());"))
  249
+       ((1)
  250
+	(assign-code '(lex-set 1 1) ()
  251
+	   "LEXSET1(1,POP());"))
  252
+       ((2)
  253
+	(assign-code '(lex-set 1 2) ()
  254
+	   "LEXSET1(2,POP());"))
  255
+       (else
  256
+	(assign-code '(lex-set 1 slot) (slot)
  257
+	   "LEXSET1(slot,POP());"))))
  258
+    ((2)
  259
+     (case slot
  260
+       ((0)
  261
+	(assign-code '(lex-set 2 0) ()
  262
+	   "LEXSET2(0,POP());"))
  263
+       ((1)
  264
+	(assign-code '(lex-set 2 1) ()
  265
+	   "LEXSET2(1,POP());"))
  266
+       ((2)
  267
+	(assign-code '(lex-set 2 2) ()
  268
+	   "LEXSET2(2,POP());"))
  269
+       (else
  270
+	(assign-code '(lex-set 2 slot) (slot)
  271
+	   "LEXSET2(slot,POP());"))))
  272
+    (else
  273
+     (assign-code (frame slot)
  274
+	"gvec_write( nth_enclosing_envt(frame), SLOT(slot+1), POP() );"))))
  275
+
  276
+(bytecode (tl-ref i)
  277
+  (if (> i 255)
  278
+      (assign-code ((i i <uint-16>)) "PUSH( TLREF(i+1) );")
  279
+      (assign-code (i) "PUSH( TLREF(i+1) );")))
  280
+
  281
+(bytecode (tl-set i)
  282
+  (if (> i 255)
  283
+      (assign-code ((i i <uint-16>)) "TLSET((i+1),POP());")
  284
+      (assign-code (i) "TLSET((i+1),POP());")))
  285
+
  286
+(bytecode (immob x)
  287
+  (case x
  288
+    ((#t) (assign-code '(immob #t) () "PUSH( TRUE_OBJ );"))
  289
+    ((#f) (assign-code '(immob #f) () "PUSH( FALSE_OBJ );"))
  290
+    ((()) (assign-code '(immob ()) () "PUSH( NIL_OBJ );"))
  291
+    (else
  292
+     (cond
  293
+      ((ascii-char? x)
  294
+       (assign-code '(immob/char v) ((v (ascii-char->integer x)))
  295
+		    "PUSH( MAKE_ASCII_CHAR(v) );"))
  296
+      ((unicode-char? x)
  297
+       (assign-code '(immob/unicode v) ((v (unicode-char->integer x) 
  298
+				       <uint-16>))
  299
+		    "PUSH( MAKE_UNICODE_CHAR(v) );"))
  300
+      ((unique-obj? x)
  301
+       (assign-code '(immob/unique v) ((v (get-immob-value x)))
  302
+		    "PUSH( MAKE_UNIQ_OBJ(v) );"))
  303
+      (else
  304
+       (assign-code '(immob/bits hi lo) ((hi (obj-high-bits x) <uint-16>)
  305
+					 (lo (obj-low-bits x) <uint-16>))
  306
+		    "PUSH( OBJ( (hi<<16) + lo ) );"))))))
  307
+
  308
+(include "primops.dat")
  309
+
  310
+(bytecode (make-primop num-args)
  311
+  ;; make's first argument is the class to be made
  312
+  (assign-code '(make n) ((n (- num-args 1)))
  313
+    "{ unsigned i;"
  314
+    "  obj r = alloc( SLOT(n), TOP(n) );"
  315
+    "  for (i=n; i>0;)"
  316
+    "  { i--; gvec_write_init( r, SLOT(i), POP() ); }"
  317
+    "  POP(); /* the class */"
  318
+    "  PUSH(r); }"))
  319
+
  320
+;; this handles "special" primops
  321
+;; -- that is, primop AML insns whose
  322
+;;    translation to bytecodes is a symbol
  323
+
  324
+(bytecode (special-primop op num-args)
  325
+  (case op
  326
+    ;; special-case cons, car, and cdr to be single-byte codes
  327
+    ((cons)
  328
+     (assert (= num-args 2))
  329
+     (assign-code '(cons) ()
  330
+       "{ obj h, t;"
  331
+       "  t = POP();"
  332
+       "  h = POP();"
  333
+       "  PUSH( cons( h, t ) ); }"))
  334
+    ((car)
  335
+     (assert (= num-args 1))
  336
+     (assign-code '(car) ()
  337
+       "{ CHECK_PAIR(TOP(0));"
  338
+       "  SETTOP(0,pair_car(TOP(0))); }"))
  339
+    ((cdr)
  340
+     (assert (= num-args 1))
  341
+     (assign-code '(cdr) ()
  342
+       "{ CHECK_PAIR(TOP(0));"
  343
+       "  SETTOP(0,pair_cdr(TOP(0))); }"))
  344
+    ((make)
  345
+     ;; special-case make to take variable # arguments
  346
+     (emit-make-primop num-args))
  347
+    (else
  348
+     (error/internal "special-primop not defined: ~s" op))))
  349
+
  350
+;; note that the SET_PARTCONT_REG()'s invocations
  351
+;; don't usually involve a write barrier, because they only
  352
+;; modify the freshly created partial-continuation which
  353
+;; is in the stack cache (see stakcach.h)
  354
+
  355
+(bytecode (save n l)
  356
+  (case n
  357
+    ((0)
  358
+     (assign-code '(save 0 label) ((label (ref-label l) <uint-16>))
  359
+	"{ unsigned i;"
  360
+	"  PUSH_PARTCONT(bci_1,1);"
  361
+	"  SET_PARTCONT_REG(0,int2fx(label)); }"))
  362
+    ((1)
  363
+     (assign-code '(save 1 label) ((label (ref-label l) <uint-16>))
  364
+	"{ "
  365
+	"  PUSH_PARTCONT(bci_1,2);"
  366
+	"  SET_PARTCONT_REG(0,int2fx(label));"
  367
+	"  SET_PARTCONT_REG(1,REG0); }"))
  368
+    ((2)
  369
+     (assign-code '(save 2 label) ((label (ref-label l) <uint-16>))
  370
+	"{ "
  371
+	"  PUSH_PARTCONT(bci_1,3);"
  372
+	"  SET_PARTCONT_REG(0,int2fx(label));"
  373
+	"  SET_PARTCONT_REG(1,REG0);"
  374
+	"  SET_PARTCONT_REG(2,REG1); }"))
  375
+    ((3)
  376
+     (assign-code '(save 3 label) ((label (ref-label l) <uint-16>))
  377
+	"{ "
  378
+	"  PUSH_PARTCONT(bci_1,4);"
  379
+	"  SET_PARTCONT_REG(0,int2fx(label));"
  380
+	"  SET_PARTCONT_REG(1,REG0);"
  381
+	"  SET_PARTCONT_REG(2,REG1);"
  382
+	"  SET_PARTCONT_REG(3,REG2); }"))
  383
+    ((4)
  384
+     (assign-code '(save 4 label) ((label (ref-label l) <uint-16>))
  385
+	"{ "
  386
+	"  PUSH_PARTCONT(bci_1,5);"
  387
+	"  SET_PARTCONT_REG(0,int2fx(label));"
  388
+	"  SET_PARTCONT_REG(1,REG0);"
  389
+	"  SET_PARTCONT_REG(2,REG1);"
  390
+	"  SET_PARTCONT_REG(3,REG2);"
  391
+	"  SET_PARTCONT_REG(4,REG3); }"))
  392
+    ((5)
  393
+     (assign-code '(save 5 label) ((label (ref-label l) <uint-16>))
  394
+	"{ "
  395
+	"  PUSH_PARTCONT(bci_1,6);"
  396
+	"  SET_PARTCONT_REG(0,int2fx(label));"
  397
+	"  SET_PARTCONT_REG(1,REG0);"
  398
+	"  SET_PARTCONT_REG(2,REG1);"
  399
+	"  SET_PARTCONT_REG(3,REG2);"
  400
+	"  SET_PARTCONT_REG(4,REG3);"
  401
+	"  SET_PARTCONT_REG(5,REG4); }"))
  402
+    (else
  403
+     (if (> n 255)
  404
+         (assign-code '(save num label) ((num n <uint-16>)
  405
+                                         (label (ref-label l) <uint-16>))
  406
+            "{ unsigned i;"
  407
+            "  PUSH_PARTCONT(bci_1,(num+1));"
  408
+            "  SET_PARTCONT_REG(0,int2fx(label));"
  409
+            "  for (i=0; i<num; i++)"
  410
+            "  {"
  411
+            "    SET_PARTCONT_REG(i+1,reg_ref(i));"
  412
+            "  } }")
  413
+         (assign-code '(save num label) ((num n) 
  414
+                                         (label (ref-label l) <uint-16>))
  415
+            "{ unsigned i;"
  416
+            "  PUSH_PARTCONT(bci_1,(num+1));"
  417
+            "  SET_PARTCONT_REG(0,int2fx(label));"
  418
+            "  for (i=0; i<num; i++)"
  419
+            "  {"
  420
+            "    SET_PARTCONT_REG(i+1,reg_ref(i));"
  421
+            "  } }")))))
  422
+
  423
+(bytecode (restore n)
  424
+  (case n
  425
+    ((0)
  426
+     (assign-code '(restore 0) ()
  427
+	"{"
  428
+	"  RESTORE_CONT_REG();"
  429
+	"}"))
  430
+    ((1)
  431
+     (assign-code '(restore 1) ()
  432
+	"{ REG0 = PARTCONT_REG(1);"
  433
+	"  RESTORE_CONT_REG();"
  434
+	"}"))
  435
+    ((2)
  436
+     (assign-code '(restore 2) ()
  437
+	"{ REG0 = PARTCONT_REG(1);"
  438
+	"  REG1 = PARTCONT_REG(2);"
  439
+	"  RESTORE_CONT_REG();"
  440
+	"}"))
  441
+    ((3)
  442
+     (assign-code '(restore 3) ()
  443
+	"{ REG0 = PARTCONT_REG(1);"
  444
+	"  REG1 = PARTCONT_REG(2);"
  445
+	"  REG2 = PARTCONT_REG(3);"
  446
+	"  RESTORE_CONT_REG();"
  447
+	"}"))
  448
+    ((4)
  449
+     (assign-code '(restore 4) ()
  450
+	"{ REG0 = PARTCONT_REG(1);"
  451
+	"  REG1 = PARTCONT_REG(2);"
  452
+	"  REG2 = PARTCONT_REG(3);"
  453
+	"  REG3 = PARTCONT_REG(4);"
  454
+	"  RESTORE_CONT_REG();"
  455
+	"}"))
  456
+    ((5)
  457
+     (assign-code '(restore 5) ()
  458
+	"{ REG0 = PARTCONT_REG(1);"
  459
+	"  REG1 = PARTCONT_REG(2);"