The whole thing is 1750 lines of code (about twice what it should be) and includes a garbage collector and user-level implementations of user-defined types and structures, single-dispatch object-oriented "messaging", and generic "multimethods" (all of which are all needed by the compiler). The compiled binary code runs at about 30% the speed of aggressively-optimised C.
On Linux just type make, otherwise edit the first part of emit.l appropriately.
The recursive implementation and compiler (in the three .l files) is split into three parts for clarity, but they could all be in a single source file.
The s-expression language has a few interesting characteristics some of which are exhibited by the way user-defined types and structures are implemented, and the way object-oriented single-dispatch messaging and generic functions (multimethods) are added to the language at runtime in boot.l. The compiler makes some attempt to be small and simple, and no attempt whatsoever to optimise.
The performance figure of 30% of optimised C was calculated by
comparing the time needed for generating eval.s
by eval and boot-eval. (The
C-compiled boot-eval gains a significant advantage by
inlining the entire implementation of the critical
function assq into callers in several places.)
| Name | Last modified | Size | Description | |
|---|---|---|---|---|
| Makefile | 23-Dec-2010 14:34 | 802 | ||
| boot-eval.c | 23-Dec-2010 00:51 | 59K | ||
| boot.l | 22-Dec-2010 05:18 | 11K | ||
| emit.l | 24-Feb-2011 19:07 | 18K | ||
| eval.l | 22-Dec-2010 06:30 | 44K | ||