Wayback 20060529104413
www.stripedgazelle.org/joey/dream.html
This commit is contained in:
parent
173caa9702
commit
bc874e8ecc
|
@ -1,19 +1,23 @@
|
|||
<html>
|
||||
<title>The 'dream' Scheme Interpreter</title>
|
||||
<h1>The 'dream' Scheme Interpreter</h1>
|
||||
<dd>Download source (gcc on PowerPC): <a href="http://www.stripedgazelle.org/joey/src/dream_ppc.tar.gz">dream_ppc.tar.gz</a></dd>
|
||||
<dd>Download source (gcc on x86): <a href="http://www.stripedgazelle.org/joey/src/dream_x86.tar.gz">dream_x86.tar.gz</a></dd>
|
||||
by David Joseph Stith
|
||||
<p>
|
||||
I am proud to announce the premier production version of my Scheme interpreter, 'dream', written entirely in assembly language (GAS syntax.) :-)
|
||||
All essential syntax and procedures from the R4RS standard are implemented.
|
||||
The interpreter passes all applicable tests from the 'r4rstest.scm' test suite.
|
||||
All essential syntax and procedures from the <a href="http://www.swiss.ai.mit.edu/~jaffer/r4rs_toc.html">R4RS standard</a> are implemented.
|
||||
The interpreter is properly tail recursive and passes all applicable tests from the 'r4rstest.scm' test suite.
|
||||
Rational arithmetic with 32 bit numerator and denominator is supported, but no Real or Complex numbers.
|
||||
My overarching goal has been SIMPLICITY.
|
||||
I have chosen a design and implementation that is as straightforward and direct as I could imagine.
|
||||
The result is an executable that is quite small and, for an interpreter, quite fast as well. :-)
|
||||
</p>
|
||||
<dd>Download source (gcc on PowerPC): <a href="http://www.stripedgazelle.org/joey/src/dream_ppc.tar.gz">dream_ppc.tar.gz</a></dd>
|
||||
<dd>Download source (gcc on x86): <a href="http://www.stripedgazelle.org/joey/src/dream_x86.tar.gz">dream_x86.tar.gz</a></dd>
|
||||
<dd>Download source (gcc-mingw on x86): <a href="http://www.stripedgazelle.org/joey/src/dream_x86_mingw.zip">dream_x86_mingw.zip</a></dd>
|
||||
<hr>
|
||||
<h1>Notes on the Design of the 'dream' Scheme Interpreter</h1>
|
||||
<p>
|
||||
The design for the 'dream' Scheme interpreter began with the design given in Abelson and Sussman's <u>Structure and Interpretation of Computer Programs</u>.
|
||||
The design for the 'dream' Scheme interpreter began with the design given in Abelson and Sussman's <a href="http://mitpress.mit.edu/sicp/full-text/book/book.html">Structure and Interpretation of Computer Programs</a>.
|
||||
</p>
|
||||
<h2>Garbage Collection</h2>
|
||||
<p>
|
||||
|
@ -58,8 +62,8 @@ When combinations are evaluated, if the 'car' of the combination is a symbol of
|
|||
This way, each time this combination is evaluated afterwards, the symbol lookup in the top-level environment will no longer be necessary, and the efficiency of the interpreter is greatly enhanced.
|
||||
However, the R4RS standard for scheme requires that these symbols, bound to built-in procedures, may be redefined, and we may presume that any redefinition should then be effective retroactively for all occurences of the symbol within the same environment.
|
||||
The memoizing technique described above is inconsistent with this requirement.
|
||||
Therefore, symbols of the type MEMOIZABLE_SYMBOL are allowed by R4RS to be bound only to special forms.
|
||||
Consequently, we provide this standards compliant behavior as a conditional compilation option, but for efficiency's sake we retain memoization of built-in procedures as the default.
|
||||
Therefore, symbols of the type MEMOIZABLE_SYMBOL are allowed by <a href="http://www.swiss.ai.mit.edu/~jaffer/r4rs_toc.html">R4RS</a> to be bound only to special forms.
|
||||
Consequently, we make this standards compliant behavior the default, but for efficiency's sake we provide memoization of built-in procedures as a conditional compilation option.
|
||||
</p>
|
||||
<p>
|
||||
Number types are distinguished by the high byte of the low word, which increases as the complexity of the type of number ascends the numeric tower. Integers simply store their 32 bit signed value in the second half of the quad-word. Rationals are stored as a pair of integers, thus the low bit in the high byte of the low word of their type is set so that the garbage collector will see the pair. Inexactness of a number is indicated by setting the lowest bit of the high word of the number's type. Note, however, that all internal representations of numbers are exact (no floating point numbers are used), and so inexactness is given only as an auxiliary property of the number.
|
||||
|
@ -68,7 +72,7 @@ Number types are distinguished by the high byte of the low word, which increases
|
|||
</p>
|
||||
Input ports use the low byte of the high word of the type field to store the last character read by the (peek) procedure. The second half of the quad-word for both input and output ports holds the FILE* pointer associated with the port.
|
||||
The ports returned by (current-input-port) and (current-output-port) are stored internally for efficiency's sake.
|
||||
They therefore must be treated by the garbage collector as if they were registers (which indeed they would be if only we had more registers to work with).
|
||||
They therefore must be treated by the garbage collector as if they were registers (which indeed they are in the register-rich PowerPC version).
|
||||
<h2>The Stack</h2>
|
||||
<p>
|
||||
The scheme object stack is maintained as a scheme list (dynamically allocated as pairs).
|
||||
|
@ -79,7 +83,7 @@ Consequently when call-with-current-continuation is invoked, this native stack i
|
|||
</p>
|
||||
<h2>Scheme Registers</h2>
|
||||
<p>
|
||||
The registers denoted by EXP, ENV, UNEV, ARGL, VAL, FREE, OLD, NEW, and SCAN in <u>Structure and Interpretation of Computer Programs</u> are defined via preprocessor macros to the machine registers that implement them.
|
||||
The registers denoted by EXP, ENV, UNEV, ARGL, VAL, FREE, OLD, NEW, and SCAN in <a href="http://mitpress.mit.edu/sicp/full-text/book/book.html">Structure and Interpretation of Computer Programs</a> are defined via preprocessor macros to the machine registers that implement them.
|
||||
EXP, ENV, UNEV, ARGL, and VAL must point to a valid scheme object (or null) when the garbage collector is invoked.
|
||||
</p>
|
||||
<h2>Input/Output</h2>
|
||||
|
|
Loading…
Reference in New Issue