The compiler generator itself is called
cogen. If the
interpreter is called like this:
(define tlc top-level-continuation) (define ans (eval-root interp (list program arguments tlc)))Then you could compile
programand compute the same
(define binding-time-pattern '(static dynamic dynamic)) (define compiler (cogen interp binding-time-pattern)) (define fast-prog (eval-root compiler (list tlc program))) (define ans (eval-root fast-prog (list arguments tlc)))
The binding time pattern specifies which arguments to the interpreter are the program (static) and which are the data (dynamic). Note that generated compilers take their continuation as their first argument (this should probably change). An additional continuation is introduced because the compiler has to return somewhere.
interp argument is a
code structure [note coding].
cogen slightly extends the semantics of the
root language to
include the semantics of hints, lifting, and a number of primops.
The primops are convered in section bta except
is used to create interpreters with an open-ended set of primops.
It also accepts lift directives (syntactically they appear like
instructions). Lifting is required to avoid excessive specialization
and non-termination. Obviously required lifts are handled
automatically, but manual annotation is still often required when
writing programs directly in
[example simple lift directive, mention complex lifting]