Skip to main content

Module pred

Module pred 

Source
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: see plg_rt_b_is.
plg_rt_b_compare
compare/3: unify order with the atom ‘<’, ‘=’, or ‘>’ according to the standard order of a and b. 1 = success, 0 = failure.
plg_rt_b_is
is/2: evaluate expr, unify lhs with the result. 1 = success, 0 = failure or error (error already set in m.error). site_id carries source provenance (SPANS.md Layer 3): set around the eval so any error constructor it reaches appends at file:line:col via set_formal.
plg_rt_b_neq
\=/2: succeed iff a and b do 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.