Expand description
C-ABI surface for the M3 builtins: arithmetic (is/2, comparisons),
term comparison (==, @<, compare/3), structural inequality
(\=/2), cut, and a few codegen helpers. Mirrors the style of
abi.rs (#[unsafe(no_mangle)] pub extern "C" fn plg_rt_*).
Functions§
- plg_
rt_ b_ arith_ cmp - Arithmetic comparison. op: 0:‘<’ 1:‘>’ 2:‘=<’ 3:‘>=’ 4:‘=:=’ 5:‘=\=’.
1 = holds, 0 = does not hold or error.
site_id: seeplg_rt_b_is. - plg_
rt_ b_ compare compare/3: unifyorderwith the atom ‘<’, ‘=’, or ‘>’ according to the standard order ofaandb. 1 = success, 0 = failure.- plg_
rt_ b_ is is/2: evaluateexpr, unifylhswith the result. 1 = success, 0 = failure or error (error already set inm.error).site_idcarries source provenance (SPANS.md Layer 3): set around the eval so any error constructor it reaches appendsat file:line:colviaset_formal.- plg_
rt_ b_ neq \=/2: succeed iffaandbdo NOT unify. Always undoes any bindings made during the trial unification (rewinds the trail to the entry mark); the heap top is left untouched (no terms are constructed here).- plg_
rt_ b_ term_ cmp - Term comparison via standard order. op: 0:‘==’ 1:‘\==’ 2:‘@<’ 3:‘@>’ 4:‘@=<’ 5:‘@>=’. 1 = holds, 0 = does not.
- plg_
rt_ cp_ top - Current choice-point stack height (the cut barrier to capture on entry).
- plg_
rt_ cut - Cut: truncate the choice-point stack to
height. - plg_
rt_ deref - Dereference a word through REF chains (exposes
Machine::deref). - plg_
rt_ str_ key - First-argument indexing key for a DEREFED word: for an STR, the packed
functor cell (
heap[idx], i.e.pack_functor(functor, arity)); for anything else,u64::MAX. Codegen switches on this to pick a clause set.