ScriptRuntime

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.

Types

Link copied to clipboard

What a call site needs: the callee and the this it goes with.

Link copied to clipboard

A property key resolved to either a string name or an array index, never both.

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
const val ENUMERATE_ARRAY: Int = 2
Link copied to clipboard
Link copied to clipboard
const val ENUMERATE_KEYS: Int = 0
Link copied to clipboard
Link copied to clipboard
const val ENUMERATE_VALUES: Int = 1
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val NaN: Double
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val zeroObj: Double = 0.0

Functions

Link copied to clipboard
fun add(val1: Any?, val2: CharSequence): CharSequence
fun add(val1: CharSequence, val2: Any?): CharSequence

fun add(i1: Int, i2: Int): Any

Int plus Int, falling back to a double on overflow.

fun add(lval: Any?, rval: Any?, cx: Context): Any?

The + operator: string concatenation when either side is a string, addition otherwise.

Link copied to clipboard
fun addInstructionCount(cx: Context, instructionsToAdd: Int)

Adds to the instruction budget and tells the context when the threshold is crossed.

Link copied to clipboard
fun advanceStringIndex(string: String, index: Long, unicode: Boolean): Long

The next index to try after an empty match. In unicode mode a surrogate pair counts as one step, so an empty match never lands between the two halves.

Link copied to clipboard
fun applyOrCall(isApply: Boolean, cx: Context, scope: Scriptable, thisObj: Scriptable?, args: Array<Any?>): Any?

Function.prototype.apply and call, which differ only in how the arguments arrive.

Link copied to clipboard

A bigint printed in base, which is just what KBigInt already does.

Link copied to clipboard
fun bind(cx: Context, scope: Scriptable, id: String): Scriptable?

Finds the object in the scope chain that holds id, for an assignment. Null if none does.

Link copied to clipboard
fun bitwiseAND(val1: Any?, val2: Any?): Any
fun bitwiseAND(val1: Double, val2: Double): Double
Link copied to clipboard
fun bitwiseNOT(value: Any?): Any
Link copied to clipboard
fun bitwiseOR(val1: Any?, val2: Any?): Any
fun bitwiseOR(val1: Double, val2: Double): Double
Link copied to clipboard
fun bitwiseXOR(val1: Any?, val2: Any?): Any
fun bitwiseXOR(val1: Double, val2: Double): Double
Link copied to clipboard
fun call(cx: Context, fun_: Any?, thisArg: Any?, args: Array<Any?>, scope: Scriptable): Any?

Calls fun_ the way script would, with thisArg converted to an object.

Link copied to clipboard
fun callIterator(obj: Any?, cx: Context, scope: Scriptable): Any?

Calls obj[Symbol.iterator]().

Link copied to clipboard
fun callRef(function: Callable, thisObj: Scriptable?, args: Array<Any?>, cx: Context): Ref
Link copied to clipboard
fun callSpecial(cx: Context, fun_: Callable?, thisObj: Scriptable?, args: Array<Any?>, scope: Scriptable, callerThis: Scriptable?, callType: Int, filename: String?, lineNumber: Int, isOptionalChainingCall: Boolean): Any?

A call to eval or With, which get special treatment when they are the real ones.

Link copied to clipboard

The number a property name stands for when it is a canonical numeric index, or null. A typed array treats those names as element positions and everything else as ordinary properties.

Link copied to clipboard
Link copied to clipboard
fun clamp(value: Int, min: Int, max: Int): Int
Link copied to clipboard
fun compare(val1: Any?, val2: Any?, op: Int): Boolean

The relational operators, op being one of GE, LE, GT and LT.

Link copied to clipboard
fun compareNumeric(val1: Any?, val2: Any?, op: Int): Boolean

The numeric half, where each side is already a number or a bigint.

Link copied to clipboard
fun concat(lhs: Any?, rhs: Any?): Any

The + operator applied to two values that both have to become strings.

