diff options
| author | bozo.kopic <bozo@kopic.xyz> | 2022-08-02 01:20:12 +0200 |
|---|---|---|
| committer | bozo.kopic <bozo@kopic.xyz> | 2022-09-25 02:40:23 +0200 |
| commit | 288727f09a1b3458c268497d111349e608c3f9fa (patch) | |
| tree | d62565249fa3c7127856c65405752572fc41aca9 /docs/env.rst | |
Diffstat (limited to 'docs/env.rst')
| -rw-r--r-- | docs/env.rst | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/docs/env.rst b/docs/env.rst new file mode 100644 index 0000000..5a4a243 --- /dev/null +++ b/docs/env.rst @@ -0,0 +1,34 @@ +Environment +=========== + +Environment (not to be mixed with context) represent current state of +interpreter instance. It contains reference to memory, input stream and +output stream. To enable +`tail call optimization <https://en.wikipedia.org/wiki/Tail_call>`_, +environment is also used as storage for next expression evaluation. + +Main method responsible for environment evaluation is `lsp_env_resolve`. +This function implements evaluation loop (also known as trampoline), which +iteratively evaluates sequence of expressions. Evaluation of single expression +can result in direct data value (which is registered with +`lsp_env_set_result_value` function) or can be delegated to execution +of another expression (which is registered with `lsp_env_set_result_eval` +function). Evaluation loop (trampoline) repeats expression evaluation +until resulting data value is fully resolved. + + +Source code +----------- + +env.h +''''' + +.. literalinclude:: ../src_c/env.h + :language: c + + +env.c +''''' + +.. literalinclude:: ../src_c/env.c + :language: c |
