boa-cat 0.3.0

Tree-walking ECMAScript interpreter built on ecma-syntax-cat. v0.3.0 adds accessor-property support at the engine level: `Object::with_accessor(key, AccessorPair)` installs a getter/setter pair, and `obj.key` / `obj.key = value` dispatch through the pair instead of doing plain data read/write. Embedders (web-api-cat etc.) can now wire DOM accessors like `document.cookie` via native getter/setter functions. Object-literal `{ get x() {} }` syntax remains gated on ecma-parse-cat learning to emit `ObjectPropertyKind::Get/Set` (the engine handles those AST variants already).
docs.rs failed to build boa-cat-0.3.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

boa-cat

Tree-walking ECMAScript interpreter, built on ecma-syntax-cat and the rest of the parser stack (ecma-lex-cat, ecma-parse-cat).

boa-cat is the engine layer of a comp-cat-rs reformulation of a JavaScript runtime targeting Tauri integration. It consumes a parsed Program and evaluates it to a Value over a persistent Heap, with all the framework constraints intact: no mut, no Rc/Arc, no interior mutability, no panics, exhaustive matches, static dispatch.

Example

use boa_cat::{run, Error};

fn main() -> Result<(), Error> {
    let value = run("function fact(n) { if (n <= 1) { return 1; } return n * fact(n - 1); } fact(5)").run()?;
    assert_eq!(format!("{value}"), "120");
    Ok(())
}

v0 scope

  • All literals (number, string, boolean, null, template).
  • Variable resolution with var / let / const.
  • All binary, unary, logical, conditional, and compound-assignment operators with ECMA-262 semantics.
  • Functions: declarations, expressions, arrow forms; closures; call + return; parameter defaults.
  • Member access (dot, computed, optional chain).
  • Array and object literals (with spread and shorthand).
  • if, while, do-while, for(;;), throw, try/catch/finally, return, break, continue.
  • Recursive function self-reference (via cell pre-allocation).

Deferred to v0.2+

  • Classes, modules, async/await/yield, generators, destructuring, tagged templates, labeled break/continue, for-in/for-of/switch, full BigInt and RegExp support. Built-ins (Math, JSON, console, etc.) live in the upcoming ecma-runtime-cat.

Design

Heap and environment are persistent: every operation that conceptually mutates state returns a new value, and the caller threads it forward. Variables live in heap-allocated cells so that assignment can update a cell without rebuilding the surrounding environment, while keeping Env itself immutable.

The top-level run returns comp_cat_rs::effect::io::Io<Error, Value>; the actual evaluator is plain Result and is wrapped at the boundary.

License

MIT OR Apache-2.0