Link copied to clipboard
fun constructError(error: String, message: String): EcmaError
fun constructError(error: String, message: String, sourceName: String?, lineNumber: Int, lineSource: String?, columnNumber: Int): EcmaError
Link copied to clipboard
fun createArrowFunctionActivation(funObj: JSFunction, cx: Context, scope: Scriptable, args: Array<Any?>?, isStrict: Boolean, argsHasRest: Boolean, requiresArgumentObject: Boolean = true): Scriptable
Link copied to clipboard
fun createFunctionActivation(funObj: JSFunction, cx: Context, scope: Scriptable, args: Array<Any?>?, isStrict: Boolean, argsHasRest: Boolean, requiresArgumentObject: Boolean = true): Scriptable
Link copied to clipboard
fun delete(obj: Any?, id: Any?, cx: Context): Any?
fun delete(obj: Any?, id: Any?, cx: Context, isName: Boolean): Any?
fun delete(obj: Any?, id: Any?, cx: Context, scope: Scriptable, isName: Boolean): Any?
Link copied to clipboard
fun deleteObjectElem(target: Scriptable, elem: Any?, cx: Context): Boolean
Link copied to clipboard
fun divide(val1: Any?, val2: Any?): Any
Link copied to clipboard
fun doTopCall(script: Script, cx: Context, scope: Scriptable, thisObj: Scriptable): Any?
fun doTopCall(callable: Callable, cx: Context, scope: Scriptable, thisObj: Scriptable?, args: Array<Any?>): Any?
fun doTopCall(script: Script, cx: Context, scope: Scriptable, thisObj: Scriptable, isTopLevelStrict: Boolean): Any?

fun doTopCall(callable: Callable, cx: Context, scope: Scriptable, thisObj: Scriptable?, args: Array<Any?>, isTopLevelStrict: Boolean): Any?

Runs callable as the outermost call, setting up and tearing down the top scope around it.

Link copied to clipboard
fun elemIncrDecr(obj: Any?, index: Any?, cx: Context, incrDecrMask: Int): Any?
fun elemIncrDecr(obj: Any?, index: Any?, cx: Context, scope: Scriptable, incrDecrMask: Int): Any?
Link copied to clipboard
Link copied to clipboard
fun enterWith(obj: Any?, cx: Context, scope: Scriptable): Scriptable
Link copied to clipboard
fun enumId(enumObj: Any?, cx: Context): Any?
Link copied to clipboard
fun enumInit(value: Any?, cx: Context, enumValues: Boolean): Any
fun enumInit(value: Any?, cx: Context, enumType: Int): Any
fun enumInit(value: Any?, cx: Context, scope: Scriptable, enumType: Int): Any
Link copied to clipboard
fun enumNext(enumObj: Any?): Boolean
fun enumNext(enumObj: Any?, cx: Context): Boolean
Link copied to clipboard
fun enumValue(enumObj: Any?, cx: Context): Any?
Link copied to clipboard
fun eq(x: Any?, y: Any?): Boolean

The == operator.

Link copied to clipboard
fun escapeString(s: String, escapeQuote: Char = '"'): String

Escapes a string for printing inside an object or array literal. Not quite the same as the escape builtin: control characters become the short escapes where they exist and hex escapes otherwise.

Link copied to clipboard
fun evalSpecial(cx: Context, scope: Scriptable, thisArg: Any?, args: Array<Any?>, filenameIn: String?, lineNumberIn: Int): Any?

Direct eval: compiles the string in the caller's scope.

Link copied to clipboard
Link copied to clipboard
fun exponentiate(val1: Any?, val2: Any?): Any
Link copied to clipboard
fun fillObjectLiteral(obj: Scriptable, propertyIds: Array<Any?>?, propertyValues: Array<Any?>, getterSetters: IntArray?, cx: Context, scope: Scriptable)
Link copied to clipboard
fun getApplyOrCallThis(cx: Context, scope: Scriptable, arg0: Any?, l: Int, target: Callable): Scriptable?
Link copied to clipboard

The elements of an array-like object, with holes read as undefined.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun getElemFunctionAndThis(obj: Any?, elem: Any?, cx: Context, scope: Scriptable): Callable?
Link copied to clipboard
fun getExistingCtor(cx: Context, scope: Scriptable, constructorName: String): Function

The constructor named constructorName in scope, or a failure explaining why not.

Link copied to clipboard
fun getMessageById(messageId: String, vararg args: Any?): String
Link copied to clipboard
Link copied to clipboard
fun getObjectElem(obj: Scriptable, elem: Any?, cx: Context): Any?

obj[elem], giving undefined where the property is missing.

fun getObjectElem(obj: Any?, elem: Any?, cx: Context): Any?
fun getObjectElem(obj: Any?, elem: Any?, cx: Context, scope: Scriptable): Any?
Link copied to clipboard
fun getObjectIndex(obj: Scriptable, index: Int, cx: Context): Any?
fun getObjectIndex(obj: Any?, dblIndex: Double, cx: Context): Any?
fun getObjectIndex(obj: Any?, dblIndex: Double, cx: Context, scope: Scriptable): Any?
Link copied to clipboard
fun getObjectProp(obj: Scriptable, property: String, cx: Context): Any?
fun getObjectProp(obj: Any?, property: String, cx: Context): Any?
fun getObjectProp(obj: Any?, property: String, cx: Context, scope: Scriptable): Any?
Link copied to clipboard
fun getObjectPropNoWarn(obj: Any?, property: String, cx: Context): Any?
fun getObjectPropNoWarn(obj: Any?, property: String, cx: Context, scope: Scriptable): Any?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The regexp engine, built on first use. Upstream discovers it through a service loader so the regexp package can be left out of a build; there is one implementation here and no service loader in common Kotlin, so it is simply constructed (D-44).

