docs and gm pretty printer

This commit is contained in:
crumbtoo
2023-11-29 17:23:41 -07:00
parent 60162f30f3
commit 066f883178
3 changed files with 147 additions and 1 deletions

View File

@@ -207,3 +207,30 @@ WIP. state transition rules
& m
}
*********************************
Compilation: How to Squash a Tree
*********************************
WIP.
Notice that we do not keep a (local) environment at run-time. The environment
only exists at compile-time to map local names to stack indices. When compiling
a supercombinator, the arguments are enumerated from zero (the top of the
stack), and passed to :code:`compileR` as an environment.
.. literalinclude:: /../../src/GM.hs
:dedent:
:start-after: -- >> [ref/compileSc]
:end-before: -- << [ref/compileSc]
:caption: src/GM.hs
Of course, variables being indexed relative to the top of the stack means that
they will become inaccurate the moment we push or pop the stack a single time.
The way around this is quite simple: simply offset the stack when w
.. literalinclude:: /../../src/GM.hs
:dedent:
:start-after: -- >> [ref/compileC]
:end-before: -- << [ref/compileC]
:caption: src/GM.hs