blob: 5a4a243d3d7e587b6a60b671c962ce94cbacc8f6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
|