Context
The state one run of the engine carries: the language version, the error reporter, the feature flags, and the call stack bookkeeping the interpreter needs.
Upstream keeps the current context in a ThreadLocal, one per thread. This port is single-thread confined (D-3), so there is exactly one slot. Enter a context before running anything and exit it afterwards, or use ContextFactory.call, which does both.
Gone from upstream: class shutters, wrap factories, security controllers, class loaders, the debugger hooks and the E4X and LiveConnect surfaces. None of them have a meaning off the JVM.
Types
Properties
Where warnings and errors go. Defaults to a reporter that throws on error.
The version of this engine.
Always true: there is no bytecode compiler in this port (D-15).
Whether the code running right now is in strict mode.
The language version this context evaluates at. Changing it affects what gets compiled from then on. New code should use VERSION_ES6 or VERSION_ECMASCRIPT.
How deep the interpreter's call frames may go before it gives up.
Where rejected promises with nothing to catch them are collected. Nothing is collected until trackUnhandledPromiseRejections turns it on, because what to do about them is the embedder's decision.
Functions
Compiles source, which has to hold exactly one function, into a function object.
Queues work to run after the current top-level call finishes.
The elements of an array-like object, with holes read as undefined.
A value an embedder parks on the context under key.
Whether an optional engine behaviour is on. The factory decides.
Makes a global scope with every standard object in it.
Fills scope, or a new TopLevel when null, with the standard objects.
Runs the queued work, including anything it queues in turn, until the queue is empty.
Sets the reporter and returns the old one, the way upstream's setter does.
How many instructions the interpreter runs between calls to ContextFactory.observeInstructionCount. Zero turns the observer off.
Whether source is a complete statement, or needs more lines before it could parse.