Closure values
Continuation values
Base machine value types Null value
Type alias for environments, stacks and so forth
Primitives - values which contain simple code segments.
Evaluate a single instruction.
Evaluate a single instruction.
We implement this as a partial function, which may be overridden in traits in order to compose on handlers for new bytecode instructions (using orElse composition).
Rule to execute one step of this machine.
Rule to execute one step of this machine.
Raise a machine exception
Raise a machine exception
This particular error handler assumes that the environment contains a binding of the name '@exnHandler' to a reference value containing a continuation. This continuation is resumed with the exception value passed to this function as its parameter.
If '@exnHandler' is unbound in the environment or is bound to a value that is not a refernce to a continuation then this function reports a machine panic and stops the machine.
Machine registers
Machine registers
A little work is needed here to ensure that these registers are printed in a reasonable way when we turn on debugging.
(Since version 1.2.1) Use PrettyPrinter.any instead.
The basic SECD machine implementation
This only implements the bare bones of an operating SECD machine. In particular it does not provide any primitive builtin functions for operating on data values such as strings and integers. You can add these using traits to implement each one in a stackable manner.