patch_prolog_shared/atom.rs
1//! Atom identifiers and well-known atoms.
2//!
3//! Atoms are interned to dense `u32` ids at compile time. The compiler
4//! emits the full atom table into the binary as global data; the runtime
5//! rebuilds the same nameāid map at startup so a `--query` goal interns
6//! into the identical id space. Well-known atoms get FIXED ids so codegen
7//! and runtime agree without consulting the table.
8
9/// Interned atom identifier.
10pub type AtomId = u32;
11
12/// Well-known atoms with fixed ids. The interner pre-seeds these in
13/// order, so `intern("[]") == ATOM_NIL` always holds.
14pub const ATOM_NIL: AtomId = 0; // []
15pub const ATOM_DOT: AtomId = 1; // '.' (list functor)
16pub const ATOM_TRUE: AtomId = 2;
17pub const ATOM_FAIL: AtomId = 3;
18pub const ATOM_FALSE: AtomId = 4;
19pub const ATOM_ERROR: AtomId = 5; // error/2 wrapper
20
21/// Names of the well-known atoms, in id order. Used by the interner to
22/// pre-seed and by tests to verify the contract.
23pub const WELL_KNOWN_ATOMS: &[&str] = &["[]", ".", "true", "fail", "false", "error"];