Statifier.Compiler.FunctionCalls (Statifier v2.15.0)

Copy Markdown View Source

The compile-time check that every function a chart's expressions call is one the chart can be evaluated with: In/1, a predicator builtin, or a function the host registers through Statifier.compile/2's :function_providers option.

It reads the compiled Statifier.Machine rather than the document: every cond, expr, <script> and other predicator source has already been compiled to a %Predicator.Compiled{} by then, and a call is one top-level ["call", name, arity] instruction in it. A name outside the known set becomes one Statifier.Compiler.Error with reason {:unknown_function, name, source}, reported at the location of the element whose expression makes the call.

Only the name is checked, not the arity: a call with the wrong number of arguments to a known function still compiles and fails at evaluation, as it always has.

Summary

Functions

One error per distinct {name, location} pair whose name is not in known, ordered by location. [] when every call names a known function, which is always true of a chart that calls none.

Functions

check(machine, known)

@spec check(machine :: Statifier.Machine.t(), known :: MapSet.t(String.t())) :: [
  Statifier.Compiler.Error.t()
]

One error per distinct {name, location} pair whose name is not in known, ordered by location. [] when every call names a known function, which is always true of a chart that calls none.