mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-09 07:16:52 +00:00
vectorcraft-js gains a Realm that runs ECMAScript 5.1 scripts. The parsed script compiles to stack-machine bytecode, a verifier checks every jump target, handler, constant index and stack depth before the code runs, and the interpreter keeps JavaScript calls on its own frame stack. Closures, this, arguments, with, direct and indirect eval, new Function, try/catch/finally, labeled break and continue, and for-in in insertion order follow sections 10 to 14 of ECMA-262 5.1. Variable references are resolved before the right-hand side of an assignment runs (11.13). Objects and environments live in an arena with a mark-and-sweep collector and index handles. Built-ins are limited to Object and Object.prototype's basic methods, Function with call and apply, eval and the error constructors. Every run is bounded by fuel, heap bytes, frames, nested host calls and an interrupt flag another thread can set, with smaller defaults in the wasm build. A run that reaches a limit ends with a limit error that a script's try cannot catch. Source passed to eval and Function counts against Options::max_source_units. cargo xtask test262 also runs the suite's ES5 test/language tests that need only these built-ins and prints their counts apart from the parse counts. Nothing in the app calls the interpreter yet.