Modifying evaluator
This section described how to modify the explicit-control evaluator so that interpreted code can call compiled procedures. Show how to modify the compiler so that compiled procedures can call not only primitive procedures and compiled procedures, but interpreted procedures as well. This requires modifying
compile-procedure-call
to handle the case of compound (interpreted) procedures. Be sure to handle all the same
target
and
linkage
combinations as in
compile-proc-appl
. To do the actual procedure application, the code needs to jump to the evaluator’s
compound-apply
entry point. This label cannot be directly referenced in object code (since the assembler requires that all labels referenced by the code it is assembling be defined there), so we will add a register called
compapp
to the evaluator machine to hold this entry point, and add an instruction to initialize it:
(assign compapp (label compound-apply))
;; branches if flag is set:
(branch (label external-entry))
read-eval-print-loop …
To test your code, start by defining a procedure
f
that calls a procedure
g
. Use
compile-and-go
to compile the definition of
f
and start the evaluator. Now, typing at the evaluator, define
g
and try to call
f
.