Bug 1782273 - Part 29: Rewrap self-hosted code at 80 columns. r=tcampbell

Differential Revision: https://phabricator.services.mozilla.com/D153614
This commit is contained in:
André Bargull 2022-08-04 17:13:03 +00:00
parent 6b70286fc4
commit 539c3a8fca
26 changed files with 1772 additions and 364 deletions

View file

@ -281,7 +281,9 @@ function ArrayGroup(callbackfn /*, thisArg*/) {
* Let propertyKey be ? ToPropertyKey(
* ? Call(callbackfn, thisArg, « kValue, 𝔽(k), O »)).
*/
var propertyKey = TO_PROPERTY_KEY(callContentFunction(callbackfn, T, kValue, k, O));
var propertyKey = TO_PROPERTY_KEY(
callContentFunction(callbackfn, T, kValue, k, O)
);
/* Step 6.d. Perform ! AddValueToKeyedGroup(groups, propertyKey, kValue). */
if (!groups[propertyKey]) {
@ -440,7 +442,14 @@ function ArrayReduce(callbackfn /*, initialValue*/) {
/* Step b */
if (k in O) {
/* Step c. */
accumulator = callContentFunction(callbackfn, undefined, accumulator, O[k], k, O);
accumulator = callContentFunction(
callbackfn,
undefined,
accumulator,
O[k],
k,
O
);
}
}
@ -503,7 +512,14 @@ function ArrayReduceRight(callbackfn /*, initialValue*/) {
/* Step b */
if (k in O) {
/* Step c. */
accumulator = callContentFunction(callbackfn, undefined, accumulator, O[k], k, O);
accumulator = callContentFunction(
callbackfn,
undefined,
accumulator,
O[k],
k,
O
);
}
}
@ -591,20 +607,27 @@ function ArrayCopyWithin(target, start, end = undefined) {
// Step 4.
var to =
relativeTarget < 0 ? std_Math_max(len + relativeTarget, 0) : std_Math_min(relativeTarget, len);
relativeTarget < 0
? std_Math_max(len + relativeTarget, 0)
: std_Math_min(relativeTarget, len);
// Step 5.
var relativeStart = ToInteger(start);
// Step 6.
var from =
relativeStart < 0 ? std_Math_max(len + relativeStart, 0) : std_Math_min(relativeStart, len);
relativeStart < 0
? std_Math_max(len + relativeStart, 0)
: std_Math_min(relativeStart, len);
// Step 7.
var relativeEnd = end === undefined ? len : ToInteger(end);
// Step 8.
var final = relativeEnd < 0 ? std_Math_max(len + relativeEnd, 0) : std_Math_min(relativeEnd, len);
var final =
relativeEnd < 0
? std_Math_max(len + relativeEnd, 0)
: std_Math_min(relativeEnd, len);
// Step 9.
var count = std_Math_min(final - from, len - to);
@ -660,13 +683,18 @@ function ArrayFill(value, start = 0, end = undefined) {
// Step 4.
var k =
relativeStart < 0 ? std_Math_max(len + relativeStart, 0) : std_Math_min(relativeStart, len);
relativeStart < 0
? std_Math_max(len + relativeStart, 0)
: std_Math_min(relativeStart, len);
// Step 5.
var relativeEnd = end === undefined ? len : ToInteger(end);
// Step 6.
var final = relativeEnd < 0 ? std_Math_max(len + relativeEnd, 0) : std_Math_min(relativeEnd, len);
var final =
relativeEnd < 0
? std_Math_max(len + relativeEnd, 0)
: std_Math_min(relativeEnd, len);
// Step 7.
for (; k < final; k++) {
@ -693,7 +721,11 @@ function ArrayIteratorNext() {
// Step 1-3.
var obj = this;
if (!IsObject(obj) || (obj = GuardToArrayIterator(obj)) === null) {
return callFunction(CallArrayIteratorMethodIfWrapped, this, "ArrayIteratorNext");
return callFunction(
CallArrayIteratorMethodIfWrapped,
this,
"ArrayIteratorNext"
);
}
// Step 4.
@ -821,7 +853,9 @@ function ArrayFrom(items, mapfn = undefined, thisArg = undefined) {
*/
// Steps 5.e.vi-vii.
var mappedValue = mapping ? callContentFunction(mapfn, T, nextValue, k) : nextValue;
var mappedValue = mapping
? callContentFunction(mapfn, T, nextValue, k)
: nextValue;
// Steps 5.e.ii (reordered), 5.e.viii.
DefineDataProperty(A, k++, mappedValue);
@ -842,7 +876,9 @@ function ArrayFrom(items, mapfn = undefined, thisArg = undefined) {
var len = ToLength(arrayLike.length);
// Steps 12-14.
var A = IsConstructor(C) ? constructContentFunction(C, C, len) : std_Array(len);
var A = IsConstructor(C)
? constructContentFunction(C, C, len)
: std_Array(len);
// Steps 15-16.
for (var k = 0; k < len; k++) {
@ -850,7 +886,9 @@ function ArrayFrom(items, mapfn = undefined, thisArg = undefined) {
var kValue = items[k];
// Steps 16.d-e.
var mappedValue = mapping ? callContentFunction(mapfn, T, kValue, k) : kValue;
var mappedValue = mapping
? callContentFunction(mapfn, T, kValue, k)
: kValue;
// Steps 16.f-g.
DefineDataProperty(A, k, mappedValue);
@ -919,9 +957,18 @@ function ArrayToLocaleString(locales, options) {
R = "";
} else {
#if JS_HAS_INTL_API
R = ToString(callContentFunction(firstElement.toLocaleString, firstElement, locales, options));
R = ToString(
callContentFunction(
firstElement.toLocaleString,
firstElement,
locales,
options
)
);
#else
R = ToString(callContentFunction(firstElement.toLocaleString, firstElement));
R = ToString(
callContentFunction(firstElement.toLocaleString, firstElement)
);
#endif
}
@ -938,9 +985,18 @@ function ArrayToLocaleString(locales, options) {
R += separator;
if (!(nextElement === undefined || nextElement === null)) {
#if JS_HAS_INTL_API
R += ToString(callContentFunction(nextElement.toLocaleString, nextElement, locales, options));
R += ToString(
callContentFunction(
nextElement.toLocaleString,
nextElement,
locales,
options
)
);
#else
R += ToString(callContentFunction(nextElement.toLocaleString, nextElement));
R += ToString(
callContentFunction(nextElement.toLocaleString, nextElement)
);
#endif
}
}
@ -1184,7 +1240,15 @@ function ArrayFlat(/* depth */) {
// ES2020 draft rev dc1e21c454bd316810be1c0e7af0131a2d7f38e9
// 22.1.3.10.1 FlattenIntoArray ( target, source, sourceLen, start, depth [ , mapperFunction, thisArg ] )
function FlattenIntoArray(target, source, sourceLen, start, depth, mapperFunction, thisArg) {
function FlattenIntoArray(
target,
source,
sourceLen,
start,
depth,
mapperFunction,
thisArg
) {
// Step 1.
var targetIndex = start;
@ -1200,7 +1264,13 @@ function FlattenIntoArray(target, source, sourceLen, start, depth, mapperFunctio
assert(arguments.length === 7, "thisArg is present");
// Step 3.c.ii.2.
element = callContentFunction(mapperFunction, thisArg, element, sourceIndex, source);
element = callContentFunction(
mapperFunction,
thisArg,
element,
sourceIndex,
source
);
}
// Step 3.c.iii.
@ -1218,7 +1288,13 @@ function FlattenIntoArray(target, source, sourceLen, start, depth, mapperFunctio
var elementLen = ToLength(element.length);
// Step 3.c.v.2.
targetIndex = FlattenIntoArray(target, element, elementLen, targetIndex, depth - 1);
targetIndex = FlattenIntoArray(
target,
element,
elementLen,
targetIndex,
depth - 1
);
} else {
// Step 3.c.vi.1.
if (targetIndex >= MAX_NUMERIC_INDEX) {

View file

@ -93,7 +93,10 @@ function AsyncIteratorHelperNext(value) {
"AsyncIteratorHelperNext"
);
}
const generator = UnsafeGetReservedSlot(O, ASYNC_ITERATOR_HELPER_GENERATOR_SLOT);
const generator = UnsafeGetReservedSlot(
O,
ASYNC_ITERATOR_HELPER_GENERATOR_SLOT
);
return callFunction(IntrinsicAsyncGeneratorNext, generator, value);
}
@ -107,7 +110,10 @@ function AsyncIteratorHelperReturn(value) {
"AsyncIteratorHelperReturn"
);
}
const generator = UnsafeGetReservedSlot(O, ASYNC_ITERATOR_HELPER_GENERATOR_SLOT);
const generator = UnsafeGetReservedSlot(
O,
ASYNC_ITERATOR_HELPER_GENERATOR_SLOT
);
return callFunction(IntrinsicAsyncGeneratorReturn, generator, value);
}
@ -121,7 +127,10 @@ function AsyncIteratorHelperThrow(value) {
"AsyncIteratorHelperThrow"
);
}
const generator = UnsafeGetReservedSlot(O, ASYNC_ITERATOR_HELPER_GENERATOR_SLOT);
const generator = UnsafeGetReservedSlot(
O,
ASYNC_ITERATOR_HELPER_GENERATOR_SLOT
);
return callFunction(IntrinsicAsyncGeneratorThrow, generator, value);
}
@ -144,7 +153,11 @@ function AsyncIteratorMap(mapper) {
const iteratorHelper = NewAsyncIteratorHelper();
const generator = AsyncIteratorMapGenerator(iterated, mapper);
callFunction(IntrinsicAsyncGeneratorNext, generator);
UnsafeSetReservedSlot(iteratorHelper, ASYNC_ITERATOR_HELPER_GENERATOR_SLOT, generator);
UnsafeSetReservedSlot(
iteratorHelper,
ASYNC_ITERATOR_HELPER_GENERATOR_SLOT,
generator
);
return iteratorHelper;
}
@ -191,7 +204,11 @@ function AsyncIteratorFilter(filterer) {
const iteratorHelper = NewAsyncIteratorHelper();
const generator = AsyncIteratorFilterGenerator(iterated, filterer);
callFunction(IntrinsicAsyncGeneratorNext, generator);
UnsafeSetReservedSlot(iteratorHelper, ASYNC_ITERATOR_HELPER_GENERATOR_SLOT, generator);
UnsafeSetReservedSlot(
iteratorHelper,
ASYNC_ITERATOR_HELPER_GENERATOR_SLOT,
generator
);
return iteratorHelper;
}
@ -242,7 +259,11 @@ function AsyncIteratorTake(limit) {
const iteratorHelper = NewAsyncIteratorHelper();
const generator = AsyncIteratorTakeGenerator(iterated, remaining);
callFunction(IntrinsicAsyncGeneratorNext, generator);
UnsafeSetReservedSlot(iteratorHelper, ASYNC_ITERATOR_HELPER_GENERATOR_SLOT, generator);
UnsafeSetReservedSlot(
iteratorHelper,
ASYNC_ITERATOR_HELPER_GENERATOR_SLOT,
generator
);
return iteratorHelper;
}
@ -292,7 +313,11 @@ function AsyncIteratorDrop(limit) {
const iteratorHelper = NewAsyncIteratorHelper();
const generator = AsyncIteratorDropGenerator(iterated, remaining);
callFunction(IntrinsicAsyncGeneratorNext, generator);
UnsafeSetReservedSlot(iteratorHelper, ASYNC_ITERATOR_HELPER_GENERATOR_SLOT, generator);
UnsafeSetReservedSlot(
iteratorHelper,
ASYNC_ITERATOR_HELPER_GENERATOR_SLOT,
generator
);
return iteratorHelper;
}
@ -341,7 +366,11 @@ function AsyncIteratorAsIndexedPairs() {
const iteratorHelper = NewAsyncIteratorHelper();
const generator = AsyncIteratorAsIndexedPairsGenerator(iterated);
callFunction(IntrinsicAsyncGeneratorNext, generator);
UnsafeSetReservedSlot(iteratorHelper, ASYNC_ITERATOR_HELPER_GENERATOR_SLOT, generator);
UnsafeSetReservedSlot(
iteratorHelper,
ASYNC_ITERATOR_HELPER_GENERATOR_SLOT,
generator
);
return iteratorHelper;
}
@ -387,7 +416,11 @@ function AsyncIteratorFlatMap(mapper) {
const iteratorHelper = NewAsyncIteratorHelper();
const generator = AsyncIteratorFlatMapGenerator(iterated, mapper);
callFunction(IntrinsicAsyncGeneratorNext, generator);
UnsafeSetReservedSlot(iteratorHelper, ASYNC_ITERATOR_HELPER_GENERATOR_SLOT, generator);
UnsafeSetReservedSlot(
iteratorHelper,
ASYNC_ITERATOR_HELPER_GENERATOR_SLOT,
generator
);
return iteratorHelper;
}
@ -399,7 +432,11 @@ async function* AsyncIteratorFlatMapGenerator(iterated, mapper) {
needClose = false;
// Step 1.
for (let next = await IteratorNext(iterated); !next.done; next = await IteratorNext(iterated)) {
for (
let next = await IteratorNext(iterated);
!next.done;
next = await IteratorNext(iterated)
) {
// Step c.
const value = next.value;
@ -451,7 +488,12 @@ async function AsyncIteratorReduce(reducer /*, initialValue*/) {
// Step 5.
for await (const value of allowContentIter(iterated)) {
// Steps d-h.
accumulator = await callContentFunction(reducer, undefined, accumulator, value);
accumulator = await callContentFunction(
reducer,
undefined,
accumulator,
value
);
}
// Step 5b.
return accumulator;

View file

@ -44,7 +44,9 @@ var dateTimeFormatCache = new_Record();
*/
function GetCachedFormat(format, required, defaults) {
assert(
format === "dateTimeFormat" || format === "dateFormat" || format === "timeFormat",
format === "dateTimeFormat" ||
format === "dateFormat" ||
format === "timeFormat",
"unexpected format key: please update the comment by dateTimeFormatCache"
);

View file

@ -134,30 +134,80 @@ function bind_bindFunction1(fun, thisArg, boundArgs) {
case 0:
return constructContentFunction(fun, newTarget, bound1);
case 1:
return constructContentFunction(fun, newTarget, bound1, SPREAD(arguments, 1));
return constructContentFunction(
fun,
newTarget,
bound1,
SPREAD(arguments, 1)
);
case 2:
return constructContentFunction(fun, newTarget, bound1, SPREAD(arguments, 2));
return constructContentFunction(
fun,
newTarget,
bound1,
SPREAD(arguments, 2)
);
case 3:
return constructContentFunction(fun, newTarget, bound1, SPREAD(arguments, 3));
return constructContentFunction(
fun,
newTarget,
bound1,
SPREAD(arguments, 3)
);
case 4:
return constructContentFunction(fun, newTarget, bound1, SPREAD(arguments, 4));
return constructContentFunction(
fun,
newTarget,
bound1,
SPREAD(arguments, 4)
);
case 5:
return constructContentFunction(fun, newTarget, bound1, SPREAD(arguments, 5));
return constructContentFunction(
fun,
newTarget,
bound1,
SPREAD(arguments, 5)
);
}
} else {
switch (arguments.length) {
case 0:
return callContentFunction(fun, thisArg, bound1);
case 1:
return callContentFunction(fun, thisArg, bound1, SPREAD(arguments, 1));
return callContentFunction(
fun,
thisArg,
bound1,
SPREAD(arguments, 1)
);
case 2:
return callContentFunction(fun, thisArg, bound1, SPREAD(arguments, 2));
return callContentFunction(
fun,
thisArg,
bound1,
SPREAD(arguments, 2)
);
case 3:
return callContentFunction(fun, thisArg, bound1, SPREAD(arguments, 3));
return callContentFunction(
fun,
thisArg,
bound1,
SPREAD(arguments, 3)
);
case 4:
return callContentFunction(fun, thisArg, bound1, SPREAD(arguments, 4));
return callContentFunction(
fun,
thisArg,
bound1,
SPREAD(arguments, 4)
);
case 5:
return callContentFunction(fun, thisArg, bound1, SPREAD(arguments, 5));
return callContentFunction(
fun,
thisArg,
bound1,
SPREAD(arguments, 5)
);
}
}
@ -202,30 +252,90 @@ function bind_bindFunction2(fun, thisArg, boundArgs) {
case 0:
return constructContentFunction(fun, newTarget, bound1, bound2);
case 1:
return constructContentFunction(fun, newTarget, bound1, bound2, SPREAD(arguments, 1));
return constructContentFunction(
fun,
newTarget,
bound1,
bound2,
SPREAD(arguments, 1)
);
case 2:
return constructContentFunction(fun, newTarget, bound1, bound2, SPREAD(arguments, 2));
return constructContentFunction(
fun,
newTarget,
bound1,
bound2,
SPREAD(arguments, 2)
);
case 3:
return constructContentFunction(fun, newTarget, bound1, bound2, SPREAD(arguments, 3));
return constructContentFunction(
fun,
newTarget,
bound1,
bound2,
SPREAD(arguments, 3)
);
case 4:
return constructContentFunction(fun, newTarget, bound1, bound2, SPREAD(arguments, 4));
return constructContentFunction(
fun,
newTarget,
bound1,
bound2,
SPREAD(arguments, 4)
);
case 5:
return constructContentFunction(fun, newTarget, bound1, bound2, SPREAD(arguments, 5));
return constructContentFunction(
fun,
newTarget,
bound1,
bound2,
SPREAD(arguments, 5)
);
}
} else {
switch (arguments.length) {
case 0:
return callContentFunction(fun, thisArg, bound1, bound2);
case 1:
return callContentFunction(fun, thisArg, bound1, bound2, SPREAD(arguments, 1));
return callContentFunction(
fun,
thisArg,
bound1,
bound2,
SPREAD(arguments, 1)
);
case 2:
return callContentFunction(fun, thisArg, bound1, bound2, SPREAD(arguments, 2));
return callContentFunction(
fun,
thisArg,
bound1,
bound2,
SPREAD(arguments, 2)
);
case 3:
return callContentFunction(fun, thisArg, bound1, bound2, SPREAD(arguments, 3));
return callContentFunction(
fun,
thisArg,
bound1,
bound2,
SPREAD(arguments, 3)
);
case 4:
return callContentFunction(fun, thisArg, bound1, bound2, SPREAD(arguments, 4));
return callContentFunction(
fun,
thisArg,
bound1,
bound2,
SPREAD(arguments, 4)
);
case 5:
return callContentFunction(fun, thisArg, bound1, bound2, SPREAD(arguments, 5));
return callContentFunction(
fun,
thisArg,
bound1,
bound2,
SPREAD(arguments, 5)
);
}
}
@ -251,7 +361,10 @@ function bind_bindFunction2(fun, thisArg, boundArgs) {
}
function bind_bindFunctionN(fun, thisArg, boundArgs) {
assert(boundArgs.length > 2, "Fast paths should be used for few-bound-args cases.");
assert(
boundArgs.length > 2,
"Fast paths should be used for few-bound-args cases."
);
var combiner = null;
return function $bound() {
var newTarget;

View file

@ -9,7 +9,12 @@ function GeneratorNext(val) {
if (!IsSuspendedGenerator(this)) {
if (!IsObject(this) || !IsGeneratorObject(this)) {
return callFunction(CallGeneratorMethodIfWrapped, this, val, "GeneratorNext");
return callFunction(
CallGeneratorMethodIfWrapped,
this,
val,
"GeneratorNext"
);
}
if (GeneratorObjectIsClosed(this)) {
@ -34,7 +39,12 @@ function GeneratorNext(val) {
function GeneratorThrow(val) {
if (!IsSuspendedGenerator(this)) {
if (!IsObject(this) || !IsGeneratorObject(this)) {
return callFunction(CallGeneratorMethodIfWrapped, this, val, "GeneratorThrow");
return callFunction(
CallGeneratorMethodIfWrapped,
this,
val,
"GeneratorThrow"
);
}
if (GeneratorObjectIsClosed(this)) {
@ -59,7 +69,12 @@ function GeneratorThrow(val) {
function GeneratorReturn(val) {
if (!IsSuspendedGenerator(this)) {
if (!IsObject(this) || !IsGeneratorObject(this)) {
return callFunction(CallGeneratorMethodIfWrapped, this, val, "GeneratorReturn");
return callFunction(
CallGeneratorMethodIfWrapped,
this,
val,
"GeneratorReturn"
);
}
if (GeneratorObjectIsClosed(this)) {

View file

@ -12,7 +12,11 @@ function IteratorNext(iteratorRecord, value) {
const result =
arguments.length < 2
? callContentFunction(iteratorRecord.nextMethod, iteratorRecord.iterator)
: callContentFunction(iteratorRecord.nextMethod, iteratorRecord.iterator, value);
: callContentFunction(
iteratorRecord.nextMethod,
iteratorRecord.iterator,
value
);
// Step 3.
if (!IsObject(result)) {
ThrowTypeError(JSMSG_OBJECT_REQUIRED, result);
@ -133,9 +137,16 @@ function IteratorStep(iteratorRecord, value) {
// Steps 2-3.
let result;
if (arguments.length === 2) {
result = callContentFunction(iteratorRecord.nextMethod, iteratorRecord.iterator, value);
result = callContentFunction(
iteratorRecord.nextMethod,
iteratorRecord.iterator,
value
);
} else {
result = callContentFunction(iteratorRecord.nextMethod, iteratorRecord.iterator);
result = callContentFunction(
iteratorRecord.nextMethod,
iteratorRecord.iterator
);
}
// IteratorNext Step 3.
@ -271,7 +282,12 @@ function WrapForValidIteratorThrow(value) {
function IteratorHelperNext(value) {
let O = this;
if (!IsObject(O) || (O = GuardToIteratorHelper(O)) === null) {
return callFunction(CallIteratorHelperMethodIfWrapped, this, value, "IteratorHelperNext");
return callFunction(
CallIteratorHelperMethodIfWrapped,
this,
value,
"IteratorHelperNext"
);
}
const generator = UnsafeGetReservedSlot(O, ITERATOR_HELPER_GENERATOR_SLOT);
return callContentFunction(GeneratorNext, generator, value);
@ -280,7 +296,12 @@ function IteratorHelperNext(value) {
function IteratorHelperReturn(value) {
let O = this;
if (!IsObject(O) || (O = GuardToIteratorHelper(O)) === null) {
return callFunction(CallIteratorHelperMethodIfWrapped, this, value, "IteratorHelperReturn");
return callFunction(
CallIteratorHelperMethodIfWrapped,
this,
value,
"IteratorHelperReturn"
);
}
const generator = UnsafeGetReservedSlot(O, ITERATOR_HELPER_GENERATOR_SLOT);
return callContentFunction(GeneratorReturn, generator, value);
@ -289,7 +310,12 @@ function IteratorHelperReturn(value) {
function IteratorHelperThrow(value) {
let O = this;
if (!IsObject(O) || (O = GuardToIteratorHelper(O)) === null) {
return callFunction(CallIteratorHelperMethodIfWrapped, this, value, "IteratorHelperThrow");
return callFunction(
CallIteratorHelperMethodIfWrapped,
this,
value,
"IteratorHelperThrow"
);
}
const generator = UnsafeGetReservedSlot(O, ITERATOR_HELPER_GENERATOR_SLOT);
return callContentFunction(GeneratorThrow, generator, value);
@ -334,7 +360,11 @@ function IteratorMap(mapper) {
const iteratorHelper = NewIteratorHelper();
const generator = IteratorMapGenerator(iterated, mapper);
callContentFunction(GeneratorNext, generator);
UnsafeSetReservedSlot(iteratorHelper, ITERATOR_HELPER_GENERATOR_SLOT, generator);
UnsafeSetReservedSlot(
iteratorHelper,
ITERATOR_HELPER_GENERATOR_SLOT,
generator
);
return iteratorHelper;
}
@ -381,7 +411,11 @@ function IteratorFilter(filterer) {
const iteratorHelper = NewIteratorHelper();
const generator = IteratorFilterGenerator(iterated, filterer);
callContentFunction(GeneratorNext, generator);
UnsafeSetReservedSlot(iteratorHelper, ITERATOR_HELPER_GENERATOR_SLOT, generator);
UnsafeSetReservedSlot(
iteratorHelper,
ITERATOR_HELPER_GENERATOR_SLOT,
generator
);
return iteratorHelper;
}
@ -432,7 +466,11 @@ function IteratorTake(limit) {
const iteratorHelper = NewIteratorHelper();
const generator = IteratorTakeGenerator(iterated, remaining);
callContentFunction(GeneratorNext, generator);
UnsafeSetReservedSlot(iteratorHelper, ITERATOR_HELPER_GENERATOR_SLOT, generator);
UnsafeSetReservedSlot(
iteratorHelper,
ITERATOR_HELPER_GENERATOR_SLOT,
generator
);
return iteratorHelper;
}
@ -481,7 +519,11 @@ function IteratorDrop(limit) {
const iteratorHelper = NewIteratorHelper();
const generator = IteratorDropGenerator(iterated, remaining);
callContentFunction(GeneratorNext, generator);
UnsafeSetReservedSlot(iteratorHelper, ITERATOR_HELPER_GENERATOR_SLOT, generator);
UnsafeSetReservedSlot(
iteratorHelper,
ITERATOR_HELPER_GENERATOR_SLOT,
generator
);
return iteratorHelper;
}
@ -529,7 +571,11 @@ function IteratorAsIndexedPairs() {
const iteratorHelper = NewIteratorHelper();
const generator = IteratorAsIndexedPairsGenerator(iterated);
callContentFunction(GeneratorNext, generator);
UnsafeSetReservedSlot(iteratorHelper, ITERATOR_HELPER_GENERATOR_SLOT, generator);
UnsafeSetReservedSlot(
iteratorHelper,
ITERATOR_HELPER_GENERATOR_SLOT,
generator
);
return iteratorHelper;
}
@ -575,7 +621,11 @@ function IteratorFlatMap(mapper) {
const iteratorHelper = NewIteratorHelper();
const generator = IteratorFlatMapGenerator(iterated, mapper);
callContentFunction(GeneratorNext, generator);
UnsafeSetReservedSlot(iteratorHelper, ITERATOR_HELPER_GENERATOR_SLOT, generator);
UnsafeSetReservedSlot(
iteratorHelper,
ITERATOR_HELPER_GENERATOR_SLOT,
generator
);
return iteratorHelper;
}
@ -587,7 +637,11 @@ function* IteratorFlatMapGenerator(iterated, mapper) {
yield;
needClose = false;
for (let next = IteratorStep(iterated); next; next = IteratorStep(iterated)) {
for (
let next = IteratorStep(iterated);
next;
next = IteratorStep(iterated)
) {
// Step c.
const value = next.value;

View file

@ -35,7 +35,13 @@ function MapForEach(callbackfn, thisArg = undefined) {
// Steps 2-3.
if (!IsObject(M) || (M = GuardToMapObject(M)) === null) {
return callFunction(CallMapMethodIfWrapped, this, callbackfn, thisArg, "MapForEach");
return callFunction(
CallMapMethodIfWrapped,
this,
callbackfn,
thisArg,
"MapForEach"
);
}
// Step 4.
@ -75,7 +81,11 @@ function MapIteratorNext() {
// Steps 2-3.
if (!IsObject(O) || (O = GuardToMapIterator(O)) === null) {
return callFunction(CallMapIteratorMethodIfWrapped, this, "MapIteratorNext");
return callFunction(
CallMapIteratorMethodIfWrapped,
this,
"MapIteratorNext"
);
}
// Steps 4-5 (implemented in GetNextMapEntryForIterator).

View file

@ -213,7 +213,10 @@ function ObjectGetOwnPropertyDescriptor(obj, propertyKey) {
}
// 6.2.4.4 FromPropertyDescriptor, steps 2-3, 6-11.
assert(attrsAndKind & ACCESSOR_DESCRIPTOR_KIND, "expected accessor property descriptor");
assert(
attrsAndKind & ACCESSOR_DESCRIPTOR_KIND,
"expected accessor property descriptor"
);
return {
get: desc[PROP_DESC_GETTER_INDEX],
set: desc[PROP_DESC_SETTER_INDEX],

View file

@ -8,7 +8,10 @@ function CreateListFromArrayLikeForArgs(obj) {
// Step 1 (not applicable).
// Step 2.
assert(IsObject(obj), "object must be passed to CreateListFromArrayLikeForArgs");
assert(
IsObject(obj),
"object must be passed to CreateListFromArrayLikeForArgs"
);
// Step 3.
var len = ToLength(obj.length);
@ -143,7 +146,12 @@ function Reflect_getOwnPropertyDescriptor(target, propertyKey) {
function Reflect_has(target, propertyKey) {
// Step 1.
if (!IsObject(target)) {
ThrowTypeError(JSMSG_OBJECT_REQUIRED_ARG, "`target`", "Reflect.has", ToSource(target));
ThrowTypeError(
JSMSG_OBJECT_REQUIRED_ARG,
"`target`",
"Reflect.has",
ToSource(target)
);
}
// Steps 2-3 are identical to the runtime semantics of the "in" operator.
@ -155,7 +163,12 @@ function Reflect_has(target, propertyKey) {
function Reflect_get(target, propertyKey /*, receiver*/) {
// Step 1.
if (!IsObject(target)) {
ThrowTypeError(JSMSG_OBJECT_REQUIRED_ARG, "`target`", "Reflect.get", ToSource(target));
ThrowTypeError(
JSMSG_OBJECT_REQUIRED_ARG,
"`target`",
"Reflect.get",
ToSource(target)
);
}
// Step 3 (reordered).

View file

@ -83,7 +83,10 @@ function AdvanceStringIndex(S, index) {
assert(typeof S === "string", "Expected string as 1st argument");
// Step 2.
assert(index >= 0 && index <= MAX_NUMERIC_INDEX, "Expected integer as 2nd argument");
assert(
index >= 0 && index <= MAX_NUMERIC_INDEX,
"Expected integer as 2nd argument"
);
// Step 3 (skipped).
@ -191,7 +194,9 @@ function RegExpMatchSlowPath(rx, S) {
// Step 6.e.iii.4.
if (matchStr === "") {
var lastIndex = ToLength(rx.lastIndex);
rx.lastIndex = fullUnicode ? AdvanceStringIndex(S, lastIndex) : lastIndex + 1;
rx.lastIndex = fullUnicode
? AdvanceStringIndex(S, lastIndex)
: lastIndex + 1;
}
// Step 6.e.iii.5.
@ -235,7 +240,9 @@ function RegExpGlobalMatchOpt(rx, S, fullUnicode) {
// Step 6.e.iii.4.
if (matchStr === "") {
lastIndex = fullUnicode ? AdvanceStringIndex(S, lastIndex) : lastIndex + 1;
lastIndex = fullUnicode
? AdvanceStringIndex(S, lastIndex)
: lastIndex + 1;
if (lastIndex > lengthS) {
return A;
}
@ -321,13 +328,27 @@ function RegExpReplace(string, replaceValue) {
if (lengthS > 5000) {
var elemBase = GetElemBaseForLambda(replaceValue);
if (IsObject(elemBase)) {
return RegExpGlobalReplaceOptElemBase(rx, S, lengthS, replaceValue, flags, elemBase);
return RegExpGlobalReplaceOptElemBase(
rx,
S,
lengthS,
replaceValue,
flags,
elemBase
);
}
}
return RegExpGlobalReplaceOptFunc(rx, S, lengthS, replaceValue, flags);
}
if (firstDollarIndex !== -1) {
return RegExpGlobalReplaceOptSubst(rx, S, lengthS, replaceValue, flags, firstDollarIndex);
return RegExpGlobalReplaceOptSubst(
rx,
S,
lengthS,
replaceValue,
flags,
firstDollarIndex
);
}
if (lengthS < 0x7fff) {
return RegExpGlobalReplaceShortOpt(rx, S, lengthS, replaceValue, flags);
@ -339,7 +360,13 @@ function RegExpReplace(string, replaceValue) {
return RegExpLocalReplaceOptFunc(rx, S, lengthS, replaceValue);
}
if (firstDollarIndex !== -1) {
return RegExpLocalReplaceOptSubst(rx, S, lengthS, replaceValue, firstDollarIndex);
return RegExpLocalReplaceOptSubst(
rx,
S,
lengthS,
replaceValue,
firstDollarIndex
);
}
if (lengthS < 0x7fff) {
return RegExpLocalReplaceOptShort(rx, S, lengthS, replaceValue);
@ -348,13 +375,27 @@ function RegExpReplace(string, replaceValue) {
}
// Steps 8-16.
return RegExpReplaceSlowPath(rx, S, lengthS, replaceValue, functionalReplace, firstDollarIndex);
return RegExpReplaceSlowPath(
rx,
S,
lengthS,
replaceValue,
functionalReplace,
firstDollarIndex
);
}
// ES 2017 draft rev 03bfda119d060aca4099d2b77cf43f6d4f11cfa2 21.2.5.8
// steps 7-16.
// Slow path for @@replace.
function RegExpReplaceSlowPath(rx, S, lengthS, replaceValue, functionalReplace, firstDollarIndex) {
function RegExpReplaceSlowPath(
rx,
S,
lengthS,
replaceValue,
functionalReplace,
firstDollarIndex
) {
// Step 7.
var global = !!rx.global;
@ -396,7 +437,9 @@ function RegExpReplaceSlowPath(rx, S, lengthS, replaceValue, functionalReplace,
// Step 11.c.iii.2.
if (matchStr === "") {
var lastIndex = ToLength(rx.lastIndex);
rx.lastIndex = fullUnicode ? AdvanceStringIndex(S, lastIndex) : lastIndex + 1;
rx.lastIndex = fullUnicode
? AdvanceStringIndex(S, lastIndex)
: lastIndex + 1;
}
}
@ -420,7 +463,10 @@ function RegExpReplaceSlowPath(rx, S, lengthS, replaceValue, functionalReplace,
var matchLength = matched.length;
// Steps 14.e-f.
var position = std_Math_max(std_Math_min(ToInteger(result.index), lengthS), 0);
var position = std_Math_max(
std_Math_min(ToInteger(result.index), lengthS),
0
);
var n, capN, replacement;
if (functionalReplace || firstDollarIndex !== -1) {
@ -461,7 +507,8 @@ function RegExpReplaceSlowPath(rx, S, lengthS, replaceValue, functionalReplace,
if (position >= nextSourcePosition) {
// Step 14.m.ii.
accumulatedResult +=
Substring(S, nextSourcePosition, position - nextSourcePosition) + replacement;
Substring(S, nextSourcePosition, position - nextSourcePosition) +
replacement;
// Step 14.m.iii.
nextSourcePosition = position + matchLength;
@ -474,7 +521,10 @@ function RegExpReplaceSlowPath(rx, S, lengthS, replaceValue, functionalReplace,
}
// Step 16.
return accumulatedResult + Substring(S, nextSourcePosition, lengthS - nextSourcePosition);
return (
accumulatedResult +
Substring(S, nextSourcePosition, lengthS - nextSourcePosition)
);
}
// ES 2021 draft 21.2.5.10
@ -525,23 +575,53 @@ function RegExpGetComplexReplacement(
switch (nCaptures) {
case 0:
return ToString(
callContentFunction(replaceValue, undefined, SPREAD(captures, 1), position, S)
callContentFunction(
replaceValue,
undefined,
SPREAD(captures, 1),
position,
S
)
);
case 1:
return ToString(
callContentFunction(replaceValue, undefined, SPREAD(captures, 2), position, S)
callContentFunction(
replaceValue,
undefined,
SPREAD(captures, 2),
position,
S
)
);
case 2:
return ToString(
callContentFunction(replaceValue, undefined, SPREAD(captures, 3), position, S)
callContentFunction(
replaceValue,
undefined,
SPREAD(captures, 3),
position,
S
)
);
case 3:
return ToString(
callContentFunction(replaceValue, undefined, SPREAD(captures, 4), position, S)
callContentFunction(
replaceValue,
undefined,
SPREAD(captures, 4),
position,
S
)
);
case 4:
return ToString(
callContentFunction(replaceValue, undefined, SPREAD(captures, 5), position, S)
callContentFunction(
replaceValue,
undefined,
SPREAD(captures, 5),
position,
S
)
);
}
}
@ -551,7 +631,9 @@ function RegExpGetComplexReplacement(
if (namedCaptures !== undefined) {
DefineDataProperty(captures, capturesLength++, namedCaptures);
}
return ToString(callFunction(std_Function_apply, replaceValue, undefined, captures));
return ToString(
callFunction(std_Function_apply, replaceValue, undefined, captures)
);
}
// Step 14.l.
@ -589,23 +671,53 @@ function RegExpGetFunctionalReplacement(result, S, position, replaceValue) {
switch (nCaptures) {
case 0:
return ToString(
callContentFunction(replaceValue, undefined, SPREAD(result, 1), position, S)
callContentFunction(
replaceValue,
undefined,
SPREAD(result, 1),
position,
S
)
);
case 1:
return ToString(
callContentFunction(replaceValue, undefined, SPREAD(result, 2), position, S)
callContentFunction(
replaceValue,
undefined,
SPREAD(result, 2),
position,
S
)
);
case 2:
return ToString(
callContentFunction(replaceValue, undefined, SPREAD(result, 3), position, S)
callContentFunction(
replaceValue,
undefined,
SPREAD(result, 3),
position,
S
)
);
case 3:
return ToString(
callContentFunction(replaceValue, undefined, SPREAD(result, 4), position, S)
callContentFunction(
replaceValue,
undefined,
SPREAD(result, 4),
position,
S
)
);
case 4:
return ToString(
callContentFunction(replaceValue, undefined, SPREAD(result, 5), position, S)
callContentFunction(
replaceValue,
undefined,
SPREAD(result, 5),
position,
S
)
);
}
}
@ -630,7 +742,9 @@ function RegExpGetFunctionalReplacement(result, S, position, replaceValue) {
}
// Steps 14.k.v-vi.
return ToString(callFunction(std_Function_apply, replaceValue, undefined, captures));
return ToString(
callFunction(std_Function_apply, replaceValue, undefined, captures)
);
}
// ES 2017 draft rev 03bfda119d060aca4099d2b77cf43f6d4f11cfa2 21.2.5.8
@ -668,14 +782,17 @@ function RegExpGlobalReplaceShortOpt(rx, S, lengthS, replaceValue, flags) {
// Step 14.l.ii.
accumulatedResult +=
Substring(S, nextSourcePosition, position - nextSourcePosition) + replaceValue;
Substring(S, nextSourcePosition, position - nextSourcePosition) +
replaceValue;
// Step 14.l.iii.
nextSourcePosition = lastIndex;
// Step 11.c.iii.2.
if (lastIndex === position) {
lastIndex = fullUnicode ? AdvanceStringIndex(S, lastIndex) : lastIndex + 1;
lastIndex = fullUnicode
? AdvanceStringIndex(S, lastIndex)
: lastIndex + 1;
if (lastIndex > lengthS) {
break;
}
@ -688,7 +805,10 @@ function RegExpGlobalReplaceShortOpt(rx, S, lengthS, replaceValue, flags) {
}
// Step 16.
return accumulatedResult + Substring(S, nextSourcePosition, lengthS - nextSourcePosition);
return (
accumulatedResult +
Substring(S, nextSourcePosition, lengthS - nextSourcePosition)
);
}
// ES 2017 draft rev 03bfda119d060aca4099d2b77cf43f6d4f11cfa2 21.2.5.8
@ -886,7 +1006,8 @@ function RegExpSplit(string, limit) {
var C = SpeciesConstructor(rx, GetBuiltinConstructor("RegExp"));
var optimizable =
IsRegExpSplitOptimizable(rx, C) && (limit === undefined || typeof limit == "number");
IsRegExpSplitOptimizable(rx, C) &&
(limit === undefined || typeof limit == "number");
var flags, unicodeMatching, splitter;
if (optimizable) {
@ -1077,7 +1198,12 @@ function RegExp_prototype_Exec(string) {
// Steps 1-3.
var R = this;
if (!IsObject(R) || !IsRegExpObject(R)) {
return callFunction(CallRegExpMethodIfWrapped, R, string, "RegExp_prototype_Exec");
return callFunction(
CallRegExpMethodIfWrapped,
R,
string,
"RegExp_prototype_Exec"
);
}
// Steps 4-5.
@ -1188,7 +1314,13 @@ function RegExpBuiltinExec(R, S, forTest) {
}
function UnwrapAndCallRegExpBuiltinExec(R, S, forTest) {
return callFunction(CallRegExpMethodIfWrapped, R, S, forTest, "CallRegExpBuiltinExec");
return callFunction(
CallRegExpMethodIfWrapped,
R,
S,
forTest,
"CallRegExpBuiltinExec"
);
}
function CallRegExpBuiltinExec(S, forTest) {
@ -1228,7 +1360,10 @@ function IsRegExpMatchAllOptimizable(rx, C) {
}
var RegExpProto = RegExpCtor.prototype;
return RegExpPrototypeOptimizable(RegExpProto) && RegExpInstanceOptimizable(rx, RegExpProto);
return (
RegExpPrototypeOptimizable(RegExpProto) &&
RegExpInstanceOptimizable(rx, RegExpProto)
);
}
// String.prototype.matchAll proposal.
@ -1305,7 +1440,11 @@ function CreateRegExpStringIterator(regexp, string, source, flags, lastIndex) {
UnsafeSetReservedSlot(iterator, REGEXP_STRING_ITERATOR_STRING_SLOT, string);
UnsafeSetReservedSlot(iterator, REGEXP_STRING_ITERATOR_SOURCE_SLOT, source);
UnsafeSetReservedSlot(iterator, REGEXP_STRING_ITERATOR_FLAGS_SLOT, flags | 0);
UnsafeSetReservedSlot(iterator, REGEXP_STRING_ITERATOR_LASTINDEX_SLOT, lastIndex);
UnsafeSetReservedSlot(
iterator,
REGEXP_STRING_ITERATOR_LASTINDEX_SLOT,
lastIndex
);
// Step 10.
return iterator;
@ -1315,7 +1454,10 @@ function IsRegExpStringIteratorNextOptimizable() {
var RegExpProto = GetBuiltinPrototype("RegExp");
// If RegExpPrototypeOptimizable succeeds, `RegExpProto.exec` is
// guaranteed to be a data property.
return RegExpPrototypeOptimizable(RegExpProto) && RegExpProto.exec === RegExp_prototype_Exec;
return (
RegExpPrototypeOptimizable(RegExpProto) &&
RegExpProto.exec === RegExp_prototype_Exec
);
}
// String.prototype.matchAll proposal.
@ -1325,45 +1467,70 @@ function RegExpStringIteratorNext() {
// Steps 1-3.
var obj = this;
if (!IsObject(obj) || (obj = GuardToRegExpStringIterator(obj)) === null) {
return callFunction(CallRegExpStringIteratorMethodIfWrapped, this, "RegExpStringIteratorNext");
return callFunction(
CallRegExpStringIteratorMethodIfWrapped,
this,
"RegExpStringIteratorNext"
);
}
var result = { value: undefined, done: false };
// Step 4.
var lastIndex = UnsafeGetReservedSlot(obj, REGEXP_STRING_ITERATOR_LASTINDEX_SLOT);
var lastIndex = UnsafeGetReservedSlot(
obj,
REGEXP_STRING_ITERATOR_LASTINDEX_SLOT
);
if (lastIndex === REGEXP_STRING_ITERATOR_LASTINDEX_DONE) {
result.done = true;
return result;
}
// Step 5.
var regexp = UnsafeGetObjectFromReservedSlot(obj, REGEXP_STRING_ITERATOR_REGEXP_SLOT);
var regexp = UnsafeGetObjectFromReservedSlot(
obj,
REGEXP_STRING_ITERATOR_REGEXP_SLOT
);
// Step 6.
var string = UnsafeGetStringFromReservedSlot(obj, REGEXP_STRING_ITERATOR_STRING_SLOT);
var string = UnsafeGetStringFromReservedSlot(
obj,
REGEXP_STRING_ITERATOR_STRING_SLOT
);
// Steps 7-8.
var flags = UnsafeGetInt32FromReservedSlot(obj, REGEXP_STRING_ITERATOR_FLAGS_SLOT);
var flags = UnsafeGetInt32FromReservedSlot(
obj,
REGEXP_STRING_ITERATOR_FLAGS_SLOT
);
var global = !!(flags & REGEXP_GLOBAL_FLAG);
var fullUnicode = !!(flags & REGEXP_UNICODE_FLAG);
if (lastIndex >= 0) {
assert(IsRegExpObject(regexp), "|regexp| is a RegExp object");
var source = UnsafeGetStringFromReservedSlot(obj, REGEXP_STRING_ITERATOR_SOURCE_SLOT);
var source = UnsafeGetStringFromReservedSlot(
obj,
REGEXP_STRING_ITERATOR_SOURCE_SLOT
);
if (
IsRegExpStringIteratorNextOptimizable() &&
UnsafeGetStringFromReservedSlot(regexp, REGEXP_SOURCE_SLOT) === source &&
UnsafeGetInt32FromReservedSlot(regexp, REGEXP_FLAGS_SLOT) === flags
) {
// Step 9 (Inlined RegExpBuiltinExec).
var globalOrSticky = !!(flags & (REGEXP_GLOBAL_FLAG | REGEXP_STICKY_FLAG));
var globalOrSticky = !!(
flags &
(REGEXP_GLOBAL_FLAG | REGEXP_STICKY_FLAG)
);
if (!globalOrSticky) {
lastIndex = 0;
}
var match = lastIndex <= string.length ? RegExpMatcher(regexp, string, lastIndex) : null;
var match =
lastIndex <= string.length
? RegExpMatcher(regexp, string, lastIndex)
: null;
// Step 10.
if (match === null) {
@ -1388,10 +1555,16 @@ function RegExpStringIteratorNext() {
// Step 11.a.ii.
if (matchLength === 0) {
// Steps 11.a.ii.1-3.
lastIndex = fullUnicode ? AdvanceStringIndex(string, lastIndex) : lastIndex + 1;
lastIndex = fullUnicode
? AdvanceStringIndex(string, lastIndex)
: lastIndex + 1;
}
UnsafeSetReservedSlot(obj, REGEXP_STRING_ITERATOR_LASTINDEX_SLOT, lastIndex);
UnsafeSetReservedSlot(
obj,
REGEXP_STRING_ITERATOR_LASTINDEX_SLOT,
lastIndex
);
} else {
// Step 11.b.i.
UnsafeSetReservedSlot(
@ -1447,7 +1620,9 @@ function RegExpStringIteratorNext() {
var thisIndex = ToLength(regexp.lastIndex);
// Step 11.a.ii.2.
var nextIndex = fullUnicode ? AdvanceStringIndex(string, thisIndex) : thisIndex + 1;
var nextIndex = fullUnicode
? AdvanceStringIndex(string, thisIndex)
: thisIndex + 1;
// Step 11.a.ii.3.
regexp.lastIndex = nextIndex;

View file

@ -81,7 +81,12 @@ function FUNC_NAME(
// Steps g-l.
var replacement;
#if defined(FUNCTIONAL)
replacement = RegExpGetFunctionalReplacement(result, S, position, replaceValue);
replacement = RegExpGetFunctionalReplacement(
result,
S,
position,
replaceValue
);
#elif defined(SUBSTITUTION)
// Step l.i
var namedCaptures = result.groups;
@ -112,7 +117,12 @@ function FUNC_NAME(
}
if (!IsObject(elemBase)) {
replacement = RegExpGetFunctionalReplacement(result, S, position, replaceValue);
replacement = RegExpGetFunctionalReplacement(
result,
S,
position,
replaceValue
);
}
#else
replacement = replaceValue;
@ -120,14 +130,17 @@ function FUNC_NAME(
// Step 14.m.ii.
accumulatedResult +=
Substring(S, nextSourcePosition, position - nextSourcePosition) + replacement;
Substring(S, nextSourcePosition, position - nextSourcePosition) +
replacement;
// Step 14.m.iii.
nextSourcePosition = lastIndex;
// Step 11.c.iii.2.
if (matchLength === 0) {
lastIndex = fullUnicode ? AdvanceStringIndex(S, lastIndex) : lastIndex + 1;
lastIndex = fullUnicode
? AdvanceStringIndex(S, lastIndex)
: lastIndex + 1;
if (lastIndex > lengthS) {
break;
}
@ -138,7 +151,8 @@ function FUNC_NAME(
// Ensure the current source and flags match the original regexp, the
// replaceValue function may have called RegExp#compile.
if (
UnsafeGetStringFromReservedSlot(rx, REGEXP_SOURCE_SLOT) !== originalSource ||
UnsafeGetStringFromReservedSlot(rx, REGEXP_SOURCE_SLOT) !==
originalSource ||
UnsafeGetInt32FromReservedSlot(rx, REGEXP_FLAGS_SLOT) !== originalFlags
) {
rx = RegExpConstructRaw(originalSource, originalFlags);
@ -152,5 +166,8 @@ function FUNC_NAME(
}
// Step 16.
return accumulatedResult + Substring(S, nextSourcePosition, lengthS - nextSourcePosition);
return (
accumulatedResult +
Substring(S, nextSourcePosition, lengthS - nextSourcePosition)
);
}

View file

@ -122,7 +122,12 @@ function FUNC_NAME(
var replacement;
// Steps g-l.
#if defined(FUNCTIONAL)
replacement = RegExpGetFunctionalReplacement(result, S, position, replaceValue);
replacement = RegExpGetFunctionalReplacement(
result,
S,
position,
replaceValue
);
#elif defined(SUBSTITUTION)
// Step l.i
var namedCaptures = result.groups;
@ -151,5 +156,8 @@ function FUNC_NAME(
}
// Step 16.
return accumulatedResult + Substring(S, nextSourcePosition, lengthS - nextSourcePosition);
return (
accumulatedResult +
Substring(S, nextSourcePosition, lengthS - nextSourcePosition)
);
}

View file

@ -505,7 +505,13 @@ function SetForEach(callbackfn, thisArg = undefined) {
// Steps 2-3.
if (!IsObject(S) || (S = GuardToSetObject(S)) === null) {
return callFunction(CallSetMethodIfWrapped, this, callbackfn, thisArg, "SetForEach");
return callFunction(
CallSetMethodIfWrapped,
this,
callbackfn,
thisArg,
"SetForEach"
);
}
// Step 4.
@ -552,7 +558,11 @@ function SetIteratorNext() {
// Steps 2-3.
if (!IsObject(O) || (O = GuardToSetIterator(O)) === null) {
return callFunction(CallSetIteratorMethodIfWrapped, this, "SetIteratorNext");
return callFunction(
CallSetIteratorMethodIfWrapped,
this,
"SetIteratorNext"
);
}
// Steps 4-5 (implemented in GetNextSetEntryForIterator).

View file

@ -29,7 +29,10 @@ function InsertionSort(array, from, to, comparefn) {
function Merge(list, out, start, mid, end, comparefn) {
// Skip lopsided runs to avoid doing useless work.
// Skip calling the comparator if the sub-list is already sorted.
if (mid >= end || callContentFunction(comparefn, undefined, list[mid], list[mid + 1]) <= 0) {
if (
mid >= end ||
callContentFunction(comparefn, undefined, list[mid], list[mid + 1]) <= 0
) {
for (var i = start; i <= end; i++) {
DefineDataProperty(out, i, list[i]);
}
@ -134,7 +137,10 @@ function MergeSort(array, len, comparefn) {
function MergeTypedArray(list, out, start, mid, end, comparefn) {
// Skip lopsided runs to avoid doing useless work.
// Skip calling the comparator if the sub-list is already sorted.
if (mid >= end || callContentFunction(comparefn, undefined, list[mid], list[mid + 1]) <= 0) {
if (
mid >= end ||
callContentFunction(comparefn, undefined, list[mid], list[mid + 1]) <= 0
) {
for (var i = start; i <= end; i++) {
out[i] = list[i];
}
@ -167,7 +173,10 @@ function MergeTypedArray(list, out, start, mid, end, comparefn) {
// Iterative, bottom up, mergesort. Optimized version for TypedArrays.
function MergeSortTypedArray(array, len, comparefn) {
assert(IsPossiblyWrappedTypedArray(array), "MergeSortTypedArray works only with typed arrays.");
assert(
IsPossiblyWrappedTypedArray(array),
"MergeSortTypedArray works only with typed arrays."
);
// Use the same TypedArray kind for the buffer.
var C = ConstructorForTypedArray(array);

View file

@ -35,7 +35,11 @@ function String_match(regexp) {
// Step 2.
var isPatternString = typeof regexp === "string";
if (!(isPatternString && StringProtoHasNoMatch()) && regexp !== undefined && regexp !== null) {
if (
!(isPatternString && StringProtoHasNoMatch()) &&
regexp !== undefined &&
regexp !== null
) {
// Step 2.a.
var matcher = GetMethod(regexp, GetBuiltinSymbol("match"));
@ -110,7 +114,11 @@ function String_matchAll(regexp) {
var rx = RegExpCreate(regexp, "g");
// Step 5.
return callContentFunction(GetMethod(rx, GetBuiltinSymbol("matchAll")), rx, string);
return callContentFunction(
GetMethod(rx, GetBuiltinSymbol("matchAll")),
rx,
string
);
}
/**
@ -156,7 +164,11 @@ function String_pad(maxLength, fillString, padEnd) {
// Step 10.
// Perform an int32 division to ensure String_repeat is not called with a
// double to avoid repeated bailouts in ToInteger.
let truncatedStringFiller = callFunction(String_repeat, filler, (fillLen / filler.length) | 0);
let truncatedStringFiller = callFunction(
String_repeat,
filler,
(fillLen / filler.length) | 0
);
truncatedStringFiller += Substring(filler, 0, fillLen % filler.length);
@ -188,8 +200,14 @@ function StringProtoHasNoReplace() {
// Caller should check the range of |from| and |length|.
function Substring(str, from, length) {
assert(typeof str === "string", "|str| should be a string");
assert((from | 0) === from, "coercing |from| into int32 should not change the value");
assert((length | 0) === length, "coercing |length| into int32 should not change the value");
assert(
(from | 0) === from,
"coercing |from| into int32 should not change the value"
);
assert(
(length | 0) === length,
"coercing |length| into int32 should not change the value"
);
return SubstringKernel(str, from | 0, length | 0);
}
@ -240,7 +258,9 @@ function String_replace(searchValue, replaceValue) {
}
// Step 8.
var replStr = ToString(callContentFunction(replaceValue, undefined, searchString, pos, string));
var replStr = ToString(
callContentFunction(replaceValue, undefined, searchString, pos, string)
);
// Step 10.
var tailPos = pos + searchString.length;
@ -336,7 +356,12 @@ function String_replaceAll(searchValue, replaceValue) {
// whereas |"abc".indexOf("", 4)| returns 3. That means we need to
// exit the loop when |nextPosition| is smaller than |position| and
// not just when |nextPosition| is -1.
var nextPosition = callFunction(std_String_indexOf, string, searchString, position);
var nextPosition = callFunction(
std_String_indexOf,
string,
searchString,
position
);
if (nextPosition < position) {
break;
}
@ -344,13 +369,23 @@ function String_replaceAll(searchValue, replaceValue) {
// Step 14.a.
var replacement = ToString(
callContentFunction(replaceValue, undefined, searchString, position, string)
callContentFunction(
replaceValue,
undefined,
searchString,
position,
string
)
);
// Step 14.b (not applicable).
// Step 14.c.
var stringSlice = Substring(string, endOfLastMatch, position - endOfLastMatch);
var stringSlice = Substring(
string,
endOfLastMatch,
position - endOfLastMatch
);
// Step 14.d.
result += stringSlice + replacement;
@ -401,7 +436,11 @@ function String_search(regexp) {
// Step 2.
var isPatternString = typeof regexp === "string";
if (!(isPatternString && StringProtoHasNoSearch()) && regexp !== undefined && regexp !== null) {
if (
!(isPatternString && StringProtoHasNoSearch()) &&
regexp !== undefined &&
regexp !== null
) {
// Step 2.a.
var searcher = GetMethod(regexp, GetBuiltinSymbol("search"));
@ -425,7 +464,11 @@ function String_search(regexp) {
var rx = RegExpCreate(regexp);
// Step 5.
return callContentFunction(GetMethod(rx, GetBuiltinSymbol("search")), rx, string);
return callContentFunction(
GetMethod(rx, GetBuiltinSymbol("search")),
rx,
string
);
}
function StringProtoHasNoSplit() {
@ -657,10 +700,14 @@ function String_slice(start, end) {
var intEnd = end === undefined ? len : ToInteger(end);
// Step 6.
var from = intStart < 0 ? std_Math_max(len + intStart, 0) : std_Math_min(intStart, len);
var from =
intStart < 0
? std_Math_max(len + intStart, 0)
: std_Math_min(intStart, len);
// Step 7.
var to = intEnd < 0 ? std_Math_max(len + intEnd, 0) : std_Math_min(intEnd, len);
var to =
intEnd < 0 ? std_Math_max(len + intEnd, 0) : std_Math_min(intEnd, len);
// Step 8.
var span = std_Math_max(to - from, 0);
@ -769,7 +816,12 @@ function String_repeat(count) {
function String_iterator() {
// Step 1.
if (this === undefined || this === null) {
ThrowTypeError(JSMSG_INCOMPATIBLE_PROTO2, "String", "Symbol.iterator", ToString(this));
ThrowTypeError(
JSMSG_INCOMPATIBLE_PROTO2,
"String",
"Symbol.iterator",
ToString(this)
);
}
// Step 2.
@ -785,7 +837,11 @@ function String_iterator() {
function StringIteratorNext() {
var obj = this;
if (!IsObject(obj) || (obj = GuardToStringIterator(obj)) === null) {
return callFunction(CallStringIteratorMethodIfWrapped, this, "StringIteratorNext");
return callFunction(
CallStringIteratorMethodIfWrapped,
this,
"StringIteratorNext"
);
}
var S = UnsafeGetStringFromReservedSlot(obj, ITERATOR_SLOT_TARGET);
@ -889,7 +945,8 @@ function String_toLocaleLowerCase() {
var requestedLocales = CanonicalizeLocaleList(locales);
// Steps 4-6.
requestedLocale = requestedLocales.length > 0 ? requestedLocales[0] : undefined;
requestedLocale =
requestedLocales.length > 0 ? requestedLocales[0] : undefined;
}
// Trivial case: When the input is empty, directly return the empty string.
@ -934,7 +991,8 @@ function String_toLocaleUpperCase() {
var requestedLocales = CanonicalizeLocaleList(locales);
// Steps 4-6.
requestedLocale = requestedLocales.length > 0 ? requestedLocales[0] : undefined;
requestedLocale =
requestedLocales.length > 0 ? requestedLocales[0] : undefined;
}
// Trivial case: When the input is empty, directly return the empty string.

View file

@ -220,14 +220,24 @@ function TupleConcat() {
// Tuple.prototype.includes()
function TupleIncludes(valueToFind /* , fromIndex */) {
var fromIndex = arguments.length > 1 ? arguments[1] : undefined;
return callFunction(std_Array_includes, ThisTupleValue(this), valueToFind, fromIndex);
return callFunction(
std_Array_includes,
ThisTupleValue(this),
valueToFind,
fromIndex
);
}
// proposal-record-tuple
// Tuple.prototype.indexOf()
function TupleIndexOf(valueToFind /* , fromIndex */) {
var fromIndex = arguments.length > 1 ? arguments[1] : undefined;
return callFunction(std_Array_indexOf, ThisTupleValue(this), valueToFind, fromIndex);
return callFunction(
std_Array_indexOf,
ThisTupleValue(this),
valueToFind,
fromIndex
);
}
// proposal-record-tuple
@ -241,7 +251,9 @@ function TupleJoin(separator) {
// Steps 3-4
var sep = ",";
if (separator != undefined && separator !== null) {
let toString = IsCallable(separator.toString) ? separator.toString : std_Object_toString;
let toString = IsCallable(separator.toString)
? separator.toString
: std_Object_toString;
sep = callContentFunction(toString, separator);
}
@ -262,7 +274,9 @@ function TupleJoin(separator) {
// Step 7c
var next = "";
if (element != undefined && element != null) {
let toString = IsCallable(element.toString) ? element.toString : std_Object_toString;
let toString = IsCallable(element.toString)
? element.toString
: std_Object_toString;
next = callContentFunction(toString, element);
}
// Step 7d
@ -278,9 +292,18 @@ function TupleJoin(separator) {
// Tuple.prototype.lastIndexOf()
function TupleLastIndexOf(valueToFind /* , fromIndex */) {
if (arguments.length < 2) {
return callFunction(std_Array_lastIndexOf, ThisTupleValue(this), valueToFind);
return callFunction(
std_Array_lastIndexOf,
ThisTupleValue(this),
valueToFind
);
}
return callFunction(std_Array_lastIndexOf, ThisTupleValue(this), valueToFind, arguments[1]);
return callFunction(
std_Array_lastIndexOf,
ThisTupleValue(this),
valueToFind,
arguments[1]
);
}
// proposal-record-tuple
@ -301,7 +324,12 @@ function TupleToString() {
// Tuple.prototype.toLocaleString()
function TupleToLocaleString(locales, options) {
var T = ThisTupleValue(this);
return callContentFunction(ArrayToLocaleString, TupleToArray(T), locales, options);
return callContentFunction(
ArrayToLocaleString,
TupleToArray(T),
locales,
options
);
}
// proposal-record-tuple
@ -360,7 +388,9 @@ function TupleFilter(callbackfn) {
/* Step 7a. */
var kValue = list[k];
/* Step 7b. */
var selected = ToBoolean(callContentFunction(callbackfn, T, kValue, k, list));
var selected = ToBoolean(
callContentFunction(callbackfn, T, kValue, k, list)
);
/* Step 7c. */
if (selected) {
/* Step 7c.i. */
@ -434,16 +464,30 @@ function TupleReduce(callbackfn /*, initialVal */) {
if (arguments.length < 2) {
return callContentFunction(ArrayReduce, ThisTupleValue(this), callbackfn);
}
return callContentFunction(ArrayReduce, ThisTupleValue(this), callbackfn, arguments[1]);
return callContentFunction(
ArrayReduce,
ThisTupleValue(this),
callbackfn,
arguments[1]
);
}
// proposal-record-tuple
// Tuple.prototype.reduceRight()
function TupleReduceRight(callbackfn /*, initialVal*/) {
if (arguments.length < 2) {
return callContentFunction(ArrayReduceRight, ThisTupleValue(this), callbackfn);
return callContentFunction(
ArrayReduceRight,
ThisTupleValue(this),
callbackfn
);
}
return callContentFunction(ArrayReduceRight, ThisTupleValue(this), callbackfn, arguments[1]);
return callContentFunction(
ArrayReduceRight,
ThisTupleValue(this),
callbackfn,
arguments[1]
);
}
// proposal-record-tuple
@ -483,7 +527,13 @@ function FlattenIntoTuple(target, source, depth) {
/* Step 6a. */
if (mapperIsPresent) {
/* Step 6a.i. */
element = callContentFunction(mapperFunction, thisArg, element, sourceIndex, source);
element = callContentFunction(
mapperFunction,
thisArg,
element,
sourceIndex,
source
);
/* Step 6a.ii. */
if (IsObject(element)) {
ThrowTypeError(JSMSG_RECORD_TUPLE_NO_OBJECT);
@ -624,7 +674,9 @@ function TupleFrom(items /*, mapFn, thisArg */) {
/* Step 10b */
let kValue = arrayLike[k];
/* Step 10c-d */
let mappedValue = mapping ? callContentFunction(mapfn, thisArg, kValue, k) : kValue;
let mappedValue = mapping
? callContentFunction(mapfn, thisArg, kValue, k)
: kValue;
/* Step 10e */
if (IsObject(mappedValue)) {
ThrowTypeError(JSMSG_RECORD_TUPLE_NO_OBJECT);

View file

@ -11,7 +11,8 @@ function ViewedArrayBufferIfReified(tarray) {
assert(
buf === null ||
(IsObject(buf) &&
(GuardToArrayBuffer(buf) !== null || GuardToSharedArrayBuffer(buf) !== null)),
(GuardToArrayBuffer(buf) !== null ||
GuardToSharedArrayBuffer(buf) !== null)),
"unexpected value in buffer slot"
);
return buf;
@ -25,7 +26,8 @@ function IsDetachedBuffer(buffer) {
}
assert(
GuardToArrayBuffer(buffer) !== null || GuardToSharedArrayBuffer(buffer) !== null,
GuardToArrayBuffer(buffer) !== null ||
GuardToSharedArrayBuffer(buffer) !== null,
"non-ArrayBuffer passed to IsDetachedBuffer"
);
@ -71,7 +73,11 @@ function IsTypedArrayEnsuringArrayBuffer(arg) {
return true;
}
callFunction(CallTypedArrayMethodIfWrapped, arg, "GetAttachedArrayBufferMethod");
callFunction(
CallTypedArrayMethodIfWrapped,
arg,
"GetAttachedArrayBufferMethod"
);
return false;
}
@ -112,7 +118,10 @@ function TypedArraySpeciesConstructor(obj) {
}
// Step 8.
ThrowTypeError(JSMSG_NOT_CONSTRUCTOR, "@@species property of object's constructor");
ThrowTypeError(
JSMSG_NOT_CONSTRUCTOR,
"@@species property of object's constructor"
);
}
// ES2017 draft rev 6859bb9ccaea9c6ede81d71e5320e3833b92cb3e
@ -143,7 +152,11 @@ function ValidateTypedArray(obj) {
// 22.2.4.6 TypedArrayCreate ( constructor, argumentList )
function TypedArrayCreateWithLength(constructor, length) {
// Step 1.
var newTypedArray = constructContentFunction(constructor, constructor, length);
var newTypedArray = constructContentFunction(
constructor,
constructor,
length
);
// Step 2.
var isTypedArray = ValidateTypedArray(newTypedArray);
@ -153,7 +166,11 @@ function TypedArrayCreateWithLength(constructor, length) {
if (isTypedArray) {
len = TypedArrayLength(newTypedArray);
} else {
len = callFunction(CallTypedArrayMethodIfWrapped, newTypedArray, "TypedArrayLengthMethod");
len = callFunction(
CallTypedArrayMethodIfWrapped,
newTypedArray,
"TypedArrayLengthMethod"
);
}
if (len < length) {
@ -199,7 +216,12 @@ function TypedArraySpeciesCreateWithLength(exemplar, length) {
// ES2017 draft rev 6859bb9ccaea9c6ede81d71e5320e3833b92cb3e
// 22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
function TypedArraySpeciesCreateWithBuffer(exemplar, buffer, byteOffset, length) {
function TypedArraySpeciesCreateWithBuffer(
exemplar,
buffer,
byteOffset,
length
) {
// Step 1 (omitted).
// Steps 2-3.
@ -250,7 +272,11 @@ function TypedArrayEvery(callbackfn /*, thisArg*/) {
if (isTypedArray) {
len = TypedArrayLength(O);
} else {
len = callFunction(CallTypedArrayMethodIfWrapped, O, "TypedArrayLengthMethod");
len = callFunction(
CallTypedArrayMethodIfWrapped,
O,
"TypedArrayLengthMethod"
);
}
// Step 4.
@ -288,7 +314,14 @@ SetIsInlinableLargeFunction(TypedArrayEvery);
function TypedArrayFill(value, start = 0, end = undefined) {
// This function is not generic.
if (!IsObject(this) || !IsTypedArray(this)) {
return callFunction(CallTypedArrayMethodIfWrapped, this, value, start, end, "TypedArrayFill");
return callFunction(
CallTypedArrayMethodIfWrapped,
this,
value,
start,
end,
"TypedArrayFill"
);
}
// Step 1.
@ -313,13 +346,18 @@ function TypedArrayFill(value, start = 0, end = undefined) {
// Step 6.
var k =
relativeStart < 0 ? std_Math_max(len + relativeStart, 0) : std_Math_min(relativeStart, len);
relativeStart < 0
? std_Math_max(len + relativeStart, 0)
: std_Math_min(relativeStart, len);
// Step 7.
var relativeEnd = end === undefined ? len : ToInteger(end);
// Step 8.
var final = relativeEnd < 0 ? std_Math_max(len + relativeEnd, 0) : std_Math_min(relativeEnd, len);
var final =
relativeEnd < 0
? std_Math_max(len + relativeEnd, 0)
: std_Math_min(relativeEnd, len);
// Step 9.
if (buffer === null) {
@ -359,7 +397,11 @@ function TypedArrayFilter(callbackfn /*, thisArg*/) {
if (isTypedArray) {
len = TypedArrayLength(O);
} else {
len = callFunction(CallTypedArrayMethodIfWrapped, O, "TypedArrayLengthMethod");
len = callFunction(
CallTypedArrayMethodIfWrapped,
O,
"TypedArrayLengthMethod"
);
}
// Step 4.
@ -424,7 +466,11 @@ function TypedArrayFind(predicate /*, thisArg*/) {
if (isTypedArray) {
len = TypedArrayLength(O);
} else {
len = callFunction(CallTypedArrayMethodIfWrapped, O, "TypedArrayLengthMethod");
len = callFunction(
CallTypedArrayMethodIfWrapped,
O,
"TypedArrayLengthMethod"
);
}
// Step 4.
@ -469,12 +515,20 @@ function TypedArrayFindIndex(predicate /*, thisArg*/) {
if (isTypedArray) {
len = TypedArrayLength(O);
} else {
len = callFunction(CallTypedArrayMethodIfWrapped, O, "TypedArrayLengthMethod");
len = callFunction(
CallTypedArrayMethodIfWrapped,
O,
"TypedArrayLengthMethod"
);
}
// Step 4.
if (arguments.length === 0) {
ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, "%TypedArray%.prototype.findIndex");
ThrowTypeError(
JSMSG_MISSING_FUN_ARG,
0,
"%TypedArray%.prototype.findIndex"
);
}
if (!IsCallable(predicate)) {
ThrowTypeError(JSMSG_NOT_FUNCTION, DecompileArg(0, predicate));
@ -511,7 +565,11 @@ function TypedArrayForEach(callbackfn /*, thisArg*/) {
if (isTypedArray) {
len = TypedArrayLength(O);
} else {
len = callFunction(CallTypedArrayMethodIfWrapped, O, "TypedArrayLengthMethod");
len = callFunction(
CallTypedArrayMethodIfWrapped,
O,
"TypedArrayLengthMethod"
);
}
// Step 4.
@ -621,7 +679,12 @@ function TypedArrayIndexOf(searchElement, fromIndex = 0) {
function TypedArrayJoin(separator) {
// Step 2.
if (!IsObject(this) || !IsTypedArray(this)) {
return callFunction(CallTypedArrayMethodIfWrapped, this, separator, "TypedArrayJoin");
return callFunction(
CallTypedArrayMethodIfWrapped,
this,
separator,
"TypedArrayJoin"
);
}
GetAttachedArrayBuffer(this);
@ -778,7 +841,11 @@ function TypedArrayMap(callbackfn /*, thisArg*/) {
if (isTypedArray) {
len = TypedArrayLength(O);
} else {
len = callFunction(CallTypedArrayMethodIfWrapped, O, "TypedArrayLengthMethod");
len = callFunction(
CallTypedArrayMethodIfWrapped,
O,
"TypedArrayLengthMethod"
);
}
// Step 4.
@ -827,7 +894,11 @@ function TypedArrayReduce(callbackfn /*, initialValue*/) {
if (isTypedArray) {
len = TypedArrayLength(O);
} else {
len = callFunction(CallTypedArrayMethodIfWrapped, O, "TypedArrayLengthMethod");
len = callFunction(
CallTypedArrayMethodIfWrapped,
O,
"TypedArrayLengthMethod"
);
}
// Step 4.
@ -851,7 +922,14 @@ function TypedArrayReduce(callbackfn /*, initialValue*/) {
// Step 10.
for (; k < len; k++) {
accumulator = callContentFunction(callbackfn, undefined, accumulator, O[k], k, O);
accumulator = callContentFunction(
callbackfn,
undefined,
accumulator,
O[k],
k,
O
);
}
// Step 11.
@ -875,12 +953,20 @@ function TypedArrayReduceRight(callbackfn /*, initialValue*/) {
if (isTypedArray) {
len = TypedArrayLength(O);
} else {
len = callFunction(CallTypedArrayMethodIfWrapped, O, "TypedArrayLengthMethod");
len = callFunction(
CallTypedArrayMethodIfWrapped,
O,
"TypedArrayLengthMethod"
);
}
// Step 4.
if (arguments.length === 0) {
ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, "%TypedArray%.prototype.reduceRight");
ThrowTypeError(
JSMSG_MISSING_FUN_ARG,
0,
"%TypedArray%.prototype.reduceRight"
);
}
if (!IsCallable(callbackfn)) {
ThrowTypeError(JSMSG_NOT_FUNCTION, DecompileArg(0, callbackfn));
@ -899,7 +985,14 @@ function TypedArrayReduceRight(callbackfn /*, initialValue*/) {
// Step 10.
for (; k >= 0; k--) {
accumulator = callContentFunction(callbackfn, undefined, accumulator, O[k], k, O);
accumulator = callContentFunction(
callbackfn,
undefined,
accumulator,
O[k],
k,
O
);
}
// Step 11.
@ -912,7 +1005,11 @@ function TypedArrayReduceRight(callbackfn /*, initialValue*/) {
function TypedArrayReverse() {
// Step 2.
if (!IsObject(this) || !IsTypedArray(this)) {
return callFunction(CallTypedArrayMethodIfWrapped, this, "TypedArrayReverse");
return callFunction(
CallTypedArrayMethodIfWrapped,
this,
"TypedArrayReverse"
);
}
GetAttachedArrayBuffer(this);
@ -954,7 +1051,13 @@ function TypedArraySlice(start, end) {
// Step 2.
if (!IsObject(O) || !IsTypedArray(O)) {
return callFunction(CallTypedArrayMethodIfWrapped, O, start, end, "TypedArraySlice");
return callFunction(
CallTypedArrayMethodIfWrapped,
O,
start,
end,
"TypedArraySlice"
);
}
var buffer = GetAttachedArrayBuffer(O);
@ -967,13 +1070,18 @@ function TypedArraySlice(start, end) {
// Step 5.
var k =
relativeStart < 0 ? std_Math_max(len + relativeStart, 0) : std_Math_min(relativeStart, len);
relativeStart < 0
? std_Math_max(len + relativeStart, 0)
: std_Math_min(relativeStart, len);
// Step 6.
var relativeEnd = end === undefined ? len : ToInteger(end);
// Step 7.
var final = relativeEnd < 0 ? std_Math_max(len + relativeEnd, 0) : std_Math_min(relativeEnd, len);
var final =
relativeEnd < 0
? std_Math_max(len + relativeEnd, 0)
: std_Math_min(relativeEnd, len);
// Step 8.
var count = std_Math_max(final - k, 0);
@ -1031,7 +1139,11 @@ function TypedArraySome(callbackfn /*, thisArg*/) {
if (isTypedArray) {
len = TypedArrayLength(O);
} else {
len = callFunction(CallTypedArrayMethodIfWrapped, O, "TypedArrayLengthMethod");
len = callFunction(
CallTypedArrayMethodIfWrapped,
O,
"TypedArrayLengthMethod"
);
}
// Step 4.
@ -1087,7 +1199,11 @@ function TypedArraySort(comparefn) {
if (isTypedArray) {
len = TypedArrayLength(obj);
} else {
len = callFunction(CallTypedArrayMethodIfWrapped, obj, "TypedArrayLengthMethod");
len = callFunction(
CallTypedArrayMethodIfWrapped,
obj,
"TypedArrayLengthMethod"
);
}
// Arrays with less than two elements remain unchanged when sorted.
@ -1136,7 +1252,11 @@ function TypedArrayToLocaleString(locales = undefined, options = undefined) {
if (isTypedArray) {
len = TypedArrayLength(array);
} else {
len = callFunction(CallTypedArrayMethodIfWrapped, array, "TypedArrayLengthMethod");
len = callFunction(
CallTypedArrayMethodIfWrapped,
array,
"TypedArrayLengthMethod"
);
}
// Step 4.
@ -1152,10 +1272,17 @@ function TypedArrayToLocaleString(locales = undefined, options = undefined) {
// or null elements.
#if JS_HAS_INTL_API
var R = ToString(
callContentFunction(firstElement.toLocaleString, firstElement, locales, options)
callContentFunction(
firstElement.toLocaleString,
firstElement,
locales,
options
)
);
#else
var R = ToString(callContentFunction(firstElement.toLocaleString, firstElement));
var R = ToString(
callContentFunction(firstElement.toLocaleString, firstElement)
);
#endif
// Step 3 (reordered).
@ -1179,7 +1306,14 @@ function TypedArrayToLocaleString(locales = undefined, options = undefined) {
// Step 9.d.
#if JS_HAS_INTL_API
R = ToString(callContentFunction(nextElement.toLocaleString, nextElement, locales, options));
R = ToString(
callContentFunction(
nextElement.toLocaleString,
nextElement,
locales,
options
)
);
#else
R = ToString(callContentFunction(nextElement.toLocaleString, nextElement));
#endif
@ -1201,7 +1335,13 @@ function TypedArraySubarray(begin, end) {
// Steps 2-3.
// This function is not generic.
if (!IsObject(obj) || !IsTypedArray(obj)) {
return callFunction(CallTypedArrayMethodIfWrapped, this, begin, end, "TypedArraySubarray");
return callFunction(
CallTypedArrayMethodIfWrapped,
this,
begin,
end,
"TypedArraySubarray"
);
}
// Step 4.
@ -1245,7 +1385,12 @@ function TypedArraySubarray(begin, end) {
var beginByteOffset = srcByteOffset + beginIndex * elementSize;
// Steps 15-16.
return TypedArraySpeciesCreateWithBuffer(obj, buffer, beginByteOffset, newLength);
return TypedArraySpeciesCreateWithBuffer(
obj,
buffer,
beginByteOffset,
newLength
);
}
// https://tc39.es/proposal-relative-indexing-method
@ -1257,7 +1402,12 @@ function TypedArrayAt(index) {
// Step 2.
// This function is not generic.
if (!IsObject(obj) || !IsTypedArray(obj)) {
return callFunction(CallTypedArrayMethodIfWrapped, obj, index, "TypedArrayAt");
return callFunction(
CallTypedArrayMethodIfWrapped,
obj,
index,
"TypedArrayAt"
);
}
GetAttachedArrayBuffer(obj);
@ -1304,7 +1454,11 @@ function TypedArrayFindLast(predicate /*, thisArg*/) {
if (isTypedArray) {
len = TypedArrayLength(O);
} else {
len = callFunction(CallTypedArrayMethodIfWrapped, O, "TypedArrayLengthMethod");
len = callFunction(
CallTypedArrayMethodIfWrapped,
O,
"TypedArrayLengthMethod"
);
}
// Step 4.
@ -1348,12 +1502,20 @@ function TypedArrayFindLastIndex(predicate /*, thisArg*/) {
if (isTypedArray) {
len = TypedArrayLength(O);
} else {
len = callFunction(CallTypedArrayMethodIfWrapped, O, "TypedArrayLengthMethod");
len = callFunction(
CallTypedArrayMethodIfWrapped,
O,
"TypedArrayLengthMethod"
);
}
// Step 4.
if (arguments.length === 0) {
ThrowTypeError(JSMSG_MISSING_FUN_ARG, 0, "%TypedArray%.prototype.findLastIndex");
ThrowTypeError(
JSMSG_MISSING_FUN_ARG,
0,
"%TypedArray%.prototype.findLastIndex"
);
}
if (!IsCallable(predicate)) {
ThrowTypeError(JSMSG_NOT_FUNCTION, DecompileArg(0, predicate));
@ -1555,7 +1717,9 @@ function TypedArrayStaticFrom(source, mapfn = undefined, thisArg = undefined) {
var kValue = values[k];
// Steps 7.e.iii-iv.
var mappedValue = mapping ? callContentFunction(mapfn, T, kValue, k) : kValue;
var mappedValue = mapping
? callContentFunction(mapfn, T, kValue, k)
: kValue;
// Step 7.e.v.
targetObj[k] = mappedValue;
@ -1588,7 +1752,9 @@ function TypedArrayStaticFrom(source, mapfn = undefined, thisArg = undefined) {
var kValue = arrayLike[k];
// Steps 13.c-d.
var mappedValue = mapping ? callContentFunction(mapfn, T, kValue, k) : kValue;
var mappedValue = mapping
? callContentFunction(mapfn, T, kValue, k)
: kValue;
// Step 13.e.
targetObj[k] = mappedValue;
@ -1685,7 +1851,13 @@ function ArrayBufferSlice(start, end) {
// Steps 2-3,
// This function is not generic.
if (!IsObject(O) || (O = GuardToArrayBuffer(O)) === null) {
return callFunction(CallArrayBufferMethodIfWrapped, this, start, end, "ArrayBufferSlice");
return callFunction(
CallArrayBufferMethodIfWrapped,
this,
start,
end,
"ArrayBufferSlice"
);
}
// Step 4.
@ -1701,13 +1873,18 @@ function ArrayBufferSlice(start, end) {
// Step 7.
var first =
relativeStart < 0 ? std_Math_max(len + relativeStart, 0) : std_Math_min(relativeStart, len);
relativeStart < 0
? std_Math_max(len + relativeStart, 0)
: std_Math_min(relativeStart, len);
// Step 8.
var relativeEnd = end === undefined ? len : ToInteger(end);
// Step 9.
var final = relativeEnd < 0 ? std_Math_max(len + relativeEnd, 0) : std_Math_min(relativeEnd, len);
var final =
relativeEnd < 0
? std_Math_max(len + relativeEnd, 0)
: std_Math_min(relativeEnd, len);
// Step 10.
var newLen = std_Math_max(final - first, 0);
@ -1737,7 +1914,13 @@ function ArrayBufferSlice(start, end) {
isWrapped = true;
// Step 15.
if (callFunction(CallArrayBufferMethodIfWrapped, newBuffer, "IsDetachedBufferThis")) {
if (
callFunction(
CallArrayBufferMethodIfWrapped,
newBuffer,
"IsDetachedBufferThis"
)
) {
ThrowTypeError(JSMSG_TYPED_ARRAY_DETACHED);
}
}
@ -1809,13 +1992,18 @@ function SharedArrayBufferSlice(start, end) {
// Step 6.
var first =
relativeStart < 0 ? std_Math_max(len + relativeStart, 0) : std_Math_min(relativeStart, len);
relativeStart < 0
? std_Math_max(len + relativeStart, 0)
: std_Math_min(relativeStart, len);
// Step 7.
var relativeEnd = end === undefined ? len : ToInteger(end);
// Step 8.
var final = relativeEnd < 0 ? std_Math_max(len + relativeEnd, 0) : std_Math_min(relativeEnd, len);
var final =
relativeEnd < 0
? std_Math_max(len + relativeEnd, 0)
: std_Math_min(relativeEnd, len);
// Step 9.
var newLen = std_Math_max(final - first, 0);
@ -1882,7 +2070,11 @@ function TypedArrayCreateSameType(exemplar, length) {
function TypedArrayToReversed() {
// Step 2. Perform ? ValidateTypedArray(O).
if (!IsObject(this) || !IsTypedArray(this)) {
return callFunction(CallTypedArrayMethodIfWrapped, this, "TypedArrayToReversed");
return callFunction(
CallTypedArrayMethodIfWrapped,
this,
"TypedArrayToReversed"
);
}
// Step 1. Let O be the this value.
@ -1928,7 +2120,13 @@ function isValidIntegerIndex(a, index) {
function TypedArrayWith(index, value) {
// Step 2. Perform ? ValidateTypedArray(O).
if (!IsObject(this) || !IsTypedArray(this)) {
return callFunction(CallTypedArrayMethodIfWrapped, this, "TypedArrayWith", index, value);
return callFunction(
CallTypedArrayMethodIfWrapped,
this,
"TypedArrayWith",
index,
value
);
}
// Step 1. Let O be the this value.
@ -1980,7 +2178,12 @@ function TypedArrayWith(index, value) {
function TypedArrayToSorted(comparefn) {
// Step 3. Perform ? ValidateTypedArray(this)
if (!IsObject(this) || !IsTypedArray(this)) {
return callFunction(CallTypedArrayMethodIfWrapped, this, "TypedArrayToSorted", comparefn);
return callFunction(
CallTypedArrayMethodIfWrapped,
this,
"TypedArrayToSorted",
comparefn
);
}
// Step 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception.
@ -2010,7 +2213,12 @@ function TypedArrayToSorted(comparefn) {
}
// Equivalent to steps 8-9 and 12
return callFunction(CallTypedArrayMethodIfWrapped, A, comparefn, "TypedArraySort");
return callFunction(
CallTypedArrayMethodIfWrapped,
A,
comparefn,
"TypedArraySort"
);
}
// https://github.com/tc39/proposal-change-array-by-copy

View file

@ -118,7 +118,10 @@ function SpeciesConstructor(obj, defaultConstructor) {
}
// Step 8.
ThrowTypeError(JSMSG_NOT_CONSTRUCTOR, "@@species property of object's constructor");
ThrowTypeError(
JSMSG_NOT_CONSTRUCTOR,
"@@species property of object's constructor"
);
}
function GetTypeError(msg) {
@ -182,7 +185,10 @@ function CopyDataProperties(target, source, excludedItems) {
// We abbreviate this by calling propertyIsEnumerable which is faster
// and returns false for not defined properties.
if (!hasOwn(key, excludedItems) && callFunction(std_Object_propertyIsEnumerable, from, key)) {
if (
!hasOwn(key, excludedItems) &&
callFunction(std_Object_propertyIsEnumerable, from, key)
) {
DefineDataProperty(target, key, from[key]);
}
}

View file

@ -19,7 +19,9 @@ function resolveCollatorInternals(lazyCollatorData) {
// Steps 6-7.
var collatorIsSorting = lazyCollatorData.usage === "sort";
var localeData = collatorIsSorting ? Collator.sortLocaleData : Collator.searchLocaleData;
var localeData = collatorIsSorting
? Collator.sortLocaleData
: Collator.searchLocaleData;
// Compute effective locale.
// Step 16.
@ -81,10 +83,16 @@ function resolveCollatorInternals(lazyCollatorData) {
*/
function getCollatorInternals(obj) {
assert(IsObject(obj), "getCollatorInternals called with non-object");
assert(intl_GuardToCollator(obj) !== null, "getCollatorInternals called with non-Collator");
assert(
intl_GuardToCollator(obj) !== null,
"getCollatorInternals called with non-Collator"
);
var internals = getIntlObjectInternals(obj);
assert(internals.type === "Collator", "bad type escaped getIntlObjectInternals");
assert(
internals.type === "Collator",
"bad type escaped getIntlObjectInternals"
);
// If internal properties have already been computed, use them.
var internalProps = maybeInternalProperties(internals);
@ -111,7 +119,10 @@ function getCollatorInternals(obj) {
*/
function InitializeCollator(collator, locales, options) {
assert(IsObject(collator), "InitializeCollator called with non-object");
assert(intl_GuardToCollator(collator) != null, "InitializeCollator called with non-Collator");
assert(
intl_GuardToCollator(collator) != null,
"InitializeCollator called with non-Collator"
);
// Lazy Collator data has the following structure:
//
@ -159,18 +170,40 @@ function InitializeCollator(collator, locales, options) {
lazyCollatorData.opt = opt;
// Steps 9-10.
var matcher = GetOption(options, "localeMatcher", "string", ["lookup", "best fit"], "best fit");
var matcher = GetOption(
options,
"localeMatcher",
"string",
["lookup", "best fit"],
"best fit"
);
opt.localeMatcher = matcher;
// https://github.com/tc39/ecma402/pull/459
var collation = GetOption(options, "collation", "string", undefined, undefined);
var collation = GetOption(
options,
"collation",
"string",
undefined,
undefined
);
if (collation !== undefined) {
collation = intl_ValidateAndCanonicalizeUnicodeExtensionType(collation, "collation", "co");
collation = intl_ValidateAndCanonicalizeUnicodeExtensionType(
collation,
"collation",
"co"
);
}
opt.co = collation;
// Steps 11-13.
var numericValue = GetOption(options, "numeric", "boolean", undefined, undefined);
var numericValue = GetOption(
options,
"numeric",
"boolean",
undefined,
undefined
);
if (numericValue !== undefined) {
numericValue = numericValue ? "true" : "false";
}
@ -372,8 +405,15 @@ function $Intl_Collator_compare_get() {
var collator = this;
// Steps 2-3.
if (!IsObject(collator) || (collator = intl_GuardToCollator(collator)) === null) {
return callFunction(intl_CallCollatorMethodIfWrapped, this, "$Intl_Collator_compare_get");
if (
!IsObject(collator) ||
(collator = intl_GuardToCollator(collator)) === null
) {
return callFunction(
intl_CallCollatorMethodIfWrapped,
this,
"$Intl_Collator_compare_get"
);
}
var internals = getCollatorInternals(collator);
@ -399,8 +439,15 @@ function Intl_Collator_resolvedOptions() {
var collator = this;
// Steps 2-3.
if (!IsObject(collator) || (collator = intl_GuardToCollator(collator)) === null) {
return callFunction(intl_CallCollatorMethodIfWrapped, this, "Intl_Collator_resolvedOptions");
if (
!IsObject(collator) ||
(collator = intl_GuardToCollator(collator)) === null
) {
return callFunction(
intl_CallCollatorMethodIfWrapped,
this,
"Intl_Collator_resolvedOptions"
);
}
var internals = getCollatorInternals(collator);

View file

@ -53,7 +53,10 @@ function startOfUnicodeExtensions(locale) {
function endOfUnicodeExtensions(locale, start) {
assert(typeof locale === "string", "locale is a string");
assert(0 <= start && start < locale.length, "start is an index into locale");
assert(Substring(locale, start, 3) === "-u-", "start points to Unicode extension sequence");
assert(
Substring(locale, start, 3) === "-u-",
"start points to Unicode extension sequence"
);
#define HYPHEN 0x2D
assert(
@ -92,7 +95,10 @@ function endOfUnicodeExtensions(locale, start) {
* Removes Unicode locale extension sequences from the given language tag.
*/
function removeUnicodeExtensions(locale) {
assertIsValidAndCanonicalLanguageTag(locale, "locale with possible Unicode extension");
assertIsValidAndCanonicalLanguageTag(
locale,
"locale with possible Unicode extension"
);
var start = startOfUnicodeExtensions(locale);
if (start < 0) {
@ -221,7 +227,10 @@ function CanonicalizeLocaleList(locales) {
// Steps 7.c.iii-iv.
var tag = intl_ValidateAndCanonicalizeLanguageTag(kValue, true);
assert(typeof tag === "string", "ValidateAndCanonicalizeLanguageTag returns a string value");
assert(
typeof tag === "string",
"ValidateAndCanonicalizeLanguageTag returns a string value"
);
// Step 7.c.v.
if (callFunction(std_Array_indexOf, seen, tag) === -1) {
@ -281,7 +290,10 @@ function LookupMatcher(availableLocales, requestedLocales) {
var noExtensionsLocale = removeUnicodeExtensions(locale);
// Step 2.b.
var availableLocale = BestAvailableLocale(availableLocales, noExtensionsLocale);
var availableLocale = BestAvailableLocale(
availableLocales,
noExtensionsLocale
);
// Step 2.c.
if (availableLocale !== undefined) {
@ -455,12 +467,19 @@ function ResolveLocale(
// Step 8.h.ii.
if (requestedValue !== undefined) {
// Steps 8.a-d.
keyLocaleData = callFunction(localeDataProvider[key], null, foundLocale);
keyLocaleData = callFunction(
localeDataProvider[key],
null,
foundLocale
);
// Step 8.h.ii.1.
if (requestedValue !== "") {
// Step 8.h.ii.1.a.
if (callFunction(std_Array_indexOf, keyLocaleData, requestedValue) !== -1) {
if (
callFunction(std_Array_indexOf, keyLocaleData, requestedValue) !==
-1
) {
value = requestedValue;
supportedExtensionAddition = "-" + key + "-" + value;
}
@ -484,7 +503,9 @@ function ResolveLocale(
// Step 8.i.ii.
assert(
typeof optionsValue === "string" || optionsValue === undefined || optionsValue === null,
typeof optionsValue === "string" ||
optionsValue === undefined ||
optionsValue === null,
"unexpected type for options value"
);
@ -492,7 +513,11 @@ function ResolveLocale(
if (optionsValue !== undefined && optionsValue !== value) {
// Steps 8.a-d.
if (keyLocaleData === undefined) {
keyLocaleData = callFunction(localeDataProvider[key], null, foundLocale);
keyLocaleData = callFunction(
localeDataProvider[key],
null,
foundLocale
);
}
// Step 8.i.iii.
@ -512,7 +537,10 @@ function ResolveLocale(
}
// Step 8.j.
assert(typeof value === "string" || value === null, "unexpected locale data value");
assert(
typeof value === "string" || value === null,
"unexpected locale data value"
);
result[key] = value;
// Step 8.k.
@ -538,7 +566,10 @@ function ResolveLocale(
*/
function addUnicodeExtension(locale, extension) {
assert(typeof locale === "string", "locale is a string value");
assert(!callFunction(std_String_startsWith, locale, "x-"), "unexpected privateuse-only locale");
assert(
!callFunction(std_String_startsWith, locale, "x-"),
"unexpected privateuse-only locale"
);
assert(
startOfUnicodeExtensions(locale) < 0,
"Unicode extension subtag already present in locale"
@ -589,7 +620,10 @@ function LookupSupportedLocales(availableLocales, requestedLocales) {
var noExtensionsLocale = removeUnicodeExtensions(locale);
// Step 2.b.
var availableLocale = BestAvailableLocale(availableLocales, noExtensionsLocale);
var availableLocale = BestAvailableLocale(
availableLocales,
noExtensionsLocale
);
// Step 2.c.
if (availableLocale !== undefined) {
@ -666,7 +700,10 @@ function GetOption(options, property, type, values, fallback) {
}
// Step 2.d.
if (values !== undefined && callFunction(std_Array_indexOf, values, value) === -1) {
if (
values !== undefined &&
callFunction(std_Array_indexOf, values, value) === -1
) {
ThrowRangeError(JSMSG_INVALID_OPTION_VALUE, property, `"${value}"`);
}
@ -683,7 +720,14 @@ function GetOption(options, property, type, values, fallback) {
* a boolean or string, checks whether it is one of a list of allowed values,
* and fills in a fallback value if necessary.
*/
function GetStringOrBooleanOption(options, property, values, trueValue, falsyValue, fallback) {
function GetStringOrBooleanOption(
options,
property,
values,
trueValue,
falsyValue,
fallback
) {
assert(IsObject(values), "GetStringOrBooleanOption");
// Step 1.
@ -724,10 +768,17 @@ function GetStringOrBooleanOption(options, property, values, trueValue, falsyVal
* Spec: ECMAScript Internationalization API Specification, 9.2.11.
*/
function DefaultNumberOption(value, minimum, maximum, fallback) {
assert(typeof minimum === "number" && (minimum | 0) === minimum, "DefaultNumberOption");
assert(typeof maximum === "number" && (maximum | 0) === maximum, "DefaultNumberOption");
assert(
fallback === undefined || (typeof fallback === "number" && (fallback | 0) === fallback),
typeof minimum === "number" && (minimum | 0) === minimum,
"DefaultNumberOption"
);
assert(
typeof maximum === "number" && (maximum | 0) === maximum,
"DefaultNumberOption"
);
assert(
fallback === undefined ||
(typeof fallback === "number" && (fallback | 0) === fallback),
"DefaultNumberOption"
);
assert(
@ -799,7 +850,8 @@ function initializeIntlObject(obj, type, lazyData) {
(type === "ListFormat" && intl_GuardToListFormat(obj) !== null) ||
(type === "NumberFormat" && intl_GuardToNumberFormat(obj) !== null) ||
(type === "PluralRules" && intl_GuardToPluralRules(obj) !== null) ||
(type === "RelativeTimeFormat" && intl_GuardToRelativeTimeFormat(obj) !== null),
(type === "RelativeTimeFormat" &&
intl_GuardToRelativeTimeFormat(obj) !== null),
"type must match the object's class"
);
assert(IsObject(lazyData), "non-object lazy data");
@ -859,7 +911,10 @@ function maybeInternalProperties(internals) {
if (lazyData) {
return null;
}
assert(IsObject(internals.internalProps), "missing lazy data and computed internals");
assert(
IsObject(internals.internalProps),
"missing lazy data and computed internals"
);
return internals.internalProps;
}
@ -890,12 +945,18 @@ function getIntlObjectInternals(obj) {
assert(hasOwn("type", internals), "missing type");
assert(
(internals.type === "Collator" && intl_GuardToCollator(obj) !== null) ||
(internals.type === "DateTimeFormat" && intl_GuardToDateTimeFormat(obj) !== null) ||
(internals.type === "DisplayNames" && intl_GuardToDisplayNames(obj) !== null) ||
(internals.type === "ListFormat" && intl_GuardToListFormat(obj) !== null) ||
(internals.type === "NumberFormat" && intl_GuardToNumberFormat(obj) !== null) ||
(internals.type === "PluralRules" && intl_GuardToPluralRules(obj) !== null) ||
(internals.type === "RelativeTimeFormat" && intl_GuardToRelativeTimeFormat(obj) !== null),
(internals.type === "DateTimeFormat" &&
intl_GuardToDateTimeFormat(obj) !== null) ||
(internals.type === "DisplayNames" &&
intl_GuardToDisplayNames(obj) !== null) ||
(internals.type === "ListFormat" &&
intl_GuardToListFormat(obj) !== null) ||
(internals.type === "NumberFormat" &&
intl_GuardToNumberFormat(obj) !== null) ||
(internals.type === "PluralRules" &&
intl_GuardToPluralRules(obj) !== null) ||
(internals.type === "RelativeTimeFormat" &&
intl_GuardToRelativeTimeFormat(obj) !== null),
"type must match the object's class"
);
assert(hasOwn("lazyData", internals), "missing lazyData");

View file

@ -130,7 +130,10 @@ function getDateTimeFormatInternals(obj) {
);
var internals = getIntlObjectInternals(obj);
assert(internals.type === "DateTimeFormat", "bad type escaped getIntlObjectInternals");
assert(
internals.type === "DateTimeFormat",
"bad type escaped getIntlObjectInternals"
);
// If internal properties have already been computed, use them.
var internalProps = maybeInternalProperties(internals);
@ -153,7 +156,11 @@ function UnwrapDateTimeFormat(dtf) {
IsObject(dtf) &&
intl_GuardToDateTimeFormat(dtf) === null &&
!intl_IsWrappedDateTimeFormat(dtf) &&
callFunction(std_Object_isPrototypeOf, GetBuiltinPrototype("DateTimeFormat"), dtf)
callFunction(
std_Object_isPrototypeOf,
GetBuiltinPrototype("DateTimeFormat"),
dtf
)
) {
dtf = dtf[intlFallbackSymbol()];
}
@ -172,7 +179,10 @@ function CanonicalizeTimeZoneName(timeZone) {
// Step 1. (Not applicable, the input is already a valid IANA time zone.)
assert(timeZone !== "Etc/Unknown", "Invalid time zone");
assert(timeZone === intl_IsValidTimeZoneName(timeZone), "Time zone name not normalized");
assert(
timeZone === intl_IsValidTimeZoneName(timeZone),
"Time zone name not normalized"
);
// Step 2.
var ianaTimeZone = intl_canonicalizeTimeZone(timeZone);
@ -226,7 +236,8 @@ function DefaultTimeZone() {
if (offsetHoursFraction === 0) {
// Etc/GMT + offset uses POSIX-style signs, i.e. a positive offset
// means a location west of GMT.
timeZone = "Etc/GMT" + (offsetHours < 0 ? "+" : "-") + std_Math_abs(offsetHours);
timeZone =
"Etc/GMT" + (offsetHours < 0 ? "+" : "-") + std_Math_abs(offsetHours);
// Check if the fallback is valid.
timeZone = intl_IsValidTimeZoneName(timeZone);
@ -258,8 +269,17 @@ function DefaultTimeZone() {
*
* Spec: ECMAScript Internationalization API Specification, 12.1.1.
*/
function InitializeDateTimeFormat(dateTimeFormat, thisValue, locales, options, mozExtensions) {
assert(IsObject(dateTimeFormat), "InitializeDateTimeFormat called with non-Object");
function InitializeDateTimeFormat(
dateTimeFormat,
thisValue,
locales,
options,
mozExtensions
) {
assert(
IsObject(dateTimeFormat),
"InitializeDateTimeFormat called with non-Object"
);
assert(
intl_GuardToDateTimeFormat(dateTimeFormat) !== null,
"InitializeDateTimeFormat called with non-DateTimeFormat"
@ -324,12 +344,22 @@ function InitializeDateTimeFormat(dateTimeFormat, thisValue, locales, options, m
var calendar = GetOption(options, "calendar", "string", undefined, undefined);
if (calendar !== undefined) {
calendar = intl_ValidateAndCanonicalizeUnicodeExtensionType(calendar, "calendar", "ca");
calendar = intl_ValidateAndCanonicalizeUnicodeExtensionType(
calendar,
"calendar",
"ca"
);
}
localeOpt.ca = calendar;
var numberingSystem = GetOption(options, "numberingSystem", "string", undefined, undefined);
var numberingSystem = GetOption(
options,
"numberingSystem",
"string",
undefined,
undefined
);
if (numberingSystem !== undefined) {
numberingSystem = intl_ValidateAndCanonicalizeUnicodeExtensionType(
@ -345,7 +375,13 @@ function InitializeDateTimeFormat(dateTimeFormat, thisValue, locales, options, m
var hr12 = GetOption(options, "hour12", "boolean", undefined, undefined);
// Step 7.
var hc = GetOption(options, "hourCycle", "string", ["h11", "h12", "h23", "h24"], undefined);
var hc = GetOption(
options,
"hourCycle",
"string",
["h11", "h12", "h23", "h24"],
undefined
);
// Step 8.
if (hr12 !== undefined) {
@ -396,8 +432,20 @@ function InitializeDateTimeFormat(dateTimeFormat, thisValue, locales, options, m
["narrow", "short", "long"],
undefined
);
formatOpt.era = GetOption(options, "era", "string", ["narrow", "short", "long"], undefined);
formatOpt.year = GetOption(options, "year", "string", ["2-digit", "numeric"], undefined);
formatOpt.era = GetOption(
options,
"era",
"string",
["narrow", "short", "long"],
undefined
);
formatOpt.year = GetOption(
options,
"year",
"string",
["2-digit", "numeric"],
undefined
);
formatOpt.month = GetOption(
options,
"month",
@ -405,7 +453,13 @@ function InitializeDateTimeFormat(dateTimeFormat, thisValue, locales, options, m
["2-digit", "numeric", "narrow", "short", "long"],
undefined
);
formatOpt.day = GetOption(options, "day", "string", ["2-digit", "numeric"], undefined);
formatOpt.day = GetOption(
options,
"day",
"string",
["2-digit", "numeric"],
undefined
);
formatOpt.dayPeriod = GetOption(
options,
"dayPeriod",
@ -413,9 +467,27 @@ function InitializeDateTimeFormat(dateTimeFormat, thisValue, locales, options, m
["narrow", "short", "long"],
undefined
);
formatOpt.hour = GetOption(options, "hour", "string", ["2-digit", "numeric"], undefined);
formatOpt.minute = GetOption(options, "minute", "string", ["2-digit", "numeric"], undefined);
formatOpt.second = GetOption(options, "second", "string", ["2-digit", "numeric"], undefined);
formatOpt.hour = GetOption(
options,
"hour",
"string",
["2-digit", "numeric"],
undefined
);
formatOpt.minute = GetOption(
options,
"minute",
"string",
["2-digit", "numeric"],
undefined
);
formatOpt.second = GetOption(
options,
"second",
"string",
["2-digit", "numeric"],
undefined
);
formatOpt.fractionalSecondDigits = GetNumberOption(
options,
"fractionalSecondDigits",
@ -427,7 +499,14 @@ function InitializeDateTimeFormat(dateTimeFormat, thisValue, locales, options, m
options,
"timeZoneName",
"string",
["short", "long", "shortOffset", "longOffset", "shortGeneric", "longGeneric"],
[
"short",
"long",
"shortOffset",
"longOffset",
"shortGeneric",
"longGeneric",
],
undefined
);
@ -507,12 +586,20 @@ function InitializeDateTimeFormat(dateTimeFormat, thisValue, locales, options, m
//
// We've done everything that must be done now: mark the lazy data as fully
// computed and install it.
initializeIntlObject(dateTimeFormat, "DateTimeFormat", lazyDateTimeFormatData);
initializeIntlObject(
dateTimeFormat,
"DateTimeFormat",
lazyDateTimeFormatData
);
// 12.2.1, steps 4-5.
if (
dateTimeFormat !== thisValue &&
callFunction(std_Object_isPrototypeOf, GetBuiltinPrototype("DateTimeFormat"), thisValue)
callFunction(
std_Object_isPrototypeOf,
GetBuiltinPrototype("DateTimeFormat"),
thisValue
)
) {
DefineDataProperty(
thisValue,
@ -596,11 +683,19 @@ function ToDateTimeOptions(options, required, defaults) {
}
if (required === "date" && timeStyle !== undefined) {
ThrowTypeError(JSMSG_INVALID_DATETIME_STYLE, "timeStyle", "toLocaleDateString");
ThrowTypeError(
JSMSG_INVALID_DATETIME_STYLE,
"timeStyle",
"toLocaleDateString"
);
}
if (required === "time" && dateStyle !== undefined) {
ThrowTypeError(JSMSG_INVALID_DATETIME_STYLE, "dateStyle", "toLocaleTimeString");
ThrowTypeError(
JSMSG_INVALID_DATETIME_STYLE,
"dateStyle",
"toLocaleTimeString"
);
}
// Step 6.
@ -784,7 +879,11 @@ function Intl_DateTimeFormat_formatRange(startDate, endDate) {
// Step 3.
if (startDate === undefined || endDate === undefined) {
ThrowTypeError(JSMSG_UNDEFINED_DATE, startDate === undefined ? "start" : "end", "formatRange");
ThrowTypeError(
JSMSG_UNDEFINED_DATE,
startDate === undefined ? "start" : "end",
"formatRange"
);
}
// Step 4.
@ -883,7 +982,11 @@ function Intl_DateTimeFormat_resolvedOptions() {
if (hasTimeStyle) {
// timeStyle (unlike dateStyle) requires resolving the pattern to
// ensure "hourCycle" and "hour12" properties are added to |result|.
intl_resolveDateTimeFormatComponents(dtf, result, /* includeDateTimeFields = */ false);
intl_resolveDateTimeFormatComponents(
dtf,
result,
/* includeDateTimeFields = */ false
);
}
if (hasDateStyle) {
DefineDataProperty(result, "dateStyle", internals.dateStyle);
@ -893,7 +996,11 @@ function Intl_DateTimeFormat_resolvedOptions() {
}
} else {
// Components bag or a (Mozilla-only) raw pattern.
intl_resolveDateTimeFormatComponents(dtf, result, /* includeDateTimeFields = */ true);
intl_resolveDateTimeFormatComponents(
dtf,
result,
/* includeDateTimeFields = */ true
);
}
// Step 6.

View file

@ -95,7 +95,10 @@ function getDisplayNamesInternals(obj) {
);
var internals = getIntlObjectInternals(obj);
assert(internals.type === "DisplayNames", "bad type escaped getIntlObjectInternals");
assert(
internals.type === "DisplayNames",
"bad type escaped getIntlObjectInternals"
);
// If internal properties have already been computed, use them.
var internalProps = maybeInternalProperties(internals);
@ -121,7 +124,10 @@ function getDisplayNamesInternals(obj) {
* here occur there.
*/
function InitializeDisplayNames(displayNames, locales, options, mozExtensions) {
assert(IsObject(displayNames), "InitializeDisplayNames called with non-object");
assert(
IsObject(displayNames),
"InitializeDisplayNames called with non-object"
);
assert(
intl_GuardToDisplayNames(displayNames) !== null,
"InitializeDisplayNames called with non-DisplayNames"
@ -165,7 +171,10 @@ function InitializeDisplayNames(displayNames, locales, options, mozExtensions) {
// Step 4.
if (!IsObject(options)) {
ThrowTypeError(JSMSG_OBJECT_REQUIRED, options === null ? "null" : typeof options);
ThrowTypeError(
JSMSG_OBJECT_REQUIRED,
options === null ? "null" : typeof options
);
}
// Step 5.
@ -174,14 +183,30 @@ function InitializeDisplayNames(displayNames, locales, options, mozExtensions) {
lazyDisplayNamesData.mozExtensions = mozExtensions;
// Steps 7-8.
var matcher = GetOption(options, "localeMatcher", "string", ["lookup", "best fit"], "best fit");
var matcher = GetOption(
options,
"localeMatcher",
"string",
["lookup", "best fit"],
"best fit"
);
opt.localeMatcher = matcher;
if (mozExtensions) {
var calendar = GetOption(options, "calendar", "string", undefined, undefined);
var calendar = GetOption(
options,
"calendar",
"string",
undefined,
undefined
);
if (calendar !== undefined) {
calendar = intl_ValidateAndCanonicalizeUnicodeExtensionType(calendar, "calendar", "ca");
calendar = intl_ValidateAndCanonicalizeUnicodeExtensionType(
calendar,
"calendar",
"ca"
);
}
opt.ca = calendar;
@ -198,7 +223,13 @@ function InitializeDisplayNames(displayNames, locales, options, mozExtensions) {
"long"
);
} else {
style = GetOption(options, "style", "string", ["narrow", "short", "long"], "long");
style = GetOption(
options,
"style",
"string",
["narrow", "short", "long"],
"long"
);
}
// Step 11.
@ -244,7 +275,13 @@ function InitializeDisplayNames(displayNames, locales, options, mozExtensions) {
lazyDisplayNamesData.type = type;
// Step 15.
var fallback = GetOption(options, "fallback", "string", ["code", "none"], "code");
var fallback = GetOption(
options,
"fallback",
"string",
["code", "none"],
"code"
);
// Step 16.
lazyDisplayNamesData.fallback = fallback;
@ -294,8 +331,15 @@ function Intl_DisplayNames_of(code) {
var displayNames = this;
// Steps 2-3.
if (!IsObject(displayNames) || (displayNames = intl_GuardToDisplayNames(displayNames)) === null) {
return callFunction(intl_CallDisplayNamesMethodIfWrapped, this, "Intl_DisplayNames_of");
if (
!IsObject(displayNames) ||
(displayNames = intl_GuardToDisplayNames(displayNames)) === null
) {
return callFunction(
intl_CallDisplayNamesMethodIfWrapped,
this,
"Intl_DisplayNames_of"
);
}
code = ToString(code);
@ -304,7 +348,14 @@ function Intl_DisplayNames_of(code) {
// Unpack the internals object to avoid a slow runtime to selfhosted JS call
// in |intl_ComputeDisplayName()|.
var { locale, calendar = "", style, type, languageDisplay = "", fallback } = internals;
var {
locale,
calendar = "",
style,
type,
languageDisplay = "",
fallback,
} = internals;
// Steps 5-10.
return intl_ComputeDisplayName(
@ -327,7 +378,10 @@ function Intl_DisplayNames_resolvedOptions() {
var displayNames = this;
// Steps 2-3.
if (!IsObject(displayNames) || (displayNames = intl_GuardToDisplayNames(displayNames)) === null) {
if (
!IsObject(displayNames) ||
(displayNames = intl_GuardToDisplayNames(displayNames)) === null
) {
return callFunction(
intl_CallDisplayNamesMethodIfWrapped,
this,

View file

@ -61,10 +61,16 @@ function resolveListFormatInternals(lazyListFormatData) {
*/
function getListFormatInternals(obj) {
assert(IsObject(obj), "getListFormatInternals called with non-object");
assert(intl_GuardToListFormat(obj) !== null, "getListFormatInternals called with non-ListFormat");
assert(
intl_GuardToListFormat(obj) !== null,
"getListFormatInternals called with non-ListFormat"
);
var internals = getIntlObjectInternals(obj);
assert(internals.type === "ListFormat", "bad type escaped getIntlObjectInternals");
assert(
internals.type === "ListFormat",
"bad type escaped getIntlObjectInternals"
);
// If internal properties have already been computed, use them.
var internalProps = maybeInternalProperties(internals);
@ -122,7 +128,10 @@ function InitializeListFormat(listFormat, locales, options) {
if (options === undefined) {
options = std_Object_create(null);
} else if (!IsObject(options)) {
ThrowTypeError(JSMSG_OBJECT_REQUIRED, options === null ? "null" : typeof options);
ThrowTypeError(
JSMSG_OBJECT_REQUIRED,
options === null ? "null" : typeof options
);
}
// Step 6.
@ -130,7 +139,13 @@ function InitializeListFormat(listFormat, locales, options) {
lazyListFormatData.opt = opt;
// Steps 7-8.
let matcher = GetOption(options, "localeMatcher", "string", ["lookup", "best fit"], "best fit");
let matcher = GetOption(
options,
"localeMatcher",
"string",
["lookup", "best fit"],
"best fit"
);
opt.localeMatcher = matcher;
// Compute formatting options.
@ -146,7 +161,13 @@ function InitializeListFormat(listFormat, locales, options) {
lazyListFormatData.type = type;
// Steps 14-15.
var style = GetOption(options, "style", "string", ["long", "short", "narrow"], "long");
var style = GetOption(
options,
"style",
"string",
["long", "short", "narrow"],
"long"
);
lazyListFormatData.style = style;
// We've done everything that must be done now: mark the lazy data as fully
@ -188,7 +209,12 @@ function StringListFromIterable(iterable, methodName) {
for (var element of allowContentIter(iterable)) {
// Step 5.b.ii.
if (typeof element !== "string") {
ThrowTypeError(JSMSG_NOT_EXPECTED_TYPE, methodName, "string", typeof element);
ThrowTypeError(
JSMSG_NOT_EXPECTED_TYPE,
methodName,
"string",
typeof element
);
}
// Step 5.b.iii.
@ -207,8 +233,16 @@ function Intl_ListFormat_format(list) {
var listFormat = this;
// Steps 2-3.
if (!IsObject(listFormat) || (listFormat = intl_GuardToListFormat(listFormat)) === null) {
return callFunction(intl_CallListFormatMethodIfWrapped, this, list, "Intl_ListFormat_format");
if (
!IsObject(listFormat) ||
(listFormat = intl_GuardToListFormat(listFormat)) === null
) {
return callFunction(
intl_CallListFormatMethodIfWrapped,
this,
list,
"Intl_ListFormat_format"
);
}
// Step 4.
@ -234,7 +268,10 @@ function Intl_ListFormat_formatToParts(list) {
var listFormat = this;
// Steps 2-3.
if (!IsObject(listFormat) || (listFormat = intl_GuardToListFormat(listFormat)) === null) {
if (
!IsObject(listFormat) ||
(listFormat = intl_GuardToListFormat(listFormat)) === null
) {
return callFunction(
intl_CallListFormatMethodIfWrapped,
this,
@ -248,7 +285,9 @@ function Intl_ListFormat_formatToParts(list) {
// We can directly return if |stringList| contains less than two elements.
if (stringList.length < 2) {
return stringList.length === 0 ? [] : [{ type: "element", value: stringList[0] }];
return stringList.length === 0
? []
: [{ type: "element", value: stringList[0] }];
}
// Ensure the ListFormat internals are resolved.
@ -266,7 +305,10 @@ function Intl_ListFormat_resolvedOptions() {
var listFormat = this;
// Steps 2-3.
if (!IsObject(listFormat) || (listFormat = intl_GuardToListFormat(listFormat)) === null) {
if (
!IsObject(listFormat) ||
(listFormat = intl_GuardToListFormat(listFormat)) === null
) {
return callFunction(
intl_CallListFormatMethodIfWrapped,
this,

View file

@ -67,22 +67,33 @@ function resolveNumberFormatInternals(lazyNumberFormatData) {
internalProps.notation = notation;
// Step 22.
internalProps.minimumIntegerDigits = lazyNumberFormatData.minimumIntegerDigits;
internalProps.minimumIntegerDigits =
lazyNumberFormatData.minimumIntegerDigits;
if ("minimumFractionDigits" in lazyNumberFormatData) {
// Note: Intl.NumberFormat.prototype.resolvedOptions() exposes the
// actual presence (versus undefined-ness) of these properties.
assert("maximumFractionDigits" in lazyNumberFormatData, "min/max frac digits mismatch");
internalProps.minimumFractionDigits = lazyNumberFormatData.minimumFractionDigits;
internalProps.maximumFractionDigits = lazyNumberFormatData.maximumFractionDigits;
assert(
"maximumFractionDigits" in lazyNumberFormatData,
"min/max frac digits mismatch"
);
internalProps.minimumFractionDigits =
lazyNumberFormatData.minimumFractionDigits;
internalProps.maximumFractionDigits =
lazyNumberFormatData.maximumFractionDigits;
}
if ("minimumSignificantDigits" in lazyNumberFormatData) {
// Note: Intl.NumberFormat.prototype.resolvedOptions() exposes the
// actual presence (versus undefined-ness) of these properties.
assert("maximumSignificantDigits" in lazyNumberFormatData, "min/max sig digits mismatch");
internalProps.minimumSignificantDigits = lazyNumberFormatData.minimumSignificantDigits;
internalProps.maximumSignificantDigits = lazyNumberFormatData.maximumSignificantDigits;
assert(
"maximumSignificantDigits" in lazyNumberFormatData,
"min/max sig digits mismatch"
);
internalProps.minimumSignificantDigits =
lazyNumberFormatData.minimumSignificantDigits;
internalProps.maximumSignificantDigits =
lazyNumberFormatData.maximumSignificantDigits;
}
// Intl.NumberFormat v3 Proposal
@ -122,7 +133,10 @@ function getNumberFormatInternals(obj) {
);
var internals = getIntlObjectInternals(obj);
assert(internals.type === "NumberFormat", "bad type escaped getIntlObjectInternals");
assert(
internals.type === "NumberFormat",
"bad type escaped getIntlObjectInternals"
);
// If internal properties have already been computed, use them.
var internalProps = maybeInternalProperties(internals);
@ -145,7 +159,11 @@ function UnwrapNumberFormat(nf) {
IsObject(nf) &&
intl_GuardToNumberFormat(nf) === null &&
!intl_IsWrappedNumberFormat(nf) &&
callFunction(std_Object_isPrototypeOf, GetBuiltinPrototype("NumberFormat"), nf)
callFunction(
std_Object_isPrototypeOf,
GetBuiltinPrototype("NumberFormat"),
nf
)
) {
nf = nf[intlFallbackSymbol()];
}
@ -157,7 +175,13 @@ function UnwrapNumberFormat(nf) {
*
* Spec: ECMAScript Internationalization API Specification, 11.1.1.
*/
function SetNumberFormatDigitOptions(lazyData, options, mnfdDefault, mxfdDefault, notation) {
function SetNumberFormatDigitOptions(
lazyData,
options,
mnfdDefault,
mxfdDefault,
notation
) {
// We skip step 1 because we set the properties on a lazyData object.
// Steps 2-4.
@ -193,7 +217,8 @@ function SetNumberFormatDigitOptions(lazyData, options, mnfdDefault, mxfdDefault
const hasSignificantDigits = mnsd !== undefined || mxsd !== undefined;
const hasFractionDigits = mnfd !== undefined || mxfd !== undefined;
const needSignificantDigits = roundingPriority !== "auto" || hasSignificantDigits;
const needSignificantDigits =
roundingPriority !== "auto" || hasSignificantDigits;
const needFractionalDigits =
roundingPriority !== "auto" ||
!(hasSignificantDigits || (!hasFractionDigits && notation === "compact"));
@ -233,7 +258,10 @@ function SetNumberFormatDigitOptions(lazyData, options, mnfdDefault, mxfdDefault
// Step 12.d.
if (mnfd === undefined) {
assert(mxfd !== undefined, "mxfd isn't undefined when mnfd is undefined");
assert(
mxfd !== undefined,
"mxfd isn't undefined when mnfd is undefined"
);
mnfd = std_Math_min(mnfdDefault, mxfd);
}
@ -267,8 +295,14 @@ function SetNumberFormatDigitOptions(lazyData, options, mnfdDefault, mxfdDefault
lazyData.roundingPriority = roundingPriority;
} else {
assert(!hasSignificantDigits, "bad significant digits in fallback case");
assert(roundingPriority === "auto", `bad rounding in fallback case: ${roundingPriority}`);
assert(notation === "compact", `bad notation in fallback case: ${notation}`);
assert(
roundingPriority === "auto",
`bad rounding in fallback case: ${roundingPriority}`
);
assert(
notation === "compact",
`bad notation in fallback case: ${notation}`
);
lazyData.roundingPriority = "morePrecision";
lazyData.minimumFractionDigits = 0;
@ -293,7 +327,9 @@ function toASCIIUpperCase(s) {
for (var i = 0; i < s.length; i++) {
var c = callFunction(std_String_charCodeAt, s, i);
result +=
0x61 <= c && c <= 0x7a ? callFunction(std_String_fromCharCode, null, c & ~0x20) : s[i];
0x61 <= c && c <= 0x7a
? callFunction(std_String_fromCharCode, null, c & ~0x20)
: s[i];
}
return result;
}
@ -319,7 +355,10 @@ function IsWellFormedCurrencyCode(currency) {
* Intl.NumberFormat Unified API Proposal
*/
function IsWellFormedUnitIdentifier(unitIdentifier) {
assert(typeof unitIdentifier === "string", "unitIdentifier is a string value");
assert(
typeof unitIdentifier === "string",
"unitIdentifier is a string value"
);
// Step 1.
if (IsSanctionedSimpleUnitIdentifier(unitIdentifier)) {
@ -336,11 +375,16 @@ function IsWellFormedUnitIdentifier(unitIdentifier) {
// Steps 3 and 5.
var numerator = Substring(unitIdentifier, 0, pos);
var denominator = Substring(unitIdentifier, next, unitIdentifier.length - next);
var denominator = Substring(
unitIdentifier,
next,
unitIdentifier.length - next
);
// Steps 4 and 6.
return (
IsSanctionedSimpleUnitIdentifier(numerator) && IsSanctionedSimpleUnitIdentifier(denominator)
IsSanctionedSimpleUnitIdentifier(numerator) &&
IsSanctionedSimpleUnitIdentifier(denominator)
);
}
@ -358,7 +402,10 @@ var availableMeasurementUnits = {
* Also see: https://unicode.org/reports/tr35/tr35-general.html#Unit_Elements
*/
function IsSanctionedSimpleUnitIdentifier(unitIdentifier) {
assert(typeof unitIdentifier === "string", "unitIdentifier is a string value");
assert(
typeof unitIdentifier === "string",
"unitIdentifier is a string value"
);
var isSanctioned = hasOwn(unitIdentifier, sanctionedSimpleUnitIdentifiers);
@ -403,7 +450,10 @@ function IsSanctionedSimpleUnitIdentifier(unitIdentifier) {
* Spec: ECMAScript Internationalization API Specification, 11.1.2.
*/
function InitializeNumberFormat(numberFormat, thisValue, locales, options) {
assert(IsObject(numberFormat), "InitializeNumberFormat called with non-object");
assert(
IsObject(numberFormat),
"InitializeNumberFormat called with non-object"
);
assert(
intl_GuardToNumberFormat(numberFormat) !== null,
"InitializeNumberFormat called with non-NumberFormat"
@ -491,10 +541,22 @@ function InitializeNumberFormat(numberFormat, thisValue, locales, options) {
lazyNumberFormatData.opt = opt;
// Steps 5-6.
var matcher = GetOption(options, "localeMatcher", "string", ["lookup", "best fit"], "best fit");
var matcher = GetOption(
options,
"localeMatcher",
"string",
["lookup", "best fit"],
"best fit"
);
opt.localeMatcher = matcher;
var numberingSystem = GetOption(options, "numberingSystem", "string", undefined, undefined);
var numberingSystem = GetOption(
options,
"numberingSystem",
"string",
undefined,
undefined
);
if (numberingSystem !== undefined) {
numberingSystem = intl_ValidateAndCanonicalizeUnicodeExtensionType(
@ -611,11 +673,23 @@ function InitializeNumberFormat(numberFormat, thisValue, locales, options) {
lazyNumberFormatData.notation = notation;
// Step 22.
SetNumberFormatDigitOptions(lazyNumberFormatData, options, mnfdDefault, mxfdDefault, notation);
SetNumberFormatDigitOptions(
lazyNumberFormatData,
options,
mnfdDefault,
mxfdDefault,
notation
);
#ifdef NIGHTLY_BUILD
// Intl.NumberFormat v3 Proposal
var roundingIncrement = GetNumberOption(options, "roundingIncrement", 1, 5000, 1);
var roundingIncrement = GetNumberOption(
options,
"roundingIncrement",
1,
5000,
1
);
switch (roundingIncrement) {
case 1:
case 2:
@ -634,21 +708,36 @@ function InitializeNumberFormat(numberFormat, thisValue, locales, options) {
case 5000:
break;
default:
ThrowRangeError(JSMSG_INVALID_OPTION_VALUE, "roundingIncrement", roundingIncrement);
ThrowRangeError(
JSMSG_INVALID_OPTION_VALUE,
"roundingIncrement",
roundingIncrement
);
}
lazyNumberFormatData.roundingIncrement = roundingIncrement;
if (roundingIncrement !== 1) {
// [[RoundingType]] must be `fractionDigits`.
if (lazyNumberFormatData.roundingPriority !== "auto") {
ThrowTypeError(JSMSG_INVALID_NUMBER_OPTION, "roundingIncrement", "roundingPriority");
ThrowTypeError(
JSMSG_INVALID_NUMBER_OPTION,
"roundingIncrement",
"roundingPriority"
);
}
if (hasOwn("minimumSignificantDigits", lazyNumberFormatData)) {
ThrowTypeError(JSMSG_INVALID_NUMBER_OPTION, "roundingIncrement", "minimumSignificantDigits");
ThrowTypeError(
JSMSG_INVALID_NUMBER_OPTION,
"roundingIncrement",
"minimumSignificantDigits"
);
}
// Minimum and maximum fraction digits must be equal.
if (lazyNumberFormatData.minimumFractionDigits !== lazyNumberFormatData.maximumFractionDigits) {
if (
lazyNumberFormatData.minimumFractionDigits !==
lazyNumberFormatData.maximumFractionDigits
) {
ThrowRangeError(JSMSG_UNEQUAL_FRACTION_DIGITS);
}
}
@ -671,7 +760,13 @@ function InitializeNumberFormat(numberFormat, thisValue, locales, options) {
#endif
// Intl.NumberFormat Unified API Proposal
var compactDisplay = GetOption(options, "compactDisplay", "string", ["short", "long"], "short");
var compactDisplay = GetOption(
options,
"compactDisplay",
"string",
["short", "long"],
"short"
);
if (notation === "compact") {
lazyNumberFormatData.compactDisplay = compactDisplay;
}
@ -688,7 +783,13 @@ function InitializeNumberFormat(numberFormat, thisValue, locales, options) {
defaultUseGrouping
);
#else
var useGrouping = GetOption(options, "useGrouping", "boolean", undefined, true);
var useGrouping = GetOption(
options,
"useGrouping",
"boolean",
undefined,
true
);
#endif
lazyNumberFormatData.useGrouping = useGrouping;
@ -739,7 +840,11 @@ function InitializeNumberFormat(numberFormat, thisValue, locales, options) {
// 11.2.1, steps 4-5.
if (
numberFormat !== thisValue &&
callFunction(std_Object_isPrototypeOf, GetBuiltinPrototype("NumberFormat"), thisValue)
callFunction(
std_Object_isPrototypeOf,
GetBuiltinPrototype("NumberFormat"),
thisValue
)
) {
DefineDataProperty(
thisValue,
@ -1032,28 +1137,50 @@ function Intl_NumberFormat_resolvedOptions() {
DefineDataProperty(result, "unitDisplay", internals.unitDisplay);
}
DefineDataProperty(result, "minimumIntegerDigits", internals.minimumIntegerDigits);
DefineDataProperty(
result,
"minimumIntegerDigits",
internals.minimumIntegerDigits
);
// Min/Max fraction digits are either both present or not present at all.
assert(
hasOwn("minimumFractionDigits", internals) === hasOwn("maximumFractionDigits", internals),
hasOwn("minimumFractionDigits", internals) ===
hasOwn("maximumFractionDigits", internals),
"minimumFractionDigits is present iff maximumFractionDigits is present"
);
if (hasOwn("minimumFractionDigits", internals)) {
DefineDataProperty(result, "minimumFractionDigits", internals.minimumFractionDigits);
DefineDataProperty(result, "maximumFractionDigits", internals.maximumFractionDigits);
DefineDataProperty(
result,
"minimumFractionDigits",
internals.minimumFractionDigits
);
DefineDataProperty(
result,
"maximumFractionDigits",
internals.maximumFractionDigits
);
}
// Min/Max significant digits are either both present or not present at all.
assert(
hasOwn("minimumSignificantDigits", internals) === hasOwn("maximumSignificantDigits", internals),
hasOwn("minimumSignificantDigits", internals) ===
hasOwn("maximumSignificantDigits", internals),
"minimumSignificantDigits is present iff maximumSignificantDigits is present"
);
if (hasOwn("minimumSignificantDigits", internals)) {
DefineDataProperty(result, "minimumSignificantDigits", internals.minimumSignificantDigits);
DefineDataProperty(result, "maximumSignificantDigits", internals.maximumSignificantDigits);
DefineDataProperty(
result,
"minimumSignificantDigits",
internals.minimumSignificantDigits
);
DefineDataProperty(
result,
"maximumSignificantDigits",
internals.maximumSignificantDigits
);
}
DefineDataProperty(result, "useGrouping", internals.useGrouping);
@ -1070,7 +1197,11 @@ function Intl_NumberFormat_resolvedOptions() {
#ifdef NIGHTLY_BUILD
DefineDataProperty(result, "roundingMode", internals.roundingMode);
DefineDataProperty(result, "roundingIncrement", internals.roundingIncrement);
DefineDataProperty(result, "trailingZeroDisplay", internals.trailingZeroDisplay);
DefineDataProperty(
result,
"trailingZeroDisplay",
internals.trailingZeroDisplay
);
DefineDataProperty(result, "roundingPriority", internals.roundingPriority);
#endif

View file

@ -51,15 +51,25 @@ function resolvePluralRulesInternals(lazyPluralRulesData) {
internalProps.minimumIntegerDigits = lazyPluralRulesData.minimumIntegerDigits;
if ("minimumFractionDigits" in lazyPluralRulesData) {
assert("maximumFractionDigits" in lazyPluralRulesData, "min/max frac digits mismatch");
internalProps.minimumFractionDigits = lazyPluralRulesData.minimumFractionDigits;
internalProps.maximumFractionDigits = lazyPluralRulesData.maximumFractionDigits;
assert(
"maximumFractionDigits" in lazyPluralRulesData,
"min/max frac digits mismatch"
);
internalProps.minimumFractionDigits =
lazyPluralRulesData.minimumFractionDigits;
internalProps.maximumFractionDigits =
lazyPluralRulesData.maximumFractionDigits;
}
if ("minimumSignificantDigits" in lazyPluralRulesData) {
assert("maximumSignificantDigits" in lazyPluralRulesData, "min/max sig digits mismatch");
internalProps.minimumSignificantDigits = lazyPluralRulesData.minimumSignificantDigits;
internalProps.maximumSignificantDigits = lazyPluralRulesData.maximumSignificantDigits;
assert(
"maximumSignificantDigits" in lazyPluralRulesData,
"min/max sig digits mismatch"
);
internalProps.minimumSignificantDigits =
lazyPluralRulesData.minimumSignificantDigits;
internalProps.maximumSignificantDigits =
lazyPluralRulesData.maximumSignificantDigits;
}
// Intl.NumberFormat v3 Proposal
@ -82,7 +92,10 @@ function getPluralRulesInternals(obj) {
);
var internals = getIntlObjectInternals(obj);
assert(internals.type === "PluralRules", "bad type escaped getIntlObjectInternals");
assert(
internals.type === "PluralRules",
"bad type escaped getIntlObjectInternals"
);
var internalProps = maybeInternalProperties(internals);
if (internalProps) {
@ -157,11 +170,23 @@ function InitializePluralRules(pluralRules, locales, options) {
lazyPluralRulesData.opt = opt;
// Steps 5-6.
let matcher = GetOption(options, "localeMatcher", "string", ["lookup", "best fit"], "best fit");
let matcher = GetOption(
options,
"localeMatcher",
"string",
["lookup", "best fit"],
"best fit"
);
opt.localeMatcher = matcher;
// Step 7.
const type = GetOption(options, "type", "string", ["cardinal", "ordinal"], "cardinal");
const type = GetOption(
options,
"type",
"string",
["cardinal", "ordinal"],
"cardinal"
);
lazyPluralRulesData.type = type;
// Step 9.
@ -206,7 +231,10 @@ function Intl_PluralRules_select(value) {
let pluralRules = this;
// Steps 2-3.
if (!IsObject(pluralRules) || (pluralRules = intl_GuardToPluralRules(pluralRules)) === null) {
if (
!IsObject(pluralRules) ||
(pluralRules = intl_GuardToPluralRules(pluralRules)) === null
) {
return callFunction(
intl_CallPluralRulesMethodIfWrapped,
this,
@ -235,7 +263,10 @@ function Intl_PluralRules_selectRange(start, end) {
var pluralRules = this;
// Step 2.
if (!IsObject(pluralRules) || (pluralRules = intl_GuardToPluralRules(pluralRules)) === null) {
if (
!IsObject(pluralRules) ||
(pluralRules = intl_GuardToPluralRules(pluralRules)) === null
) {
return callFunction(
intl_CallPluralRulesMethodIfWrapped,
this,
@ -275,7 +306,10 @@ function Intl_PluralRules_resolvedOptions() {
var pluralRules = this;
// Steps 2-3.
if (!IsObject(pluralRules) || (pluralRules = intl_GuardToPluralRules(pluralRules)) === null) {
if (
!IsObject(pluralRules) ||
(pluralRules = intl_GuardToPluralRules(pluralRules)) === null
) {
return callFunction(
intl_CallPluralRulesMethodIfWrapped,
this,
@ -294,24 +328,42 @@ function Intl_PluralRules_resolvedOptions() {
// Min/Max fraction digits are either both present or not present at all.
assert(
hasOwn("minimumFractionDigits", internals) === hasOwn("maximumFractionDigits", internals),
hasOwn("minimumFractionDigits", internals) ===
hasOwn("maximumFractionDigits", internals),
"minimumFractionDigits is present iff maximumFractionDigits is present"
);
if (hasOwn("minimumFractionDigits", internals)) {
DefineDataProperty(result, "minimumFractionDigits", internals.minimumFractionDigits);
DefineDataProperty(result, "maximumFractionDigits", internals.maximumFractionDigits);
DefineDataProperty(
result,
"minimumFractionDigits",
internals.minimumFractionDigits
);
DefineDataProperty(
result,
"maximumFractionDigits",
internals.maximumFractionDigits
);
}
// Min/Max significant digits are either both present or not present at all.
assert(
hasOwn("minimumSignificantDigits", internals) === hasOwn("maximumSignificantDigits", internals),
hasOwn("minimumSignificantDigits", internals) ===
hasOwn("maximumSignificantDigits", internals),
"minimumSignificantDigits is present iff maximumSignificantDigits is present"
);
if (hasOwn("minimumSignificantDigits", internals)) {
DefineDataProperty(result, "minimumSignificantDigits", internals.minimumSignificantDigits);
DefineDataProperty(result, "maximumSignificantDigits", internals.maximumSignificantDigits);
DefineDataProperty(
result,
"minimumSignificantDigits",
internals.minimumSignificantDigits
);
DefineDataProperty(
result,
"maximumSignificantDigits",
internals.maximumSignificantDigits
);
}
// Step 6.

View file

@ -63,14 +63,20 @@ function resolveRelativeTimeFormatInternals(lazyRelativeTimeFormatData) {
* Returns an object containing the RelativeTimeFormat internal properties of |obj|.
*/
function getRelativeTimeFormatInternals(obj) {
assert(IsObject(obj), "getRelativeTimeFormatInternals called with non-object");
assert(
IsObject(obj),
"getRelativeTimeFormatInternals called with non-object"
);
assert(
intl_GuardToRelativeTimeFormat(obj) !== null,
"getRelativeTimeFormatInternals called with non-RelativeTimeFormat"
);
var internals = getIntlObjectInternals(obj);
assert(internals.type === "RelativeTimeFormat", "bad type escaped getIntlObjectInternals");
assert(
internals.type === "RelativeTimeFormat",
"bad type escaped getIntlObjectInternals"
);
var internalProps = maybeInternalProperties(internals);
if (internalProps) {
@ -94,7 +100,10 @@ function getRelativeTimeFormatInternals(obj) {
* Spec: ECMAScript 402 API, RelativeTimeFormat, 1.1.1.
*/
function InitializeRelativeTimeFormat(relativeTimeFormat, locales, options) {
assert(IsObject(relativeTimeFormat), "InitializeRelativeimeFormat called with non-object");
assert(
IsObject(relativeTimeFormat),
"InitializeRelativeimeFormat called with non-object"
);
assert(
intl_GuardToRelativeTimeFormat(relativeTimeFormat) !== null,
"InitializeRelativeTimeFormat called with non-RelativeTimeFormat"
@ -133,11 +142,23 @@ function InitializeRelativeTimeFormat(relativeTimeFormat, locales, options) {
let opt = new_Record();
// Steps 5-6.
let matcher = GetOption(options, "localeMatcher", "string", ["lookup", "best fit"], "best fit");
let matcher = GetOption(
options,
"localeMatcher",
"string",
["lookup", "best fit"],
"best fit"
);
opt.localeMatcher = matcher;
// Steps 7-9.
let numberingSystem = GetOption(options, "numberingSystem", "string", undefined, undefined);
let numberingSystem = GetOption(
options,
"numberingSystem",
"string",
undefined,
undefined
);
if (numberingSystem !== undefined) {
numberingSystem = intl_ValidateAndCanonicalizeUnicodeExtensionType(
numberingSystem,
@ -150,14 +171,30 @@ function InitializeRelativeTimeFormat(relativeTimeFormat, locales, options) {
lazyRelativeTimeFormatData.opt = opt;
// Steps 16-17.
const style = GetOption(options, "style", "string", ["long", "short", "narrow"], "long");
const style = GetOption(
options,
"style",
"string",
["long", "short", "narrow"],
"long"
);
lazyRelativeTimeFormatData.style = style;
// Steps 18-19.
const numeric = GetOption(options, "numeric", "string", ["always", "auto"], "always");
const numeric = GetOption(
options,
"numeric",
"string",
["always", "auto"],
"always"
);
lazyRelativeTimeFormatData.numeric = numeric;
initializeIntlObject(relativeTimeFormat, "RelativeTimeFormat", lazyRelativeTimeFormatData);
initializeIntlObject(
relativeTimeFormat,
"RelativeTimeFormat",
lazyRelativeTimeFormatData
);
}
/**
@ -194,7 +231,9 @@ function Intl_RelativeTimeFormat_format(value, unit) {
// Step 2.
if (
!IsObject(relativeTimeFormat) ||
(relativeTimeFormat = intl_GuardToRelativeTimeFormat(relativeTimeFormat)) === null
(relativeTimeFormat = intl_GuardToRelativeTimeFormat(
relativeTimeFormat
)) === null
) {
return callFunction(
intl_CallRelativeTimeFormatMethodIfWrapped,
@ -229,7 +268,9 @@ function Intl_RelativeTimeFormat_formatToParts(value, unit) {
// Step 2.
if (
!IsObject(relativeTimeFormat) ||
(relativeTimeFormat = intl_GuardToRelativeTimeFormat(relativeTimeFormat)) === null
(relativeTimeFormat = intl_GuardToRelativeTimeFormat(
relativeTimeFormat
)) === null
) {
return callFunction(
intl_CallRelativeTimeFormatMethodIfWrapped,
@ -262,7 +303,9 @@ function Intl_RelativeTimeFormat_resolvedOptions() {
// Steps 2-3.
if (
!IsObject(relativeTimeFormat) ||
(relativeTimeFormat = intl_GuardToRelativeTimeFormat(relativeTimeFormat)) === null
(relativeTimeFormat = intl_GuardToRelativeTimeFormat(
relativeTimeFormat
)) === null
) {
return callFunction(
intl_CallRelativeTimeFormatMethodIfWrapped,