Add instructions for doing very late binding
authorAndy Wingo <wingo@pobox.com>
Mon, 19 May 2008 15:46:05 +0000 (17:46 +0200)
committerAndy Wingo <wingo@pobox.com>
Mon, 19 May 2008 15:46:05 +0000 (17:46 +0200)
commit9cc649b880fe81ff4b2dd1929beb45ea313dee42
treecc2b20ef0d5ba0339de0dd86362bfdd5c4c4d997
parent1b8abe55148e6ff3e11acb5aff8c8ba6c50e3f2c
Add instructions for doing very late binding

Fixes the mutually-recursive toplevel definitions case. This could be
fixed by rewriting bodies as letrecs, as r6 does, but that's not really
repl-compatible.

* module/system/il/ghil.scm (ghil-lookup): Ok, if we can't locate a
  variable, mark it as unresolved.

* module/system/il/compile.scm (make-glil-var): Compile unresolved
  variables as <glil-late-bound> objects.

* module/system/il/glil.scm: Add <glil-late-bound> definition.

* module/system/vm/assemble.scm (codegen): And, finally, when we see a
  <vlate-bound> object, allocate a slot for it in the object vector,
  setting it to a symbol. Add a new pair of instructions to resolve that
  symbol to a variable at the last minute.

* src/vm_loader.c (load-number): Bugfix: the radix argument should be
  SCM_UNDEFINED in order to default to 10.
  (late-bind): Add an unresolved symbol to the object vector. Could be
  replaced with load-symbol I guess.

* src/vm_system.c (late-variable-ref, late-variable-set): New
  instructions to do late symbol binding.

* testsuite/Makefile.am (vm_test_files):
* testsuite/t-mutual-toplevel-defines.scm: New test, failing for some
  reason involving the core even? and odd? definitions.
module/system/il/compile.scm
module/system/il/ghil.scm
module/system/il/glil.scm
module/system/vm/assemble.scm
src/vm_loader.c
src/vm_system.c
testsuite/Makefile.am
testsuite/run-vm-tests.scm
testsuite/t-mutual-toplevel-defines.scm [new file with mode: 0644]