Link copied to clipboard
fun getSuperElem(elem: Any?, superScriptable: Scriptable, thisScriptable: Scriptable): Any?
fun getSuperElem(superObject: Any?, elem: Any?, cx: Context, scope: Scriptable, thisObject: Any?): Any?
Link copied to clipboard
fun getSuperIndex(superObject: Any?, dblIndex: Double, cx: Context, scope: Scriptable, thisObject: Any?): Any?
Link copied to clipboard
fun getSuperProp(superObject: Any?, property: String, cx: Context, scope: Scriptable, thisObject: Any?, noWarn: Boolean): Any?
Link copied to clipboard
fun getTemplateLiteralCallSite(cx: Context, scope: Scriptable, strings: Array<Any?>, index: Int): Scriptable

The frozen strings object a tagged template passes to its tag, built once per call site.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun hasObjectElem(target: Scriptable, elem: Any?, cx: Context): Boolean
Link copied to clipboard
Link copied to clipboard
fun in(a: Any?, b: Any?, cx: Context): Boolean
Link copied to clipboard

If str is an array index, returns it as a value in 0..2^32-1. Otherwise returns -1. Leading zeroes and "-0" are not indexes.

Link copied to clipboard
fun initFunction(cx: Context, scope: Scriptable, function: JSFunction, type: Int, fromEvalCode: Boolean)

Puts a declared function into the scope it belongs to.

Link copied to clipboard
Link copied to clipboard
fun initScript(execObj: ScriptOrFn<*>, thisObj: Scriptable?, cx: Context, scope: Scriptable, evalScript: Boolean)

Puts a script's declared variables into scope before it runs.

Link copied to clipboard

Builds the global scope.

Link copied to clipboard
fun instanceOf(a: Any?, b: Any?, cx: Context): Boolean
Link copied to clipboard
Link copied to clipboard
fun isInt(value: Any?): Boolean

value is Int that stays true to its name on Kotlin/JS (D-32), where every number passes the is Int check. The extra test is free on the JVM, where an Int is always a whole number.

Link copied to clipboard
fun isIteratorDone(cx: Context, result: Any?): Boolean

True when an iterator result object says the iteration is over.

Link copied to clipboard
Link copied to clipboard
fun isNaN(n: Any?): Boolean
Link copied to clipboard
fun isObject(value: Any?): Boolean

True for what the spec calls an Object: everything except the primitives.

Link copied to clipboard
fun isPrimitive(obj: Any?): Boolean
Link copied to clipboard

Whether rhs is somewhere in lhs's prototype chain.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun leftShift(val1: Any?, val2: Any?): Any
fun leftShift(val1: Double, val2: Double): Double
Link copied to clipboard
fun loadFromIterable(cx: Context, scope: Scriptable, arg1: Any?, setter: (Any?, Any?) -> Unit): Boolean

Walks the iterable arg1 and hands each [key, value] pair to setter. Returns false when there is nothing to walk.

Link copied to clipboard
fun multiply(val1: Any?, val2: Any?): Any
fun multiply(i1: Int, i2: Int): Number
Link copied to clipboard
fun name(cx: Context, scope: Scriptable, name: String): Any?

Looks name up through the scope chain, the way a bare identifier does.

Link copied to clipboard
fun nameIncrDecr(scopeChain: Scriptable, id: String, incrDecrMask: Int): Any?
fun nameIncrDecr(scopeChainIn: Scriptable, id: String, cx: Context, incrDecrMask: Int): Any?
Link copied to clipboard
fun negate(value: Any?): Any
Link copied to clipboard
fun newArrayLiteral(objects: Array<Any?>, skipIndices: IntArray?, cx: Context, scope: Scriptable): Scriptable

Builds an array from a literal's values, with skipIndices naming the holes.

