From 2302efe24e2909da58fc344810db96e89c3bc42a Mon Sep 17 00:00:00 2001 From: bdc Date: Sat, 14 Oct 1995 03:34:21 +0000 Subject: [PATCH] *** empty log message *** --- .gdbinit | 106 + .gitignore | 28 + .notify | 0 COPYING | 37 + Changes | 3 + INSTALL | 120 + Makefile.in | 662 +++ NEWS | 35 + NEWS.s48-0.36 | 497 +++ README | 23 + README.s48-0.36 | 66 + RELEASE | 61 + TODO | 59 + TODO.s48-0.36 | 263 ++ alt-packages.scm | 166 + alt/annotate.scm | 13 + alt/ascii.scm | 69 + alt/bitwise-tests.scm | 58 + alt/bitwise.scm | 44 + alt/closure.scm | 11 + alt/code-vector.scm | 19 + alt/config.scm | 192 + alt/contin.scm | 20 + alt/environments.scm | 6 + alt/escape.scm | 32 + alt/features-packages.scm | 29 + alt/features.scm | 58 + alt/fluid.scm | 33 + alt/init-defpackage.scm | 14 + alt/locations.scm | 30 + alt/loophole.scm | 9 + alt/low-packages.scm | 26 + alt/low.scm | 25 + alt/primitives.scm | 175 + alt/pseudoscheme-features.scm | 120 + alt/pseudoscheme-record.scm | 18 + alt/queue.scm | 28 + alt/record.scm | 96 + alt/reroot.scm | 54 + alt/schemetoc-features.scm | 142 + alt/schemetoc-record.scm | 120 + alt/silly.scm | 8 + alt/syntax.scm | 204 + alt/t-features.scm | 118 + alt/t-record.scm | 57 + alt/table.scm | 14 + alt/template.scm | 21 + alt/values.scm | 19 + alt/weak.scm | 8 + bcomp/comp.scm | 573 +++ bcomp/config.scm | 35 + bcomp/cprim.scm | 384 ++ bcomp/ctop.scm | 259 ++ bcomp/ddata.scm | 89 + bcomp/for-reify.scm | 35 + bcomp/interface.scm | 88 + bcomp/module-language.scm | 229 + bcomp/mtype.scm | 711 +++ bcomp/package.scm | 425 ++ bcomp/recon.scm | 383 ++ bcomp/rules.scm | 253 ++ bcomp/scan.scm | 291 ++ bcomp/schemify.scm | 125 + bcomp/segment.scm | 230 + bcomp/state.scm | 79 + bcomp/syntax.scm | 825 ++++ bcomp/type.scm | 53 + bcomp/undefined.scm | 56 + bcomp/usual.scm | 233 + big/array.scm | 315 ++ big/big-util.scm | 192 + big/bigbit.scm | 207 + big/compose-cont.scm | 44 + big/defrecord.scm | 93 + big/destructure.scm | 53 + big/dump.scm | 429 ++ big/external.scm | 126 + big/filename.scm | 115 + big/format.scm | 151 + big/general-table.scm | 213 + big/lu-decomp.scm | 144 + big/new-ports.scm | 298 ++ big/pp.scm | 431 ++ big/queue.scm | 92 + big/random.scm | 54 + big/receive.scm | 8 + big/search-tree.scm | 397 ++ big/sleep.scm | 101 + big/sort.scm | 151 + big/thread.scm | 390 ++ big/xport.scm | 170 + build-usual-image | 32 + cig/cig.scm | 989 +++++ cig/doc/boxedminipage.sty | 45 + cig/doc/cig.tex | 658 +++ cig/doc/code.sty | 293 ++ cig/doc/ct.sty | 44 + cig/doc/draftfooters.sty | 76 + cig/doc/headings.tex | 16 + cig/image2script | 48 + cig/libcig.c | 86 + cig/libcig.h | 23 + cig/libcig.scm | 132 + cig/libcig1.c | 150 + comp-packages.scm | 160 + config.guess | 539 +++ config.sub | 866 ++++ configure | 1855 ++++++++ configure.in | 321 ++ debug-packages.scm | 134 + debug/byte-code-test.scm | 76 + debug/check.scm | 104 + debug/describe.scm | 41 + debug/fact.scm | 8 + debug/fix-low.scm | 72 + debug/for-debugging.scm | 59 + debug/level-0.scm | 30 + debug/link-debug.scm | 36 + debug/linker.scm | 34 + debug/mini-command.scm | 65 + debug/mini-eval.scm | 112 + debug/mini-package.scm | 74 + debug/mini-start.scm | 19 + debug/mumble-packages.scm | 73 + debug/mutation.scm | 130 + debug/profile.scm | 107 + debug/read-image.scm | 223 + debug/run.scm | 258 ++ debug/spatial-hack.scm | 63 + debug/test-generic.scm | 34 + debug/test-methods.scm | 37 + debug/test.scm | 32 + debug/tiny-packages.scm | 7 + debug/tiny.scm | 20 + debug/vector-space.scm | 132 + debug/wind-test.scm | 52 + doc/big-scheme.txt | 314 ++ doc/call-back.txt | 87 + doc/cheat.txt | 631 +++ doc/code.tex | 94 + doc/external.txt | 95 + doc/hacking.txt | 290 ++ doc/install.txt | 92 + doc/install.txt.s48-0.36 | 174 + doc/latex-stuff.tex | 45 + doc/meeting.ps | 1090 +++++ doc/meeting.tex | 439 ++ doc/module.ps | 1417 ++++++ doc/module.tex | 728 ++++ doc/newtime-spec.txt | 161 + doc/no-leaf-env.txt | 175 + doc/olins-changes | 71 + doc/package.txt | 81 + doc/scsh-manual.ps | 6799 +++++++++++++++++++++++++++++ doc/scsh-manual/awk.tex | 677 +++ doc/scsh-manual/front.tex | 51 + doc/scsh-manual/intro.tex | 189 + doc/scsh-manual/miscprocs.tex | 42 + doc/scsh-manual/network.tex | 423 ++ doc/scsh-manual/procnotation.tex | 527 +++ doc/scsh-manual/running.tex | 224 + doc/scsh-manual/strings.tex | 560 +++ doc/scsh-manual/syscalls.tex | 2312 ++++++++++ doc/scsh-manual/todo.tex | 52 + doc/scsh-paper.ps | 3723 ++++++++++++++++ doc/scsh-paper.tex | 2004 +++++++++ doc/scsh-src-roadmap.txt | 83 + doc/summary.tex | 83 + doc/threads.txt | 113 + doc/type.txt | 240 ++ doc/user-guide.txt | 682 +++ dynload.c | 477 ++ emacs/README | 47 + emacs/cmulisp.el | 693 +++ emacs/cmuscheme.el | 433 ++ emacs/cmuscheme48.el | 99 + emacs/cmushell.el | 594 +++ emacs/comint.el | 1372 ++++++ emacs/jar-hacks.el | 91 + env/assem.scm | 317 ++ env/basic-command.scm | 55 + env/build.scm | 76 + env/command.scm | 583 +++ env/debug.scm | 575 +++ env/debuginfo.scm | 77 + env/disasm.scm | 132 + env/disclosers.scm | 261 ++ env/dispcond.scm | 77 + env/flatload.scm | 107 + env/init-defpackage.scm | 23 + env/inspect.scm | 401 ++ env/jar-assem.scm | 133 + env/list-interface.scm | 46 + env/load-package.scm | 26 + env/more-thread.scm | 112 + env/pacman.scm | 333 ++ env/pedit.scm | 351 ++ env/read-command.scm | 186 + env/shadow.scm | 70 + env/space.scm | 206 + env/start.scm | 67 + env/traverse.scm | 213 + env/version-info.scm | 1 + extension.c | 381 ++ filenames.make | 7 + filenames.scm | 46 + infix/packages.scm | 29 + infix/pratt.scm | 308 ++ infix/sgol-runtime.scm | 11 + infix/sgol.scm | 213 + infix/tokenize.scm | 154 + initial-packages.scm | 94 + initial.debug | 2711 ++++++++++++ initial.image | Bin 0 -> 397660 bytes initial.scm | 59 + install-sh | 238 + interfaces.scm | 913 ++++ link-packages.scm | 101 + link/data.scm | 142 + link/generate-c-header.scm | 152 + link/link.scm | 147 + link/load-linker.exec | 89 + link/loadc.scm | 21 + link/lucid-script.lisp | 62 + link/reify.scm | 281 ++ link/transport.scm | 279 ++ link/write-image.scm | 73 + low-packages.scm | 30 + main-original.c | 160 + main.c | 198 + minor-version-number | 1 + misc/annotate.scm | 38 + misc/argument.scm | 49 + misc/doodl.scm | 299 ++ misc/either.scm | 90 + misc/getenv.scm | 15 + misc/hilbert.scm | 107 + misc/ilength.scm | 33 + misc/integertostring.scm | 64 + misc/load-static.scm | 40 + misc/mail.scm | 34 + misc/packages.scm | 103 + misc/psd-s48.scm | 130 + misc/remote.scm | 145 + misc/require.scm | 40 + misc/separate.scm | 140 + misc/shift-reset.scm | 91 + misc/sicp.scm | 112 + misc/slib-init.scm | 151 + misc/socket.scm | 55 + misc/static.scm | 210 + misc/test-doodl.scm | 52 + more-interfaces.scm | 375 ++ more-packages.scm | 592 +++ opt/analyze.scm | 397 ++ opt/expand.scm | 289 ++ opt/inline.scm | 96 + opt/tst.scm | 26 + packages.scm | 357 ++ postgcstub.c | 1 + prescheme.c | 37 + prescheme.h | 36 + proc2.c | 364 ++ rts-packages.scm | 188 + rts/arch.scm | 263 ++ rts/base.scm | 380 ++ rts/bignum.scm | 336 ++ rts/bummed-jar-defrecord.scm | 69 + rts/condition.scm | 76 + rts/continuation.scm | 43 + rts/defenum.scm | 72 + rts/enum.scm | 25 + rts/env.scm | 97 + rts/eval.scm | 67 + rts/exception.scm | 147 + rts/floatnum.scm | 296 ++ rts/fluid.scm | 89 + rts/init.scm | 18 + rts/innum.scm | 108 + rts/interrupt.scm | 72 + rts/jar-defrecord.scm | 47 + rts/lize.scm | 35 + rts/low.scm | 118 + rts/method.scm | 512 +++ rts/number.scm | 78 + rts/numio.scm | 175 + rts/population.scm | 37 + rts/port.scm | 80 + rts/ratnum.scm | 141 + rts/read.scm | 266 ++ rts/recnum.scm | 117 + rts/record.scm | 119 + rts/signal.scm | 35 + rts/template.scm | 27 + rts/util.scm | 67 + rts/wind.scm | 100 + rts/write.scm | 151 + rts/xnum.scm | 292 ++ rts/xprim.scm | 125 + scheme48.1 | 80 + scheme48.h | 94 + scheme48.man | 80 + scheme48vm.c | 6942 ++++++++++++++++++++++++++++++ scsh.man | 82 + scsh/aix/Makefile.inc | 11 + scsh/aix/bufpol.scm | 17 + scsh/aix/errno.scm | 145 + scsh/aix/fdflags.scm | 44 + scsh/aix/netconst.scm | 133 + scsh/aix/packages.scm | 142 + scsh/aix/signals.scm | 56 + scsh/aix/sigset.h | 10 + scsh/aix/stdio_dep.c | 70 + scsh/aix/sysdep.h | 4 + scsh/aix/time_dep.scm | 8 + scsh/aix/time_dep1.c | 38 + scsh/aix/waitcodes.scm | 40 + scsh/awk.scm | 505 +++ scsh/bdbmo.c | 107 + scsh/bsd/Makefile.inc | 0 scsh/bsd/bufpol.scm | 18 + scsh/bsd/errno.scm | 137 + scsh/bsd/fdflags.scm | 86 + scsh/bsd/netconst.scm | 139 + scsh/bsd/packages.scm | 138 + scsh/bsd/signals.scm | 73 + scsh/bsd/sigset.h | 10 + scsh/bsd/stdio_dep.c | 81 + scsh/bsd/sysdep.h | 0 scsh/bsd/time_dep.scm | 8 + scsh/bsd/time_dep1.c | 38 + scsh/bsd/waitcodes.scm | 40 + scsh/char-set.scm | 201 + scsh/cstuff.h | 9 + scsh/cxux/Makefile.inc | 4 + scsh/cxux/bufpol.scm | 17 + scsh/cxux/errno.scm | 200 + scsh/cxux/fdflags.scm | 26 + scsh/cxux/netconst.scm | 121 + scsh/cxux/packages.scm | 209 + scsh/cxux/signals.scm | 35 + scsh/cxux/stdio_dep.c | 68 + scsh/cxux/sysdep.h | 2 + scsh/cxux/time_dep.scm | 8 + scsh/cxux/time_dep1.c | 38 + scsh/cxux/waitcodes.scm | 40 + scsh/db.c | 30 + scsh/db.scm | 93 + scsh/dbm.c | 184 + scsh/dbm.scm | 390 ++ scsh/dbm1.c | 95 + scsh/defrec.scm | 168 + scsh/dirstuff1.c | 136 + scsh/ekko.scm | 13 + scsh/enumconst.scm | 16 + scsh/fdports.h | 16 + scsh/fdports.scm | 93 + scsh/fdports1.c | 453 ++ scsh/fileinfo.scm | 106 + scsh/filemtch.scm | 71 + scsh/filesys.scm | 112 + scsh/flock.c | 50 + scsh/flock.scm | 138 + scsh/flock1.c | 38 + scsh/fname.scm | 268 ++ scsh/fr.c | 8 + scsh/fr.scm | 418 ++ scsh/generic/Makefile.inc | 0 scsh/generic/bufpol.scm | 17 + scsh/generic/errno.scm | 137 + scsh/generic/fdflags.scm | 26 + scsh/generic/netconst.scm | 121 + scsh/generic/packages.scm | 112 + scsh/generic/signals.scm | 35 + scsh/generic/stdio_dep.c | 68 + scsh/generic/sysdep.h | 0 scsh/generic/time_dep.scm | 8 + scsh/generic/time_dep1.c | 38 + scsh/generic/waitcodes.scm | 40 + scsh/glob.scm | 272 ++ scsh/here.scm | 119 + scsh/hpux/Makefile.inc | 0 scsh/hpux/bufpol.scm | 17 + scsh/hpux/errno.scm | 149 + scsh/hpux/fdflags.scm | 43 + scsh/hpux/netconst.scm | 128 + scsh/hpux/packages.scm | 64 + scsh/hpux/signals.scm | 48 + scsh/hpux/sigset.h | 10 + scsh/hpux/stdio_dep.c | 82 + scsh/hpux/sysdep.h | 0 scsh/hpux/time_dep.scm | 8 + scsh/hpux/time_dep1.c | 38 + scsh/hpux/waitcodes.scm | 40 + scsh/irix/Makefile.inc | 0 scsh/irix/bufpol.scm | 18 + scsh/irix/errno.scm | 163 + scsh/irix/fdflags.scm | 40 + scsh/irix/netconst.scm | 126 + scsh/irix/packages.scm | 151 + scsh/irix/signals.scm | 48 + scsh/irix/sigset.h | 10 + scsh/irix/stdio_dep.c | 81 + scsh/irix/sysdep.h | 0 scsh/irix/time_dep.scm | 8 + scsh/irix/time_dep1.c | 38 + scsh/irix/waitcodes.scm | 40 + scsh/jcontrol.scm | 64 + scsh/jcontrol1.c | 95 + scsh/jcontrol2.c | 101 + scsh/jcontrol2.scm | 195 + scsh/linux/Makefile.inc | 0 scsh/linux/bufpol.scm | 18 + scsh/linux/errno.scm | 144 + scsh/linux/fdflags.scm | 87 + scsh/linux/netconst.scm | 128 + scsh/linux/packages.scm | 126 + scsh/linux/signals.scm | 48 + scsh/linux/sigset.h | 10 + scsh/linux/stdio_dep.c | 78 + scsh/linux/sysdep.h | 0 scsh/linux/time_dep.scm | 8 + scsh/linux/time_dep1.c | 38 + scsh/linux/waitcodes.scm | 40 + scsh/meta-arg.scm | 129 + scsh/minor-version-number | 1 + scsh/ndbm.c | 131 + scsh/ndbm.scm | 116 + scsh/ndbm1.c | 107 + scsh/ndbmo.c | 29 + scsh/network.c | 402 ++ scsh/network.scm | 970 +++++ scsh/network1.c | 604 +++ scsh/newports.scm | 403 ++ scsh/next/Makefile.inc | 0 scsh/next/bufpol.scm | 17 + scsh/next/errno.scm | 147 + scsh/next/fdflags.scm | 80 + scsh/next/netconst.scm | 121 + scsh/next/packages.scm | 115 + scsh/next/signals.scm | 72 + scsh/next/sigset.h | 7 + scsh/next/stdio_dep.c | 89 + scsh/next/sysdep.h | 2 + scsh/next/time_dep.scm | 8 + scsh/next/time_dep1.c | 38 + scsh/next/waitcodes.scm | 40 + scsh/nextbs.c | 17 + scsh/nt2.c | 16 + scsh/old-static.scm | 303 ++ scsh/oldfr.scm | 568 +++ scsh/oldhere.scm | 100 + scsh/oldtop.scm | 133 + scsh/procobj.scm | 294 ++ scsh/putenv.c | 175 + scsh/rdelim.c | 22 + scsh/rdelim.scm | 272 ++ scsh/re.c | 23 + scsh/re.scm | 67 + scsh/regexp/Makefile.in | 93 + scsh/regexp/README | 84 + scsh/regexp/regerror.c | 14 + scsh/regexp/regexp.c | 1211 ++++++ scsh/regexp/regexp.h | 21 + scsh/regexp/regmagic.h | 5 + scsh/regexp/regsub.c | 83 + scsh/regexp/try.c | 236 + scsh/rescm.c | 74 + scsh/rw.scm | 208 + scsh/scsh-condition.scm | 90 + scsh/scsh-interfaces.scm | 858 ++++ scsh/scsh-package.scm | 282 ++ scsh/scsh-read.scm | 125 + scsh/scsh-tramp.c | 73 + scsh/scsh-version.scm | 3 + scsh/scsh.scm | 793 ++++ scsh/scsh_aux.h | 7 + scsh/select.c | 26 + scsh/select.scm | 58 + scsh/select1.c | 196 + scsh/solaris/Makefile.inc | 0 scsh/solaris/bufpol.scm | 17 + scsh/solaris/errno.scm | 183 + scsh/solaris/fdflags.scm | 82 + scsh/solaris/netconst.scm | 121 + scsh/solaris/packages.scm | 159 + scsh/solaris/signals.scm | 55 + scsh/solaris/sigset.h | 10 + scsh/solaris/stdio_dep.c | 81 + scsh/solaris/sysdep.h | 1 + scsh/solaris/time_dep.scm | 8 + scsh/solaris/time_dep1.c | 38 + scsh/solaris/waitcodes.scm | 40 + scsh/startup.scm | 64 + scsh/static-heap.scm | 8 + scsh/static.scm | 30 + scsh/static1.scm | 663 +++ scsh/stringcoll.scm | 166 + scsh/sunos/Makefile.inc | 0 scsh/sunos/bufpol.scm | 17 + scsh/sunos/errno.scm | 158 + scsh/sunos/fdflags.scm | 83 + scsh/sunos/netconst.scm | 121 + scsh/sunos/packages.scm | 111 + scsh/sunos/signals.scm | 35 + scsh/sunos/sigset.h | 10 + scsh/sunos/stdio_dep.c | 81 + scsh/sunos/sysdep.h | 0 scsh/sunos/time_dep.scm | 8 + scsh/sunos/time_dep1.c | 38 + scsh/sunos/waitcodes.scm | 40 + scsh/syntax-helpers.scm | 231 + scsh/syntax.scm | 71 + scsh/syscalls.c | 1147 +++++ scsh/syscalls.scm | 1046 +++++ scsh/syscalls1.c | 496 +++ scsh/tc.c | 60 + scsh/tc.scm | 274 ++ scsh/tc1.c | 55 + scsh/time.c | 109 + scsh/time.scm | 305 ++ scsh/time1.c | 408 ++ scsh/time1.h | 23 + scsh/top.scm | 292 ++ scsh/ultrix/Makefile.inc | 0 scsh/ultrix/bufpol.scm | 17 + scsh/ultrix/errno.scm | 140 + scsh/ultrix/fdflags.scm | 44 + scsh/ultrix/netconst.scm | 121 + scsh/ultrix/packages.scm | 128 + scsh/ultrix/signals.scm | 48 + scsh/ultrix/sigset.h | 10 + scsh/ultrix/stdio_dep.c | 81 + scsh/ultrix/sysdep.h | 0 scsh/ultrix/time_dep.scm | 8 + scsh/ultrix/time_dep1.c | 38 + scsh/ultrix/waitcodes.scm | 40 + scsh/userinfo.c | 93 + scsh/utilities.scm | 204 + sysdep.h.in | 126 + unix.c | 654 +++ vm/README | 49 + vm/arch.scm | 263 ++ vm/arith.scm | 117 + vm/data.scm | 240 ++ vm/defenum.scm | 71 + vm/define-primitive.scm | 68 + vm/disasm.scm | 106 + vm/env.scm | 91 + vm/external.scm | 17 + vm/gc.scm | 218 + vm/heap.scm | 302 ++ vm/interfaces.scm | 233 + vm/interp.scm | 737 ++++ vm/macro-package-defs.scm | 6 + vm/memory.scm | 99 + vm/package-defs.scm | 68 + vm/prescheme.scm | 48 + vm/prim.scm | 673 +++ vm/ps-interface.scm | 90 + vm/ps-memory.scm | 116 + vm/ps-package-defs.scm | 28 + vm/ps-package.scm | 5 + vm/resume.scm | 65 + vm/s48-package-defs.scm | 31 + vm/stack.scm | 470 ++ vm/stob.scm | 128 + vm/struct.scm | 300 ++ vm/vm-utilities.scm | 52 + vm/vmio.scm | 195 + 570 files changed, 111763 insertions(+) create mode 100644 .gdbinit create mode 100644 .gitignore create mode 100644 .notify create mode 100644 COPYING create mode 100644 Changes create mode 100644 INSTALL create mode 100644 Makefile.in create mode 100644 NEWS create mode 100644 NEWS.s48-0.36 create mode 100644 README create mode 100644 README.s48-0.36 create mode 100644 RELEASE create mode 100644 TODO create mode 100644 TODO.s48-0.36 create mode 100644 alt-packages.scm create mode 100644 alt/annotate.scm create mode 100644 alt/ascii.scm create mode 100644 alt/bitwise-tests.scm create mode 100644 alt/bitwise.scm create mode 100644 alt/closure.scm create mode 100644 alt/code-vector.scm create mode 100644 alt/config.scm create mode 100644 alt/contin.scm create mode 100644 alt/environments.scm create mode 100644 alt/escape.scm create mode 100644 alt/features-packages.scm create mode 100644 alt/features.scm create mode 100644 alt/fluid.scm create mode 100644 alt/init-defpackage.scm create mode 100644 alt/locations.scm create mode 100644 alt/loophole.scm create mode 100644 alt/low-packages.scm create mode 100644 alt/low.scm create mode 100644 alt/primitives.scm create mode 100644 alt/pseudoscheme-features.scm create mode 100644 alt/pseudoscheme-record.scm create mode 100644 alt/queue.scm create mode 100644 alt/record.scm create mode 100644 alt/reroot.scm create mode 100644 alt/schemetoc-features.scm create mode 100644 alt/schemetoc-record.scm create mode 100644 alt/silly.scm create mode 100644 alt/syntax.scm create mode 100644 alt/t-features.scm create mode 100644 alt/t-record.scm create mode 100644 alt/table.scm create mode 100644 alt/template.scm create mode 100644 alt/values.scm create mode 100644 alt/weak.scm create mode 100644 bcomp/comp.scm create mode 100644 bcomp/config.scm create mode 100644 bcomp/cprim.scm create mode 100644 bcomp/ctop.scm create mode 100644 bcomp/ddata.scm create mode 100644 bcomp/for-reify.scm create mode 100644 bcomp/interface.scm create mode 100644 bcomp/module-language.scm create mode 100644 bcomp/mtype.scm create mode 100644 bcomp/package.scm create mode 100644 bcomp/recon.scm create mode 100644 bcomp/rules.scm create mode 100644 bcomp/scan.scm create mode 100644 bcomp/schemify.scm create mode 100644 bcomp/segment.scm create mode 100644 bcomp/state.scm create mode 100644 bcomp/syntax.scm create mode 100644 bcomp/type.scm create mode 100644 bcomp/undefined.scm create mode 100644 bcomp/usual.scm create mode 100644 big/array.scm create mode 100644 big/big-util.scm create mode 100644 big/bigbit.scm create mode 100644 big/compose-cont.scm create mode 100644 big/defrecord.scm create mode 100644 big/destructure.scm create mode 100644 big/dump.scm create mode 100644 big/external.scm create mode 100644 big/filename.scm create mode 100644 big/format.scm create mode 100644 big/general-table.scm create mode 100644 big/lu-decomp.scm create mode 100644 big/new-ports.scm create mode 100644 big/pp.scm create mode 100644 big/queue.scm create mode 100644 big/random.scm create mode 100644 big/receive.scm create mode 100644 big/search-tree.scm create mode 100644 big/sleep.scm create mode 100644 big/sort.scm create mode 100644 big/thread.scm create mode 100644 big/xport.scm create mode 100644 build-usual-image create mode 100644 cig/cig.scm create mode 100644 cig/doc/boxedminipage.sty create mode 100644 cig/doc/cig.tex create mode 100644 cig/doc/code.sty create mode 100644 cig/doc/ct.sty create mode 100644 cig/doc/draftfooters.sty create mode 100644 cig/doc/headings.tex create mode 100755 cig/image2script create mode 100644 cig/libcig.c create mode 100644 cig/libcig.h create mode 100644 cig/libcig.scm create mode 100644 cig/libcig1.c create mode 100644 comp-packages.scm create mode 100755 config.guess create mode 100755 config.sub create mode 100755 configure create mode 100644 configure.in create mode 100644 debug-packages.scm create mode 100644 debug/byte-code-test.scm create mode 100644 debug/check.scm create mode 100644 debug/describe.scm create mode 100644 debug/fact.scm create mode 100644 debug/fix-low.scm create mode 100644 debug/for-debugging.scm create mode 100644 debug/level-0.scm create mode 100644 debug/link-debug.scm create mode 100644 debug/linker.scm create mode 100644 debug/mini-command.scm create mode 100644 debug/mini-eval.scm create mode 100644 debug/mini-package.scm create mode 100644 debug/mini-start.scm create mode 100644 debug/mumble-packages.scm create mode 100644 debug/mutation.scm create mode 100644 debug/profile.scm create mode 100644 debug/read-image.scm create mode 100644 debug/run.scm create mode 100644 debug/spatial-hack.scm create mode 100644 debug/test-generic.scm create mode 100644 debug/test-methods.scm create mode 100644 debug/test.scm create mode 100644 debug/tiny-packages.scm create mode 100644 debug/tiny.scm create mode 100644 debug/vector-space.scm create mode 100644 debug/wind-test.scm create mode 100644 doc/big-scheme.txt create mode 100644 doc/call-back.txt create mode 100644 doc/cheat.txt create mode 100644 doc/code.tex create mode 100644 doc/external.txt create mode 100644 doc/hacking.txt create mode 100644 doc/install.txt create mode 100644 doc/install.txt.s48-0.36 create mode 100644 doc/latex-stuff.tex create mode 100644 doc/meeting.ps create mode 100644 doc/meeting.tex create mode 100644 doc/module.ps create mode 100644 doc/module.tex create mode 100644 doc/newtime-spec.txt create mode 100644 doc/no-leaf-env.txt create mode 100644 doc/olins-changes create mode 100644 doc/package.txt create mode 100644 doc/scsh-manual.ps create mode 100644 doc/scsh-manual/awk.tex create mode 100644 doc/scsh-manual/front.tex create mode 100644 doc/scsh-manual/intro.tex create mode 100644 doc/scsh-manual/miscprocs.tex create mode 100644 doc/scsh-manual/network.tex create mode 100644 doc/scsh-manual/procnotation.tex create mode 100644 doc/scsh-manual/running.tex create mode 100644 doc/scsh-manual/strings.tex create mode 100644 doc/scsh-manual/syscalls.tex create mode 100644 doc/scsh-manual/todo.tex create mode 100644 doc/scsh-paper.ps create mode 100644 doc/scsh-paper.tex create mode 100644 doc/scsh-src-roadmap.txt create mode 100644 doc/summary.tex create mode 100644 doc/threads.txt create mode 100644 doc/type.txt create mode 100644 doc/user-guide.txt create mode 100644 dynload.c create mode 100644 emacs/README create mode 100644 emacs/cmulisp.el create mode 100644 emacs/cmuscheme.el create mode 100644 emacs/cmuscheme48.el create mode 100644 emacs/cmushell.el create mode 100644 emacs/comint.el create mode 100644 emacs/jar-hacks.el create mode 100644 env/assem.scm create mode 100644 env/basic-command.scm create mode 100644 env/build.scm create mode 100644 env/command.scm create mode 100644 env/debug.scm create mode 100644 env/debuginfo.scm create mode 100644 env/disasm.scm create mode 100644 env/disclosers.scm create mode 100644 env/dispcond.scm create mode 100644 env/flatload.scm create mode 100644 env/init-defpackage.scm create mode 100644 env/inspect.scm create mode 100644 env/jar-assem.scm create mode 100644 env/list-interface.scm create mode 100644 env/load-package.scm create mode 100644 env/more-thread.scm create mode 100644 env/pacman.scm create mode 100644 env/pedit.scm create mode 100644 env/read-command.scm create mode 100644 env/shadow.scm create mode 100644 env/space.scm create mode 100644 env/start.scm create mode 100644 env/traverse.scm create mode 100644 env/version-info.scm create mode 100644 extension.c create mode 100644 filenames.make create mode 100644 filenames.scm create mode 100644 infix/packages.scm create mode 100644 infix/pratt.scm create mode 100644 infix/sgol-runtime.scm create mode 100644 infix/sgol.scm create mode 100644 infix/tokenize.scm create mode 100644 initial-packages.scm create mode 100644 initial.debug create mode 100644 initial.image create mode 100644 initial.scm create mode 100755 install-sh create mode 100644 interfaces.scm create mode 100644 link-packages.scm create mode 100644 link/data.scm create mode 100644 link/generate-c-header.scm create mode 100644 link/link.scm create mode 100644 link/load-linker.exec create mode 100644 link/loadc.scm create mode 100644 link/lucid-script.lisp create mode 100644 link/reify.scm create mode 100644 link/transport.scm create mode 100644 link/write-image.scm create mode 100644 low-packages.scm create mode 100644 main-original.c create mode 100644 main.c create mode 100644 minor-version-number create mode 100644 misc/annotate.scm create mode 100644 misc/argument.scm create mode 100644 misc/doodl.scm create mode 100644 misc/either.scm create mode 100644 misc/getenv.scm create mode 100644 misc/hilbert.scm create mode 100644 misc/ilength.scm create mode 100644 misc/integertostring.scm create mode 100644 misc/load-static.scm create mode 100644 misc/mail.scm create mode 100644 misc/packages.scm create mode 100644 misc/psd-s48.scm create mode 100644 misc/remote.scm create mode 100644 misc/require.scm create mode 100644 misc/separate.scm create mode 100644 misc/shift-reset.scm create mode 100644 misc/sicp.scm create mode 100644 misc/slib-init.scm create mode 100644 misc/socket.scm create mode 100644 misc/static.scm create mode 100644 misc/test-doodl.scm create mode 100644 more-interfaces.scm create mode 100644 more-packages.scm create mode 100644 opt/analyze.scm create mode 100644 opt/expand.scm create mode 100644 opt/inline.scm create mode 100644 opt/tst.scm create mode 100644 packages.scm create mode 100644 postgcstub.c create mode 100644 prescheme.c create mode 100644 prescheme.h create mode 100644 proc2.c create mode 100644 rts-packages.scm create mode 100644 rts/arch.scm create mode 100644 rts/base.scm create mode 100644 rts/bignum.scm create mode 100644 rts/bummed-jar-defrecord.scm create mode 100644 rts/condition.scm create mode 100644 rts/continuation.scm create mode 100644 rts/defenum.scm create mode 100644 rts/enum.scm create mode 100644 rts/env.scm create mode 100644 rts/eval.scm create mode 100644 rts/exception.scm create mode 100644 rts/floatnum.scm create mode 100644 rts/fluid.scm create mode 100644 rts/init.scm create mode 100644 rts/innum.scm create mode 100644 rts/interrupt.scm create mode 100644 rts/jar-defrecord.scm create mode 100644 rts/lize.scm create mode 100644 rts/low.scm create mode 100644 rts/method.scm create mode 100644 rts/number.scm create mode 100644 rts/numio.scm create mode 100644 rts/population.scm create mode 100644 rts/port.scm create mode 100644 rts/ratnum.scm create mode 100644 rts/read.scm create mode 100644 rts/recnum.scm create mode 100644 rts/record.scm create mode 100644 rts/signal.scm create mode 100644 rts/template.scm create mode 100644 rts/util.scm create mode 100644 rts/wind.scm create mode 100644 rts/write.scm create mode 100644 rts/xnum.scm create mode 100644 rts/xprim.scm create mode 100644 scheme48.1 create mode 100644 scheme48.h create mode 100644 scheme48.man create mode 100644 scheme48vm.c create mode 100644 scsh.man create mode 100644 scsh/aix/Makefile.inc create mode 100644 scsh/aix/bufpol.scm create mode 100644 scsh/aix/errno.scm create mode 100644 scsh/aix/fdflags.scm create mode 100644 scsh/aix/netconst.scm create mode 100644 scsh/aix/packages.scm create mode 100644 scsh/aix/signals.scm create mode 100644 scsh/aix/sigset.h create mode 100644 scsh/aix/stdio_dep.c create mode 100644 scsh/aix/sysdep.h create mode 100644 scsh/aix/time_dep.scm create mode 100644 scsh/aix/time_dep1.c create mode 100644 scsh/aix/waitcodes.scm create mode 100644 scsh/awk.scm create mode 100644 scsh/bdbmo.c create mode 100644 scsh/bsd/Makefile.inc create mode 100644 scsh/bsd/bufpol.scm create mode 100644 scsh/bsd/errno.scm create mode 100644 scsh/bsd/fdflags.scm create mode 100644 scsh/bsd/netconst.scm create mode 100644 scsh/bsd/packages.scm create mode 100644 scsh/bsd/signals.scm create mode 100644 scsh/bsd/sigset.h create mode 100644 scsh/bsd/stdio_dep.c create mode 100644 scsh/bsd/sysdep.h create mode 100644 scsh/bsd/time_dep.scm create mode 100644 scsh/bsd/time_dep1.c create mode 100644 scsh/bsd/waitcodes.scm create mode 100644 scsh/char-set.scm create mode 100644 scsh/cstuff.h create mode 100644 scsh/cxux/Makefile.inc create mode 100644 scsh/cxux/bufpol.scm create mode 100644 scsh/cxux/errno.scm create mode 100644 scsh/cxux/fdflags.scm create mode 100644 scsh/cxux/netconst.scm create mode 100644 scsh/cxux/packages.scm create mode 100644 scsh/cxux/signals.scm create mode 100644 scsh/cxux/stdio_dep.c create mode 100644 scsh/cxux/sysdep.h create mode 100644 scsh/cxux/time_dep.scm create mode 100644 scsh/cxux/time_dep1.c create mode 100644 scsh/cxux/waitcodes.scm create mode 100644 scsh/db.c create mode 100644 scsh/db.scm create mode 100644 scsh/dbm.c create mode 100644 scsh/dbm.scm create mode 100644 scsh/dbm1.c create mode 100644 scsh/defrec.scm create mode 100644 scsh/dirstuff1.c create mode 100755 scsh/ekko.scm create mode 100644 scsh/enumconst.scm create mode 100644 scsh/fdports.h create mode 100644 scsh/fdports.scm create mode 100644 scsh/fdports1.c create mode 100644 scsh/fileinfo.scm create mode 100644 scsh/filemtch.scm create mode 100644 scsh/filesys.scm create mode 100644 scsh/flock.c create mode 100644 scsh/flock.scm create mode 100644 scsh/flock1.c create mode 100644 scsh/fname.scm create mode 100644 scsh/fr.c create mode 100644 scsh/fr.scm create mode 100644 scsh/generic/Makefile.inc create mode 100644 scsh/generic/bufpol.scm create mode 100644 scsh/generic/errno.scm create mode 100644 scsh/generic/fdflags.scm create mode 100644 scsh/generic/netconst.scm create mode 100644 scsh/generic/packages.scm create mode 100644 scsh/generic/signals.scm create mode 100644 scsh/generic/stdio_dep.c create mode 100644 scsh/generic/sysdep.h create mode 100644 scsh/generic/time_dep.scm create mode 100644 scsh/generic/time_dep1.c create mode 100644 scsh/generic/waitcodes.scm create mode 100644 scsh/glob.scm create mode 100644 scsh/here.scm create mode 100644 scsh/hpux/Makefile.inc create mode 100644 scsh/hpux/bufpol.scm create mode 100644 scsh/hpux/errno.scm create mode 100644 scsh/hpux/fdflags.scm create mode 100644 scsh/hpux/netconst.scm create mode 100644 scsh/hpux/packages.scm create mode 100644 scsh/hpux/signals.scm create mode 100644 scsh/hpux/sigset.h create mode 100644 scsh/hpux/stdio_dep.c create mode 100644 scsh/hpux/sysdep.h create mode 100644 scsh/hpux/time_dep.scm create mode 100644 scsh/hpux/time_dep1.c create mode 100644 scsh/hpux/waitcodes.scm create mode 100644 scsh/irix/Makefile.inc create mode 100644 scsh/irix/bufpol.scm create mode 100644 scsh/irix/errno.scm create mode 100644 scsh/irix/fdflags.scm create mode 100644 scsh/irix/netconst.scm create mode 100644 scsh/irix/packages.scm create mode 100644 scsh/irix/signals.scm create mode 100644 scsh/irix/sigset.h create mode 100644 scsh/irix/stdio_dep.c create mode 100644 scsh/irix/sysdep.h create mode 100644 scsh/irix/time_dep.scm create mode 100644 scsh/irix/time_dep1.c create mode 100644 scsh/irix/waitcodes.scm create mode 100644 scsh/jcontrol.scm create mode 100644 scsh/jcontrol1.c create mode 100644 scsh/jcontrol2.c create mode 100644 scsh/jcontrol2.scm create mode 100644 scsh/linux/Makefile.inc create mode 100644 scsh/linux/bufpol.scm create mode 100644 scsh/linux/errno.scm create mode 100644 scsh/linux/fdflags.scm create mode 100644 scsh/linux/netconst.scm create mode 100644 scsh/linux/packages.scm create mode 100644 scsh/linux/signals.scm create mode 100644 scsh/linux/sigset.h create mode 100644 scsh/linux/stdio_dep.c create mode 100644 scsh/linux/sysdep.h create mode 100644 scsh/linux/time_dep.scm create mode 100644 scsh/linux/time_dep1.c create mode 100644 scsh/linux/waitcodes.scm create mode 100644 scsh/meta-arg.scm create mode 100644 scsh/minor-version-number create mode 100644 scsh/ndbm.c create mode 100644 scsh/ndbm.scm create mode 100644 scsh/ndbm1.c create mode 100644 scsh/ndbmo.c create mode 100644 scsh/network.c create mode 100644 scsh/network.scm create mode 100644 scsh/network1.c create mode 100644 scsh/newports.scm create mode 100644 scsh/next/Makefile.inc create mode 100644 scsh/next/bufpol.scm create mode 100644 scsh/next/errno.scm create mode 100644 scsh/next/fdflags.scm create mode 100644 scsh/next/netconst.scm create mode 100644 scsh/next/packages.scm create mode 100644 scsh/next/signals.scm create mode 100644 scsh/next/sigset.h create mode 100644 scsh/next/stdio_dep.c create mode 100644 scsh/next/sysdep.h create mode 100644 scsh/next/time_dep.scm create mode 100644 scsh/next/time_dep1.c create mode 100644 scsh/next/waitcodes.scm create mode 100644 scsh/nextbs.c create mode 100644 scsh/nt2.c create mode 100644 scsh/old-static.scm create mode 100644 scsh/oldfr.scm create mode 100644 scsh/oldhere.scm create mode 100644 scsh/oldtop.scm create mode 100644 scsh/procobj.scm create mode 100644 scsh/putenv.c create mode 100644 scsh/rdelim.c create mode 100644 scsh/rdelim.scm create mode 100644 scsh/re.c create mode 100644 scsh/re.scm create mode 100644 scsh/regexp/Makefile.in create mode 100644 scsh/regexp/README create mode 100644 scsh/regexp/regerror.c create mode 100644 scsh/regexp/regexp.c create mode 100644 scsh/regexp/regexp.h create mode 100644 scsh/regexp/regmagic.h create mode 100644 scsh/regexp/regsub.c create mode 100644 scsh/regexp/try.c create mode 100644 scsh/rescm.c create mode 100644 scsh/rw.scm create mode 100644 scsh/scsh-condition.scm create mode 100644 scsh/scsh-interfaces.scm create mode 100644 scsh/scsh-package.scm create mode 100644 scsh/scsh-read.scm create mode 100644 scsh/scsh-tramp.c create mode 100644 scsh/scsh-version.scm create mode 100644 scsh/scsh.scm create mode 100644 scsh/scsh_aux.h create mode 100644 scsh/select.c create mode 100644 scsh/select.scm create mode 100644 scsh/select1.c create mode 100644 scsh/solaris/Makefile.inc create mode 100644 scsh/solaris/bufpol.scm create mode 100644 scsh/solaris/errno.scm create mode 100644 scsh/solaris/fdflags.scm create mode 100644 scsh/solaris/netconst.scm create mode 100644 scsh/solaris/packages.scm create mode 100644 scsh/solaris/signals.scm create mode 100644 scsh/solaris/sigset.h create mode 100644 scsh/solaris/stdio_dep.c create mode 100644 scsh/solaris/sysdep.h create mode 100644 scsh/solaris/time_dep.scm create mode 100644 scsh/solaris/time_dep1.c create mode 100644 scsh/solaris/waitcodes.scm create mode 100644 scsh/startup.scm create mode 100644 scsh/static-heap.scm create mode 100755 scsh/static.scm create mode 100644 scsh/static1.scm create mode 100644 scsh/stringcoll.scm create mode 100644 scsh/sunos/Makefile.inc create mode 100644 scsh/sunos/bufpol.scm create mode 100644 scsh/sunos/errno.scm create mode 100644 scsh/sunos/fdflags.scm create mode 100644 scsh/sunos/netconst.scm create mode 100644 scsh/sunos/packages.scm create mode 100644 scsh/sunos/signals.scm create mode 100644 scsh/sunos/sigset.h create mode 100644 scsh/sunos/stdio_dep.c create mode 100644 scsh/sunos/sysdep.h create mode 100644 scsh/sunos/time_dep.scm create mode 100644 scsh/sunos/time_dep1.c create mode 100644 scsh/sunos/waitcodes.scm create mode 100644 scsh/syntax-helpers.scm create mode 100644 scsh/syntax.scm create mode 100644 scsh/syscalls.c create mode 100644 scsh/syscalls.scm create mode 100644 scsh/syscalls1.c create mode 100644 scsh/tc.c create mode 100644 scsh/tc.scm create mode 100644 scsh/tc1.c create mode 100644 scsh/time.c create mode 100644 scsh/time.scm create mode 100644 scsh/time1.c create mode 100644 scsh/time1.h create mode 100644 scsh/top.scm create mode 100644 scsh/ultrix/Makefile.inc create mode 100644 scsh/ultrix/bufpol.scm create mode 100644 scsh/ultrix/errno.scm create mode 100644 scsh/ultrix/fdflags.scm create mode 100644 scsh/ultrix/netconst.scm create mode 100644 scsh/ultrix/packages.scm create mode 100644 scsh/ultrix/signals.scm create mode 100644 scsh/ultrix/sigset.h create mode 100644 scsh/ultrix/stdio_dep.c create mode 100644 scsh/ultrix/sysdep.h create mode 100644 scsh/ultrix/time_dep.scm create mode 100644 scsh/ultrix/time_dep1.c create mode 100644 scsh/ultrix/waitcodes.scm create mode 100644 scsh/userinfo.c create mode 100644 scsh/utilities.scm create mode 100644 sysdep.h.in create mode 100644 unix.c create mode 100644 vm/README create mode 100644 vm/arch.scm create mode 100644 vm/arith.scm create mode 100644 vm/data.scm create mode 100644 vm/defenum.scm create mode 100644 vm/define-primitive.scm create mode 100644 vm/disasm.scm create mode 100644 vm/env.scm create mode 100644 vm/external.scm create mode 100644 vm/gc.scm create mode 100644 vm/heap.scm create mode 100644 vm/interfaces.scm create mode 100644 vm/interp.scm create mode 100644 vm/macro-package-defs.scm create mode 100644 vm/memory.scm create mode 100644 vm/package-defs.scm create mode 100644 vm/prescheme.scm create mode 100644 vm/prim.scm create mode 100644 vm/ps-interface.scm create mode 100644 vm/ps-memory.scm create mode 100644 vm/ps-package-defs.scm create mode 100644 vm/ps-package.scm create mode 100644 vm/resume.scm create mode 100644 vm/s48-package-defs.scm create mode 100644 vm/stack.scm create mode 100644 vm/stob.scm create mode 100644 vm/struct.scm create mode 100644 vm/vm-utilities.scm create mode 100644 vm/vmio.scm diff --git a/.gdbinit b/.gdbinit new file mode 100644 index 0000000..be8c6b5 --- /dev/null +++ b/.gdbinit @@ -0,0 +1,106 @@ +# +# Commands useful for debugging the Scheme48 VM. +# + +#Set a breakpoint at label "raise". +#Obtain the proper line number using "egrep -n raise: scheme48vm.c". +#break scheme48vm.c:4831 + +#display/i $pc + +define scsh +run -o ./scshvm -i ./scsh/scsh.image +end +# +document scsh +For testing scsh -bri +end + +define pcont +echo template id = \ +output *(long *)((*(long *)(($ & ~3) + 8) & ~3) + 4) / 4 +echo \npc = \ +output (*(long *)(($ & ~3) + 4) / 4) +echo \nparent = \ +output *(long *)($ & ~3) +echo \nenv = \ +output *(long *)(($ & ~3) + 12) +echo \ncount = \ +output *(long *)(($ & ~3) - 4) >> 10 +echo \n +end +# +document pcont +Print $ as a continuation. +end + + +define parent +print *(long *)($ & ~3) +pcont +end +# +document parent +Select parent continuation. +end + + +define preview +set $cont = ScontS +preview-loop +end +# +define preview-loop +output $cont +echo \040 +output *(long *)((*(long *)(($cont & ~3) + 8) & ~3) + 4) / 4 +echo \n +set $cont = *(long *)($cont & ~3) +preview-loop +end +# +document preview +Display Scheme stack trace. Look up the template uids in the .debug file. +end + + +define show-header +echo Header length:\ +output $hdr >> 8 +echo \ type:\040 +output ($hdr & 127) >> 2 +echo \ tag:\040 +output $hdr & 3 +echo \n +end + +define look +output ($ - Snewspace_beginS) +echo :\n +set $hdr = *(long *)($ - 7) +show-header +output *(long *)($ - 3) +echo \n +output *(long *)($ + 1) +echo \n +output *(long *)($ + 5) +echo \n +end + +define go0 +print *(long *)($ - 3) +end + +define bytes +set $foo = RScode_pointerS +output (int)*(unsigned char *)($foo + 0) +echo \040 +output (int)*(unsigned char *)($foo + 1) +echo \040 +output (int)*(unsigned char *)($foo + 2) +echo \040 +output (int)*(unsigned char *)($foo + 3) +echo \040 +output (int)*(unsigned char *)($foo + 4) +echo \n +end diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..da8168b --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +# CVS default ignores begin +tags +TAGS +.make.state +.nse_depinfo +*~ +\#* +.#* +,* +_$* +*$ +*.old +*.bak +*.BAK +*.orig +*.rej +.del-* +*.a +*.olb +*.o +*.obj +*.so +*.exe +*.Z +*.elc +*.ln +core +# CVS default ignores end diff --git a/.notify b/.notify new file mode 100644 index 0000000..e69de29 diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..14cb6d6 --- /dev/null +++ b/COPYING @@ -0,0 +1,37 @@ +Copyright (c) 1993, 1994 by Richard Kelsey and Jonathan Rees. +Copyright (c) 1994, 1995 by Olin Shivers and Brian D. Carlstrom. + + Use of this program for non-commercial purposes is permitted provided +that such use is acknowledged both in the software itself and in +accompanying documentation. + + Use of this program for commercial purposes is also permitted, but +only if, in addition to the acknowledgement required for +non-commercial users, written notification of such use is provided by +the commercial user to the authors prior to the fabrication and +distribution of the resulting software. + + This software is provided ``as is'' without express or implied warranty. + + + +Distributing Autoconf Output +**************************** + +[excerpt from autoconf documentation] + + The configuration scripts that Autoconf produces are covered by the +GNU General Public License. This is because they consist almost +entirely of parts of Autoconf itself, rearranged somewhat, and Autoconf +is distributed under the terms of the GPL. As applied to Autoconf, the +GPL just means that you need to distribute `configure.in' along with +`configure'. + + Programs that use Autoconf scripts to configure themselves do not +automatically come under the GPL. Distributing an Autoconf +configuration script as part of a program is considered to be *mere +aggregation* of that work with the Autoconf script. Such programs are +not derivative works based on Autoconf; only their configuration scripts +are. We still encourage software authors to distribute their work under +terms like those of the GPL, but doing so is not required to use +Autoconf. diff --git a/Changes b/Changes new file mode 100644 index 0000000..97e2126 --- /dev/null +++ b/Changes @@ -0,0 +1,3 @@ +BEGIN process forms are now wrapped in a stdio->stdports call, so the + body sees the I/O environment established by the pf's EPF. + diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..420b629 --- /dev/null +++ b/INSTALL @@ -0,0 +1,120 @@ + This is a generic INSTALL file for utilities distributions. +If this package does not come with, e.g., installable documentation or +data files, please ignore the references to them below. + + [For information specific to scsh, see doc/install.txt.] + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation, and +creates the Makefile(s) (one in each subdirectory of the source +directory). In some packages it creates a C header file containing +system-dependent definitions. It also creates a file `config.status' +that you can run in the future to recreate the current configuration. + +To compile this package: + +1. Configure the package for your system. + + Normally, you just `cd' to the directory containing the package's +source code and type `./configure'. If you're using `csh' on an old +version of System V, you might need to type `sh configure' instead to +prevent `csh' from trying to execute `configure' itself. + + Running `configure' takes a minute or two. While it is running, it +prints some messages that tell what it is doing. If you don't want to +see the messages, run `configure' with its standard output redirected +to `/dev/null'; for example, `./configure >/dev/null'. + + To compile the package in a different directory from the one +containing the source code, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. If +for some reason `configure' is not in the source code directory that +you are configuring, then it will report that it can't find the source +code. In that case, run `configure' with the option `--srcdir=DIR', +where DIR is the directory that contains the source code. + + By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. Alternately, you can do so by consistently +giving a value for the `prefix' variable when you run `make', e.g., + make prefix=/usr/gnu + make prefix=/usr/gnu install + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PATH' or set the `make' +variable `exec_prefix' to PATH, the package will use PATH as the prefix +for installing programs and libraries. Data files and documentation +will still use the regular prefix. Normally, all files are installed +using the same prefix. + + Some packages pay attention to `--with-PACKAGE' options to +`configure', where PACKAGE is something like `gnu-as' or `x' (for the X +Window System). The README should mention any `--with-' options that +the package recognizes. + + `configure' ignores any other arguments that you give it. + + On systems that require unusual options for compilation or linking +that the package's `configure' script does not know about, you can give +`configure' initial values for variables by setting them in the +environment. In Bourne-compatible shells, you can do that on the +command line like this: + + CC='gcc -traditional' LIBS=-lposix ./configure + + Here are the `make' variables that you might want to override with +environment variables when running `configure'. + + For these variables, any value given in the environment overrides the +value that `configure' would choose: + + - Variable: CC + C compiler program. The default is `cc'. + + - Variable: INSTALL + Program to use to install files. The default is `install' if you + have it, `cp' otherwise. + + For these variables, any value given in the environment is added to +the value that `configure' chooses: + + - Variable: DEFS + Configuration options, in the form `-Dfoo -Dbar...'. Do not use + this variable in packages that create a configuration header file. + + - Variable: LIBS + Libraries to link with, in the form `-lfoo -lbar...'. + + If you need to do unusual things to compile the package, we encourage +you to figure out how `configure' could check whether to do them, and +mail diffs or instructions to the address given in the README so we +can include them in the next release. + +2. Type `make' to compile the package. If you want, you can override +the `make' variables CFLAGS and LDFLAGS like this: + + make CFLAGS=-O2 LDFLAGS=-s + +3. If the package comes with self-tests and you want to run them, +type `make check'. If you're not sure whether there are any, try it; +if `make' responds with something like + make: *** No way to make target `check'. Stop. +then the package does not come with self-tests. + +4. Type `make install' to install programs, data files, and +documentation. + +5. You can remove the program binaries and object files from the +source directory by typing `make clean'. To also remove the +Makefile(s), the header file containing system-dependent definitions +(if the package uses one), and `config.status' (all the files that +`configure' created), type `make distclean'. + + The file `configure.in' is used to create `configure' by a program +called `autoconf'. You only need it if you want to regenerate +`configure' using a newer version of `autoconf'. diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..b07d38a --- /dev/null +++ b/Makefile.in @@ -0,0 +1,662 @@ +# Scheme Shell Makefile +# Last updated September 1995 by BDC + +# Documentation in files INSTALL and doc/install.txt + +srcdir = @srcdir@ +VPATH = @srcdir@ +CC = @CC@ +DEFS = @DEFS@ +LIBS = @LIBS@ +#DBOPEN = @DBOPEN@ +CFLAGS = @CFLAGS@ +CPPFLAGS= @CPPFLAGS@ -I$(srcdir)/cig -I$(srcdir)/scsh/regexp +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ -c +INSTALL_DATA = @INSTALL_DATA@ -c + +LDFLAGS = -g @LDFLAGS@ +LDFLAGS_AIX= @LDFLAGS_AIX@ + +RM = rm -f + +AR = ar cq +RANLIB = ranlib + +SHELL = /bin/sh + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = $(exec_prefix)/bin +libdir = $(exec_prefix)/lib +incdir = $(exec_prefix)/include +mandir = $(prefix)/man +manext = 1 + +# HP 9000 series, if you don't have gcc +# CC = cc +# CFLAGS = -Aa -O +Obb1800 +# DEFS = -D_HPUX_SOURCE -Dhpux + +# Ultrix +# LDFLAGS = -N + +.c.o: + $(CC) -c $(CPPFLAGS) $(DEFS) -I$(srcdir) -I. $(CFLAGS) -o $@ $< + +# You might want to change RUNNABLE to "s48" # NOT -bri +RUNNABLE = scsh +MANPAGE = $(RUNNABLE).$(manext) +LIB = $(libdir)/$(RUNNABLE) + +distdir = /users/ftp/pub/s48 +#distdir = /net/mini-wheats/fs/admin/ftp/pub/s48 + +# If make barfs on this include line, just comment it out. It's only +# really needed if you want to build the linker or rebuild initial.image. +include $(srcdir)/filenames.make +# +#NetBSD make wants to see this instead: (or use GNU make on BSD. -bri) +#.include "$(srcdir)/filenames.make" + + +# Static linker: +# +# You only need the linker if you're going to make changes to the +# things that go into the initial.image, which in general means the +# files in rts/. If you decide you need to use the linker, then you +# gots your choice; it can run in just about any version of Scheme 48 +# or Pseudoscheme. (It has also been made to run in Scheme->C.) It +# doesn't matter a whole lot which Scheme you use as long as it's not +# broken or unavailable. The two best choices are: +# 1. As below: build the linker on the scheme48vm and scheme48.image +# that are in the current directory. +# 2. LINKER_VM = $(RUNNABLE) $(BIG_HEAP) +# LINKER_RUNNABLE = $(RUNNABLE) +# These settings requires you to already have a $(RUNNABLE) +# command. This is desirable if you are making changes to the +# system that might break scheme48vm and/or scheme48.image. But it +# requires you to have squirreled away a previous working version +# of scheme48. + +BIG_HEAP = -h 4000000 +LINKER_VM = ./$(VM) $(BIG_HEAP) +LINKER_RUNNABLE = $(LINKER_VM) -i $(IMAGE) +LINKER_IMAGE = link/linker.image +LINKER = $(LINKER_VM) -i $(LINKER_IMAGE) +START_LINKER = echo ,batch; echo ,bench on; + + +# -------------------- +# You shouldn't have to change anything below this point. + +# Targets: + +IMAGE = scheme48.image +INITIAL = $(srcdir)/initial.image +VM = scshvm +LIBCIG = cig/lib$(VM).a +CIG = cig/cig +CIGOBJS = cig/libcig.o cig/libcig1.o +SCSHVMHACKS = proc2.o # postgcstub.o +SCSHOBJS = \ + scsh/dirstuff1.o \ + scsh/fdports1.o \ + scsh/flock.o scsh/flock1.o \ + scsh/jcontrol2.o scsh/jcontrol1.o \ + scsh/machine/stdio_dep.o \ + scsh/machine/time_dep1.o \ + scsh/network.o scsh/network1.o \ + scsh/putenv.o \ + scsh/re.o \ + scsh/rescm.o \ + scsh/syscalls.o scsh/syscalls1.o \ + scsh/tc.o scsh/tc1.o \ + scsh/time.o scsh/time1.o \ + scsh/userinfo.o \ + scsh/regexp/libregexp.a \ + scsh/rdelim.o \ + scsh/select.o scsh/select1.o + +# scsh/$(DBOPEN) \ +# scsh/dbm.o scsh/dbm1.o + +OBJS = unix.o dynload.o prescheme.o extension.o scheme48vm.o \ + $(CIGOBJS) $(SCSHVMHACKS) $(SCSHOBJS) + +# Sources: + +CONFIG_FILES = interfaces.scm low-packages.scm rts-packages.scm \ + comp-packages.scm + +# Rules: + +# The following is the first rule and therefore the "make" command's +# default target. +enough: $(VM) $(IMAGE) script $(LIBCIG) scsh $(MANPAGE) .notify + +# The developers are curious to know. Don't be concerned if this fails. +.notify: minor-version-number + touch .notify + -echo SCSH 0.`cat $(srcdir)/scsh/minor-version-number` \ + Scheme48 0.`cat $(srcdir)/minor-version-number` infestation. \ + | mail scheme-48-notifications@martigny.ai.mit.edu + -echo Another scsh 0.`cat $(srcdir)/scsh/minor-version-number` \ + infestation. | mail scsh-notifications@martigny.ai.mit.edu + +# This says how to process .scm files with cig to make .c stubs. +.SUFFIXES: .scm +.scm.c: + $(srcdir)/$(VM) -o $(srcdir)/$(VM) -i $(CIG) < $< > $*.c + +include $(srcdir)/scsh/machine/Makefile.inc +#NetBSD make wants to see this instead: (or use GNU make on BSD. -bri) +#.include "$(srcdir)/scsh/machine/Makefile.inc" + +$(VM): main.o $(OBJS) $(AIX_P) + $(CC) $(LDFLAGS) $(LDFLAGS_AIX) -o $@ main.o $(OBJS) $(LIBS) + +$(LIBCIG): main.o $(OBJS) +# $(CC) -r -o $@ main.o $(OBJS) + $(RM) $@ + $(AR) $@ main.o $(OBJS) + @echo Do not be alarmed if the following ranlib command + @echo fails due to the absence of a ranlib program on your system. + -$(RANLIB) $@ || true +#If running ranlib fails, probably there is none. +#That's ok. So don't stop the build. + +main.o: main.c + $(CC) -c -o $@ -DDEFAULT_IMAGE_NAME=\"$(LIB)/scsh.image\" \ + $(CPPFLAGS) $(CFLAGS) $(srcdir)/main.c +scheme48vm.o: scheme48vm.c prescheme.h +extension.o: extension.c sysdep.h scheme48.h +unix.o: unix.c sysdep.h +dynload.o: dynload.c sysdep.h scheme48.h + +# -------------------- +# Make scheme48.image from initial.image and library .scm files. +# +# In the following, "make" passes $$USER to the shell as $USER, which +# the shell sees as an environment variable reference. +# +# For bootstrap reasons, initial.image is *not* listed as a source, +# even though it really is. + +$(IMAGE): $(VM) env/init-defpackage.scm more-interfaces.scm link-packages.scm \ + more-packages.scm $(usual-files) initial.debug build-usual-image + sh $(srcdir)/build-usual-image "$(srcdir)" "$(LIB)" "$(IMAGE)" \ + "$(VM)" "$(INITIAL)" + +# Unix man page... + +$(MANPAGE): scsh.man Makefile + sed 's=LBIN=$(bindir)=g' $(srcdir)/scsh.man \ + | sed 's=LLIB=$(LIB)=g' \ + | sed 's=LSCSH=$(RUNNABLE)=g' >$@ + -chmod +r $@ + +script: + (echo '#!/bin/sh'; \ + echo exec '$(LIB)/$(VM)' -o '$(LIB)/$(VM)' -i '$(LIB)/$(IMAGE)' \"\$$\@\") \ + > script + -chmod +x script + +### Fake targets: all clean install man dist + +install: install-vm install-misc \ + install-man install-inc install-cig install-scsh + +#install: script install-dirs install-vm install-image install-misc \ +# install-man install-inc install-cig install-scsh +# This is now install-scsh +# $(INSTALL_PROGRAM) script $(bindir)/$(RUNNABLE) + +install-dirs: + -mkdir $(prefix) + -mkdir $(execfix) + -mkdir $(bindir) + -mkdir $(libdir) + -mkdir $(incdir) + -mkdir $(mandir) + -mkdir $(mandir)/man$(manext) + -mkdir $(LIB) + -mkdir $(LIB)/cig + -mkdir $(LIB)/rts + -mkdir $(LIB)/env + -mkdir $(LIB)/opt + -mkdir $(LIB)/big + -mkdir $(LIB)/misc + -mkdir $(LIB)/link + +install-vm: $(VM) + $(INSTALL_PROGRAM) $(VM) $(LIB)/ + +install-image: $(IMAGE) + $(INSTALL_DATA) $(IMAGE) $(LIB)/ + +install-man: $(MANPAGE) + if test -d $(mandir)/man$(manext); \ + then $(INSTALL_DATA) $(MANPAGE) $(mandir)/man$(manext); \ + else echo "No man directory, not installing man page"; fi + +install-inc: scheme48.h + $(INSTALL_DATA) $(srcdir)/scheme48.h $(incdir)/ + +install-cig: cig + $(INSTALL_PROGRAM) $(srcdir)/$(CIG) $(LIB)/cig + $(INSTALL_PROGRAM) $(srcdir)/$(CIG).image $(LIB)/cig + $(INSTALL_DATA) $(srcdir)/$(LIBCIG) $(LIB)/cig + $(INSTALL_DATA) $(srcdir)/cig/libcig.h $(LIB)/cig + +install-misc: $(LIB)/rts $(LIB)/env $(LIB)/big $(LIB)/opt \ + $(LIB)/misc $(LIB)/link + for f in $(srcdir)/rts/*num.scm; \ + do $(INSTALL_DATA) $$f $(LIB)/rts/; done + for f in $(srcdir)/env/*.scm; do $(INSTALL_DATA) $$f $(LIB)/env/; done + for f in $(srcdir)/big/*.scm; do $(INSTALL_DATA) $$f $(LIB)/big/; done + for f in $(srcdir)/opt/*.scm; do $(INSTALL_DATA) $$f $(LIB)/opt/; done + for f in $(srcdir)/misc/*.scm; \ + do $(INSTALL_DATA) $$f $(LIB)/misc/; done + for f in $(srcdir)/link/*.scm; \ + do $(INSTALL_DATA) $$f $(LIB)/link/; done + $(INSTALL_DATA) $(srcdir)/rts/jar-defrecord.scm $(LIB)/rts/ +# -p: Intermediate directories are created as necessary. +# -p not portable...it is POSIX 2, bit its not widely available -bri +# just added install-dirs +$(LIB)/rts: + mkdir $(LIB)/rts +$(LIB)/env: + mkdir $(LIB)/env +$(LIB)/opt: + mkdir $(LIB)/opt +$(LIB)/big: + mkdir $(LIB)/big +$(LIB)/misc: + mkdir $(LIB)/misc +$(LIB)/link: + mkdir $(LIB)/link + +configure: configure.in + cd $(srcdir); autoconf + +clean: clean-scsh + -rm -f $(VM) *.o TAGS $(IMAGE) *.tmp script $(MANPAGE) \ + link/*.image debug/*.image debug/*.debug mini mini-heap.c \ + cig/*.o $(CIG) $(CIG).image $(LIBCIG) + -find . -name "*~" -o -name ".#*" -o -name core -exec rm {} \; + +distclean: clean + $(RM) Makefile sysdep.h config.status config.log config.cache \ + scsh/machine scsh/regexp/Makefile + +man: $(MANPAGE) + +check: $(VM) $(IMAGE) debug/check.scm + (echo ,translate =scheme48/ $(srcdir)/; \ + echo ,config ,load $(srcdir)/debug/test.scm; \ + echo ,exec ,load $(srcdir)/debug/check.scm; echo ,exec "(done)") \ + | ./$(VM) -o ./$(VM) -i $(IMAGE) batch + +# -------------------- +# Rules from here on down are not essential for the basic installation +# procedure, and are not expected to work when srcdir is not the +# distribution directory. + +all: vm linker + $(MAKE) image +vm: $(VM) +linker: $(LINKER_IMAGE) +image: $(INITIAL) + $(MAKE) $(IMAGE) + +tags: + etags scsh/*.scm scsh/*.c \ + rts/*.scm bcomp/*.scm *.scm env/*.scm big/*.scm \ + link/*.scm opt/*.scm debug/*.scm misc/*.scm \ + vm/*.scm + +# -------------------- +# Increment the minor version number +inc: + (cat minor-version-number; echo 1+p) | dc >minor-version-number.tmp + mv minor-version-number.tmp minor-version-number + echo \(define version-info \"0.`cat minor-version-number`\"\) \ + >env/version-info.scm + + +# -------------------- +# Generate filenames.make from *packages.scm +# +# This hack traces the module dependencies described in the +# various configuration files and converts them into dependency lists +# that "make" can use for its purposes. +# +# Since the distribution comes with a filenames.make, this rule +# shouldn't be invoked for simple installations. But it will be used +# if you change any of the *-packages.scm files. +# +# You can actually the forms in filenames.scm to any Scheme +# implementation that has syntax-rules and explicit-renaming low-level +# macros (e.g., most versions of Scheme 48 and Pseudoscheme). +# If there are errors running this script, and you need to debug, +# don't use the initial.image, use something that has a reasonable +# environment. +# +# If this fails and you don't feel like debugging or fixing the problem, +# try "touch filenames.make" and hope for the best. + +PACKAGES=packages.scm rts-packages.scm alt-packages.scm \ + comp-packages.scm initial-packages.scm link-packages.scm \ + more-packages.scm filenames.scm + +filenames.make: $(PACKAGES) + $(MAKE) $(VM) PACKAGES= + ./$(VM) -o ./$(VM) -i $(INITIAL) batch $(CIG) + -chmod +x $(CIG) + $(RM) /tmp/cig + +$(CIG)2: + (echo ",batch"; \ + echo ",translate =scheme48/ $(srcdir)/"; \ + echo ",config ,load $(srcdir)/cig/cig2.scm"; \ + echo ",config ,load $(srcdir)/cig/libcig.scm"; \ + echo ",load-package cig-standalone"; \ + echo ",in cig-standalone"; \ + echo ",translate =scheme48/ $(LIB)/"; \ + echo '(dump-scsh-program cig-standalone-toplevel "/tmp/cig")') \ + | ./$(VM) -o ./$(VM) -i ./scsh/scsh.image + $(srcdir)/cig/image2script $(LIB)/$(VM) $(CIG)2 + -chmod +x $(CIG)2 + $(RM) /tmp/cig + +$(CIG).image: $(IMAGE) $(VM) $(srcdir)/cig/cig.scm $(srcdir)/cig/libcig.scm + (echo ",batch"; \ + echo ",translate =scheme48/ $(srcdir)/"; \ + echo ",config ,load $(srcdir)/cig/cig.scm"; \ + echo ",config ,load $(srcdir)/cig/libcig.scm"; \ + echo ",load-package cig-aux"; \ + echo ",open define-foreign-syntax"; \ + echo ",translate =scheme48/ $(LIB)/"; \ + echo ",dump /tmp/cig \"(CIG Preloaded -bri)\"") \ + | ./$(VM) -o ./$(VM) -i ./$(IMAGE) + $(srcdir)/cig/image2script $(LIB)/$(VM) \ + -o $(LIB)/$(VM) \ + $(CIG).image + -chmod +x $(CIG).image + $(RM) /tmp/cig + +#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +# SCSH Specifics +#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +scsh: cig scsh/scsh scsh/scsh.image + +SCHEME =scsh/defrec.scm \ + scsh/fdports.scm \ + scsh/fileinfo.scm \ + scsh/filemtch.scm \ + scsh/filesys.scm \ + scsh/flock.scm \ + scsh/fname.scm \ + scsh/glob.scm \ + scsh/machine/bufpol.scm \ + scsh/machine/errno.scm \ + scsh/machine/fdflags.scm \ + scsh/machine/netconst.scm \ + scsh/machine/packages.scm \ + scsh/machine/signals.scm \ + scsh/machine/waitcodes.scm \ + scsh/machine/time_dep.scm \ + scsh/network.scm \ + scsh/newports.scm \ + scsh/procobj.scm \ + scsh/re.scm \ + scsh/rw.scm \ + scsh/scsh-condition.scm \ + scsh/scsh-interfaces.scm \ + scsh/scsh-package.scm \ + scsh/scsh.scm \ + scsh/select.scm \ + scsh/stringcoll.scm \ + scsh/syntax-helpers.scm \ + scsh/syntax.scm \ + scsh/syscalls.scm \ + scsh/tc.scm \ + scsh/time.scm \ + scsh/top.scm \ + scsh/utilities.scm + +# scsh/dbm.scm + +# Bogus, but it makes the scm->c->o two-ply dependency work. +# Explicitly giving the .o/.c dependency also makes it go. +############################################################ +#scsh/dbm.c: scsh/dbm.scm +scsh/flock.c: scsh/flock.scm +scsh/network.c: scsh/network.scm +scsh/re.c: scsh/re.scm +scsh/select.c: scsh/select.scm +scsh/syscalls.c: scsh/syscalls.scm +scsh/tc.c: scsh/tc.scm +scsh/time.c: scsh/time.scm +scsh/rdelim.c: scsh/rdelim.scm +scsh/select.c: scsh/select.scm +scsh/jcontrol2.c: scsh/jcontrol2.scm + +scsh/scsh: scsh/scsh-tramp.c + $(CC) -o $@ $(CPPFLAGS) $(CFLAGS) \ + -DVM=\"$(LIB)/$(VM)\" \ + -DIMAGE=\"$(LIB)/scsh.image\" \ + scsh/scsh-tramp.c + +scsh/scsh.image: $(VM) $(SCHEME) $(CIG).image + (echo ",translate =scheme48/ $(srcdir)/"; \ + echo ",batch on"; \ + echo ",open externals"; \ + echo "(lookup-all-externals)"; \ + echo ",config"; \ + echo ",load $(srcdir)/scsh/scsh-interfaces.scm"; \ + echo ",load $(srcdir)/scsh/machine/packages.scm"; \ + echo ",load $(srcdir)/scsh/scsh-package.scm"; \ + echo ",user"; \ + echo ",load-package scsh"; \ + echo ",load-package scsh-here-string-hax"; \ + echo ",open scsh"; \ + echo ",translate =scheme48/ $(LIB)/"; \ + echo "(dump-scsh \"scsh/scsh.image\")") \ + | ./$(VM) -o ./$(VM) -i $(CIG).image + +# Removed these lines from scsh/scsh.image rule so you don't lose so +# badly when you are debugging in scsh. -Olin 6/95 +# echo ",flush"; +# echo ",flush maps source names files table"; + +#scsh/scsh.runnable: scsh/scsh.image +# cig/image2script $(LIB)/$(VM) -o $(LIB)/$(VM) -h 1800000 \ +# < scsh/scsh.image > $@ +# -chmod +x $@ + +scsh/regexp/libregexp.a: + cd scsh/regexp; $(MAKE) + +# SCSH static heaps +.SUFFIXES: .scm .image .a .vm + +.image.a: + $(RM) $@ + (echo ",batch on"; \ + echo ",config ,load vm/ps-interface.scm"; \ + echo ",config ,load vm/interfaces.scm"; \ + echo ",config ,load vm/package-defs.scm"; \ + echo ",config ,load vm/s48-package-defs.scm"; \ + echo ",load-package bigbit"; \ + echo ",load-package destructuring"; \ + echo ",load-package heap"; \ + echo ",in heap"; \ + echo "(define (newspace-begin) *newspace-begin*)"; \ + echo "(define (heap-pointer) *hp*)"; \ + echo ",structure heap-extra (export newspace-begin"; \ + echo " heap-pointer"; \ + echo " header-a-units"; \ + echo " d-vector? "; \ + echo " stob-type)"; \ + echo ",config"; \ + echo "(define-structure static (export scsh-do-it"; \ + echo " test"; \ + echo " do-it)"; \ + echo " (open scheme heap memory data stob struct"; \ + echo " heap-extra"; \ + echo " vm-architecture"; \ + echo " formats"; \ + echo " enumerated"; \ + echo " signals"; \ + echo " tables"; \ + echo " defrec-package"; \ + echo " externals"; \ + echo " scsh)"; \ + echo " (files (scsh static)))"; \ + echo ",user"; \ + echo ",load-package static"; \ + echo ",open static"; \ + echo \(scsh-do-it \"$<\" \"/homes/bdc/tmp\" \"$@\" \ + \"$(CC) -c\" \"$(AR)\" \)) \ + | ./$(VM) -o ./$(VM) -h 4000000 -i scsh/scsh.image + @echo Do not be alarmed if the following ranlib command + @echo fails due to the absence of a ranlib program on your system. + -$(RANLIB) $@ || true +#If running ranlib fails, probably there is none. +#That's ok. So don't stop the build. + +.a.vm: + $(CC) $(LDFLAGS) -o $@ smain.o $< $(OBJS) $(LIBS) + +install-scsh: scsh + $(INSTALL_PROGRAM) $(srcdir)/scsh/scsh.image $(LIB)/scsh.image + $(INSTALL_PROGRAM) $(srcdir)/scsh/scsh $(LIB)/$(RUNNABLE) +# -mkdir $(bindir) + $(RM) $(bindir)/$(RUNNABLE) + ln -s $(LIB)/$(RUNNABLE) $(bindir)/$(RUNNABLE) + +clean-scsh: + $(RM) scsh/*.o scsh/regexp/*.o scsh/*.image scsh/scsh install + -cd scsh/regexp; $(MAKE) clean diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..63ff60d --- /dev/null +++ b/NEWS @@ -0,0 +1,35 @@ +-*- Mode: Indented-text; -*- + +Recent changes to the Scheme Shell. + +09/xx/95 (version 0.4.0) + New minor versioning introduced + configure upgraded to autoconf-2.4 and overhauled in general + static heap system improved from Scheme 48 version + POSIX job control? + POSIX terminal control + pseudo terminal (pty) interface + select interface + +12/25/94 (version 0.3) + New network package. + New awk and field reader package. + Harris NightHawk support has been added courtesy Brent Benson. + IBM AIX support has been added courtesy Michael Sperber. + Ultrix support has been added. + IRIX support has been added. + Some bugs have been fixed in the manual and elsewhere. + Machine dependent code has been updated. + user-info and group-info routines have be unified. + file-info record used now now for naming consistency. + +11/15/94 (version 0.2) + New time package. + Makefile bug has been fixed; makes should be totally painless. + There is now a friendly, ASCII-format cheat sheet with all the + system calls listed in doc/cheat.txt. + Some bugs in the manual have been fixed. + Solaris support has been added courtesy Travis V. Broughton. + +10/31/94 (version 0.1) + First release. diff --git a/NEWS.s48-0.36 b/NEWS.s48-0.36 new file mode 100644 index 0000000..d61487f --- /dev/null +++ b/NEWS.s48-0.36 @@ -0,0 +1,497 @@ +-*- Mode: Indented-text; -*- + +Recent changes to Scheme 48. + +3/22/94 (version 0.36) + Removed doc/lsc.ps for copyright reasons. + Fixed (* 47123 46039) multiply bug. + Modified vm/README to make it easier to run the VM. + +3/16/94 (version 0.35) + Fixed (exact->inexact 0.1) -> 0..1. bug. + Fixed VM bug that permitted the creation of stored objects with + negative sizes. + +3/8/94 (version 0.34) + "make check" target tests out various features. + Fixes for SGI IRIX 4.0.5 and MIPS RISC/OS 4.51, courtesy + Bryan O'Sullivan. + debug/run.scm and the "medium system" work again now. + misc/static.scm should work on the 68000. + Command processor no longer fluid-binds (interaction-environment) + on recursive entry. + +2/24/94 (version 0.33) + Fixed bug in VM's interrupt system. + Made non-local srcdir work in Makefile. + Added (load-package 'bigbit) to vm/README. + +2/23/94 (version 0.32) + Some incompatible changes to the VM; .image files will have + to be rebuilt. + Improvements to configuration script and to unix.c to support + a wider variety of Unixes. The system should now work + under any Posix-compliant Unix (except maybe for + char-ready?; see comments in unix.c). + Upped the default heap size from 4 meg (2 per semispace) to 6 + meg (3 per semispace). + New command line argument -s for specifying size of + stack buffer. Default is 2500 (words). + $@ -> "$@" in script (thanks to Paul Stodghill for this fix). + Obscure interrupt/exception VM bug fixed. + It is now possible to put an initial heap image into static + memory (effectively allocated by OS process creation). + Immutable initial objects go into static read-only memory, + and mutable initial objects go into static read-write + memory. Initial objects not copied by the GC. There is no + documentation yet, but look at the rules for little and + debug/little.o in the Makefile if you're interested. + +2/13/94 (version 0.31) + Incompatible changes: + In interfaces, all exported syntactic keywords must be + given type :syntax. For example, + (define-interface my-macros + (export (my-macro :syntax) ...)) + Image entry procedures for the ,build command are now + passed a list of strings, not just a single string, for + the command line arguments following -a. + The names of the macros defined in scheme48.h + (pairp, car, string_length, etc.) are now all upper case. + New "configure" script generates Makefile from Makefile.in + and sysdep.h from sysdep.h.in (thanks to Gnu autoconf). + See INSTALL and doc/install.txt. + Bug fixes: + Can now make vectors (strings, etc.) as big as the amount + of heap space available (but you're still screwed if you + try to make one bigger than 2^23-1 bytes - don't do it). + Non-ANSI-ness fixed in scheme48vm.c (jump out of, then + back into, a block expected block-local variables to be + unchanged). + Fixed big/external.scm (had VECTOR-POSQ instead of ENUM). + In (define-syntax foo bar) you got an error if bar was a + variable reference. + Plugged a storage leak (file-environments table in + env/debug.scm). Images made with ,build were too large. + Flushed extraneous delay from make-reflective-tower. + Renamed variables in Makefile to resemble Gnu standards. + Fixed definition of LINKER_RUNNABLE in Makefile. + Added doc/call-back.txt. + Fixed define-enumerated documentation (doc/big-scheme.txt). + Environment maps no longer retained for things in initial.image + and scheme48.image. This makes scheme48.image about 170K + smaller. + +2/3/94 (version 0.30) + Faster EXPT. + FLOATNUMS improvement: (inexact->exact ) should now + work, e.g. + (inexact->exact (/ 1. 3.)) => 6004799503160661/18014398509481984 + Reinstated ACCESS-SCHEME-48 for the benefit of PSD (portable + scheme debugger) and a certain other software package that + shall remain nameless. It only knows about a small number of + procedures, including things like ERROR and FORCE-OUTPUT. + Various changes to support the Pre-Scheme compiler, notably + SET-REFLECTIVE-TOWER-MAKER!. + Incompatible change to the ENUMERATED structure: the names + foo/bar no longer become defined. Write (enum foo bar) + instead. This will macro expand into the correct small + integer. + +1/30/94 (version 0.29) + Fixed ps_run_time() to call sysconf() to find out how many + ticks there are per second. It used to assume 60. This + affects the output of the ,time command, so don't try + comparing numbers from this version with numbers from older + versions. + ,time command will now accept a command, e.g. + ,time ,load foo.scm. + It appears that if multiple arguments follow -a on the + argument line, they are concatenated together with spaces + separating them and passed to the startup procedure. I + don't know how long this has worked. This will change in + the future so that the startup procedure gets a list of + strings. + Installed what used to be called the GENERAL-TABLES structure + as the TABLES structure used by the system. This allows + the use of other comparison predicates besides EQ?, and + eliminates some code that had a restrictive copyright + notice. + ENUM, NAME->ENUMERAND, and ENUMERAND->NAME are all macros. + Enumerated types themselves are now macros as well. + +1/23/94 Fixed bad multiplication bug in VM: (* 214760876 10) was + returning 125112. + Moved RECORD-TYPE? and RECORD-TYPE-FIELD-NAMES from the + RECORDS-INTERNAL interface to the RECORDS interface, for + a somewhat closer approximation to MIT Scheme. + Various type system improvements. + Still no documentation for the ,exec package, but see + link/load-linker.exec for an example. + New generic function feature, exported by the METHODS + interface (see interfaces.scm), almost like in a certain + dynamic object-oriented language. + +1/11/94 (version 0.27) + Change: + The isomorphism used by CHAR->INTEGER and INTEGER->CHAR is + no longer ASCII. This change was introduced in order to + assist the development of portable programs. If you need + ASCII encoding, you should open the ASCII structure and + use the procedures CHAR->ASCII and ASCII->CHAR. + Features: + The help system is somewhat improved. + New form DEFINE-STRUCTURE defines a single structure. + Incompatible changes to package system: + Renamed DEFINE-PACKAGE to DEFINE-STRUCTURES + Renamed DEFINE-STRUCTURE to DEFINE + Renamed all the base types from FOO to :FOO. E.g. + :SYNTAX, :VALUE, :PAIR, etc. + Other: + Removed socket support due to restrictive copyright on some + of the C code that was in extension.c. + +12/21/93 ,take has been flushed in favor of ,exec ,load. Commands are + now accessed via a distinguished package instead of a table. + Documentation pending. + Postscript (.ps) files now included in doc/ subdirectory. (I + thought they had been there all along, but apparently I was + wrong.) + Enhanced, but still kludgey, floating point support. Use + ,open floatnum. + +12/12/93 (version 0.26) + NetBSD port. + Hacked write-level and write-depth for inspecting circular + structure. + Recursive FORCEs signal errors, e.g. + (force (letrec ((loser (delay (force loser)))) loser)) + +12/7/93 (version 0.25) + Bug fix: + filenames.make can now be remade using initial.image. This + means that you can snarf a distribution and then edit + USUAL-FEATURES before making scheme48.image. + + +12/6/93 Incompatible changes: + Change of terminology: "signature" --> "interface". + This means that DEFINE-SIGNATURE is now called + DEFINE-INTERFACE, etc. + Some structures have been renamed: + condition -> conditions + continuation -> continuations + exception -> exceptions + queue -> queues + port -> ports + record -> records, record-internal -> records-internal + table -> tables + template -> templates + The ,load-into command has been removed. Use ,in ... ,load + instead (see below), e.g. + ,in mumble ,load myfile.scm + The heap size for -h is specified in words, not bytes. As + before, the size must account for both semispaces; -h 2n + means n words per semispace. This change was actually + made a while ago, but I was confused as to what it meant. + Bug fixes: + #e1.7 reads as 17/10, (exact? 1+1.0i) => #f, and 1.0+i prints. + Features: + Things like ((structure-ref scheme if) 1 2 3) work. + The following commands now take arbitrary commands to execute + in the specified package, not just forms: + ,config ,user ,for-syntax ,in + For example, you can say + ,in mumble ,trace foo + This subsumes the functionality of the ,load-into and + ,load-config commands. + Dynamic loading of shared libraries for System V systems + (untested). + Documentation: + Somewhat improved. user-guide.txt now lists most of the + interesting built-in packages. lsc.ps is a draft of "A + Tractable Scheme Implementation," a paper submitted to Lisp + and Symbolic Computation. See also doc/big-scheme.txt, + doc/thread.txt, and doc/external.txt. + + +10/30/93 LET-SYNTAX and LETREC-SYNTAX. + Arrays (see big/array.scm). + Lots of internal changes. + +7/20/93 Features: + Type system. See doc/types.txt. + +7/4/93 Features: + New define-package clause (for-syntax *). + E.g. (define-package ((my-package ...)) + (open ...) + (for-syntax (open scheme my-utilities) + (files more-crud-for-syntax)) + ...) + A file name to package map is now used by the emacs + interface. Whenever you load a file, or zap from a file that + hasn't been previously loaded or zapped, the package in + which forms are being evaluated is remembered in a table. + The next time you zap some forms from the same file, they + will be evaluated in that package. + Sometimes you may get an association you don't want. In that + situation, you can use the ,forget command to delete an + entry in the table. + A new ,push command goes to a deeper command level. + Experimental "command preferred" command processor mode: if + you give the command ",form-preferred off", commands will + be "preferred" to forms, meaning that you don't need to + type a comma before giving a command. To see the value + of a variable FOO you have to say (begin foo). + Experimental "no levels" command processor mode: if you + give the command ",levels off", then an error will not + push a new command level. If you want to ignore an + error, you don't need to take any action - further + evaluations will happen at top level. If you want to + enter the inspector or get a preview, you can issue these + commands or a ,push command immediately after the error + occurs (more precisely, any time until the focus object + is set by some other command). + All of the mode-control commands (batch, bench, + break-on-warnings, form-preferred, and levels) take + an optional argument. When no argument is given, they + will toggle the corresponding mode. With an argument of + ON or OFF, they turn the mode on or off. + The ,flush and ,keep commands have been made more flexible + and verbose. + + +6/18/93 Incompatible changes: + The access-scheme48 procedure has gone away. Use ,open + or the module system instead. + The user, configuration, and for-syntax packages no longer + have variables bound to them in the configuration package. + Where previously you said: Now you should say: + ,in user
,user + ,in config ,config + ,in for-syntax ,for-syntax + ,load-into config ,load-config + ,load-into for-syntax ,for-syntax (load "file") + + Features: + There is an ,expand command for debugging macros. + The ,open command takes any number of structure names, and opens + them all (like ,new-package). + New procedure DEFINE-INDENTATION exported by the PP structure. + E.g. (define-indentation 'let-fluid 1) is like Gnu emacs's + (put 'let-fluid 'scheme-indent-hook 1). + The inspector simplifies generated names in continuation + source code display. E.g. when formerly it said + "Waiting for (#{Generated lambda} () (x->node (car exps)))" + now it says + "Waiting for (lambda () (x->node (car exps)))" + Macros can signal syntax errors by returning input expression + unchanged. (Comparison uses EQ?.) + + Documentation: + The doc/ directory contains a draft of a "Scheme 48 + Progress Report." + + Cleanup: + Procedure NULL-TERMINATE added to structure EXTERNALS's + signature. + "Vulgar Scheme" renamed to "Big Scheme". + Two new subdirectories, env/ (for programming environment) + and big/ (for Big Scheme), now contain most of what was + in the misc/ directory. + Several source files that were in the top level and link/ + directories have moved to the env/ and alt/ directories. + + +5/6/93 Bug fixes: + Fixed -h command line switch. The size was being improperly + divided by 4, so if you asked for an N megabyte heap, you'd + actually only get an N/4 megabyte heap. + Nested backquotes were broken for a while; should be fixed + now. + + Features: + Quoted structure is read-only: e.g. (set-car! '(a b) 3) will + produce an exception. + ,config [] and ,user [] are like ,in . + Unix socket support; see misc/socket.scm. + Now using gzip instead of compress for distributions. + ,open command offers to load packages. + A .gdbinit file sets a breakpoint at CM's exception raising + code, and defines a handy "preview" command. + +1/18/93 Feature: + Scheme 48 distributions now have version numbers. The + version number is printed in the image startup message. + Please include it in bug reports. + The module system is now documented. See doc/module.tex. + +12/17/92 Bug fixes: + Macro templates of the form (x ... y) are supported. + Macro templates are now less fussy about meta-variable + rank: you can do "(x y) ..." even when the rank of either + x or y (but not both) is too low; the low-ranking text + will be copied as many times as necessary. (A + meta-variable's "rank" is the number of ...'s it sits + under in the left-hand side of the rewrite rule.) + SYNTAX-RULES is now itself hygienic. This means you can + have a meta-variable named CAR, for instance. + + New development environment features: + Commands now start with comma (",") instead of colon + (":"). (Easier to type since it's not shifted.) + values, call-with-values, dynamic-wind, eval, + interaction-environment, and scheme-report-environment + added per upcoming Revised^5 Scheme report. See + doc/meeting.tex. + Modifications to quoted structure will now be detected and + reported as errors. + An interrupt will occur if an insufficient amount of memory + is reclaimed by a garbage collection. + Inspector now accepts arbitrary command processor commands + (with or without leading comma) + ,keep command controls retention of debugging information. + + Features removed: + #\page and #\tab. These aren't in the Scheme report. + Their absence in Scheme 48 will encourage portability. + access-scheme48 works with fewer names than before. Use the + package system instead. + Complex numbers not in the system, by default. Get them + back by changing usual-features in more-packages.scm. + + Features changed: + Many changes to package system. See doc/module.tex. + The :identify-image command is gone. Instead, supply a + second argument (optional) to the ,dump command. + The inspector's TEM command has been shortened to T. + + Internal changes and features: + Stored objects types are now part of the virtual machine + architecture, i.e. known to the byte-code compiler. + Run-time system is split up into many little modules. + File names are retained in debug database. (But not used for + anything yet...) + Tweaks to table package reduce standard image size by 50K + and increase compiler speed by 7%. + Immutability bit in object headers. + Weak pointers. + +7/18/92 Features removed: + Table package's default hash function no longer supports + string, pairs, or vectors. + +7/9/92 Bug fixes: + (- 0 -536870912) + Inspector now uses command i/o ports instead of current ones + Inexact integers print as N. instead of #iN + Throwing back into a call-with-....put-port now produces a + warning instead of an error + + Feature fixes: + In DEFINE-PACKAGE, OPEN no longer implies ACCESS. + misc/receive.scm renamed to rts/values.scm, made to conform + with Revised^5 Report, and installed internally. + + Features: + New :load-package command. Uses file names in (file ...) clause + of a define-package. These are interpreted relative to the + directory in which the file containing the define-package + was found. + #\tab and #\page now print this way. + + +6/17/92 Bug fixes: + Fixed bug in modulo. + Flushed LAST-PAIR (which disappeared between R^3 and R^4). + DEFINE-SYNTAX and SYNTAX-RULES now exist. + CEILING, FLOOR, and ROUND now exist. + GCD and LCM are now n-ary. + STRING-CI=? and STRING-COPY fixed. + STRING->SYMBOL now copies its argument before handing it to + INTERN. + =, <, etc. now work with more than two arguments. + CHAR-READY? exists. + Calls via APPLY are now tail-recursive. + DISPLAY of vectors and lists works (ugh). + + Development environment improvements: + Type ? at inspector to get list of inspector commands. + Inspector D command goes to next continuation. + Inspector M command shows more of a long menu. + Inspector TEM command goes to a continuation's or closure's + template. + For closures and continuations, inspector displays local + variables with their names. + For continuations, inspector displays source code for + expression into which control will return. + Multiple command loop levels. EOF (control-D) now only pops + out a single level. :reset pops all the way out. :level n + goes out to level n. + Can disable benchmark mode. + Procedures made with (let ((f (lambda ...))) ...) now print + with names. + + Features: + Package system: special forms define-package and package-ref; + command processor commands :set-package, :load-into, + :clear-package, :new-package, :export, :open-package, etc. + In misc directory: threads, queues, extended ports, format, etc. + + Changes to system environment: + user-initial-environment -> user-package + record-updator -> record-modifier + primitive-throw superseded by with-continuation + ash -> arithmetic-shift + New bootstrap regime. + Support for threads: alarm clock interrupt, etc. + + Etc.: + Liberal COPYRIGHT file, and a little notice in each source file. + INSTALL and NEWS split off from README. + doc.txt renamed to user-guide.txt. + The Makefile now provides two ways to make "s48" for + installation. One depends on the exec #! script execution + feature and the other doesn't. + "make" targets for testsys.image and little.image. + Runs Jaffer's test suite and library. + Flushed s48.el. Use cmuscheme instead. + + +9/5/90 Command processor argument parser revamped. + :load, :trace, and :untrace commands take arbitrary number + of arguments. Argument to :proceed is optional. + New (but undocumented) :identify-image command. + Better error messages: wrong number of arguments, undefined + variable. + +, *, min, max, apply are now n-ary; -, /, make-string, + make-vector, read-char, peek-char, write-char have + appropriate argument optionality. + Better internal support for macros; not yet ready for release. + Added STRING as per R^3.99RS. + More testing of Scheme version of bytecode interpreter. + Better scoping of ##; files can't see command processor context. + OR and CASE don't cons closures. + VM checks for non-existent heap image file, gives error + message instead of "bus error". + Numerous internal changes in compiler and exception system. + Fixed charnumber. + +8/26/90 Tested (link-system) inside of T; seems to work. + Benchmark mode available via :BENCH command. + System is 15K bigger due to new fatter global environment + representations. + Inspector abbreviation improved. + Disassembler now works on continuations, sort of. + +7/26/90 ((lambda ...) ...) no longer makes a closure + Features now in default system: + :inspect + :dis[assemble] + Generic arithmetic: bignums, rationals, complexes + rationalize + :time command is more verbose + MOREFILES variable in Makefile for loading extra stuff + Default heap size increased to 2 megabytes per semispace diff --git a/README b/README new file mode 100644 index 0000000..ab40ad5 --- /dev/null +++ b/README @@ -0,0 +1,23 @@ +-*- Mode: Text; -*- + +Copyright (c) 1994 Brian D. Carlstrom +See file COPYING for copying information. + +Please report bugs to scsh-bugs@martigny.ai.mit.edu, and include +the version number in your message. + +Installation instructions in file INSTALL. + +A scsh manual is in file doc/scsh-manual{/*.tex,.ps}. +A scsh paper is in file doc/scsh-paper.{tex,ps}. +A scsh quick reference is in file doc/cheat.txt. + +Recent changes are listed in file NEWS. + +Known bugs and things to do in the future are listed in TODO. + +Send mail to scsh-request@martigny.ai.mit.edu to be put on a +mailing list for announcements, discussion, bug reports, and bug +fixes. + +A road-map of the source tree is also in the doc directory. diff --git a/README.s48-0.36 b/README.s48-0.36 new file mode 100644 index 0000000..6706e91 --- /dev/null +++ b/README.s48-0.36 @@ -0,0 +1,66 @@ +-*- Mode: Text; -*- + +Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. +See file COPYING for copying information. + +Please report bugs to scheme48-bugs@martigny.ai.mit.edu, and include +the version number in your message. + +Installation instructions in file INSTALL. + +A user's guide is in file doc/user-guide.txt. + +Recent changes are listed in file NEWS. + +Known bugs and things to do in the future are listed in TODO. + +Send mail to scheme-48-request@martigny.ai.mit.edu to be put on a +mailing list for announcements, discussion, bug reports, and bug +fixes. + +----- + +The Scheme 48 root directory should contain the following subdirectories: + + doc some documentation + emacs gnu emacs support + rts run-time system sources + bcomp the byte-code compiler + link static linker + env development environment modules (debugger, etc.) + big useful Scheme libraries and extensions ("Big Scheme") + vm virtual machine sources (written in Pre-Scheme) + alt portable implementations of some Scheme 48 features + opt optional code optimizer for the byte-code compiler + misc very miscellaneous things (e.g. AMB operator) + +The Scheme 48 root directory should contain the following files: + + README this file + INSTALL installation instructions + NEWS recent changes + TODO list of bugs and things to do + configure configuration script + Makefile.in input to configure + sysdep.h.in input to configure + filenames.make included by Makefile, generated automatically + initial.image an image file containing a minimal Scheme system + initial.debug debugging database for same + scheme48vm.c most of the VM (generated by Pre-Scheme compiler) + main.c part of the VM + unix.c part of the VM + prescheme.h part of the VM + prescheme.c part of the VM + extension.c default definition of vm_extension() + dynload.c dynamic object file loader + scheme48.man a Unix-style manual page + packages.scm meta-module definitions + interfaces.scm system interface definitions + more-interfaces.scm system interface definitions + *-packages.scm module definitions + initial.scm script for creating initial.image + scheme48.h C declarations and macros for Scheme 48 data structures + +The Pre-Scheme compiler, which produces scheme48vm.c from vm/*.scm, is +distributed separately. For information contact +kelsey@research.nj.nec.com. diff --git a/RELEASE b/RELEASE new file mode 100644 index 0000000..0462eb8 --- /dev/null +++ b/RELEASE @@ -0,0 +1,61 @@ +This is a release of scsh, release 0.4.0. +Scsh is a Unix shell that is embedded within R4RS Scheme. +It provides high-level shell notation and full access to +the Unix system calls. The current implementation is built +on top of Scheme 48, version 0.36. + +We currently have scsh running on: + AIX, + CXUX, + HP-UX, + IRIX, + Linux, + NetBSD, + NeXTSTEP, + Solaris, + SunOS, + Ultrix +It's not hard to port scsh to new systems. + +You can get a copy of scsh via anonymous ftp, from the following: + ftp://clark.lcs.mit.edu/pub/su/scsh/scsh.tar.gz + ftp://swiss-ftp.ai.mit.edu/pub/su/scsh/scsh.tar.gz +These tar files include a detailed manual and a paper describing +the design of the system. + +For the lazily curious, we also have the manual separately available as + ftp://clark.lcs.mit.edu/pub/su/scsh/scsh-manual.ps + ftp://swiss-ftp.ai.mit.edu/pub/su/scsh/scsh-manual.ps +Just click 'n view. + +The current release is primarily useful for writing shell scripts +and doing general systems programming. + +Real interactive use needs a parser for an sh-like syntax, job control, +and the gnu readline library. If you're interested in hacking +on these things, drop us a line at scheme-underground@ai.mit.edu. +We've got designs for most of this stuff; we're just short on time +and bodies. + +New in this release: +- The scsh network package, a complete interface for Berkeley-style sockets. + We are going to keep the code for our higher-level protocols (ftp, telnet, + http, and so forth) close to home for one more release. + +- The awk loop and field parser package. + +These two packages are documented in the reference manual. + +Lots of plans for the next release: libraries with network protocol code, +the html parser and the server kit, module switches on the command line, +threads -- we'll do our best. + +We thank Brent Benson, Travis V. Broughton, Brian Dennis, Noah Friedman Mike +Gunter, Shriram Krishnamurthi, John P. Lewis, Tom Lord, Scott Schwartz, and +Bill Sommerfeld, Michael Sperber, Axel Wienberg, for bug reports, bug fixes, +and comments that were incorporated into this release. + +Brought to you by the Scheme Underground scsh team. + -Olin Shivers, Brian Carlstrom & David Albertz + Cambridge + 25 December, 1994 diff --git a/TODO b/TODO new file mode 100644 index 0000000..502e933 --- /dev/null +++ b/TODO @@ -0,0 +1,59 @@ +--*- Mode: Indented-text; -*- + +scsh: list of bugs and things to do. +Last update by BDC on June 1995. + +Too many things to mention really but... + +immediate: + architecture support (Alpha anyone?) + +manual: + pointers to relevant unix man pages + +syscalls: + posix terminal interface + posix signals + what other stuff is missing? + +fdports: + rewrite to work with s48 0.39 + -also remove post gc vm hack + +subsystems: + a make/build system + a replacement for sed + TK + +library: + more generally useful code + if perl does it, maybe we should look at it + -dbm/ndbm + sysV shared memory if someone wants it + crypt + a more winning FORMAT than the s48 one, MIT Scheme? + standard syslog stuff + +configuration: + need more system specific code for stdio hacks + magic numbers for from c headers should be generated + automatically with scsh script... + +scheme48: + dynamicially loadable heaps + see also cig below + see also the Scheme48 TODO + +cig: + errors/warnings to stderr not stdout + portable c structure interface + +perhaps one day: + AFS and file permission bits + ,go + +conversion: + sed => scsh + awk => scsh + find => scsh + perl => scsh? diff --git a/TODO.s48-0.36 b/TODO.s48-0.36 new file mode 100644 index 0000000..86ade62 --- /dev/null +++ b/TODO.s48-0.36 @@ -0,0 +1,263 @@ +--*- Mode: Indented-text; -*- + +Scheme 48: list of bugs and things to do. +Last update by JAR on 3 March 1994. + +Run-time system bugs: + MAX and MIN don't do inexact contagion. + Compiler needs to treat calls with more than 63 arguments specially. + Compiler loses if a procedure has more than 254 literals. This + seems to happen a lot with enormous backquote forms, which really + do arise in practice (e.g. PSD, Hanson's macro expander, etc.). + Shadowing can fail sometimes for macro-referenced variables. E.g. + the following sequence will lose if entered interactively as + three separate forms: + (define (foo x) `(a ,x)) + (define cons list) + (foo 1) => (a (1 ())) + The WITH-**PUT-FILE and CALL-WITH-**PUT-PORT procedures probably + close ports sooner than the Scheme reports think they ought to. + (They just do the obvious DYNAMIC-WIND.) + If (find-all-symbols) fails due to lack of space, it should GC and + retry (I think) (bug reported by Basile Starynkevitch, 7-21-93) + +Programming environment: + Error checking for macro & special form syntax. + Fuller on-line documentation. + Error recovery. Can do better than ,proceed. LOAD should set up + restart continuations. + Types in scheme-interface (and elsewhere) aren't as tight as they + could be. + LET continuation "pessimization" to retain the environment longer. + Have the disassembler display local variable names. + This ought to be recoverable, but isn't always: + > (let loop ((x '())) (loop (cons 3 x))) + not enough room in heap for stack + Put the inspector at its own command level, so that ^D after + errors puts you back in the inspector. + The get-cont-from-heap instruction should have an exception + discloser that indicates the actual error (returning a + non-fixnum from application top level). + Separate compilation (compile a module, writing object code to a + file). (Rudiments in misc/separate.scm) + Semicolon comments don't quite work after commands (extra newline + required). + Command (and procedure) to change current directory. + +Performance: + Generational GC. + More compact representation for debugging data? + Leaf procedure compilation (RK's rts/no-leaf-env.scm): if no + continuations or lambdas, skip the make-env and access locals + using stack-ref. Expected to gain about 6% in speed. + Optimize loops somehow (maybe using call-template opcode and/or + opportunistic compilation). + The CAML light implementation has good documentation and patches + for optimizing the interpreter's switch (*pc++); perhaps we + could lift some of it. (Range check isn't necessary.) + Floating point support in VM. + Bignum support in VM: use MIT Scheme bignums or GNU Multiple + Precision Arithmetic Library (Torbjorn Granlund ). + Faster bignum printer (e.g. the one Richard wrote - but it would be + nice if it were an option tied to bignums, not built in to the + initial image). + Ratnum multiplication and division might be made more efficient by + taking cross-GCD's. + Native code compiler... + +Big Scheme features: + ,more-threads command doesn't get defined (new bug in 0.26). + How about deleting entries from tables? + Non-blocking I/O for threads. I think access to Unix select() might + be sufficient (with pause() and sleep() as degenerate cases). + Look at concurrent ML source code, which gets this right. + RPC. + Add call/gcc (invokes the Gnu C compiler). + It would be nice if WITH-MULTITASKING returned whatever the thunk + returned. + ,exit following ,start-threads causes a core dump. + +Module system bugs: + ,untrace should undefine as well if the variable wasn't bound + before. + Compound signatures don't get updated when a component signature + changes. They contain a list of signatures with no reinitialization + thunk a la structures and packages. + +Module system features: + Check for name conflicts between opened structures. + Implement interface subtraction as a way of dealing with such + conflicts: (WITHOUT ( ...) ) + Check for cycles in structure inheritance. + An ,access command, similar to ,open. + Deal with package system state better (for linker). Maybe each + package should point to a data structure containing + *location-uid*, location-name-table, *package-uid*, + package-name-table, and perhaps the compiler-state as well (see + segment.scm). + +VM: + Heaps that can grow larger. + Add a test to configure.in that can determine whether ld -A works. + If both it and dlopen() work, then both kinds of dynamic loading + should be made available. + Merge in Olin's changes and extensions (command line processing, + the #! syntax for scripts, external function call, etc.). + Interrupt while writing out image causes an exit. [Fixed?] + A jump-back instruction? Might be easier to use than call-template. + Scrutinize all VM fatal errors to see if any can be recovered + from. E.g. "out of ports" shouldn't cause a VM halt, it should + just cause open-port to return #f or an error code. [Fixed?] + Get VM interp.scm-without-gc.scm working again. + Make the number predicate instructions return #t when appropriate + for the built-in number stored object types (bignum, double, + ratnum). + Make the Unix standard error stream available as + (error-output-port) + FIND-ALL-X-RECORDS that finds all records with a particular value + in their first slot. + +Documentation: + Olin's "cig" (C interface generator). + user-guide.txt should point to the existing lsc.ps? + (optimize auto-integrate) and ,load-package analysis. + How to use the static linker. + How initial.image and scheme48.image get built, really. + Techniques for debugging the runtime system (debug/for-debugging.scm). + Threads, fluids, records, tables. [all in big-scheme.txt?] + +Cleanup: + VM: + Revert to the old exception system: vector of handlers (not just a + single procedure), and each handler gets an exception code. + Rename "unassigned" to "uninitialized"? Or phase it out entirely. + In unix.c, use getrusage(), when available, to get run time. + Run-time / features / development environment: + A DIVIDE procedure (maybe an instruction as well) that returns two + values. + Figure out how to merge the two type systems (META-METHODS and + META-TYPES). The generic function system could make use of the + SUBTYPE? and INTERSECT? predicates. + Correct floating point, esp. reading and printing. And + (= 1/3 (/ 1. 3.)) returns #t, but ought to return #f. + Parameterize over file name syntax somehow. Currently + big/filename.scm assumes Unix (cf. DIRECTORY-COMPONENT-SEPARATOR, + FILE-NAME-PREFERRED-CASE). Perhaps there should be VM support for + this. + Make sure that the disassembler and assembler are inverses of one + another. + Disassembler should generate S-expression first, and then print + it independently. + Combine conditions, signals, and handle into a single structure? + Figure out a better way to implement ##. + Be consistent about "filename" versus "file-name". + Compiler / linker / module system: + The "reflective tower" isn't really a reflective tower, it's a + syntactic tower. Rename it. + The scanner (file loader) should operate on streams, not lists. + This would result in more uniform and flexible internal + protocols for reading files, scanning for DEFINEs, compiling, + and running - passes could be interleaved or separated easily. + Flush link/data.scm. Linker should instead open the VM module + that includes vm/data.scm. + Flush (optimize ...) clause in DEFINE-STRUCTURE in favor of + optimizer argument to SCAN-STRUCTURES. + Vector patterns and templates ought to be supported in + SYNTAX-RULES. + The DEFINE-INTERFACE forms should contain types for every exported + variable; the code in cprim.scm (and recon.scm?) shouldn't have + to worry about setting up types. + Add ENVIRONMENT-DEFINED? ? + Make USUAL-TRANSFORM return a transform? + Add enough to the node signature to make it usable on its own? + make-c-header-file should put definitions for the interrupt + enumeration into scheme48.h, and unix.c et al should use them. + Etc: + Start using a source control system (like rcs). + We ought to have a test system / validation suite. + There ought to be a sanity check to ensure that the size of the + area as computed by static.scm agrees with the size as computed + by C's sizeof() operator. + +What should (syntax-rules (x) ((foo ?body) (let ((x 1)) ?body))) do? + + +To: jar@cs.cornell.edu +Subject: Not a bug this time. :-) +Date: Tue, 22 Feb 94 19:13:37 -0500 +From: Paul Stodghill + +The result of ,expand can be confusing. In particular, it doesn't +distinguish between different identifiers that have the same name. + +For instance, in the example below, it would be more useful if the result +of the ,expand was something like, + + '((lambda (.x.1) (set! x (- .x.1))) x) + +Welcome to Scheme 48 0.31 (made by jar on Sun Feb 13 18:33:57 EST 1994). +Copyright (c) 1993, 1994 by Richard Kelsey and Jonathan Rees. +Please report bugs to scheme-48-bugs@altdorf.ai.mit.edu. +Type ,? (comma question-mark) for help. +> (define-syntax foo + (syntax-rules () + ((foo var) ((lambda (x) (set! var (- x))) var)))) +> (define x 1) +> ,expand (foo x) +'((lambda (x) (set! x (- x))) x) +> + + + +Date: Mon, 14 Jun 93 18:33:30 HKT +From: shivers@csd.hku.hk +To: kelsey@flora.ccs.neu.edu +Cc: jar@cs.cornell.edu +Subject: Scheme 48 + +... +All true. My major motivation was portability. I also found the module system +to be a big win. Other things that influenced me were (1) elegance and +modularity -- I felt I could comprehend and mung the system as needed (2) +reasonable efficiency and small size and (3) real, full R4RS+ support (most +small systems do it partly). + +Actually, I wouldn't say the programming environment is particularly +exceptional, unless you count the module system. + +A small thing lacking in other Schemes that really reduced my debug times: the +loader would complain about undefined free var refs in my code. This +frequently picked out variable spelling errors, inconsistent name linkages, +and forgotten procedure defs. Not a big thing, but really effective. + +Another win was simply having the implementors around for detailed +explanations and support. + +Problems I had with S48: +- Inability to mess with the VM, as it is written in a language that can + be compiled by only 1 person in the world. + +- The foreign-function support was quite limited, and the foreign-data support + was basically non-existent. Exporting gc'd data to C, gc'ing data allocated + in C, hooks into the GC, importing C data into Scheme -- no support. Elk + handles this better, as that is critical to the type of applications at + which elk is targeted. + + I fixed some of this myself -- helped by your general, portable low-level ff + interface, which was well-designed in terms of those goals -- but I couldn't + do much about foreign-data support. + +- No support currently for linking static heap data into a text-pages + area to reduce gc copying and shrink the dynamic heap. + +- The module system was frequently frustrating. The non-uniform , command + language, bugs, the restrictions of living with a module system, + being blocked from accessing primitives whose bindings had been + gc'd away at link time, and awkwardnesses in the user interface really + slowed me down. + + The module system was also a great help; these are simply the problems + of life with an experimental system, as opposed to a polished final + product. + +[But] all in all, S48 was the best choice I could have made. diff --git a/alt-packages.scm b/alt-packages.scm new file mode 100644 index 0000000..7ca907f --- /dev/null +++ b/alt-packages.scm @@ -0,0 +1,166 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +; This configuration file provides alternative implementations of the +; low, run-time, run-time-internals structures. Cf. the interface +; definitions in packages.scm. + +; Run-time structures assumed to be inherited from somewhere: (none of +; these is used by the linker) +; conditions +; continuations +; display-conditions +; exceptions +; fluids-internal +; methods +; meta-methods +; interrupts +; low-level +; more-types +; number-i/o +; ports +; reading +; records-internal +; scheme-level-2-internal +; wind +; writing + +; -------------------- +; low + +; Features, assumed inherited: +; ascii +; bitwise +; code-vectors +; features +; signals +; Unimplemented (you'll need a VM to do these): +; vm-exposure +; Defined in alt/low-packages.scm: +; escapes +; primitives + +(define-structure scheme-level-0 scheme-level-0-interface + (open scheme)) + +(define-structure escapes escapes-interface ;cf. alt/low-packages.scm + (open scheme-level-2 define-record-types signals) + (files (alt escape))) + +(define-structures ((low-level low-level-interface) + (source-file-names (export (%file-name% :syntax))) + (structure-refs (export (structure-ref :syntax)))) + (open scheme-level-2 signals) + (files (alt low))) + +(define-structure closures closures-interface + (open scheme-level-1 records) + (files (alt closure))) + +(define-structure locations locations-interface + (open scheme-level-2 signals) + (files (alt locations))) + +(define-structure loopholes (export (loophole :syntax)) + (open scheme-level-2) + (files (alt loophole))) + +(define-structure silly (export reverse-list->string) + (open scheme-level-1) + (files (alt silly))) + +(define-structure write-images (export write-image) + (open scheme-level-2 + tables ;Forward reference + features bitwise ascii enumerated + architecture + templates + closures + signals) + (files (link data) + (link transport) + (link write-image))) + +; -------------------- +; run-time (generally speaking, things needed by the linker) + +; Same as in rts-packages.scm: +(define-structure architecture architecture-interface + (open scheme-level-1 signals enumerated) + (files (rts arch))) + +; Use the non-bummed version! +(define-structure bummed-define-record-types define-record-types-interface + (open scheme-level-1 records) + (files (rts jar-defrecord))) + +; Same as in rts-packages.scm: +(define-structure enumerated enumerated-interface + (open scheme-level-1 signals) + (files (rts enum) + (rts defenum scm))) + +(define-structure fluids fluids-interface + (open scheme-level-1 signals) + (files (alt fluid))) + +(define-structures ((scheme-level-2 scheme-level-2-interface) + (scheme-level-1 scheme-level-1-interface)) + (open scheme)) + +(define-structure templates templates-interface + (open scheme-level-1) + (files (alt template) + (rts template))) + +(define-structure util util-interface + (open scheme-level-1) + (files (rts util))) + +(define-structure weak weak-interface + (open scheme-level-1 signals) + (files (alt weak) + (rts population))) + + +; -------------------- +; run-time internals (generally speaking, things not needed by the linker) + +; * = mentioned in more-packages.scm +; conditions +; continuations +; display-conditions +; * exceptions +; * fluids-internal +; methods +; meta-methods +; interrupts +; low-level +; more-types +; * number-i/o +; * ports +; * reading +; * records-internal +; scheme-level-2-internal +; * wind +; writing + +(define-structure wind wind-interface + (open scheme-level-2) + (files (alt reroot))) + +; -------------------- +; These don't really belong here, but I sure don't know where they +; ought to go. + +(define-structure environments (export *structure-ref) + (open ) ;Assume flatloading + (files (alt environments))) + + +; Procedure annotations + +(define-structure annotations + (export annotate-procedure procedure-annotation) + (open scheme-level-1) + (files (alt annotate))) diff --git a/alt/annotate.scm b/alt/annotate.scm new file mode 100644 index 0000000..2140472 --- /dev/null +++ b/alt/annotate.scm @@ -0,0 +1,13 @@ + +; no copyright please, silly shell script + +(define *annotations* '() + +(define (annotate-procedure proc ann) + (let ((new (lambda args (apply proc args)))) + (set! *annotations* (cons (cons new ann) *annotations*)) + new)) + +(define (procedure-annotation proc) + (cond ((assq proc *annotations*) => cdr) + (else #f))) diff --git a/alt/ascii.scm b/alt/ascii.scm new file mode 100644 index 0000000..09791a2 --- /dev/null +++ b/alt/ascii.scm @@ -0,0 +1,69 @@ +; -*- Mode: Scheme; Syntax: Scheme; Package: Scheme; -*- +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +;;;; Portable definitions of char->ascii and ascii->char + +; Don't detabify this file! + +; This module defines char->ascii and ascii->char in terms of +; char->integer and integer->char, with no assumptions about the encoding. +; Portable except maybe for the strings that contain tab, page, and +; carriage return characters. Those can be flushed if necessary. + +(define ascii-limit 128) + +(define ascii-chars + (let* ((ascii-chars (make-vector ascii-limit #f)) + (unusual (lambda (s) + (if (or (not (= (string-length s) 1)) + (let ((c (string-ref s 0))) + (or (char=? c #\space) + (char=? c #\newline)))) + (error "unusual whitespace character lost" s) + s))) + (init (lambda (i s) + (do ((i i (+ i 1)) + (j 0 (+ j 1))) + ((= j (string-length s))) + (vector-set! ascii-chars i (string-ref s j)))))) + (init 9 (unusual " ")) ;tab + (init 12 (unusual " ")) ;page + (init 13 (unusual " ")) ;carriage return + (init 10 (string #\newline)) + (init 32 " !\"#$%&'()*+,-./0123456789:;<=>?") + (init 64 "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_") + (init 96 "`abcdefghijklmnopqrstuvwxyz{|}~") + ascii-chars)) + +(define (ascii->char n) + (or (vector-ref ascii-chars n) + (error "not a standard character's ASCII code" n))) + +(define native-chars + (let ((end (vector-length ascii-chars))) + (let loop ((i 0) + (least #f) + (greatest #f)) + (cond ((= i end) + (let ((v (make-vector (+ (- greatest least) 1) #f))) + (do ((i 0 (+ i 1))) + ((= i end) (cons least v)) + (let ((c (vector-ref ascii-chars i))) + (if c + (vector-set! v (- (char->integer c) least) i)))))) + (else + (let ((c (vector-ref ascii-chars i))) + (if c + (let ((n (char->integer c))) + (loop (+ i 1) + (if least (min least n) n) + (if greatest (max greatest n) n))) + (loop (+ i 1) least greatest)))))))) + +(define (char->ascii char) + (or (vector-ref (cdr native-chars) + (- (char->integer char) (car native-chars))) + (error "not a standard character" char))) + +(define ascii-whitespaces '(32 10 9 12 13)) ;space linefeed tab page return diff --git a/alt/bitwise-tests.scm b/alt/bitwise-tests.scm new file mode 100644 index 0000000..ab03a60 --- /dev/null +++ b/alt/bitwise-tests.scm @@ -0,0 +1,58 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +; Lost: (ARITHMETIC-SHIFT 5 27) => -402653184 [wanted 671088640.] +; Lost: (ARITHMETIC-SHIFT 5 28) => 268435456 [wanted 1342177280.] + + +(define (testit name proc x y z) + (let ((result (proc x y))) + (if (not (= result z)) + (begin (display "Lost: ") + (write `(,name ,x ,y)) + (display " => ") + (write result) + (display " [wanted ") + (write z) + (display "]") + (newline))))) + +(define most-positive-fixnum + (let ((n (arithmetic-shift 2 27))) (+ n (- n 1)))) + +(define (test-left-shifts x) + (let ((crossover (arithmetic-shift 2 27))) + (do ((y 0 (+ y 1)) + (z x (* z (if (>= z crossover) 2. 2)))) + ((= y 34)) + (testit 'arithmetic-shift arithmetic-shift x y z)))) + +(test-left-shifts 5) +(test-left-shifts -5) + +(define (test-right-shifts x) + (do ((y 0 (- y 1)) + (z x (quotient z 2))) + ((= y -34)) + (testit 'arithmetic-shift arithmetic-shift x y z))) + +(test-right-shifts (* 5 (expt 2 36))) +(test-right-shifts (* -5 (expt 2 36))) + +(define (bit1? x) + (if (< x 0) + (even? (quotient (- -1 x) 2)) + (odd? (quotient x 2)))) + +(define (try-truth-table name proc predicate) + (do ((x -4 (+ x 1))) + ((= x 4)) + (do ((y -4 (+ y 1))) + ((= y 4)) + (testit name proc x y + (+ (if (predicate (odd? x) (odd? y)) 1 0) + (if (predicate (bit1? x) (bit1? y)) 2 0) + (if (predicate (negative? x) (negative? y)) -4 0)))))) + +(try-truth-table 'bitwise-and bitwise-and (lambda (a b) (and a b))) +(try-truth-table 'bitwise-ior bitwise-ior (lambda (a b) (or a b))) diff --git a/alt/bitwise.scm b/alt/bitwise.scm new file mode 100644 index 0000000..d534879 --- /dev/null +++ b/alt/bitwise.scm @@ -0,0 +1,44 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + +; Bitwise operators written in vanilla Scheme. +; Written for clarity and simplicity, not for speed. + +; No need to use these in Scheme 48 since Scheme 48's virtual machine +; provides fast machine-level implementations. + + +(define (bitwise-not i) + (- -1 i)) + +(define (bitwise-and x y) + (cond ((= x 0) 0) + ((= x -1) y) + (else + (+ (* (bitwise-and (arithmetic-shift x -1) + (arithmetic-shift y -1)) + 2) + (* (modulo x 2) (modulo y 2)))))) + +(define (bitwise-ior x y) + (bitwise-not (bitwise-and (bitwise-not x) + (bitwise-not y)))) + +(define (bitwise-xor x y) + (bitwise-and (bitwise-not (bitwise-and x y)) + (bitwise-ior x y))) + +(define (bitwise-eqv x y) + (bitwise-not (bitwise-xor x y))) + + +(define (arithmetic-shift n m) + (floor (* n (expt 2 m)))) + + +(define (count-bits x) ; Count 1's in the positive 2's comp rep + (let ((x (if (< x 0) (bitwise-not x) x))) + (do ((x x (arithmetic-shift x 1)) + (result 0 (+ result (modulo x 2)))) + ((= x 0) result)))) + +;(define (integer-length integer) ...) ;? diff --git a/alt/closure.scm b/alt/closure.scm new file mode 100644 index 0000000..6bcd075 --- /dev/null +++ b/alt/closure.scm @@ -0,0 +1,11 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + + +; Closures + +(define closure-rtd (make-record-type 'closure '(template env))) +(define closure? (record-predicate closure-rtd)) +(define make-closure (record-constructor closure-rtd '(template env))) +(define closure-template (record-accessor closure-rtd 'template)) +(define closure-env (record-accessor closure-rtd 'env)) diff --git a/alt/code-vector.scm b/alt/code-vector.scm new file mode 100644 index 0000000..a4915fc --- /dev/null +++ b/alt/code-vector.scm @@ -0,0 +1,19 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + +; Code-vectors implemented as vectors. + +(define *code-vector-marker* (list '*code-vector-marker*)) + +(define (make-code-vector len init) + (let ((t (make-vector (+ len 1) init))) + (vector-set! t 0 *code-vector-marker*) + t)) + +(define (code-vector? obj) + (and (vector? obj) + (> (vector-length obj) 0) + (eq? (vector-ref obj 0) *code-vector-marker*))) + +(define (code-vector-length t) (- (vector-length t) 1)) +(define (code-vector-ref t i) (vector-ref t (+ i 1))) +(define (code-vector-set! t i x) (vector-set! t (+ i 1) x)) diff --git a/alt/config.scm b/alt/config.scm new file mode 100644 index 0000000..dc178fe --- /dev/null +++ b/alt/config.scm @@ -0,0 +1,192 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +; Stub support for DEFINE-PACKAGE and DEFINE-INTERFACE macros. + +; Interfaces are ignored. Only dependencies are significant. + + +(define (load-configuration filename . rest) + (let ((save filename)) + (dynamic-wind (lambda () (set! *source-file-name* filename)) + (lambda () + (apply load filename rest)) + (lambda () (set! *source-file-name* save))))) +(define (%file-name%) *source-file-name*) +(define *source-file-name* "") + + +; This is used to generate file lists that are "included" in "makefiles." + +(define (write-file-names target . stuff) + (call-with-output-file target + (lambda (port) + (display "Writing ") (display target) (newline) + (display "#### This file was generated automatically. ####" + port) + (newline port) + (let ((mumble (lambda (name filenames) + (newline port) + (display name port) + (display " = " port) + (for-each (lambda (filename) + (display filename port) + (display " " port)) + filenames) + (newline port)))) + (do ((stuff stuff (cddr stuff))) + ((null? stuff)) + (mumble (car stuff) (cadr stuff))) + ;(mumble 'all-files (reverse *all-files*)) + )))) + + +; -------------------- + +(define (make-indirect-interface name thunk) + (thunk)) + + +(define (make-simple-interface name items) + (cons 'export items)) + +(define (make-compound-interface name . sigs) + (cons 'compound-interface sigs)) + + +; Structures are views into packages. +; In this implementation, interface information is completely ignored. + +(define-syntax make-structure + (syntax-rules () + ((make-structure ?package ?interface ?name) + (vector ' ?name ?package)) + ((make-structure ?package ?interface) + (make-structure ?package ?interface #f)))) + +(define (structure-name s) (vector-ref s 1)) +(define (structure-package s) (vector-ref s 2)) + +(define (verify-later! thunk) 'lose) +;(define *all-files* '()) + + +; Packages are not what they appear to be. + +(define (make-a-package opens-thunk accesses-thunk tower + file-name clauses name) + (vector ' + (delay (opens-thunk)) + (delay (accesses-thunk)) + file-name + clauses + #f)) + +(define (package-opens p) (force (vector-ref p 1))) +(define (package-accesses p) (force (vector-ref p 2))) +(define (package-file-name p) (vector-ref p 3)) +(define (package-clauses p) (vector-ref p 4)) +(define (package-loaded? p) (vector-ref p 5)) +(define (set-package-loaded?! p ?) (vector-set! p 5 ?)) + +(define dummy-package + (make-a-package (lambda () '()) (lambda () '()) #f "" '() #f)) + +; source-file-names ? +(define module-system (make-structure dummy-package #f 'module-system)) +(define scheme (make-structure dummy-package #f 'scheme)) +(define built-in-structures + (make-structure dummy-package #f 'built-in-structures)) + +(define (note-name! thing name) + thing) + + +; Handy + +(define (setdiff l1 l2) + (cond ((null? l2) l1) + ((null? l1) l1) + ((member (car l1) l2) + (setdiff (cdr l1) l2)) + (else (cons (car l1) + (setdiff (cdr l1) l2))))) + + +; Stuff copied from rts/filename.scm... ugh... + +; Namelist = ((dir ...) basename type) +; or ((dir ...) basename) +; or (dir basename type) +; or (dir basename) +; or basename + +(define (namestring namelist dir default-type) + (let ((namelist (if (list? namelist) namelist (list '() namelist)))) + (let ((subdirs (if (list? (car namelist)) + (car namelist) + (list (car namelist)))) + (basename (cadr namelist)) + (type (if (null? (cddr namelist)) + default-type + (caddr namelist)))) + (string-append (or dir "") + (apply string-append + (map (lambda (subdir) + (string-append + (namestring-component subdir) + directory-component-separator)) + subdirs)) + (namestring-component basename) + (if type + (string-append type-component-separator + (namestring-component type)) + ""))))) + +(define directory-component-separator "/") ;unix sux +(define type-component-separator ".") + +(define (namestring-component x) + (cond ((string? x) x) + ((symbol? x) + (list->string (map file-name-preferred-case + (string->list (symbol->string x))))) + (else + ;; (error "bogus namelist component" x) + "bogus namelist component"))) + +(define file-name-preferred-case char-downcase) + +(define *scheme-file-type* 'scm) +(define *load-file-type* *scheme-file-type*) ;#F for Pseudoscheme or T + +(define (file-name-directory filename) + (substring filename 0 (file-nondirectory-position filename))) + +(define (file-name-nondirectory filename) + (substring filename + (file-nondirectory-position filename) + (string-length filename))) + +(define (file-nondirectory-position filename) + (let loop ((i (- (string-length filename) 1))) + (cond ((< i 0) 0) + ;; Heuristic. Should work for DOS, Unix, VMS, MacOS. + ((string-posq (string-ref filename i) "/:>]\\") (+ i 1)) + (else (loop (- i 1)))))) + +(define (string-posq thing s) + (let loop ((i 0)) + (cond ((>= i (string-length s)) #f) + ((eq? thing (string-ref s i)) i) + (else (loop (+ i 1)))))) + +; Types +(define :value ':value) +(define :syntax ':syntax) +(define :structure ':structure) +(define :procedure ':procedure) +(define :number ':number) + + +(define-reflective-tower-maker list) diff --git a/alt/contin.scm b/alt/contin.scm new file mode 100644 index 0000000..f7d4869 --- /dev/null +++ b/alt/contin.scm @@ -0,0 +1,20 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +; Continuations implemented as vectors. + +(define *continuation-marker* (list '*continuation-marker*)) + +(define (make-continuation len init) + (let ((c (make-vector (+ len 1) init))) + (vector-set! c 0 *continuation-marker*) + c)) + +(define (continuation? obj) + (and (vector? obj) + (> (vector-length obj) 0) + (eq? (vector-ref obj 0) *continuation-marker*))) + +(define (continuation-length c) (- (vector-length c) 1)) +(define (continuation-ref c i) (vector-ref c (+ i 1))) +(define (continuation-set! c i x) (vector-set! c (+ i 1) x)) diff --git a/alt/environments.scm b/alt/environments.scm new file mode 100644 index 0000000..e258447 --- /dev/null +++ b/alt/environments.scm @@ -0,0 +1,6 @@ + +; don't put a copyright notice, silly shell script + +(define (*structure-ref struct name) + (eval name (interaction-environment))) + diff --git a/alt/escape.scm b/alt/escape.scm new file mode 100644 index 0000000..45b792f --- /dev/null +++ b/alt/escape.scm @@ -0,0 +1,32 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + + +; For an explanation, see comments in rts/low.scm. + +; The debugger invokes EXTRACT-CONTINUATION on a "native" continuation +; as obtained by PRIMITIVE-CWCC in order to get a VM continuation. +; The distinction between native and VM continuations is useful when +; debugging a program running under a VM that's different from +; whatever machine is running the debugger. + +(define-record-type escape :escape + (make-escape proc) + (proc escape-procedure)) + +(define (with-continuation esc thunk) + (if esc + ((escape-procedure esc) thunk) + (let ((answer (thunk))) + (signal 'vm-return answer) ;#f means halt + (call-error "halt" answer)))) + +(define (primitive-cwcc proc) + (call-with-current-continuation + (lambda (done) + ((call-with-current-continuation + (lambda (k) + (call-with-values + (lambda () + (proc (make-escape k))) + done))))))) diff --git a/alt/features-packages.scm b/alt/features-packages.scm new file mode 100644 index 0000000..cb873f1 --- /dev/null +++ b/alt/features-packages.scm @@ -0,0 +1,29 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + + +; The following several packages have Scheme-implementation-specific +; variants that are much better for one reason or another than +; the generic versions defined here. + +(define-structures ((signals signals-interface) + (handle (export ignore-errors)) + (features features-interface)) + (open scheme-level-2) + (files features)) + +(define-structure records records-interface + (open scheme-level-2 signals) + (files record)) + +(define-structure ascii (export ascii->char char->ascii) + (open scheme-level-2 signals) + (files ascii)) + +(define-structure bitwise bitwise-interface + (open scheme-level-2 signals) + (files bitwise)) + +(define-structure code-vectors code-vectors-interface + (open scheme-level-1) + (files code-vectors)) diff --git a/alt/features.scm b/alt/features.scm new file mode 100644 index 0000000..de75805 --- /dev/null +++ b/alt/features.scm @@ -0,0 +1,58 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +; This is file features.scm. +; Synchronize any changes with all the other *-features.scm files. + +; These definitions should be quite portable to any Scheme implementation. +; Assumes Revised^5 Report Scheme, for EVAL and friends. + + +; SIGNALS + +(define (error message . irritants) + (display-error-message "Error: " message irritants) + (an-error-occurred-now-what?)) + +(define (warn message . irritants) + (display-error-message "Warning: " message irritants)) + +(define (display-error-message heading message irritants) + (display heading) + (display message) + (newline) + (let ((spaces (list->string + (map (lambda (c) #\space) (string->list heading))))) + (for-each (lambda (irritant) + (display spaces) + (write irritant) + (newline)) + irritants))) + +; Linker also needs SIGNAL, SYNTAX-ERROR, CALL-ERROR + + +; HANDLE + +(define (ignore-errors thunk) + '(error "ignore-errors isn't implemented")) + + +; FEATURES + +(define (force-output port) #f) + +(define (string-hash s) + (let ((n (string-length s))) + (do ((i 0 (+ i 1)) + (h 0 (+ h (char->ascii (string-ref s i))))) + ((>= i n) h)))) + +(define (make-immutable! thing) #f) +(define (immutable? thing) #f) +(define (unspecific) (if #f #f)) + + +; BITWISE -- use alt/bitwise.scm (!) +; ACII -- use alt/ascii.scm +; CODE-VECTORS -- use alt/code-vectors.scm diff --git a/alt/fluid.scm b/alt/fluid.scm new file mode 100644 index 0000000..b2c8c7c --- /dev/null +++ b/alt/fluid.scm @@ -0,0 +1,33 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +; Fluid variables + +(define (make-fluid val) + (vector ' val)) + +(define (fluid f) (vector-ref f 1)) + +(define (set-fluid! f val) + (vector-set! f 1 val)) + +(define (let-fluid f val thunk) + (let ((swap (lambda () (let ((temp (fluid f))) + (set-fluid! f val) + (set! val temp))))) + (dynamic-wind swap thunk swap))) + +(define (let-fluids . args) ;Kind of gross + (let loop ((args args) + (swap (lambda () #f))) + (if (null? (cdr args)) + (dynamic-wind swap (car args) swap) + (loop (cddr args) + (let ((f (car args)) + (val (cadr args))) + (lambda () + (swap) + (let ((temp (fluid f))) + (set-fluid! f val) + (set! val temp)))))))) + diff --git a/alt/init-defpackage.scm b/alt/init-defpackage.scm new file mode 100644 index 0000000..f4c8027 --- /dev/null +++ b/alt/init-defpackage.scm @@ -0,0 +1,14 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +; This file should be loaded into the bootstrap linker before any use +; of DEFINE-STRUCTURE. Compare with env/init-defpackage.scm. + +(define-reflective-tower-maker + (lambda (clauses names) + (let ((env (interaction-environment))) + (delay + (begin (if (not (null? clauses)) + (warn "a FOR-SYNTAX clause appears in a package being linked by the cross-linker" + `(for-syntax ,@clauses))) + (cons eval env)))))) diff --git a/alt/locations.scm b/alt/locations.scm new file mode 100644 index 0000000..d26c399 --- /dev/null +++ b/alt/locations.scm @@ -0,0 +1,30 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +; Locations + +(define location-rtd + (make-record-type 'location '(id defined? contents))) + +(define-record-discloser location-rtd + (lambda (l) `(location ,(location-id l)))) + +(define make-undefined-location + (let ((make (record-constructor location-rtd + '(id defined? contents)))) + (lambda (id) + (make id #f '*empty*)))) + +(define location? (record-predicate location-rtd)) +(define location-id (record-accessor location-rtd 'id)) +(define location-defined? (record-accessor location-rtd 'defined?)) +(define contents (record-accessor location-rtd 'contents)) + +(define set-defined?! (record-modifier location-rtd 'defined?)) + +(define (set-location-defined?! loc ?) + (set-defined?! loc ?) + (if (not ?) + (set-contents! loc '*empty*))) + +(define set-contents! (record-modifier location-rtd 'contents)) diff --git a/alt/loophole.scm b/alt/loophole.scm new file mode 100644 index 0000000..d3214b1 --- /dev/null +++ b/alt/loophole.scm @@ -0,0 +1,9 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +(define-syntax loophole + (syntax-rules () + ((loophole ?type ?form) + (begin (lambda () ?type) ;Elicit unbound-variable warnings, etc. + ?form)))) + diff --git a/alt/low-packages.scm b/alt/low-packages.scm new file mode 100644 index 0000000..577b20e --- /dev/null +++ b/alt/low-packages.scm @@ -0,0 +1,26 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + +; Alternate implementations of the low-structures. +; Cf. low-structures-interface in ../packages.scm and ../alt-structures.scm. + +; Most of the low-structures are assumed to be inherited or obtained +; elsewhere (probably from a running Scheme 48). This only defines +; structures that export privileged operations. + +(define-structure escapes escapes-interface + (open scheme-level-2 define-record-types signals) + (files escape)) + +(define-structures ((primitives primitives-interface) + (primitives-internal (export maybe-handle-interrupt + raise-exception + get-exception-handler + ?start))) + (open scheme-level-2 + bitwise define-record-types + features + signals + templates) + (files primitives + weak + contin)) diff --git a/alt/low.scm b/alt/low.scm new file mode 100644 index 0000000..6d33da1 --- /dev/null +++ b/alt/low.scm @@ -0,0 +1,25 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +; Portable versions of low-level things that would really like to rely +; on the Scheme 48 VM or on special features provided by the byte code +; compiler. + +(define (vector-unassigned? v i) #f) + +(define (flush-the-symbol-table!) #f) + +(define maybe-open-input-file open-input-file) +(define maybe-open-output-file open-output-file) + + +; Suppress undefined export warnings. + +(define-syntax %file-name% + (syntax-rules () + ((%file-name%) ""))) + +(define-syntax structure-ref + (syntax-rules () + ((structure-ref ?struct ?name) + (error "structure-ref isn't implemented" '?struct '?name)))) diff --git a/alt/primitives.scm b/alt/primitives.scm new file mode 100644 index 0000000..2c5f4f2 --- /dev/null +++ b/alt/primitives.scm @@ -0,0 +1,175 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +; Alternate implementation of PRIMITIVES module. + +(define underlying-error error) + +(define (unspecific) (if #f #f)) + + +; Records + +(define-record-type new-record :new-record + (make-new-record fields) + record? + (fields new-record-fields)) + +(define (make-record size init) + (make-new-record (make-vector size init))) + +(define (record-ref r i) + (vector-ref (new-record-fields r) i)) + +(define (record-set! r i value) + (vector-set! (new-record-fields r) i value)) + +(define (record-length r) + (vector-length (new-record-fields r))) + + +; Extended numbers + +(define-record-type new-extended-number :new-extended-number + (make-new-extended-number fields) + extended-number? + (fields new-extended-number-fields)) + +(define-record-discloser :new-extended-number + (lambda (n) `(extended-number ,(new-extended-number-fields n)))) + +(define (make-extended-number size init) + (make-new-extended-number (make-vector size init))) + +(define (extended-number-ref n i) + (vector-ref (new-extended-number-fields n) i)) + +(define (extended-number-set! n i value) + (vector-set! (new-extended-number-fields n) i value)) + +(define (extended-number-length n) + (vector-length (new-extended-number-fields n))) + + +; Dynamic state (= current thread) + +(define *dynamic-state* 'uninitialized-dynamic-state) +(define (get-dynamic-state) *dynamic-state*) +(define (set-dynamic-state! state) + (if (not (and (record? state) + (list? (record-ref state 1)))) + (underlying-error "invalid dynamic state" state)) + (set! *dynamic-state* state)) + +; Etc. + +(define (close-port port) + ((if (input-port? port) close-input-port close-output-port) + port)) + +(define (write-string s port) + (display s port)) + +(define (schedule-interrupt interval) + (if (not (= interval 0)) + (warn "ignoring schedule-interrupt" interval))) + +(define *pseudo-enabled-interrupts* 0) + +(define (set-enabled-interrupts! ei) + (let ((previous *pseudo-enabled-interrupts*)) + (set! *pseudo-enabled-interrupts* ei) + ;; (if (bitwise-and *pseudo-pending-interrupts* ei) ...) + previous)) + +(define *pseudo-pending-interrupts* 0) + +(define *pseudo-exception-handler* #f) +(define (set-exception-handler! h) + (set! *pseudo-exception-handler* h)) + +(define *pseudo-interrupt-handlers* #f) +(define (set-interrupt-handlers! v) + (set! *pseudo-interrupt-handlers* v)) + +(define (unimplemented name) + (lambda args (underlying-error "unimplemented primitive" name args))) +(define collect (unimplemented 'collect)) +(define external-call (unimplemented 'external-call)) +(define external-lookup (unimplemented 'external-lookup)) +(define external-name (unimplemented 'external-name)) +(define external-value (unimplemented 'external-value)) +(define (external? x) #f) +(define find-all-xs (unimplemented 'find-all-xs)) +(define make-external (unimplemented 'make-external)) +(define vm-extension (unimplemented 'vm-extension)) + +(define (memory-status which arg) + (case which + ((2) 100) + ((3) (display "(Ignoring set-minimum-recovered-space!)") (newline)) + (else (underlying-error "unimplemented memory-status" which arg)))) + +(define (time which arg) + (case which + ((0) 1000) + (else (underlying-error "unimplemented time" which arg)))) + + +; end of definitions implementing PRIMITIVES structure + + +; -------------------- + +; Auxiliary crud. + +(define (maybe-handle-interrupt which) + ;; Should actually do (get-highest-priority-interrupt!) ... + (let ((bit (arithmetic-shift 1 which))) + (cond ((= (bitwise-and *pseudo-enabled-interrupts* bit) 0) + (set! *pseudo-pending-interrupts* + (bitwise-ior *pseudo-pending-interrupts* bit)) + (display "(Interrupt deferred)") + (newline) + #f) + (else + (set! *pseudo-pending-interrupts* + (bitwise-and *pseudo-pending-interrupts* + (bitwise-not bit))) + (display "(Handling interrupt)") + (newline) + ((vector-ref *pseudo-interrupt-handlers* which) + (set-enabled-interrupts! 0)) + #t)))) + +(define (raise-exception opcode arguments) + (apply (get-exception-handler) + opcode + arguments)) + +(define (get-exception-handler) + *pseudo-exception-handler*) + + +(define (clear-registers!) + (set! *dynamic-state* 'uninitialized-dynamic-state) + (set! *pseudo-enabled-interrupts* 0) + (set! *pseudo-interrupt-handlers* #f) + (set! *pseudo-exception-handler* #f)) + +(define *vm-return* #f) + +(define (vm-return . rest) + (if *vm-return* + (apply *vm-return* rest) + (underlying-error "vm-return" rest))) + + +(define (?start entry-point arg) ;E.g. (?start (usual-resumer bare) 0) + (clear-registers!) + (call-with-current-continuation + (lambda (k) + (set! *vm-return* k) + (entry-point arg + (current-input-port) + (current-output-port))))) diff --git a/alt/pseudoscheme-features.scm b/alt/pseudoscheme-features.scm new file mode 100644 index 0000000..f9703d0 --- /dev/null +++ b/alt/pseudoscheme-features.scm @@ -0,0 +1,120 @@ +; -*- Mode: Scheme; Syntax: Scheme; Package: Scheme; -*- +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +; This is file pseudoscheme-features.scm. +; Synchronize any changes with all the other *-features.scm files. + +(define *load-file-type* #f) ;For fun + + +; SIGNALS + +(define error #'ps:scheme-error) + +(define warn #'ps:scheme-warn) + +(define (signal type . stuff) + (apply warn "condition signalled" type stuff)) + +(define (syntax-error . rest) ; Must return a valid expression. + (apply warn rest) + ''syntax-error) + +(define (call-error message proc . args) + (error message (cons proc args))) + + +; HANDLE + +(define (ignore-errors thunk) + #-Lucid + '(error "ignore-errors isn't implemented") ;No big deal if it doesn't work. + #+Lucid + (let ((result (lcl:ignore-errors (thunk)))) + (lisp:if (lisp:typep result 'lcl:condition) + (list 'error result) + result))) + + +; FEATURES + +(define force-output #'lisp:force-output) + +(define (string-hash s) + (let ((n (string-length s))) + (do ((i 0 (+ i 1)) + (h 0 (+ h (lisp:char-code (string-ref s i))))) + ((>= i n) h)))) + +(define (make-immutable! thing) #f) +(define (immutable? thing) #f) +(define (unspecific) (if #f #f)) + + +; BITWISE + +(define arithmetic-shift #'lisp:ash) +(define bitwise-and #'lisp:logand) +(define bitwise-ior #'lisp:logior) + + +; ASCII + +(define char->ascii #'lisp:char-code) +(define ascii->char #'lisp:code-char) + + +; CODE-VECTORS + +(define (make-code-vector len . fill-option) + (lisp:make-array len :element-type '(lisp:unsigned-byte 8) + :initial-element (if (null? fill-option) + 0 + (car fill-option)))) + +(define (code-vector? obj) + (ps:true? (lisp:typep obj + (lisp:quote (lisp:simple-array (lisp:unsigned-byte 8) + (lisp:*)))))) + +(define (code-vector-ref bv k) + (lisp:aref (lisp:the (lisp:simple-array (lisp:unsigned-byte 8) (lisp:*)) + bv) + k)) + +(define (code-vector-set! bv k val) + (lisp:setf (lisp:aref (lisp:the (lisp:simple-array (lisp:unsigned-byte 8) + (lisp:*)) + bv) + k) + val)) + +(define (code-vector-length bv) + (lisp:length (lisp:the (lisp:simple-array (lisp:unsigned-byte 8) (lisp:*)) + bv))) + + +; The rest is unnecessary in Pseudoscheme versions 2.8d and after. + +;(define eval #'schi:scheme-eval) +;(define (interaction-environment) schi:*current-rep-environment*) +;(define scheme-report-environment +; (let ((env (scheme-translator:make-program-env +; 'rscheme +; (list scheme-translator:revised^4-scheme-module)))) +; (lambda (n) +; n ;ignore +; env))) + +; Dynamic-wind. +; +;(define (dynamic-wind in body out) +; (in) +; (lisp:unwind-protect (body) +; (out))) +; +;(define values #'lisp:values) +; +;(define (call-with-values thunk receiver) +; (lisp:multiple-value-call receiver (thunk))) diff --git a/alt/pseudoscheme-record.scm b/alt/pseudoscheme-record.scm new file mode 100644 index 0000000..be4827d --- /dev/null +++ b/alt/pseudoscheme-record.scm @@ -0,0 +1,18 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +(define make-record-type #'scheme-translator::make-record-type) +(define record-constructor #'scheme-translator::record-constructor) +(define record-accessor #'scheme-translator::record-accessor) +(define record-modifier #'scheme-translator::record-modifier) +(define record-predicate #'scheme-translator::record-predicate) +(define define-record-discloser #'scheme-translator::define-record-discloser) + +(define record-type? #'scheme-translator::record-type-descriptor-p) +(define record-type-field-names #'scheme-translator::rtd-field-names) +(define record-type-name #'scheme-translator::rtd-identification) + +; Internal record things, for inspector or whatever +(define disclose-record #'scheme-translator::disclose-record) +(define record-type #'scheme-translator::record-type) +(define (record? x) (if (scheme-translator::record-type x) #t #f)) diff --git a/alt/queue.scm b/alt/queue.scm new file mode 100644 index 0000000..95a05c4 --- /dev/null +++ b/alt/queue.scm @@ -0,0 +1,28 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + +; Queues + +(define (make-queue) + (cons '() '())) + +(define (queue-empty? q) + (and (null? (car q)) + (null? (cdr q)))) + +(define (enqueue q obj) + (set-car! q (cons obj (car q)))) + +(define (dequeue q) + (normalize-queue! q) + (let ((head (car (cdr q)))) + (set-cdr! q (cdr (cdr q))) + head)) + +(define (normalize-queue! q) + (if (null? (cdr q)) + (begin (set-cdr! q (reverse (car q))) + (set-car! q '())))) + +(define (queue-head q) + (normalize-queue! q) + (car (cdr q))) diff --git a/alt/record.scm b/alt/record.scm new file mode 100644 index 0000000..3c1fcf4 --- /dev/null +++ b/alt/record.scm @@ -0,0 +1,96 @@ +; -*- Mode: Scheme; Syntax: Scheme; Package: Scheme; -*- +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +; This is file record.scm. + +;;;; Records + +; This is completely vanilla Scheme code. Should work anywhere. + +(define (make-record-type type-id field-names) + + (define unique (list type-id)) + + (define size (+ (length field-names) 1)) + + (define (constructor . names-option) + (let* ((names (if (null? names-option) + field-names + (car names-option))) + (number-of-inits (length names)) + (indexes (map field-index names))) + (lambda field-values + (if (= (length field-values) number-of-inits) + (let ((record (make-vector size 'uninitialized))) + (vector-set! record 0 unique) + (for-each (lambda (index value) + (vector-set! record index value)) + indexes + field-values) + record) + (error "wrong number of arguments to record constructor" + field-values type-id names))))) + + (define (predicate obj) + (and (vector? obj) + (= (vector-length obj) size) + (eq? (vector-ref obj 0) unique))) + + (define (accessor name) + (let ((i (field-index name))) + (lambda (record) + (if (predicate record) ;Faster: (eq? (vector-ref record 0) unique) + (vector-ref record i) + (error "invalid argument to record accessor" + record type-id name))))) + + (define (modifier name) + (let ((i (field-index name))) + (lambda (record new-value) + (if (predicate record) ;Faster: (eq? (vector-ref record 0) unique) + (vector-set! record i new-value) + (error "invalid argument to record modifier" + record type-id name))))) + + (define (field-index name) + (let loop ((l field-names) (i 1)) + (if (null? l) + (error "bad field name" name) + (if (eq? name (car l)) + i + (loop (cdr l) (+ i 1)))))) + + (define the-descriptor + (lambda (request) + (case request + ((constructor) constructor) + ((predicate) predicate) + ((accessor) accessor) + ((modifier) modifier) + ((name) type-id) + ((field-names) field-names)))) + + the-descriptor) + +(define (record-constructor r-t . names-option) + (apply (r-t 'constructor) names-option)) + +(define (record-predicate r-t) + (r-t 'predicate)) + +(define (record-accessor r-t field-name) + ((r-t 'accessor) field-name)) + +(define (record-modifier r-t field-name) + ((r-t 'modifier) field-name)) + +(define (record-type-name r-t) (r-t 'name)) +(define (record-type-field-names r-t) (r-t 'field-names)) + +(define (record-type? r-t) + (and (procedure? r-t) + (error "record-type? not implemented" r-t))) + +(define (define-record-discloser r-t proc) + "ignoring define-record-discloser form") diff --git a/alt/reroot.scm b/alt/reroot.scm new file mode 100644 index 0000000..e30b565 --- /dev/null +++ b/alt/reroot.scm @@ -0,0 +1,54 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +; A state space is a tree with the state at the root. Each node other +; than the root is a triple , represented in +; this implementation as a structure ((before . after) . parent). +; Moving from one state to another means re-rooting the tree by pointer +; reversal. + +(define *here* (list #f)) + +(define original-cwcc call-with-current-continuation) + +(define (call-with-current-continuation proc) + (let ((here *here*)) + (original-cwcc (lambda (cont) + (proc (lambda results + (reroot! here) + (apply cont results))))))) + +(define (dynamic-wind before during after) + (let ((here *here*)) + (reroot! (cons (cons before after) here)) + (call-with-values during + (lambda results + (reroot! here) + (apply values results))))) + +(define (reroot! there) + (if (not (eq? *here* there)) + (begin (reroot! (cdr there)) + (let ((before (caar there)) + (after (cdar there))) + (set-car! *here* (cons after before)) + (set-cdr! *here* there) + (set-car! there #f) + (set-cdr! there '()) + (set! *here* there) + (before))))) + +; ----- +; +;(define r #f) (define s #f) (define (p x) (write x) (newline)) +;(define (tst) +; (set! r *here*) +; (set! s (cons (cons (lambda () (p 'in)) (lambda () (p 'out))) *here*)) +; (reroot! s)) +; +; +;(define (check) ;Algorithm invariants +; (if (not (null? (cdr *here*))) +; (error "confusion #1")) +; (if (car *here*) +; (error "confusion #2"))) diff --git a/alt/schemetoc-features.scm b/alt/schemetoc-features.scm new file mode 100644 index 0000000..bfc6e56 --- /dev/null +++ b/alt/schemetoc-features.scm @@ -0,0 +1,142 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +; BUG: (+ (expt 2 28) (expt 2 28)), (* (expt 2 28) 2) + +(define-external schemetoc-error ;(schemetoc-error symbol format-string . args) + "scdebug" "error_v") + +(eval-when (eval) + (define schemetoc-error error)) + + +; SIGNALS + +(define (error message . irritants) + (if (symbol? message) + (apply schemetoc-error message irritants) + (apply schemetoc-error + "Error:" + (apply string-append + message + (map (lambda (x) "~% ~s") + irritants)) + irritants))) + +(define (warn message . irritants) + (display-error-message "Warning: " message irritants)) + +(define (display-error-message heading message irritants) + (display heading) + (display message) + (newline) + (let ((spaces (list->string + (map (lambda (c) #\space) (string->list heading))))) + (for-each (lambda (irritant) + (display spaces) + (write irritant) + (newline)) + irritants))) + +(define (signal type . stuff) + (apply warn "condition signalled" type stuff)) + +(define (syntax-error . rest) ; Must return a valid expression. + (apply warn rest) + ''syntax-error) + +(define (call-error message proc . args) + (error message (cons proc args))) + + +; HANDLE + +;(define (ignore-errors thunk) +; (call-with-current-continuation +; (lambda (k) +; (let* ((save (lambda rest +; (k (cons 'error rest)))) +; (swap (lambda () +; (let ((temp *error-handler*)) +; (set! *error-handler* save) +; (set! save temp))))) +; (dynamic-wind swap thunk swap))))) + +; Joel Bartlett's rewrite, which doesn't elicit compiler bug. +(define (ignore-errors thunk) + (call-with-current-continuation + (lambda (k) + (let* ((save *error-handler*) + (on-error (lambda rest (k (cons 'error rest)))) + (in (lambda () (set! *error-handler* on-error))) + (out (lambda () (set! *error-handler* save)))) + (dynamic-wind in thunk out))))) + + +; FEATURES + +(define force-output flush-buffer) + +(define (string-hash s) + (let ((n (string-length s))) + (do ((i 0 (+ i 1)) + (h 0 (+ h (char->ascii (string-ref s i))))) + ((>= i n) h)))) + +(define (make-immutable! thing) #f) +(define (immutable? thing) #f) +(define (unspecific) (if #f #f)) + + +; BITWISE + +(define (arithmetic-shift x n) + (if (< x 0) + (let ((r (- -1 (arithmetic-shift (- -1 x) n)))) + (if (> n 0) + (- r (- (arithmetic-shift 1 n) 1)) + r)) + (if (>= n 0) ;shift left? + (if (and (<= n 8) + (exact? x) + (< x 4194304)) + (bit-lsh x n) + (* x (expt 2 n))) + (if (and (<= n 28) (exact? x)) + (bit-rsh x (- n)) + (floor (* x (expt 2. n))))))) + +(define (bitwise-and x y) + (if (and (< x 0) (< y 0)) + (- -1 (bit-or (- -1 x) (- -1 y))) + (bit-and x y))) + +(define (bitwise-ior x y) + (if (or (< x 0) (< y 0)) + (- -1 (bit-and (- -1 x) (- -1 y))) + (bit-or x y))) + + +; ASCII + +(define char->ascii char->integer) +(define ascii->char integer->char) + + +; CODE-VECTORS (= alt/code-vectors.scm) + +(define *code-vector-marker* (list '*code-vector-marker*)) + +(define (make-code-vector len init) + (let ((t (make-vector (+ len 1) init))) + (vector-set! t 0 *code-vector-marker*) + t)) + +(define (code-vector? obj) + (and (vector? obj) + (> (vector-length obj) 0) + (eq? (vector-ref obj 0) *code-vector-marker*))) + +(define (code-vector-length t) (- (vector-length t) 1)) +(define (code-vector-ref t i) (vector-ref t (+ i 1))) +(define (code-vector-set! t i x) (vector-set! t (+ i 1) x)) diff --git a/alt/schemetoc-record.scm b/alt/schemetoc-record.scm new file mode 100644 index 0000000..96da051 --- /dev/null +++ b/alt/schemetoc-record.scm @@ -0,0 +1,120 @@ +; -*- Mode: Scheme; Syntax: Scheme; Package: Scheme; -*- +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +; This is file schemetoc-record.scm. +; Synchronize any changes with the other *record.scm files. + +;;;; Records + +(define (make-record-type type-id field-names) + + (define unique (lambda () the-descriptor)) + + (define size (+ (length field-names) 1)) + + (define (constructor . names-option) + (let* ((names (if (null? names-option) + field-names + (car names-option))) + (foo (cons unique + (map (lambda (name) 'uninitialized) field-names))) + (number-of-inits (length names)) + (indexes (map field-index names))) + (lambda field-values + (if (= (length field-values) number-of-inits) + (let ((record (list->%record foo))) + (for-each (lambda (index value) + (%record-set! record index value)) + indexes + field-values) + (%record-methods-set! record usual-record-methods) + record) + (error "wrong number of arguments to record constructor" + field-values type-id names))))) + + (define (predicate obj) + (and (%record? obj) + (= (%record-length obj) size) + (eq? (%record-ref obj 0) unique))) + + (define (accessor name) + (let ((i (field-index name))) + (lambda (record) + (if (predicate record) ;Faster: (eq? (%record-ref record 0) unique) + (%record-ref record i) + (error "invalid argument to record accessor" + record type-id name))))) + + (define (modifier name) + (let ((i (field-index name))) + (lambda (record new-value) + (if (predicate record) ;Faster: (eq? (%record-ref record 0) unique) + (%record-set! record i new-value) + (error "invalid argument to record modifier" + record type-id name))))) + + (define (field-index name) + (let loop ((l field-names) (i 1)) + (if (null? l) + (error "bad field name" name) + (if (eq? name (car l)) + i + (loop (cdr l) (+ i 1)))))) + + (define (discloser r) (list type-id)) + + (define the-descriptor + (lambda (request) + (case request + ((constructor) constructor) + ((predicate) predicate) + ((accessor) accessor) + ((modifier) modifier) + ((identification) type-id) + ((field-names) field-names) + ((discloser) discloser) + ((set-discloser!) (lambda (d) (set! discloser d)))))) + + the-descriptor) + +(define (record-type x) + (if (%record? x) + (let ((probe (%record-ref x 0))) + (if (procedure? probe) + (probe) + #f)) + #f)) + +(define (record-type-identification r-t) + (r-t 'identification)) + +(define (record-type-field-names r-t) + (r-t 'field-names)) + +(define (record-constructor r-t . names-option) + (apply (r-t 'constructor) names-option)) + +(define (record-predicate r-t) + (r-t 'predicate)) + +(define (record-accessor r-t field-name) + ((r-t 'accessor) field-name)) + +(define (record-modifier r-t field-name) + ((r-t 'modifier) field-name)) + +(define (define-record-discloser r-t proc) + ((r-t 'set-discloser!) proc)) + +(define (disclose-record r) + (((record-type r) 'discloser) r)) + +(define usual-record-methods + (list (cons '%to-write + (lambda (r port indent levels length seen) + (write-char #\# port) + (write-char %record-prefix-char port) + (list (disclose-record r)))))) + +(set! %record-prefix-char #\~) diff --git a/alt/silly.scm b/alt/silly.scm new file mode 100644 index 0000000..8ca9c4e --- /dev/null +++ b/alt/silly.scm @@ -0,0 +1,8 @@ + + +(define (reverse-list->string l n) + ;; Significantly faster than (list->string (reverse l)) + (let ((s (make-string n #\x))) + (let loop ((i (- n 1)) (l l)) + (if (< i 0) s (begin (string-set! s i (car l)) + (loop (- i 1) (cdr l))))))) diff --git a/alt/syntax.scm b/alt/syntax.scm new file mode 100644 index 0000000..b65aee8 --- /dev/null +++ b/alt/syntax.scm @@ -0,0 +1,204 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +; This definition of define-syntax is appropriate for Scheme-to-C. + +(define-macro define-syntax + (lambda (form expander) + (expander `(define-macro ,(cadr form) + (let ((transformer ,(caddr form))) + (lambda (form expander) + (expander (transformer form + (lambda (x) x) + eq?) + expander)))) + expander))) + + +; Rewrite-rule compiler (a.k.a. "extend-syntax") + +; Example: +; +; (define-syntax or +; (syntax-rules () +; ((or) #f) +; ((or e) e) +; ((or e1 e ...) (let ((temp e1)) +; (if temp temp (or e ...)))))) + +(define-syntax syntax-rules + (let () + + (define name? symbol?) + + (define (segment-pattern? pattern) + (and (segment-template? pattern) + (or (null? (cddr pattern)) + (syntax-error "segment matching not implemented" pattern)))) + + (define (segment-template? pattern) + (and (pair? pattern) + (pair? (cdr pattern)) + (memq (cadr pattern) indicators-for-zero-or-more))) + + (define indicators-for-zero-or-more (list (string->symbol "...") '---)) + + (lambda (exp r c) + + (define %input (r '%input)) ;Gensym these, if you like. + (define %compare (r '%compare)) + (define %rename (r '%rename)) + (define %tail (r '%tail)) + (define %temp (r '%temp)) + + (define rules (cddr exp)) + (define subkeywords (cadr exp)) + + (define (make-transformer rules) + `(lambda (,%input ,%rename ,%compare) + (let ((,%tail (cdr ,%input))) + (cond ,@(map process-rule rules) + (else + (syntax-error + "use of macro doesn't match definition" + ,%input)))))) + + (define (process-rule rule) + (if (and (pair? rule) + (pair? (cdr rule)) + (null? (cddr rule))) + (let ((pattern (cdar rule)) + (template (cadr rule))) + `((and ,@(process-match %tail pattern)) + (let* ,(process-pattern pattern + %tail + (lambda (x) x)) + ,(process-template template + 0 + (meta-variables pattern 0 '()))))) + (syntax-error "ill-formed syntax rule" rule))) + + ; Generate code to test whether input expression matches pattern + + (define (process-match input pattern) + (cond ((name? pattern) + (if (member pattern subkeywords) + `((,%compare ,input (,%rename ',pattern))) + `())) + ((segment-pattern? pattern) + (process-segment-match input (car pattern))) + ((pair? pattern) + `((let ((,%temp ,input)) + (and (pair? ,%temp) + ,@(process-match `(car ,%temp) (car pattern)) + ,@(process-match `(cdr ,%temp) (cdr pattern)))))) + ((or (null? pattern) (boolean? pattern) (char? pattern)) + `((eq? ,input ',pattern))) + (else + `((equal? ,input ',pattern))))) + + (define (process-segment-match input pattern) + (let ((conjuncts (process-match '(car l) pattern))) + (if (null? conjuncts) + `((list? ,input)) ;+++ + `((let loop ((l ,input)) + (or (null? l) + (and (pair? l) + ,@conjuncts + (loop (cdr l))))))))) + + ; Generate code to take apart the input expression + ; This is pretty bad, but it seems to work (can't say why). + + (define (process-pattern pattern path mapit) + (cond ((name? pattern) + (if (memq pattern subkeywords) + '() + (list (list pattern (mapit path))))) + ((segment-pattern? pattern) + (process-pattern (car pattern) + %temp + (lambda (x) ;temp is free in x + (mapit (if (eq? %temp x) + path ;+++ + `(map (lambda (,%temp) ,x) + ,path)))))) + ((pair? pattern) + (append (process-pattern (car pattern) `(car ,path) mapit) + (process-pattern (cdr pattern) `(cdr ,path) mapit))) + (else '()))) + + ; Generate code to compose the output expression according to template + + (define (process-template template rank env) + (cond ((name? template) + (let ((probe (assq template env))) + (if probe + (if (<= (cdr probe) rank) + template + (syntax-error "template rank error (too few ...'s?)" + template)) + `(,%rename ',template)))) + ((segment-template? template) + (let ((vars + (free-meta-variables (car template) (+ rank 1) env '()))) + (if (null? vars) + (syntax-error "too many ...'s" template) + (let* ((x (process-template (car template) + (+ rank 1) + env)) + (gen (if (equal? (list x) vars) + x ;+++ + `(map (lambda ,vars ,x) + ,@vars)))) + (if (null? (cddr template)) + gen ;+++ + `(append ,gen ,(process-template (cddr template) + rank env))))))) + ((pair? template) + `(cons ,(process-template (car template) rank env) + ,(process-template (cdr template) rank env))) + (else `(quote ,template)))) + + ; Return an association list of (var . rank) + + (define (meta-variables pattern rank vars) + (cond ((name? pattern) + (if (memq pattern subkeywords) + vars + (cons (cons pattern rank) vars))) + ((segment-pattern? pattern) + (meta-variables (car pattern) (+ rank 1) vars)) + ((pair? pattern) + (meta-variables (car pattern) rank + (meta-variables (cdr pattern) rank vars))) + (else vars))) + + ; Return a list of meta-variables of given higher rank + + (define (free-meta-variables template rank env free) + (cond ((name? template) + (if (and (not (memq template free)) + (let ((probe (assq template env))) + (and probe (>= (cdr probe) rank)))) + (cons template free) + free)) + ((segment-template? template) + (free-meta-variables (car template) + rank env + (free-meta-variables (cddr template) + rank env free))) + ((pair? template) + (free-meta-variables (car template) + rank env + (free-meta-variables (cdr template) + rank env free))) + (else free))) + + c ;ignored + + ;; Kludge for Scheme 48 static linker. + ;; `(cons ,(make-transformer rules) + ;; ',(find-free-names-in-syntax-rules subkeywords rules)) + + (make-transformer rules)))) diff --git a/alt/t-features.scm b/alt/t-features.scm new file mode 100644 index 0000000..ba63313 --- /dev/null +++ b/alt/t-features.scm @@ -0,0 +1,118 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +; This is file t-features.scm. +; Synchronize any changes with all the other *-features.scm files. + +; This hasn't been tested in a long time. + + +(define (get-from-t name) + (*value t-implementation-env name)) + +; (define error (get-from-t 'error)) - already present +; (define warn (get-from-t 'warn)) - already present? + +(define (interaction-environment) + scheme-user-env) ;Foo +(define scheme-report-environment + (let ((env (interaction-environment))) ;Isn't there a scheme-env? + (lambda (n) env))) + +(define (ignore-errors thunk) + '(error "ignore-errors isn't implemented")) + +(define force-output (get-from-t 'force-output)) + +(define char->ascii char->integer) +(define ascii->char integer->char) + +(define (string-hash s) + (let ((n (string-length s))) + (do ((i 0 (+ i 1)) + (h 0 (+ h (char->ascii (string-ref s i))))) + ((>= i n) h)))) + +;============================================================================== +; Bitwise logical operations on integers + +; T's ASH doesn't work on negative numbers + +(define arithmetic-shift + (let ((fx-ashl (get-from-t 'fx-ashl)) + (fx-ashr (get-from-t 'fx-ashr))) + (lambda (integer count) + (if (>= count 0) + (fx-ashl integer count) + (fx-ashr integer (- 0 count)))))) + +; This is from Olin Shivers: +; (define (correct-ash n m) +; (cond ((or (= m 0) (= n 0)) n) +; ((> n 0) (ash n m)) +; ;; shifting a negative number. +; ((> m 0) ; left shift +; (- (ash (- n) m))) +; (else ; right shift +; (lognot (ash (lognot n) m))))) + +(define bitwise-and (get-from-t 'fx-and)) +(define bitwise-ior (get-from-t 'fx-ior)) + +;============================================================================== +; Code vectors + +(define make-bytev (get-from-t 'make-bytev)) +(define code-vector? (get-from-t 'bytev?)) +(define code-vector-length (get-from-t 'bytev-length)) +(define code-vector-ref (get-from-t 'bref-8)) +(define code-vector-set! ((get-from-t 'setter) code-vector-ref)) + +(define (make-code-vector size . init) + (let ((vec (make-bytev size))) + (if (not (null? init)) + (code-vector-fill! vec (car init))) + vec)) + +(define (code-vector-fill! cv x) + (do ((i 0 (+ i 1))) + ((>= i (code-vector-length cv))) + (code-vector-set! cv i x))) + +;============================================================================== +; Bug fixes and modernizations +; I think syntax-rules will be needed, as well. + +; Simulate a modernized DEFINE-SYNTAX. + +(#[syntax define-syntax] (define-syntax name xformer) + `(#[syntax define-syntax] (,name . %tail%) + (,xformer (cons ',name %tail%) + (lambda (x) x) ;rename + eq?))) ;compare + +; T's MAKE-VECTOR and MAKE-STRING ignore their init argument. + +(define make-vector + (let ((broken-make-vector (get-from-t 'make-vector))) + (lambda (size . init) + (let ((vec (broken-make-vector size))) + (if (not (null? init)) + (vector-fill! vec (car init))) + vec)))) + +(define make-string + (let ((make-string (get-from-t 'make-string)) + (string-fill (get-from-t 'string-fill))) + (lambda (size . init-option) + (if (null? init-option) + (make-string size) + (string-fill (make-string size) (car init-option)))))) + +; Dynamic-wind. + +(define (dynamic-wind before during after) + (before) + (let ((result (during))) + (after) + result)) diff --git a/alt/t-record.scm b/alt/t-record.scm new file mode 100644 index 0000000..0af9262 --- /dev/null +++ b/alt/t-record.scm @@ -0,0 +1,57 @@ +; -*- Mode: Scheme; Syntax: Scheme; Package: Scheme; -*- +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +; This is file t-record.scm. +; Synchronize any changes with the other *record.scm files. + +;;;; Records + +(define make-record-type + (let ((make-stype (*value t-standard-env 'make-stype)) + (crawl-exhibit (*value t-standard-env 'crawl-exhibit)) + (exhibit-structure (*value t-standard-env 'exhibit-structure)) + (structure-type (*value t-standard-env 'structure-type)) + (object-hash (*value t-standard-env 'object-hash)) + (print (*value t-standard-env 'print)) + (format (*value t-standard-env 'format))) + (lambda (id names) + (letrec ((rtd + (make-stype id names + (#[syntax object] #f + ((crawl-exhibit self) + (exhibit-structure self)) + ((print self port) + (format port "#{Record~_~S~_~S}" id (object-hash self))) + ((structure-type self) rtd))))) + rtd)))) + +(define record-predicate (*value t-standard-env 'stype-predicator)) + +(define record-accessor (*value t-standard-env 'stype-selector)) + +(define (record-modifier rtd name) + (setter (record-accessor rtd name))) + +(define (record-constructor rtd names) + (let ((number-of-inits (length names)) + (modifiers (map (lambda (name) (record-modifier rtd name)) + names)) + (make ((*value t-implementation-env 'stype-constructor) rtd))) + (lambda values + (let ((record (make))) + (let loop ((vals values) + (ups modifiers)) + (cond ((null? vals) + (if (null? ups) + record + (error "too few arguments to record constructor" + values type-id names))) + ((null? ups) + (error "too many arguments to record constructor" + values type-id names)) + (else + ((car ups) record (car vals)) + (loop (cdr vals) (cdr ups))))))))) + +(define (define-record-discloser rtd proc) 'unimplemented) diff --git a/alt/table.scm b/alt/table.scm new file mode 100644 index 0000000..1582945 --- /dev/null +++ b/alt/table.scm @@ -0,0 +1,14 @@ + +; unworthy of copyright notice + +(define (make-table . hash-procedure-option) (list 'table)) + +(define (table-ref table key) + (let ((probe (assq key (cdr table)))) + (if probe (cdr probe) #f))) + +(define (table-set! table key value) + (let ((probe (assq key (cdr table)))) + (if probe + (set-cdr! probe value) + (set-cdr! table (cons (cons key value) (cdr table)))))) diff --git a/alt/template.scm b/alt/template.scm new file mode 100644 index 0000000..c65a3b4 --- /dev/null +++ b/alt/template.scm @@ -0,0 +1,21 @@ +; -*- Mode: Scheme; Syntax: Scheme; Package: Scheme; -*- +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +; Templates implemented as vectors. + +(define *template-marker* (list '*template-marker*)) + +(define (make-template len init) + (let ((t (make-vector (+ len 1) init))) + (vector-set! t 0 *template-marker*) + t)) + +(define (template? obj) + (and (vector? obj) + (> (vector-length obj) 0) + (eq? (vector-ref obj 0) *template-marker*))) + +(define (template-length t) (- (vector-length t) 1)) +(define (template-ref t i) (vector-ref t (+ i 1))) +(define (template-set! t i x) (vector-set! t (+ i 1) x)) diff --git a/alt/values.scm b/alt/values.scm new file mode 100644 index 0000000..789cb3f --- /dev/null +++ b/alt/values.scm @@ -0,0 +1,19 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +; Multiple return values + +(define multiple-value-token (vector 'multiple-value-token)) + +(define (values . things) + (if (and (pair? things) + (null? (cdr things))) + (car things) + (cons multiple-value-token things))) + +(define (call-with-values producer consumer) + (let ((things (producer))) + (if (and (pair? things) + (eq? (car things) multiple-value-token)) + (apply consumer (cdr things)) + (consumer things)))) diff --git a/alt/weak.scm b/alt/weak.scm new file mode 100644 index 0000000..5aa72f2 --- /dev/null +++ b/alt/weak.scm @@ -0,0 +1,8 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +(define (make-weak-pointer x) (cons ' x)) +(define weak-pointer-ref cdr) +(define (weak-pointer? x) + (and (pair? x) (eq? (car x) '))) + diff --git a/bcomp/comp.scm b/bcomp/comp.scm new file mode 100644 index 0000000..28cc89b --- /dev/null +++ b/bcomp/comp.scm @@ -0,0 +1,573 @@ +; -*- Mode: Scheme; Syntax: Scheme; Package: Scheme; -*- +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +; This is file comp.scm. + +;;;; The byte-code compiler + +; This is a two-phase compiler. The first phase does macro expansion, +; variable resolution, and instruction selection, and computes the +; size of the code vector. The second phase (assembly) creates the +; code vector, "template" (literals vector), and debugging data +; structures. + +; The output of the first phase (the COMPILE- and INSTRUCTION- +; routines) and the input to the second phase (SEGMENT->TEMPLATE) is a +; "segment." A segment is a pair (size . proc) where size is the size +; of the code segment in bytes, and proc is a procedure that during +; phase 2 will store the segment's bytes into the code vector. + +; A "cenv" maps lexical variables to pairs. Level is +; the variable's distance from the root of the environment; 0 means +; outermost level, and higher numbers mean deeper lexical levels. The +; offset is the position of the variable within its level's +; environment vector. + +; Optimizations are marked with +++, and may be flushed if desired. + + +(define (compile-top exp cenv depth cont) + (compile exp (initial-cenv cenv) depth cont)) + + +; Main dispatch for compiling a single expression. + +(define (compile exp cenv depth cont) + (let ((node (type-check (classify exp cenv) cenv))) + ((operator-table-ref compilators (node-operator-id node)) + node + cenv + depth + cont))) + +; Specialists + +(define compilators + (make-operator-table (lambda (node cenv depth cont) + (generate-trap cont + "not valid in expression context" + (schemify node cenv))) + (lambda (frob) ;for let-syntax, with-aliases, etc. + (lambda (node cenv depth cont) + (call-with-values (lambda () (frob node cenv)) + (lambda (form cenv) + (compile form cenv depth cont))))))) + +(define (define-compilator name type proc) + (operator-define! compilators name type proc)) + +(define-compilator 'literal #f + (lambda (node cenv depth cont) + (let ((obj (node-form node))) + (if (eq? obj #f) + ;; +++ hack for bootstrap from Schemes that don't distinguish #f/() + (deliver-value (instruction (enum op false)) cont) + (compile-constant obj depth cont))))) + +(define-compilator 'quote syntax-type + (lambda (node cenv depth cont) + (let ((exp (node-form node))) + cenv ;ignored + (let ((obj (cadr exp))) + (compile-constant obj depth cont))))) + +(define (compile-constant obj depth cont) + (if (ignore-values-cont? cont) + empty-segment ;+++ dead code + (deliver-value (instruction-with-literal (enum op literal) obj) + cont))) + +; Variable reference + +(define-compilator 'name #f + (lambda (node cenv depth cont) + (let* ((binding (name-node-binding node cenv)) + (name (node-form node))) + (deliver-value (if (and (binding? binding) + (pair? (binding-place binding))) + (let* ((level+over (binding-place binding)) + (back (- (environment-level cenv) + (car level+over))) + (over (cdr level+over))) + (case back + ((0) (instruction (enum op local0) over)) ;+++ + ((1) (instruction (enum op local1) over)) ;+++ + ((2) (instruction (enum op local2) over)) ;+++ + (else (instruction (enum op local) back over)))) + (instruction-with-location + (enum op global) + (get-location binding cenv name value-type))) + cont)))) + +; Assignment + +(define-compilator 'set! syntax-type + (lambda (node cenv depth cont) + (let* ((exp (node-form node)) + (lhs-node (classify (cadr exp) cenv)) + (name (node-form lhs-node)) + ;; Error if not a name node... + (binding (name-node-binding lhs-node cenv))) + (sequentially + (compile (caddr exp) cenv depth (named-cont name)) + (deliver-value + (if (and (binding? binding) (pair? (binding-place binding))) + (let ((level+over (binding-place binding))) + (instruction (enum op set-local!) + (- (environment-level cenv) (car level+over)) + (cdr level+over))) + (instruction-with-location (enum op set-global!) + (get-location binding cenv name usual-variable-type))) + cont))))) + +; Conditional + +(define-compilator 'if syntax-type + (lambda (node cenv depth cont) + (let ((exp (node-form node)) + (alt-label (make-label)) + (join-label (make-label))) + (sequentially + ;; Test + (compile (cadr exp) cenv depth (fall-through-cont node 1)) + (instruction-using-label (enum op jump-if-false) alt-label) + ;; Consequent + (compile (caddr exp) cenv depth cont) + (if (fall-through-cont? cont) + (instruction-using-label (enum op jump) join-label) + empty-segment) + ;; Alternate + (attach-label alt-label + (compile (cadddr exp) cenv depth cont)) + (attach-label join-label + empty-segment))))) + + +(define-compilator 'begin syntax-type + (lambda (node cenv depth cont) + (let ((exp (node-form node))) + (compile-begin (cdr exp) cenv depth cont)))) + +(define compile-begin + (let ((operator/begin (get-operator 'begin))) + (lambda (exp-list cenv depth cont) + (if (null? exp-list) + (generate-trap cont "null begin") + (let ((dummy + (make-node operator/begin ;For debugging database + `(begin ,@exp-list)))) + (let loop ((exp-list exp-list) (i 1)) + (if (null? (cdr exp-list)) + (compile (car exp-list) cenv depth cont) + (careful-sequentially + (compile (car exp-list) cenv depth + (ignore-values-cont dummy i)) + (loop (cdr exp-list) (+ i 1)) + depth + cont)))))))) + + +; Compile a call + +(define (compile-call node cenv depth cont) + (if (node-ref node 'type-error) + (compile-unknown-call node cenv depth cont) + (let ((proc-node (classify (car (node-form node)) cenv))) + (if (and (lambda-node? proc-node) + (not (n-ary? (cadr (node-form proc-node))))) + (compile-redex proc-node (cdr (node-form node)) cenv depth cont) + (let ((new-node (maybe-transform-call proc-node node cenv))) + (if (eq? new-node node) + (compile-unknown-call node cenv depth cont) + (compile new-node cenv depth cont))))))) + +(define-compilator 'call #f compile-call) + + +; A redex is a call of the form ((lambda (x1 ... xn) body ...) e1 ... en). + +(define lambda-node? (node-predicate 'lambda)) + +(define (compile-redex proc-node args cenv depth cont) + (let* ((proc-exp (node-form proc-node)) + (formals (cadr proc-exp)) + (body (cddr proc-exp))) + (if (null? formals) + (compile-body body cenv depth cont) ;+++ + (maybe-push-continuation + (sequentially + (push-all-with-names args formals cenv 0) + (compile-lambda-code formals body cenv (cont-name cont))) + depth + cont)))) + +; Compile a call to a computed procedure. + +(define (compile-unknown-call node cenv depth cont) + (let ((exp (node-form node))) + (let ((call (sequentially (push-arguments node cenv 0) + (compile (car exp) + cenv + (length (cdr exp)) + (fall-through-cont node 0)) + (instruction (enum op call) (length (cdr exp)))))) + (maybe-push-continuation call depth cont)))) + +(define (maybe-push-continuation code depth cont) + (if (return-cont? cont) + code + (let ((label (make-label))) + (sequentially (instruction-using-label (enum op make-cont) + label + depth) + (note-source-code (cont-source-info cont) + code) + (attach-label label + (cont-segment cont)))))) + +; Continuation is implicitly fall-through. + +(define (push-arguments node cenv depth) + (let recur ((args (cdr (node-form node))) (depth depth) (i 1)) + (if (null? args) + empty-segment + (sequentially (compile (car args) cenv depth + (fall-through-cont node i)) + (instruction (enum op push)) + (recur (cdr args) (+ depth 1) (+ i 1)))))) + +(define (push-all-with-names exp-list names cenv depth) + (if (null? exp-list) + empty-segment + (sequentially (compile (car exp-list) + cenv depth + (named-cont (car names))) + (instruction (enum op push)) + (push-all-with-names (cdr exp-list) + (cdr names) + cenv + (+ depth 1))))) + +; OK, now that you've got all that under your belt, here's LAMBDA. + +(define-compilator 'lambda syntax-type + (lambda (node cenv depth cont) + (let ((exp (node-form node)) + (name (cont-name cont))) + (deliver-value + (instruction-with-template (enum op closure) + (compile-lambda exp + cenv + ;; Hack for constructors. + ;; Cf. disclose method + ;; (if name #t #f) + #f) + name) + cont)))) + +(define (compile-lambda exp cenv body-name) + (let* ((formals (cadr exp)) + (nargs (number-of-required-args formals))) + (sequentially + ;; Check number of arguments + (if (n-ary? formals) + (if (pair? formals) + (instruction (enum op check-nargs>=) nargs) + empty-segment) ;+++ (lambda x ...) needs no check + (instruction (enum op check-nargs=) nargs)) + (compile-lambda-code formals (cddr exp) cenv body-name)))) + +; name isn't the name of the procedure, it's the name to be given to +; the value that the procedure will return. + +(define (compile-lambda-code formals body cenv name) + (if (null? formals) + (compile-body body ;+++ Don't make null environment + cenv + 0 + (return-cont name)) + ;; (if (node-ref node 'no-inferior-lambdas) ...) + (sequentially + (let ((nargs (number-of-required-args formals))) + (if (n-ary? formals) + (sequentially + (instruction (enum op make-rest-list) nargs) + (instruction (enum op push)) + (instruction (enum op make-env) (+ nargs 1))) + (instruction (enum op make-env) nargs))) + (let* ((vars (normalize-formals formals)) + (cenv (bind-vars (reverse vars) cenv))) + (note-environment + vars + (compile-body body + cenv + 0 + (return-cont name))))))) + +(define compile-letrec + (let ((operator/lambda (get-operator 'lambda syntax-type)) + (operator/set! (get-operator 'set! syntax-type)) + (operator/call (get-operator 'call)) + (operator/unassigned (get-operator 'unassigned))) + (lambda (node cenv depth cont) + ;; (if (node-ref node 'pure-letrec) ...) + (let* ((exp (node-form node)) + (specs (cadr exp)) + (body (cddr exp))) + (compile-redex (make-node operator/lambda + `(lambda ,(map car specs) + ,@(map (lambda (spec) + (make-node operator/set! + `(set! ,@spec))) + specs) + ,(make-node + operator/call + `(,(make-node operator/lambda + `(lambda () ,@body)))))) + (map (lambda (spec) + (make-node operator/unassigned + `(unassigned))) + specs) + cenv depth cont))))) + +(define-compilator 'letrec syntax-type compile-letrec) + +; -------------------- +; Deal with internal defines (ugh) + +(define (compile-body body cenv depth cont) + (scan-body body + cenv + (lambda (defs exps) + (if (null? defs) + (compile-begin exps cenv depth cont) + (compile-letrec + (make-node operator/letrec + `(letrec ,(map (lambda (node) + (cdr (node-form node))) + defs) + ,@exps)) + cenv depth cont))))) + +(define operator/letrec (get-operator 'letrec)) + +; -------------------- +; Compile-time continuations +; +; A compile-time continuation is a pair (segment . name). Segment is +; one of the following: +; a return instruction - invoke the current full continuation. +; empty-segment - fall through to subsequent instructions. +; an ignore-values instruction - ignore values, then fall through. +; If name is non-#f, then the value delivered to subsequent +; instructions will be assigned to a variable. If the value being +; assigned is a lambda, we can give that lambda that name, for +; debugging purposes. + +(define (make-cont seg source-info) (cons seg source-info)) +(define cont-segment car) +(define cont-source-info cdr) + +; Eventually we may be able to optimize jumps to jumps. Can't yet. +;(define (make-jump-cont jump cont) +; (if (fall-through-cont? cont) +; (make-cont jump (cont-name cont)) +; cont)) + +(define return-cont-segment (instruction (enum op return))) + +(define (return-cont name) + (make-cont return-cont-segment name)) + +(define (return-cont? cont) + (eq? (cont-segment cont) return-cont-segment)) + +; Fall through into next instruction + +(define (fall-through-cont node i) + (make-cont empty-segment (cons i node))) + +(define (fall-through-cont? cont) + (not (return-cont? cont))) + +; Ignore return value, then fall through + +(define ignore-values-segment + (instruction (enum op ignore-values))) + +(define (ignore-values-cont node i) + (make-cont ignore-values-segment (cons i node))) + +(define (ignore-values-cont? cont) + (eq? (cont-segment cont) ignore-values-segment)) + +; Value is in *val*; deliver it to its continuation. +; No need to generate an ignore-values instruction in this case. + +(define (deliver-value segment cont) + (if (ignore-values-cont? cont) ;+++ + segment + (sequentially segment (cont-segment cont)))) + +; For putting names to lambda expressions: + +(define (named-cont name) + (make-cont empty-segment name)) + +(define (cont-name cont) + (if (pair? (cont-source-info cont)) + #f + (cont-source-info cont))) + +; -------------------- +; Compile-time environments + +(define (bind-vars names cenv) + (let ((level (+ (environment-level cenv) 1))) + (lambda (name) + (if (eq? name funny-name/lexical-level) + level + (let loop ((over 1) (names names)) + (cond ((null? names) + (lookup cenv name)) + ((eq? name (car names)) + (make-binding usual-variable-type (cons level over) #f)) + (else (loop (+ over 1) (cdr names))))))))) + +(define (initial-cenv cenv) + (bind1 funny-name/lexical-level -1 cenv)) + +(define (environment-level cenv) + (lookup cenv funny-name/lexical-level)) + +(define funny-name/lexical-level (string->symbol "Lexical nesting level")) + +; Find lookup result that was cached by classifier + +(define (name-node-binding node cenv) + (or (node-ref node 'binding) + (node-form node))) ; = (lookup cenv (node-form node)) + + +; -------------------- +; Utilities + +; Produce something for source code that contains a compile-time error. + +(define (generate-trap cont . stuff) + (apply warn stuff) + (sequentially (instruction-with-literal (enum op literal) + (cons 'error stuff)) + (deliver-value (instruction (enum op trap)) + cont))) + +; Make a segment smaller, if it seems necessary, by introducing an +; extra template. A segment is "too big" if it accesses more literals +; than the size of the operand in a literal-accessing instruction. +; The number of literals is unknowable given current representations, +; so we conservatively shrink the segment when its size exceeds 2 +; times the largest admissible operand value, figuring that it takes +; at least 2 instruction bytes to use a literal. + +(define (careful-sequentially seg1 seg2 depth cont) + (if (and (= depth 0) + (> (+ (segment-size seg1) (segment-size seg2)) + large-segment-size)) + (if (> (segment-size seg1) (segment-size seg2)) + (sequentially (shrink-segment seg1 (fall-through-cont #f #f)) + seg2) + (sequentially seg1 + (shrink-segment seg2 cont))) + (sequentially seg1 seg2))) + +(define large-segment-size (* byte-limit 2)) + +(define (shrink-segment seg cont) + (maybe-push-continuation + (sequentially (instruction-with-template + (enum op closure) + (if (return-cont? cont) + seg + (sequentially seg + (instruction (enum op return)))) + #f) + (instruction (enum op call) 0)) + 0 + cont)) + +; -------------------- +; Type checking. This gets called on all nodes. + +(define (type-check node cenv) + (if *type-check?* + (let ((form (node-form node))) + (if (pair? form) + (let ((proc-node (car form))) + (if (node? proc-node) + (let ((proc-type (node-type proc-node cenv))) + (cond ((procedure-type? proc-type) + (if (restrictive? proc-type) + (let* ((args (if (eq? *type-check?* 'heavy) + (map (lambda (exp) + (classify exp cenv)) + (cdr form)) + (cdr form))) + (args-type (make-some-values-type + (map (lambda (arg) + (meet-type + (node-type arg cenv) + value-type)) + args))) + (node (make-similar-node node + (cons proc-node + args)))) + (if (not (meet? args-type + (procedure-type-domain proc-type))) + (diagnose-call-error node proc-type cenv)) + node) + node)) + ((not (meet? proc-type any-procedure-type)) + ;; Could also check args for one-valuedness. + (let ((message "non-procedure in operator position")) + (warn message + (schemify node cenv) + `(procedure: ,proc-type)) + (node-set! node 'type-error message)) + node) + (else node))) + node)) + node)) + node)) + +(define (set-type-check?! check?) + (set! *type-check?* check?)) + +(define *type-check?* 'heavy) + + +(define (diagnose-call-error node proc-type cenv) + (let ((message + (cond ((not (fixed-arity-procedure-type? proc-type)) + "invalid arguments") + ((= (procedure-type-arity proc-type) + (length (cdr (node-form node)))) + "argument type error") + (else + "wrong number of arguments")))) + (warn message + (schemify node cenv) + `(procedure wants: + ,(rail-type->sexp (procedure-type-domain proc-type) + #f)) + `(arguments are: ,(map (lambda (arg) + (type->sexp (node-type arg cenv) #t)) + (cdr (node-form node))))) + (node-set! node 'type-error message))) + + +; Type system loophole + +(define-compilator 'loophole syntax-type + (lambda (node cenv depth cont) + (compile (caddr (node-form node)) cenv depth cont))) diff --git a/bcomp/config.scm b/bcomp/config.scm new file mode 100644 index 0000000..21ce22a --- /dev/null +++ b/bcomp/config.scm @@ -0,0 +1,35 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + + +; For DEFINE-STRUCTURE macro + +(define (make-a-package opens-thunk accesses-thunk tower + dir clauses name) + (make-package opens-thunk accesses-thunk + #t ;unstable + tower + dir + clauses + #f + name)) + +(define (loser . rest) + (error "init-defpackage! neglected")) + +(define interface-of structure-interface) + +(define *verify-later!* (lambda (thunk) #f)) + +(define (verify-later! thunk) + (*verify-later!* thunk)) + +(define (set-verify-later! proc) + (set! *verify-later!* proc)) + +(define (note-name! thing name) + (cond ((interface? thing) + (note-interface-name! thing name)) + ((structure? thing) + (note-structure-name! thing name))) + thing) diff --git a/bcomp/cprim.scm b/bcomp/cprim.scm new file mode 100644 index 0000000..ea0dc94 --- /dev/null +++ b/bcomp/cprim.scm @@ -0,0 +1,384 @@ +; -*- Mode: Scheme; Syntax: Scheme; Package: Scheme; -*- +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +; This is file cprim.scm. + +;;;; Compiling primitive procedures and calls to them. + +(define (define-compiler-primitive name type compilator closed) + (define-compilator name type + (or compilator compile-unknown-call)) + (define-closed-compilator name closed)) + + +; Closed-compiled versions of primitives are handled separately. + +(define closed-compilators + (make-operator-table (lambda () + (error "unknown primitive procedure")))) + +(define (define-closed-compilator name proc) + (operator-define! closed-compilators name #f proc)) + +; (primitive-procedure name) => a procedure + +(define-compilator 'primitive-procedure syntax-type + (lambda (node cenv depth cont) + (let ((name (cadr (node-form node)))) + (deliver-value (instruction-with-template + (enum op closure) + ((get-closed-compilator (get-operator name))) + (cont-name cont)) + cont)))) + +(define (get-closed-compilator op) + (operator-lookup closed-compilators op)) + + +; -------------------- +; Direct primitives. + +; The simplest kind of primitive has fixed arity, corresponds to some +; single VM instruction, and takes its arguments in the usual way (all +; on the stack except the last). + +(define (direct-compilator type opcode) + (lambda (node cenv depth cont) + (let ((args (cdr (node-form node)))) + (sequentially (if (null? args) + empty-segment + (push-all-but-last args cenv depth node)) + (deliver-value (instruction opcode) cont))))) + +(define (direct-closed-compilator opcode) + (lambda () + (let ((arg-specs (vector-ref opcode-arg-specs opcode))) + (sequentially (if (pair? arg-specs) + (sequentially + (instruction (enum op check-nargs=) (car arg-specs)) + (instruction (enum op pop))) + (instruction (enum op check-nargs=) 0)) + (instruction opcode) + (instruction (enum op return)))))) + +(define (nargs->domain nargs) + (do ((nargs nargs (- nargs 1)) + (l '() (cons value-type l))) + ((= nargs 0) (make-some-values-type l)))) + + +; Define all the primitives that correspond to opcodes in the obvious way. + +(do ((opcode 0 (+ opcode 1))) + ((= opcode op-count)) + (let ((arg-specs (vector-ref opcode-arg-specs opcode)) + (name (enumerand->name opcode op))) + (cond ((memq name '(external-call return-from-interrupt return))) + ((null? arg-specs) + (let ((type (proc () value-type))) + (define-compiler-primitive name type + (direct-compilator type opcode) + (direct-closed-compilator opcode)))) + ((not (number? (car arg-specs)))) + (else + (let ((type (procedure-type (nargs->domain (car arg-specs)) + (if (eq? name 'with-continuation) + any-values-type + ;; Return a single value. + value-type) + ;; nonrestrictive - domain might be + ;; specialized later + #t))) + (define-compiler-primitive name type + (direct-compilator type opcode) + (direct-closed-compilator opcode))))))) + + +; -------------------- +; Simple primitives are executed using a fixed instruction or +; instruction sequence. + +(define (define-simple-primitive name type segment) + (let ((winner? (fixed-arity-procedure-type? type))) + (let ((nargs (if winner? + (procedure-type-arity type) + (error "n-ary simple primitive?!" name type)))) + (define-compiler-primitive name type + (simple-compilator segment) + (simple-closed-compilator nargs segment))))) + +(define (simple-compilator segment) + (lambda (node cenv depth cont) + (let ((args (cdr (node-form node)))) + (sequentially (if (null? args) + empty-segment + (push-all-but-last args cenv depth node)) + (deliver-value segment cont))))) + +(define (simple-closed-compilator nargs segment) + (lambda () + (sequentially (instruction (enum op check-nargs=) nargs) + (instruction (enum op pop)) + segment + (instruction (enum op return))))) + +(define (symbol-append . syms) + (string->symbol (apply string-append + (map symbol->string syms)))) + +(define (define-stob-predicate name stob-name) + (define-simple-primitive name + (proc (value-type) boolean-type) + (instruction (enum op stored-object-has-type?) + (name->enumerand stob-name stob)))) + +(define-stob-predicate 'code-vector? 'code-vector) +(define-stob-predicate 'string? 'string) + +; Define primitives for record-like stored objects (e.g. pairs). + +(define (define-data-struct-primitives name predicate maker . slots) + (let* ((def-prim (lambda (name type op . stuff) + (define-simple-primitive name type + (apply instruction (cons op stuff))))) + (type-byte (name->enumerand name stob)) + (type (sexp->type (symbol-append ': name) #t))) + (define-stob-predicate predicate name) + (if (not (eq? maker 'make-symbol)) ; Symbols are made using op/intern. + (def-prim maker + (procedure-type (nargs->domain (length slots)) type #t) + (enum op make-stored-object) + (length slots) + type-byte)) + (do ((i 0 (+ i 1)) + (slots slots (cdr slots))) + ((null? slots)) + (let ((slot (car slots))) + (if (car slot) + (def-prim (car slot) + (proc (type) value-type) + (enum op stored-object-ref) type-byte i)) + (if (cadr slot) + (def-prim (cadr slot) + (proc (type value-type) unspecific-type) + (enum op stored-object-set!) type-byte i)))))) + +(for-each (lambda (stuff) + (apply define-data-struct-primitives stuff)) + stob-data) + + +; Define primitives for vector-like stored objects. + +(define (define-vector-primitives name element-type make length ref set!) + (let* ((type-byte (name->enumerand name stob)) + (def-prim (lambda (name type op) + (define-simple-primitive name type + (instruction op type-byte)))) + (type (sexp->type (symbol-append ': name) #t))) + (define-stob-predicate (symbol-append name '?) name) + (def-prim (symbol-append 'make- name) + (proc (exact-integer-type element-type) type) + make) + (def-prim (symbol-append name '- 'length) + (proc (type) exact-integer-type) + length) + (def-prim (symbol-append name '- 'ref) + (proc (type exact-integer-type) element-type) + ref) + (def-prim (symbol-append name '- 'set!) + (proc (type exact-integer-type element-type) unspecific-type) + set!))) + +(for-each (lambda (name) + (define-vector-primitives name value-type + (enum op make-vector-object) + (enum op stored-object-length) + (enum op stored-object-indexed-ref) + (enum op stored-object-indexed-set!))) + '(vector record continuation extended-number template)) + +; SIGNAL-CONDITION is the same as TRAP. + +(define-simple-primitive 'signal-condition (proc (pair-type) unspecific-type) + (instruction (enum op trap))) + + +; (primitive-catch (lambda (cont) ...)) + +(define-compiler-primitive 'primitive-catch #f + ;; (primitive-catch (lambda (cont) ...)) + (lambda (node cenv depth cont) + (let* ((exp (node-form node)) + (args (cdr exp))) + (maybe-push-continuation + (sequentially (instruction (enum op current-cont)) + (instruction (enum op push)) + ;; If lambda exp, should do compile-lambda-code to + ;; avoid consing closure... + (compile (car args) cenv 1 + (fall-through-cont node 1)) + (instruction (enum op call) 1)) + 0 + cont))) + (lambda () + (sequentially (instruction (enum op check-nargs=) 1) + (instruction (enum op make-env) 1) ;Seems unavoidable. + (instruction (enum op current-cont)) + (instruction (enum op push)) + (instruction (enum op local0) 1) + (instruction (enum op call) 1)))) + +; (call-with-values (lambda () ...producer...) +; (lambda args ...consumer...)) + +(define-compiler-primitive 'call-with-values #f + (lambda (node cenv depth cont) + (let ((args (cdr (node-form node)))) + (let ((producer (car args)) + (consumer (cadr args))) + (maybe-push-continuation + (sequentially (compile consumer cenv 0 (fall-through-cont node 2)) + (instruction (enum op push)) + (maybe-push-continuation ; nothing maybe about it + (compile-call (classify `(,producer) cenv) + cenv 0 + (return-cont #f)) + 1 + (fall-through-cont #f 0)) + ;; Was: + ;; (compile-call (classify `(,producer) cenv) + ;; cenv 1 + ;; (fall-through-cont node 1)) + (instruction (enum op call-with-values))) + depth + cont)))) + (lambda () + ;; producer and consumer on stack + (let ((label (make-label))) + (sequentially (instruction (enum op check-nargs=) 2) + (instruction (enum op make-env) 2) + (instruction (enum op local0) 1) ;consumer + (instruction (enum op push)) + (instruction-using-label (enum op make-cont) label 1) + (instruction (enum op local0) 2) ;producer + (instruction (enum op call) 0) + (attach-label label + (instruction (enum op call-with-values))))))) + + +; -------------------- +; Variable-arity primitives + +(define (define-n-ary-compiler-primitive name result-type min-nargs + compilator closed) + (define-compiler-primitive name + (if result-type + (procedure-type any-arguments-type result-type #f) + #f) + (if compilator + (n-ary-primitive-compilator name min-nargs compilator) + compile-unknown-call) + closed)) + +(define (n-ary-primitive-compilator name min-nargs compilator) + (lambda (node cenv depth cont) + (let ((exp (node-form node))) + (if (>= (length (cdr exp)) min-nargs) + (compilator node cenv depth cont) + (begin (warn "too few arguments to primitive" + (schemify node cenv)) + (compile-unknown-call node cenv depth cont)))))) + + +; APPLY wants to first spread the list, then load the procedure. +; The list argument has to be in *VAL* so that its length can be checked +; before the instruction is begun. + +(define-n-ary-compiler-primitive 'apply #f 2 + (lambda (node cenv depth cont) + (let ((exp (node-form node))) ; (apply proc arg1 arg2 arg3 rest) + (let* ((proc+args+rest (cdr exp)) + (rest+args ; (rest arg3 arg2 arg1) + (reverse (cdr proc+args+rest))) + (args (cdr rest+args)) ; (arg3 arg2 arg1) + (args+proc+rest ; (arg1 arg2 arg3 proc rest) + (reverse (cons (car rest+args) + (cons (car proc+args+rest) args))))) + (maybe-push-continuation + (sequentially (push-all-but-last args+proc+rest cenv 0 #f) + ;; Operand is number of non-final arguments + (instruction (enum op apply) (length args))) + depth + cont)))) + (lambda () + (sequentially (instruction (enum op check-nargs=) 2) + (instruction (enum op pop)) + (instruction (enum op apply) 0)))) + + +; (values value1 value2 ...) + +(define-n-ary-compiler-primitive 'values #f 0 + (lambda (node cenv depth cont) + (let ((args (cdr (node-form node)))) + (maybe-push-continuation (sequentially (push-arguments node cenv 0) + (instruction (enum op return-values) + (length args))) + depth + cont))) + (lambda () (instruction (enum op values)))) + + +; (error message irritant1 irritant2) +; => (trap (cons 'error (cons message (cons irritant1 (cons irritant2 '()))))) + +(let ((cons-instruction + (instruction (enum op make-stored-object) 2 (enum stob pair)))) + + (define-n-ary-compiler-primitive 'error error-type 1 + (lambda (node cenv depth cont) + (let ((exp (node-form node))) + (let ((args (cdr exp))) + (sequentially (instruction-with-literal (enum op literal) 'error) + (instruction (enum op push)) + (push-arguments node cenv (+ depth 1)) + (instruction-with-literal (enum op literal) '()) + (apply sequentially + (map (lambda (arg) cons-instruction) args)) + cons-instruction + (deliver-value (instruction (enum op trap)) cont))))) + (lambda () + (sequentially (instruction (enum op make-rest-list) 0) + (instruction (enum op push)) + (instruction-with-literal (enum op literal) 'error) + (instruction (enum op push)) + (instruction (enum op stack-ref) 1) + cons-instruction + (instruction (enum op trap)) + (instruction (enum op return)))))) + + +; (external-call external-routine arg ...) + +(define-n-ary-compiler-primitive 'external-call value-type 1 + #f ;Must set *nargs* + (lambda () + (sequentially (instruction (enum op check-nargs>=) 1) + (instruction (enum op external-call)) + (instruction (enum op return))))) + + +; -------------------- +; Utility + +(define (push-all-but-last args cenv depth source-info) + (let recur ((args args) (depth depth) (i 1)) + (let ((first-code + (compile (car args) cenv depth (fall-through-cont source-info i)))) + (if (null? (cdr args)) + first-code + (sequentially first-code + (instruction (enum op push)) + (recur (cdr args) (+ depth 1) (+ i 1))))))) diff --git a/bcomp/ctop.scm b/bcomp/ctop.scm new file mode 100644 index 0000000..37087c3 --- /dev/null +++ b/bcomp/ctop.scm @@ -0,0 +1,259 @@ +; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees. See file COPYING. + + +; File processing, etc. for compiler + + +; Compile-form and compile-file return templates, suitable for +; execution via (invoke-closure (make-closure