logicaffeine_compile/semantics/mod.rs
1//! The shared semantics kernel.
2//!
3//! ONE implementation of LOGOS value semantics — arithmetic, comparison,
4//! equality, collections, builtins — used by BOTH the tree-walker interpreter
5//! and the bytecode VM (and later the JIT's slow paths). Routing every engine
6//! through this module makes behavioral divergence structurally impossible,
7//! and every runtime error string for these operations lives here.
8
9pub mod acceptance;
10pub mod arith;
11pub mod builtins;
12pub mod collections;
13pub mod compare;
14pub mod crdt;
15pub mod dom;
16pub mod drive;
17pub mod escape;
18pub(crate) mod defined;
19pub mod exact;
20pub mod failcode;
21pub mod format;
22pub mod native_kernels;
23pub mod patch;
24pub mod policy;
25pub mod storage;
26pub mod temporal;
27pub mod world;
28
29/// Maximum LOGOS call depth, enforced identically by every engine: recursion
30/// past this is a catchable runtime error, not a host crash. Set to 2500 (up
31/// from the old 1000) so naive deep recursion like ackermann(3,8) — depth ~2045
32/// — runs in the interpreter, closer to Node/V8's recursion headroom. The VM is
33/// heap-stacked (depth-safe); the native-recursion engines stay within their
34/// stacks at this depth (JIT ~2500 frames is a couple MB; the tree-walker's
35/// depth tests run on a big-stack thread).
36pub const MAX_CALL_DEPTH: usize = 2_500;
37/// The canonical depth-exceeded error.
38pub const CALL_DEPTH_ERR: &str = logicaffeine_data::failure::CALL_DEPTH_EXCEEDED;
39
40/// The program name of a run that has no argv of its own — an in-process engine, a chip, a circuit.
41pub const PROGRAM_NAME: &str = "logos";
42
43/// The argument vector `args()` answers: `argv` as C, Python and Go define it — the program name
44/// first, then the real arguments. A run given no vector at all (the in-process engines) still
45/// has a program name, [`PROGRAM_NAME`], so `item 2 of args()` is always the first real argument
46/// on every tier and `length of args()` is never 0.
47pub fn argv_with_program_name(args: Vec<String>) -> Vec<String> {
48 if args.is_empty() {
49 vec![PROGRAM_NAME.to_string()]
50 } else {
51 args
52 }
53}