Skip to main content

Crate plg_runtime

Crate plg_runtime 

Source
Expand description

plg-runtime: the support library linked into every compiled Prolog binary (libplg_runtime.a).

It provides the machine substrate compiled predicates call into — term heap, trail, choice-point stack, generic unification, the goal-only --query parser, solution output, and the process entry point. It contains NO clause interpreter: clause control flow lives in the LLVM IR that plgc generates (see docs/design/COMPILATION_MODEL.md and docs/design/LESSONS_FROM_V1.md).

Modules§

abi
The C-ABI surface generated code calls into (plg_rt_*).
builtins
The builtin layer: arithmetic evaluation (arith), standard term order (order), and the C-ABI predicate surface (pred) that compiled code calls into for is/2, arithmetic/term comparison, \=/2, compare/3, cut, and codegen helpers.
cell
Tagged 64-bit term words.
control
Query-level control constructs and deterministic builtins.
copyterm
Relocatable off-heap term copies.
entry
Process entry: plg_rt_init + plg_rt_main, called from the thin generated main. Owns argv parsing (hand-rolled — no clap inside compiled binaries), output, and the v1 exit-code contract:
errors
Structured runtime errors (ISO error terms).
machine
The Machine: the single runtime context every compiled predicate receives (%M in generated IR). Owns the term heap, trail, choice-point stack, argument registers, the current success continuation, step accounting, and the runtime atom table.
query
Minimal goal-only parser for runtime --query strings.
render
Solution rendering: the v1 wire contract, byte-compatible.
solve
The solve driver: dispatches a parsed goal into compiled predicates and runs the backtracking loop.
unify
Generic unification over tagged heap words.