Skip to main content

Crate kataan

Crate kataan 

Source
Expand description

kataan — a high-performance JavaScript (ECMAScript) engine written entirely in Rust, depending on no foreign code.

Kataan is built bottom-up in layers, and is usable three ways — as a Rust library, as a C library (the ffi feature), and as a standalone command- line tool / REPL (the cli feature). See ROADMAP.md for the full design and milestone plan.

The pipeline:

source ──[lexer]──▶ tokens ──[parser]──▶ AST ──[compiler]──▶ bytecode
                                                                 │
                                                           [interpreter]

§no_std

The language core is #![no_std] and needs only alloc. The std feature (default, implies alloc) adds the host runtime — the event loop, timers, file system, network (fetch over rsurl), and crypto (over purecrypto). Build the bare core with --no-default-features --features alloc.

Re-exports§

pub use error::Error;
pub use error::Result;
pub use limits::Limits;
pub use limits::WasmLimits;

Modules§

ast
The abstract syntax tree produced by the parser.
atomalloc
Interned strings (“atoms”): distinct identifiers/property keys mapped to small Copy integers for O(1) comparison. Needs alloc. Interned strings — “atoms” (ROADMAP.md §3, item 4).
bignumalloc
A pure, alloc-only arbitrary-precision integer — the foundation for a conformant BigInt (ROADMAP.md). Needs alloc. A pure, alloc-only arbitrary-precision signed integer — the foundation for a conformant BigInt (replacing the bounded i128 approximation).
bytecodealloc
A portable KTBC serialization codec for the bytecode VM’s compiled programs (the code cache — ROADMAP.md Phase D′). Needs alloc. A portable serialization codec for the bytecode VM’s compiled programs (ROADMAP.md Phase D′ — serializable bytecode / code cache).
cellalloc
Heap cells — the reference types (object / string / array / function) a heap slot holds. Needs alloc. Heap cells — the reference types the managed heap holds (ROADMAP.md §3).
common
Cross-cutting building blocks shared by every layer of the engine: source positions (Span) and, as the engine grows, the string interner, the diagnostic types, and the bump arena.
envalloc
Lexical environments (scope chains) for closures over the new model. Needs alloc. Lexical environments (scope chains) for the tree-walker over the new model (ROADMAP.md §3 → Phase D migration, the function/closure piece).
error
The engine-level error type.
flatbcalloc
Flat, fixed-record bytecode executed in place over a (possibly mmap’d) byte buffer — the true zero-copy reload path (Phase D′). Needs alloc. Flat, fixed-record bytecode executed in place over a byte buffer — the true zero-copy reload path (ROADMAP.md §2.2): the interpreter runs directly over the mapped bytes, decoding one fixed-size record at a time, without ever deserializing into an owned Vec<Op>.
gcalloc
A mark-and-sweep tracing garbage collector over heap::Heap — reclaims unreachable objects, including reference cycles. Needs alloc. A mark-and-sweep tracing collector over Heap (ROADMAP.md §3, the GC).
heapalloc
The managed heap (generational handle table) that NaN-boxed handles index into — groundwork for the object model & GC. Needs alloc. A generational handle table — the managed heap that NanBox handles point into (ROADMAP.md §3, the object model & GC).
icalloc
Inline caches for property access, keyed on shape::Shape identity — the fast path that turns a repeated obj.x into a slot load. Needs alloc. Inline caches for property access (ROADMAP.md §3, item 2).
jsonalloc
Shared, alloc-only JSON.parse / JSON.stringify over realm values. Pure, alloc-only JSON.parse / JSON.stringify over realm values.
lexer
The lexer: ECMAScript source text → a stream of Tokens.
limits
Tunable resource limits (recursion depths, allocation sizes, regex/wasm budgets) with safe defaults, overridable per realm::Realm. Central, tunable resource limits for the engine.
nanbox
NaN-boxed value representation — groundwork for the performance object model (ROADMAP.md §3).
nbevalalloc
Evaluates the real parser AST (the expression subset) over the Realm/NanBox model — the front-end → new-representation bridge. Needs alloc. Evaluating the real ast::Expr over the Realm/NanBox model (ROADMAP.md §3 → Phase D migration).
nbexecalloc
Executes real statements (variables, scope, control flow, assignment) over the Realm/NanBox model — the imperative core on the new representation. Needs alloc. Executing real statements and functions over the Realm/NanBox model (ROADMAP.md §3 → Phase D migration).
nbvmalloc
A minimal register VM over the Realm/NanBox representation — the proof that the performance object model executes code. Needs alloc. A minimal register VM over the Realm / NanBox representation (ROADMAP.md §3 → Phase D migration).
objectalloc
The performance-era object: a shape::Shape paired with nanbox::NanBox value slots — composes the object-model pillars. Needs alloc. The performance-era object: a Shape (hidden class) paired with a flat vector of NanBox value slots (ROADMAP.md §3).
parser
The parser: a token stream → an AST.
realmalloc
The object-model context (Realm) bundling the heap, the shared root shape, and the atom table behind the allocate/get/set/collect API a VM uses. Needs alloc. The object-model context that ties the foundation together (ROADMAP.md §3).
regexregex
The in-house regular-expression engine (the regex feature). Pure Rust, no_std-compatible (alloc only). A small, in-house regular-expression engine (no foreign code).
ropealloc
Rope strings: lazy O(1) concatenation so building a string piecewise is not quadratic. Needs alloc. Rope strings — lazy-concatenation string values (ROADMAP.md §3, item 4).
shapealloc
Hidden classes (“shapes”): shared property-layout descriptors with a transition tree — groundwork for the object model. Needs alloc. Hidden classes (“shapes”) — shared property-layout descriptors (ROADMAP.md §3, the object model).
snapshotalloc
Heap snapshots of the live Cell object graph — capture an initialized heap and restore it into a fresh realm (Phase D′ heap-snapshot tier). Needs alloc. Heap snapshots of the live Cell object graph (ROADMAP.md §2.2, the heap-snapshot tier).
wasmalloc
The WebAssembly peer engine: lowers the numeric subset of JS functions to WebAssembly text (WAT) — a second compilation target. Needs alloc. A WebAssembly backend — the WASM peer engine (ROADMAP.md).
wasm_rtalloc
The WebAssembly execution engine (Phase H): decodes and runs .wasm binaries — the peer engine proper, distinct from wasm (JS→WASM). Needs alloc. A WebAssembly execution engine (Phase H) — the peer engine that runs .wasm modules, distinct from crate::wasm (which compiles JS to WASM).
wasm_specalloc
A WebAssembly spec-test harness: typed assert_return/assert_trap/ assert_invalid commands run against the wasm_rt engine. Needs alloc. A WebAssembly spec-test harness (ROADMAP.md Phase H — “validated against the WebAssembly spec test suite”).
wtf8alloc
WTF-8 string codec: UTF-8 extended to encode lone UTF-16 surrogates, so DOMString values round-trip losslessly. The storage foundation for rope/atom. Needs alloc. WTF-8 — the string-storage codec (ROADMAP.md §3, item 4; milestone B1).

Constants§

VERSION
The crate version, from Cargo.toml.