interpreter
The tree-walking evaluator: `interpreter.run(ast, opts)` executes a parsed program against a realm, resolving scopes and closures, driving statements and expressions, and enforcing the per-run step budget.
interpreter
The tree-walking evaluator: interpreter.run(ast, opts) executes a parsed program against a realm, resolving scopes and closures, driving statements and expressions, and enforcing the per-run step budget.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2strict
new(parent: any?) → Env
| arg | type | description |
|---|---|---|
| parent | any? |
setGlobalObject(self: Env, rt: any, jsObj: any) → void
Attach a JS global object (globalThis) to this env so undeclared names fall back to its properties on lookup and top-level assignment writes through it.
| arg | type | description |
|---|---|---|
| self | Env | |
| rt | any | |
| jsObj | any |
functionScopeOf(env: Env) → Env
Find the nearest enclosing function scope (or the global scope) for `var` hoisting.
| arg | type | description |
|---|---|---|
| env | Env |
declare(self: Env, name: string, kind: string) → void
| arg | type | description |
|---|---|---|
| self | Env | |
| name | string | |
| kind | string |
findCell(env: Env, name: string) → Cell
Locate the cell for a name along the scope chain, or nil if unbound.
| arg | type | description |
|---|---|---|
| env | Env | |
| name | string |
globalEnvOf(env: Env) → Env
Find the env that owns the global object backing, if any.
| arg | type | description |
|---|---|---|
| env | Env |
tick(I: Interp) → void
| arg | type | description |
|---|---|---|
| I | Interp |
toInt32(I: Interp, v: any) → number
ToInt32: wrap a JS number to a signed 32-bit integer.
| arg | type | description |
|---|---|---|
| I | Interp | |
| v | any |
toUint32(I: Interp, v: any) → number
| arg | type | description |
|---|---|---|
| I | Interp | |
| v | any |
describe(I: Interp, node: Node?) → string
A short human description of a value for "X is not a function" messages.
| arg | type | description |
|---|---|---|
| I | Interp | |
| node | Node? |
setFramePos(I: Interp, node: Node) → void
Record the position the top (currently executing) frame is at: the call site of a nested call, or a throw statement. Frames below the top keep the call site that entered the frame above them.
| arg | type | description |
|---|---|---|
| I | Interp | |
| node | Node |
stackString(I: Interp) → string
Push a call-stack frame and snapshot it into a fresh error's stack when one is constructed during the call.
| arg | type | description |
|---|---|---|
| I | Interp |
raise(I: Interp, name: string, msg: string) → never
Raise a JS error of the given class, snapshotting the current call stack into its "stack" own property.
| arg | type | description |
|---|---|---|
| I | Interp | |
| name | string | |
| msg | string |
isObject(v: any) → boolean
| arg | type | description |
|---|---|---|
| v | any |
getMember(I: Interp, obj: any, key: string, keyNode: Node?) → any
Member read with primitive-string behavior and null/undefined guard.
| arg | type | description |
|---|---|---|
| I | Interp | |
| obj | any | |
| key | string | |
| keyNode | Node? |
propKey(I: Interp, node: Node, env: Env) → string
Evaluate a property key node to a string key, honouring `computed`.
| arg | type | description |
|---|---|---|
| I | Interp | |
| node | Node | |
| env | Env |
lookupVar(I: Interp, env: Env, name: string) → any
Read a variable, honouring the TDZ and the global-object fallback.
| arg | type | description |
|---|---|---|
| I | Interp | |
| env | Env | |
| name | string |
assignVar(I: Interp, env: Env, name: string, value: any) → void
Assign to a variable, honouring const and the global-object fallback.
| arg | type | description |
|---|---|---|
| I | Interp | |
| env | Env | |
| name | string | |
| value | any |
readElement(I: Interp, source: any, index: number) → any
Read one element of a destructured source: JS array/object by index key, string by character position, otherwise undefined.
| arg | type | description |
|---|---|---|
| I | Interp | |
| source | any | |
| index | number |
bindPattern(I: Interp, pat: Node, value: any, env: Env, kind: string) → void
| arg | type | description |
|---|---|---|
| I | Interp | |
| pat | Node | |
| value | any | |
| env | Env | |
| kind | string |
paramLength(params: { Node }) → number
Count the positional params before the first default/rest, for the function object's "length" own property.
| arg | type | description |
|---|---|---|
| params | { Node } |
bindParams(I: Interp, params: { Node }, args: { any }, env: Env) → void
Bind an argument list into a fresh function scope per the param patterns.
| arg | type | description |
|---|---|---|
| I | Interp | |
| params | { Node } | |
| args | { any } | |
| env | Env |
cloneForAsync(I: Interp, frameName: string) → Interp
A per-async-body execution context: it shares the run's realm, loop and step budget with `I`, but owns its call stack (seeded with the async function's frame) and its `inAsync` flag, so a suspended coroutine's frames and async state survive interleaving with the resuming coroutine.
| arg | type | description |
|---|---|---|
| I | Interp | |
| frameName | string |
makeFunction(I: Interp, node: Node, closure: Env, name: string) → any
Create a JSFunction from a Func/FuncDecl node with a captured closure env.
| arg | type | description |
|---|---|---|
| I | Interp | |
| node | Node | |
| closure | Env | |
| name | string |
runBody(bodyI: Interp, fnScope: Env) → any
Execute the function body against context `bodyI` and its bound scope, returning the completion value (a `return`'s operand, or undefined when the body falls off the end). Throws propagate as JS throws.
| arg | type | description |
|---|---|---|
| bodyI | Interp | |
| fnScope | Env |
bindInvocation(bodyI: Interp, thisVal: any, args: { any }) → Env
Bind `this`, `arguments` and the parameters into a fresh function scope for one invocation.
| arg | type | description |
|---|---|---|
| bodyI | Interp | |
| thisVal | any | |
| args | { any } |
call(rt2: any, thisVal: any, args: { any }) → void
| arg | type | description |
|---|---|---|
| rt2 | any | |
| thisVal | any | |
| args | { any } |
step(sendVal: any) → void
| arg | type | description |
|---|---|---|
| sendVal | any |
call(_rt3: any, _this3: any, nargs: { any }) → void
| arg | type | description |
|---|---|---|
| _rt3 | any | |
| _this3 | any | |
| nargs | { any } |
call(_rt3: any, _this3: any, nargs: { any }) → void
| arg | type | description |
|---|---|---|
| _rt3 | any | |
| _this3 | any | |
| nargs | { any } |
lookupThis(I: Interp, env: Env) → any
Resolve the lexical `this` for an arrow or bare function context. A `this` cell still in its TDZ marks a derived constructor that has not yet called super(), where reading `this` is a ReferenceError.
| arg | type | description |
|---|---|---|
| I | Interp | |
| env | Env |
applyBinary(I: Interp, op: string, l: any, r: any) → any
Numeric/string binary operators over already-evaluated operands.
| arg | type | description |
|---|---|---|
| I | Interp | |
| op | string | |
| l | any | |
| r | any |
spreadInto(I: Interp, out: { any }, v: any) → void
Expand an iterable spread operand into `out`. JS arrays yield their elements; strings yield their characters. Anything else is a TypeError.
| arg | type | description |
|---|---|---|
| I | Interp | |
| out | { any } | |
| v | any |
evalArguments(I: Interp, argNodes: { Node }, env: Env) → void
Evaluate a comma-free argument list, expanding spreads.
| arg | type | description |
|---|---|---|
| I | Interp | |
| argNodes | { Node } | |
| env | Env |
isSuperNode(node: Node) → boolean
Report whether a node is the `super` keyword (parsed as a bare Ident).
| arg | type | description |
|---|---|---|
| node | Node |
superGet(I: Interp, env: Env, key: string) → any
Resolve a `super.<key>` reference: the lookup starts at the home object's prototype while `this` stays the current receiver.
| arg | type | description |
|---|---|---|
| I | Interp | |
| env | Env | |
| key | string |
evalCallee(I: Interp, callee: Node, env: Env) → void
Evaluate a call target, returning (function, thisVal). Member callees bind their receiver as `this`. A `super.<key>` callee resolves through the home object's prototype but keeps the current `this` as the receiver.
| arg | type | description |
|---|---|---|
| I | Interp | |
| callee | Node | |
| env | Env |
evalExpr(I: Interp, node: Node, env: Env) → any
| arg | type | description |
|---|---|---|
| I | Interp | |
| node | Node | |
| env | Env |
evalObjectLit(I: Interp, node: Node, env: Env) → any
| arg | type | description |
|---|---|---|
| I | Interp | |
| node | Node | |
| env | Env |
classMemberKey(I: Interp, member: Node, env: Env) → string
Evaluate a class member's key to a string, honouring computed keys.
| arg | type | description |
|---|---|---|
| I | Interp | |
| member | Node | |
| env | Env |
classMethodNode(member: Node) → Node
Synthesize a Func node for a method/accessor/constructor member so makeFunction can build its closure.
| arg | type | description |
|---|---|---|
| member | Node |
makeClassMethod(I: Interp, member: Node, closure: Env, home: any, name: string) → any
Build a method function whose closure carries the home object, so `super.<key>` inside it resolves through the home object's prototype.
| arg | type | description |
|---|---|---|
| I | Interp | |
| member | Node | |
| closure | Env | |
| home | any | |
| name | string |
installAccessor(I: Interp, target: any, key: string, half: string, fn: any) → void
Install an accessor descriptor's get/set half onto a target object.
| arg | type | description |
|---|---|---|
| I | Interp | |
| target | any | |
| key | string | |
| half | string | |
| fn | any |
evalClass(I: Interp, node: Node, env: Env) → any
| arg | type | description |
|---|---|---|
| I | Interp | |
| node | Node | |
| env | Env |
call(rt2: any, thisVal: any, args: { any }) → void
| arg | type | description |
|---|---|---|
| rt2 | any | |
| thisVal | any | |
| args | { any } |
construct(rt2: any, args: { any }, newTarget: any) → void
| arg | type | description |
|---|---|---|
| rt2 | any | |
| args | { any } | |
| newTarget | any |
runFields(instance: any) → void
Run the non-static field initializers with `this` = instance.
| arg | type | description |
|---|---|---|
| instance | any |
evalSuperCall(I: Interp, node: Node, env: Env) → any
Evaluate a super(...) call inside a derived constructor: call the superclass constructor, adopt its result as `this`, then run this class's field initializers.
| arg | type | description |
|---|---|---|
| I | Interp | |
| node | Node | |
| env | Env |
evalNew(I: Interp, node: Node, env: Env) → any
| arg | type | description |
|---|---|---|
| I | Interp | |
| node | Node | |
| env | Env |
evalAssign(I: Interp, node: Node, env: Env) → any
| arg | type | description |
|---|---|---|
| I | Interp | |
| node | Node | |
| env | Env |
evalUpdate(I: Interp, node: Node, env: Env) → any
| arg | type | description |
|---|---|---|
| I | Interp | |
| node | Node | |
| env | Env |
readWrite(getf: () → void
| arg | type | description |
|---|---|---|
| getf | ( |
evalUnary(I: Interp, node: Node, env: Env) → any
| arg | type | description |
|---|---|---|
| I | Interp | |
| node | Node | |
| env | Env |
callFunction(I: Interp, fn: any, thisVal: any, args: { any }) → any
Call a JSFunction, pushing a stack frame around the invocation.
| arg | type | description |
|---|---|---|
| I | Interp | |
| fn | any | |
| thisVal | any | |
| args | { any } |
hoist(I: Interp, body: { Node }, env: Env) → void
Pre-pass over a statement list: var declarators declare into the nearest function scope; function declarations declare+initialize here; let/const/ class declare a TDZ cell in this block scope.
| arg | type | description |
|---|---|---|
| I | Interp | |
| body | { Node } | |
| env | Env |
hoistVarTargets(pat: Node) → void
| arg | type | description |
|---|---|---|
| pat | Node |
scanVars(stmt: Node) → void
Recurse into nested statements for `var` hoisting, but not into nested function bodies (they own their own function scope).
| arg | type | description |
|---|---|---|
| stmt | Node |
execBlock(I: Interp, body: { Node }, env: Env) → void
| arg | type | description |
|---|---|---|
| I | Interp | |
| body | { Node } | |
| env | Env |
execStmt(I: Interp, node: Node, env: Env) → void
| arg | type | description |
|---|---|---|
| I | Interp | |
| node | Node | |
| env | Env |
execFor(I: Interp, node: Node, env: Env) → void
| arg | type | description |
|---|---|---|
| I | Interp | |
| node | Node | |
| env | Env |
forInKeys(I: Interp, obj: any) → void
Collect the enumerable string keys of an object and its proto chain, deduped, in ownKeys order per level.
| arg | type | description |
|---|---|---|
| I | Interp | |
| obj | any |
bindForHead(I: Interp, left: Node, value: any, env: Env) → void
Bind a for-in/for-of loop variable from its head (VarDecl or pattern).
| arg | type | description |
|---|---|---|
| I | Interp | |
| left | Node | |
| value | any | |
| env | Env |
execForIn(I: Interp, node: Node, env: Env) → void
| arg | type | description |
|---|---|---|
| I | Interp | |
| node | Node | |
| env | Env |
execForOf(I: Interp, node: Node, env: Env) → void
| arg | type | description |
|---|---|---|
| I | Interp | |
| node | Node | |
| env | Env |
execSwitch(I: Interp, node: Node, env: Env) → void
| arg | type | description |
|---|---|---|
| I | Interp | |
| node | Node | |
| env | Env |
execTry(I: Interp, node: Node, env: Env) → void
| arg | type | description |
|---|---|---|
| I | Interp | |
| node | Node | |
| env | Env |
runFinalizer( ) → void
run(ast: Node, opts: any?) → void
| arg | type | description |
|---|---|---|
| ast | Node | |
| opts | any? |
currentStack( ) → void
Expose the live call stack of this run so a JS-level Error constructed during interpretation can snapshot the same frames the interpreter's internal `raise` uses. Rebound each run to the current `I`.
collectDeclNames(decl: Node, out: { string }) → void
Collect the local binding names a declaration node introduces, so a `export <decl>` can map each bound name to its module-scope binding.
| arg | type | description |
|---|---|---|
| decl | Node | |
| out | { string } |
walkPat(pat: Node) → void
| arg | type | description |
|---|---|---|
| pat | Node |
evalModuleBody(ast: Node, opts: any) → void
Evaluate a module-mode Program body in a fresh module scope whose parent is the VM global env, so global builtins resolve and top-level `globalThis` writes reach the realm. `opts.importBindings` are the already-resolved import values, installed as immutable const cells before hoisting: a later assignment to one raises the same "Assignment to constant variable." TypeError a JS const does. The body runs through the same hoist/execute and step-budget machinery as a script. On success the return is a map of this module's LOCAL exports (from decl / named / default declarations) snapshotted at body completion; re-exports carry no local binding and are assembled by the module graph, not here. On a thrown JS error the return is (false, errorValue).
| arg | type | description |
|---|---|---|
| ast | Node | |
| opts | any |
currentStack( ) → void
A JS-level Error constructed while the body runs snapshots the same frames the interpreter's internal `raise` uses.
Env = typeof(setmetatable(Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
Showing up to 3 levels deep. Open a part to see what it holds further down.
Problems
Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.
These counts cover only the parts this page shows. Problems on the parts it leaves out are not counted here.
Inside
1 problem across 1 itemagent_score is exposed.+ quality × 0.35
+ performance × 0.25
± compat factor
Usability ratings
Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".
Scoped to this part · feeds back into the world's score.