Package-level declarations

Types

Link copied to clipboard

The spec's abstract operations on objects: integrity levels, species, grouping and the rest.

Link copied to clipboard

GetSubstitution: the $1, $&, $<name> patterns a replacement string can carry.

Link copied to clipboard

A Slot whose value is produced by a getter and consumed by a setter. Unlike LambdaSlot, the property descriptor shows that this is what is happening.

Link copied to clipboard

The array methods that also work on typed arrays and other array-likes: iteration, reduce, sort.

Link copied to clipboard

The base of every function object, and also the prototype of every function defined in script except the generator functions written with function *.

Link copied to clipboard
class BoundFunction(cx: Context, scope: Scriptable, targetFunction: Callable, boundThis: Scriptable?, boundArgs: Array<Any?>) : BaseFunction

What Function.prototype.bind returns. ECMAScript 5 section 15.3.4.5.

Link copied to clipboard

A Slot for a property of a built-in object that gets created very often. It exposes a field on a native object through plain functions, and lets the owner take over attribute changes and redefinition (array length behaves unusually on both counts).

Link copied to clipboard
interface Callable

Anything that can be called from JavaScript.

Link copied to clipboard

Fills a JSDescriptor.Builder from the IR tree. Shared by every code generator.

Link copied to clipboard

Compiler configuration shared by the lexer, parser and code generator.

Link copied to clipboard

A sequence of operations run against one map. It does as little as possible: no locking, just a note of whether the map was changed, so the map underneath knows when to hand work off.

Link copied to clipboard

A lazily flattened rope of two character sequences. Repeated string concatenation builds a tree of these instead of copying, and the tree is flattened once, on the first read.

Link copied to clipboard
interface ConstProperties

Implemented by objects that can hold const bindings.

Link copied to clipboard
interface Constructable

Anything that can be used with new.

Link copied to clipboard
open class Context : AutoCloseable

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.

Link copied to clipboard
fun interface ContextAction<T>

Work to run with a Context entered. See ContextFactory.call.

Link copied to clipboard
open class ContextFactory

Makes Context objects and answers the questions a context asks about its environment: which optional behaviours are on, and what wraps a top-level call.

Link copied to clipboard

How decompile should print a function.

Link copied to clipboard

Forwards every object operation to another object. Subclass it to wrap a host object: override only what you want to change and the rest keeps working.

Link copied to clipboard

The errors the engine itself raises, as ECMA edition 3 section 15.11.6 describes them: EvalError, RangeError, ReferenceError, SyntaxError, TypeError and URIError.

Link copied to clipboard

A SlotMap built on a hash table that holds the slots directly rather than wrapping each one in another object. That saves an allocation per property, which measurably pays off.

Link copied to clipboard
interface ErrorReporter

This interface defines a protocol for the reporting of errors during JavaScript translation or execution.

Link copied to clipboard

The ES6 generator object: next, return, throw and Symbol.iterator.

Link copied to clipboard
abstract class ES6Iterator : ScriptableObject

The base for the built-in iterators (array, string, map, set and the rest). A subclass says when it is done and what the next value is; this class turns that into {value, done} results.

Link copied to clipboard
interface Evaluator

What it takes to turn an IR tree into something runnable. Upstream has two implementations, an interpreter and a bytecode compiler; this port only ever has the interpreter.

Link copied to clipboard

The class of exceptions thrown by the JavaScript engine for translation or evaluation problems.

Link copied to clipboard

Implement this to back a ScriptableObject with data that lives outside the engine.

Link copied to clipboard

A JavaScript function: an object that can also be called and constructed.

Link copied to clipboard

A SlotMap built on a linked hash map. It costs more than EmbeddedSlotMap, mostly because each slot sits inside another object, but it copes far better with a lot of hash collisions, so it takes over once an object has many properties.

Link copied to clipboard

The table behind Map and Set: a hash map for lookup plus a doubly linked list for insertion order.

Link copied to clipboard
interface IdFunctionCall

The owner of a set of id-based functions: it knows their properties and how to run them.

Link copied to clipboard

A function identified by a number, which its IdFunctionCall master dispatches on.

Link copied to clipboard

The base for a native object that exposes its methods through IdFunctionObjects hung off its prototype.

Link copied to clipboard
fun interface Initializable

A one-method interface so a lambda can stand in for the lazy setup of a native class.

Link copied to clipboard

The interpreter: the one Evaluator this engine has. It runs the icode CodeGenerator emits, one call frame per script function, with the frames linked so an exception or a yield can unwind them without touching the host stack.

Link copied to clipboard
class IRFactory(env: CompilerEnvirons, sourceName: String?, sourceString: String, errorReporter: ErrorReporter = env.errorReporter)

Lowers the AST into the Node IR that the code generator consumes.

Link copied to clipboard

Drives a script iterator from Kotlin: next() until done, and return() on close if the iterator has one. Close it when done, or hand it to use.

