From 0d3029f8539f03232f54bf8794bc76d07c3703e6 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sat, 20 Nov 2021 21:06:45 -0500 Subject: Update VM body-list format description --- docs/implementation/vm.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docs/implementation/vm.html') diff --git a/docs/implementation/vm.html b/docs/implementation/vm.html index c1916ab7..90a37177 100644 --- a/docs/implementation/vm.html +++ b/docs/implementation/vm.html @@ -30,7 +30,8 @@

Compilation separates blocks so that they are not nested in bytecode. A block consists of bodies, so that all compiled code is contained in some body of a block. The self-hosted compiler compiles the entire program into an immediate block, and the program is run by evaluating this block. Bodies are terminated with a RETN or RETD instruction.

When the block is evaluated depends on its type and immediateness. An immediate block (0,1) is evaluated as soon as it is pushed; a function (0,0) is evaluated when called on arguments, an immediate modifier (1 or 2, 1) is evaluated when called on operands, and a deferred modifier (1 or 2, 0) creates a derived function when called on operands and is evaluated when this derived function is called on arguments.

-

The last property can be a single number, or, if it's a deferred block, might be a pair of lists. For a single number the block is always evaluated by evaluating the body with the given index. For a pair, the first element gives the monadic case and the second the dyadic one. A given valence should begin at the first body in the appropriate list, moving to the next one if a header test (SETH instruction) fails.

+

The last property can be a single number or a list of lists. A single number indicates the body to be executed, and is used only for blocks with exactly one body. If it's a list of lists, the length is 1 for a block without arguments and 2 or more for a block with arguments (function or deferred modifier). Each element is a list of body indices. After selecting the appropriate list, execution begins at the first body in the appropriate list, moving to the next one if a header test (SETH or PRED instruction) fails. If a test fails but there's no next body, block evaluation is an error.

+

The five possible cases for a function are monadic, dyadic, inverse monadic (𝕊x), inverse dyadic (w𝕊x), and swapped-inverse dyadic (x𝕊˜⁼w). The first two will always be provided, while the remaining three typically don't exist as they have to be specified with undo headers. The smallest length that covers all possible cases will be used.

Bodies

Bodies in a block are separated by ;. Each entry in bodies is a list containing: