The run of an expression by the interpreter's walk, for generated code that has begun one and cannot finish it (D-164).
The BEAM backend runs some expressions through a guarded fast path (Feel.Backend.Beam.Scalar): it reads the
names it needs from the bindings, checks that they are what it expects, and does the operations without an
environment, which is how it saves the work of the interpreter's. It stays pure until it returns, so when a value is
not what it expects (a null, a name that is not bound, a value that has to be converted), when an operation does not
give a value (an overflow, a division by zero) or when the counts of the run could pass a limit, it has changed
nothing, and the generated function calls run/3 with the IR of the expression, the bindings it was given and the
environment it was given. The answer is the interpreter's, with its diagnostics and where a limit ends the run, and
so is the answer of the whole.
It is in the runtime, and not in a backend, because generated code may call only Feel.Runtime and the built-in
functions.
Summary
Functions
Evaluates the IR on the bindings and the environment, as the interpreter does, and returns the value and the environment.
Functions
@spec run(Feel.IR.t(), Feel.bindings(), Feel.Runtime.Env.t()) :: {Feel.Value.t(), Feel.Runtime.Env.t()}
Evaluates the IR on the bindings and the environment, as the interpreter does, and returns the value and the environment.
iex> ir = {:const, %{span: {0, 1}}, Decimal.new(7)}
iex> Feel.Runtime.Interpret.run(ir, %{}, Feel.Runtime.Env.new()) |> elem(0)
Decimal.new(7)