Link copied to clipboard
Link copied to clipboard
fun newCatchScope(t: Throwable, lastCatchScope: Scriptable?, exceptionName: String?, cx: Context, scope: Scriptable): Scriptable
Link copied to clipboard
fun newObject(cx: Context, scope: Scriptable, constructorName: String, args: Array<Any?>?): Scriptable
fun newObject(ctor: Any?, cx: Context, scope: Scriptable, args: Array<Any?>): Scriptable
Link copied to clipboard
fun newObjectLiteral(propertyIds: Array<Any?>?, propertyValues: Array<Any?>, getterSetters: IntArray?, cx: Context, scope: Scriptable): Scriptable
Link copied to clipboard
fun newSpecial(cx: Context, fun_: Any?, args: Array<Any?>, scope: Scriptable, callType: Int): Any?
Link copied to clipboard
Link copied to clipboard
fun notFunctionError(value: Any?, messageHelper: Any?): RuntimeException
fun notFunctionError(obj: Any?, value: Any?, propertyName: String): RuntimeException
Link copied to clipboard

Converts a number to its ECMAScript string form.

Link copied to clipboard
fun numericToDouble(value: Any?): Double

A number or a bigint, read as a double. This is what upstream got for free from Number.doubleValue() before bigints stopped being Number (D-54).

Link copied to clipboard
fun propIncrDecr(obj: Any?, id: String, cx: Context, incrDecrMask: Int): Any?
fun propIncrDecr(obj: Any?, id: String, cx: Context, scope: Scriptable, incrDecrMask: Int): Any?
Link copied to clipboard
fun rangeError(message: String): EcmaError
Link copied to clipboard
fun rangeErrorById(messageId: String, vararg args: Any?): EcmaError
Link copied to clipboard
fun refDel(ref: Ref, cx: Context): Any?
Link copied to clipboard
Link copied to clipboard
fun referenceErrorById(messageId: String, vararg args: Any?): EcmaError
Link copied to clipboard
fun refGet(ref: Ref, cx: Context): Any?
Link copied to clipboard
fun refIncrDecr(ref: Ref, cx: Context, incrDecrMask: Int): Any?
fun refIncrDecr(ref: Ref, cx: Context, scope: Scriptable, incrDecrMask: Int): Any?
Link copied to clipboard
fun refSet(ref: Ref, value: Any?, cx: Context): Any?
fun refSet(ref: Ref, value: Any?, cx: Context, scope: Scriptable): Any?
Link copied to clipboard
fun remainder(val1: Any?, val2: Any?): Any
Link copied to clipboard
fun same(x: Any?, y: Any?): Boolean

SameValue: Object.is. NaN equals NaN, and +0 and -0 differ.

Link copied to clipboard
fun sameZero(x: Any?, y: Any?): Boolean

SameValueZero: like same, but +0 and -0 are equal.

Link copied to clipboard
fun setConst(bound: Scriptable, value: Any?, cx: Context, id: String): Any?
Link copied to clipboard
fun setEnumNumbers(enumObj: Any?, enumNumbers: Boolean)

Makes the enumeration hand back Int indices rather than their string form.

Link copied to clipboard
fun setFunctionProtoAndParent(fn: BaseFunction, cx: Context?, scope: Scriptable, es6GeneratorFunction: Boolean = false)
Link copied to clipboard
fun setName(bound: Scriptable?, value: Any?, cx: Context, scope: Scriptable, id: String): Any?
Link copied to clipboard
fun setObjectElem(obj: Scriptable, elem: Any?, value: Any?, cx: Context): Any?
fun setObjectElem(obj: Any?, elem: Any?, value: Any?, cx: Context): Any?
fun setObjectElem(obj: Any?, elem: Any?, value: Any?, cx: Context, scope: Scriptable): Any?
Link copied to clipboard
fun setObjectIndex(obj: Scriptable, index: Int, value: Any?, cx: Context): Any?
fun setObjectIndex(obj: Any?, dblIndex: Double, value: Any?, cx: Context): Any?
fun setObjectIndex(obj: Any?, dblIndex: Double, value: Any?, cx: Context, scope: Scriptable): Any?
Link copied to clipboard
fun setObjectProp(obj: Scriptable, property: String, value: Any?, cx: Context): Any?
fun setObjectProp(obj: Any?, property: String, value: Any?, cx: Context): Any?
fun setObjectProp(obj: Any?, property: String, value: Any?, cx: Context, scope: Scriptable): Any?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun setSuperElem(superScriptable: Scriptable, thisScriptable: Scriptable, elem: Any?, value: Any?, cx: Context): Any?
fun setSuperElem(superObject: Any?, elem: Any?, value: Any?, cx: Context, scope: Scriptable, thisObject: Any?): Any?
Link copied to clipboard
fun setSuperIndex(superObject: Any?, dblIndex: Double, value: Any?, cx: Context, scope: Scriptable, thisObject: Any?): Any?
Link copied to clipboard
fun setSuperProp(superObject: Any?, property: String, value: Any?, cx: Context, scope: Scriptable, thisObject: Any?): Any?
Link copied to clipboard
fun shallowEq(x: Any?, y: Any?): Boolean