Link copied to clipboard
class JavaScriptException(val value: Any?, sourceName: String?, lineNumber: Int) : RhinoException

A JavaScript throw that reached Kotlin: value is whatever the script threw.

Link copied to clipboard
abstract class JSCode<T : ScriptOrFn<T>> : JSCodeExec<T> , JSCodeResume<T>

The compiled form of a script or function. The interpreter's version is InterpreterData.

Link copied to clipboard
fun interface JSCodeExec<T : ScriptOrFn<T>>

Runs compiled code.

Link copied to clipboard
fun interface JSCodeResume<T : ScriptOrFn<T>>

Resumes a suspended generator.

Link copied to clipboard

Everything known about a compiled script or function that does not change per call: its code, its names, its flags and its nested functions. Built once by the code generator through Builder, then shared by every function object made from it.

Link copied to clipboard
open class JSFunction(cx: Context, scope: Scriptable, val descriptor: JSDescriptor<JSFunction>, lexicalThis: Scriptable?, homeObjectValue: Scriptable?) : BaseFunction, ScriptOrFn<JSFunction>

A function compiled from script source. Everything about it lives in its descriptor.

Link copied to clipboard
class JSScript(val descriptor: JSDescriptor<JSScript>, val homeObject: Scriptable?) : Script, ScriptOrFn<JSScript>

A compiled script.

Link copied to clipboard

An arbitrary-precision integer: what BigInt values are made of.

Link copied to clipboard
object Kit

Collection of utilities.

Link copied to clipboard
open class KnownBuiltInFunction(val tag: Any, scope: Scriptable, name: String, length: Int, prototype: Any?, target: SerializableCallable) : LambdaFunction

A LambdaFunction the engine recognises by its tag, so the interpreter and the runtime can treat it specially. Function.prototype.apply and call are the two that matter most.

Link copied to clipboard

Like LambdaSlot, but the lambdas also get the owning object, so the property can read and write the owner's own fields. That is what makes it usable for a native property that has to behave like a normal JavaScript property without reflection.

Link copied to clipboard

A function that can be used as a constructor, with the construction handed off to a lambda. LambdaFunction adds the prototype methods the same way.

Link copied to clipboard

One JavaScript function, implemented by a single Kotlin lambda. It has the built-in Function prototype and no parent scope; binding it into a scope is the caller's job.

Link copied to clipboard

A Slot whose value comes from calling a Kotlin lambda. To script it looks like any ordinary value property, which is what separates it from AccessorSlot: the descriptor shows a plain value, not a getter and setter pair.

Link copied to clipboard
class LazilyLoadedCtor(scope: ScriptableObject, propertyName: String, sealed: Boolean, initializer: Initializable)

Holds off building a built-in class until something asks for it, which cuts startup time and the memory a scope costs when most of the globals go untouched.

Link copied to clipboard

A Slot that builds its value the first time it is read. The built-in objects use it so they are not all constructed up front.

Link copied to clipboard

The JavaScript Array.

Link copied to clipboard

The iterator behind array.keys(), entries() and values(), and for (x of array).

Link copied to clipboard

The activation record of one function call: its parameters, its variables and its arguments object, kept as properties so closures and eval can reach them.

Link copied to clipboard

One frame of a captured stack, as handed to Error.prepareStackTrace.

Link copied to clipboard

The iterator Map and Set hand back from keys, values and entries.

Link copied to clipboard

The console object: log, warn, error and friends, plus the counters and timers. Where the output goes is the embedder's choice, through a ConsolePrinter.

Link copied to clipboard

The pre-ES6 generator object from JavaScript 1.7: send, next, throw, close and the legacy __iterator__. Language versions at or above ES6 get ES6Generator instead.

Link copied to clipboard

The global functions and values: eval, parseInt, isNaN, NaN, the error constructors and the rest.

Link copied to clipboard

The legacy Iterator object from JavaScript 1.7: it walks an object's own properties and throws StopIteration when there is nothing left. The ES6 protocol lives in ES6Iterator.

Link copied to clipboard

The JavaScript JSON object.

Link copied to clipboard

The Map builtin, over the insertion-ordered Hashtable.

Link copied to clipboard

The JavaScript Object builtin: the plain object class, its constructor and the methods on both.

Link copied to clipboard

The Promise builtin.

Link copied to clipboard

The Set builtin, including the ES2025 set algebra methods.

Link copied to clipboard

The iterator behind for (const ch of "text"): one code point per step.

Link copied to clipboard

The Symbol wrapper object. The primitive symbol value is a SymbolKey; this class is only what Object(sym) produces, and it carries the key in an internal slot.

Link copied to clipboard

WeakMap: a map that does not keep its keys alive. Only objects and unregistered symbols can be keys, and there is no way to ask it what it holds, which is what makes the weakness unobservable from script.

Link copied to clipboard

WeakSet: the same weak keys as NativeWeakMap, with nothing stored against them.

Link copied to clipboard

The scope a with statement pushes: every lookup goes to the object it wraps.

Link copied to clipboard
abstract class NewLiteralStorage

Collects the pieces of an object or array literal while the interpreter evaluates them, then hands the runtime the keysField, valuesField and getter/setter flags in one go.

Link copied to clipboard
open class Node : Iterable<Node>

Root of the intermediate representation: a weakly typed tree node holding a linked list of children and a linked list of properties.

Link copied to clipboard
open class NodeTransformer

Rewrites the IR into the lower-level form the code generator wants.

Link copied to clipboard
class Parser(compilerEnv: CompilerEnvirons = CompilerEnvirons(), errorReporter: ErrorReporter = compilerEnv.errorReporter)

The JavaScript parser, based on the SpiderMonkey sources jsparse.c and jsparse.h.

Link copied to clipboard
abstract class Ref

A reference to a place a value can be read from, written to or deleted, for the cases the plain property protocol does not cover.

Link copied to clipboard
interface RefCallable : Callable

A callable that can also produce a Ref, for delete f(x) and friends.

Link copied to clipboard
interface RegExpProxy

What the runtime needs from a regular expression engine. The engine itself lands in phase 4.

Link copied to clipboard

The class of exceptions thrown by the JavaScript engine.

Link copied to clipboard
interface Script

Every compiled script implements this. It runs a script against an object scope.

Link copied to clipboard
interface Scriptable

The interface every JavaScript object implements.

Link copied to clipboard

The base of every JavaScript object. It keeps the properties, the prototype and the parent scope, and implements the property algorithm the whole language rests on.

Link copied to clipboard
interface ScriptOrFn<T : ScriptOrFn<T>>

Something compiled from source: a script or a function. T is the concrete type itself.

Link copied to clipboard

The runtime method collection. Phase 0 ports only what the lexer needs: line terminator and whitespace classification, string-to-number parsing, and the error message lookup. The rest of the file arrives with Phase 3.

Link copied to clipboard

The ES6-only runtime helpers.

Link copied to clipboard
class ScriptStackElement(val fileName: String, val functionName: String?, val lineNumber: Int)

One frame of a script stack trace.

Link copied to clipboard

The Callable that LambdaFunction and LambdaConstructor take. Upstream also requires it to be Serializable; there is no serialization here, so the name is kept for parity and the marker is empty (D-22).

Link copied to clipboard
Link copied to clipboard
open class Slot

One property of a ScriptableObject. This base class is an ordinary property holding a value; the subclasses cover the ones backed by getters and setters.

Link copied to clipboard
interface SlotMap : Iterable<Slot>

The property table behind a ScriptableObject. It is iterable but is not a Map, because a real map brings overhead this does not need.

Link copied to clipboard
abstract class SlotMapOwner

Holds the property table for whatever owns it, and swaps that table for a bigger one as the object gains properties. ScriptableObject is the only thing that extends it.

Link copied to clipboard
interface Symbol

A JavaScript Symbol. This is an interface so that more than one implementation can exist.

Link copied to clipboard
class SymbolKey(nameOrNull: String?, val kind: Symbol.Kind) : Symbol

One of the two implementations of Symbol. This one exists so native code can use the well-known symbols as plain map keys. A NativeSymbol built from a key compares equal to that key.

Link copied to clipboard

The symbol-keyed half of the property protocol, implemented alongside Scriptable.

Link copied to clipboard
object Token

This class implements the JavaScript scanner's token codes.

Link copied to clipboard

A global scope that remembers the original built-in constructors.

Link copied to clipboard
class Undefined

The JavaScript undefined value.

Link copied to clipboard

Remembers promises that were rejected with nothing to catch them. One of these belongs to each Context.

Link copied to clipboard
class UniqueTag

A marker value that is only ever compared by identity. Three of them exist and no more can be made.

Link copied to clipboard
actual class WeakRef<T : Any>(referred: T)

A weak reference to T: holds its referent without keeping it alive.

expect class WeakRef<T : Any>(referred: T)

A weak reference to T: holds its referent without keeping it alive.

actual class WeakRef<T : Any>(referred: T)

A weak reference to T: holds its referent without keeping it alive.

actual class WeakRef<T : Any>(referred: T)

A weak reference to T: holds its referent without keeping it alive.

actual class WeakRef<T : Any>(referred: T)

A weak reference to T: holds its referent without keeping it alive.

actual class WeakRef<T : Any>(referred: T)

Wasm has no weak reference. A Kotlin object on Wasm lives in the Wasm heap, not the JavaScript one, so the WeakRef global cannot hold it, and the standard library offers nothing else.

Link copied to clipboard
class WrappedException(val wrappedException: Throwable) : EvaluatorException

A host exception carried through script as a JavaScript error.

Link copied to clipboard
interface Wrapper

Wraps a value that came from outside the engine.