The === comparison. Numbers compare by value (so NaN is never equal to itself), strings by their characters, and everything else by identity.

Link copied to clipboard
fun signedRightShift(val1: Any?, val2: Any?): Any
Link copied to clipboard
fun specialRef(obj: Any?, specialProperty: String, cx: Context): Ref
fun specialRef(obj: Any?, specialProperty: String, cx: Context, scope: Scriptable): Ref
Link copied to clipboard
fun strictSetName(bound: Scriptable?, value: Any?, cx: Context, scope: Scriptable, id: String): Any?
Link copied to clipboard
fun subtract(val1: Any?, val2: Any?): Any
fun subtract(i1: Int, i2: Int): Number
Link copied to clipboard
Link copied to clipboard
fun syntaxErrorById(messageId: String, vararg args: Any?): EcmaError
Link copied to clipboard
fun throwCustomError(cx: Context, scope: Scriptable, constructorName: String, message: String): JavaScriptException

Throws an error of a named constructor found in scope, the way a builtin would build it.

Link copied to clipboard
fun toBigInt(value: Any?): KBigInt

ToBigInt. Until phase 5 only a bigint value or a plain decimal string can be converted (D-5).

Link copied to clipboard
fun toBoolean(value: Any?): Boolean

ToBoolean.

Link copied to clipboard
Link copied to clipboard
fun toIndex(value: Any?): Int

ToIndex: a non-negative integer that fits the safe range, or a RangeError.

Link copied to clipboard
fun toInt32(value: Any?): Int
fun toInt32(d: Double): Int
fun toInt32(args: Array<Any?>, index: Int): Int
Link copied to clipboard
fun toInteger(value: Any?): Double
fun toInteger(args: Array<Any?>, index: Int): Double

ECMAScript ToInteger: truncates toward zero, and maps NaN to positive zero.

Link copied to clipboard
Link copied to clipboard
fun toIterator(cx: Context, obj: Scriptable, keyOnly: Boolean): Scriptable?

The legacy __iterator__ protocol. Null when the object does not use it.

Link copied to clipboard
fun toLength(value: Any?): Long
fun toLength(args: Array<Any?>, index: Int): Long
Link copied to clipboard
fun toNumber(value: Any?): Double

ToNumber.

ECMAScript ToNumber for a string.

fun toNumber(args: Array<Any?>, index: Int): Double
Link copied to clipboard
fun toNumeric(value: Any?): Any

ToNumeric: a number or a bigint. Not Number, because a bigint is not one (D-54).

Link copied to clipboard
fun toObject(scope: Scriptable, value: Any?): Scriptable

fun toObject(cx: Context, scope: Scriptable, value: Any?): Scriptable

ToObject: wraps a primitive in its object, and refuses null and undefined.

Link copied to clipboard
Link copied to clipboard
fun toPrimitive(input: Any?, preferredType: KClass<*>? = null): Any?

ToPrimitive: turns an object into a primitive, asking Symbol.toPrimitive first and falling back to the object's own getDefaultValue.

Link copied to clipboard
fun toString(value: Any?): String

ToString: what String(value) gives.

fun toString(args: Array<Any?>, index: Int): String
Link copied to clipboard

Works out whether id names an array index or an ordinary property.

Link copied to clipboard
fun toUint16(value: Any?): Char

ToUint16: the low 16 bits of ToInt32, as a char.

Link copied to clipboard
fun toUint32(value: Any?): Long
Link copied to clipboard
fun typeError(message: String): EcmaError
Link copied to clipboard
fun typeErrorById(messageId: String, vararg args: Any?): EcmaError
Link copied to clipboard
Link copied to clipboard
fun typeOf(value: Any?): String

The result of the typeof operator.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun undefWriteError(obj: Any?, id: Any?, value: Any?): RuntimeException
Link copied to clipboard
Link copied to clipboard

Builds the script-visible error object for a Java-side exception. javaException and rhinoException are LiveConnect properties and are not ported.

Link copied to clipboard
fun wrapInt(i: Int): Int
Link copied to clipboard

Boxes a double, sharing one NaN.

Link copied to clipboard
fun wrapRegExp(cx: Context, scope: Scriptable, compiled: Any): Scriptable