mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:07:45 +00:00
LibJS: Use ECMA-262 spec URLs for .at() (relative indexing, now stage 4)
This commit is contained in:
parent
5ff7d7945d
commit
534fd41fa3
3 changed files with 97 additions and 97 deletions
|
@ -76,10 +76,10 @@ void ArrayPrototype::initialize(GlobalObject& global_object)
|
|||
// Use define_direct_property here instead of define_native_function so that
|
||||
// Object.is(Array.prototype[Symbol.iterator], Array.prototype.values)
|
||||
// evaluates to true
|
||||
// 23.1.3.33 Array.prototype [ @@iterator ] ( ), https://tc39.es/ecma262/#sec-array.prototype-@@iterator
|
||||
// 23.1.3.34 Array.prototype [ @@iterator ] ( ), https://tc39.es/ecma262/#sec-array.prototype-@@iterator
|
||||
define_direct_property(*vm.well_known_symbol_iterator(), get_without_side_effects(vm.names.values), attr);
|
||||
|
||||
// 23.1.3.34 Array.prototype [ @@unscopables ], https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
|
||||
// 23.1.3.35 Array.prototype [ @@unscopables ], https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
|
||||
// With proposal, https://tc39.es/proposal-array-find-from-last/index.html#sec-array.prototype-@@unscopables
|
||||
auto* unscopable_list = Object::create(global_object, nullptr);
|
||||
MUST(unscopable_list->create_data_property_or_throw(vm.names.copyWithin, Value(true)));
|
||||
|
@ -140,7 +140,7 @@ static ThrowCompletionOr<Object*> array_species_create(GlobalObject& global_obje
|
|||
return TRY(construct(global_object, constructor.as_function(), move(arguments)));
|
||||
}
|
||||
|
||||
// 23.1.3.7 Array.prototype.filter ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-array.prototype.filter
|
||||
// 23.1.3.8 Array.prototype.filter ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-array.prototype.filter
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::filter)
|
||||
{
|
||||
auto callback_function = vm.argument(0);
|
||||
|
@ -198,7 +198,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::filter)
|
|||
return array;
|
||||
}
|
||||
|
||||
// 23.1.3.12 Array.prototype.forEach ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-array.prototype.foreach
|
||||
// 23.1.3.13 Array.prototype.forEach ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-array.prototype.foreach
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::for_each)
|
||||
{
|
||||
auto callback_function = vm.argument(0);
|
||||
|
@ -239,7 +239,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::for_each)
|
|||
return js_undefined();
|
||||
}
|
||||
|
||||
// 23.1.3.18 Array.prototype.map ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-array.prototype.map
|
||||
// 23.1.3.19 Array.prototype.map ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-array.prototype.map
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::map)
|
||||
{
|
||||
auto callback_function = vm.argument(0);
|
||||
|
@ -286,7 +286,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::map)
|
|||
return array;
|
||||
}
|
||||
|
||||
// 23.1.3.20 Array.prototype.push ( ...items ), https://tc39.es/ecma262/#sec-array.prototype.push
|
||||
// 23.1.3.21 Array.prototype.push ( ...items ), https://tc39.es/ecma262/#sec-array.prototype.push
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::push)
|
||||
{
|
||||
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
|
||||
|
@ -302,7 +302,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::push)
|
|||
return new_length_value;
|
||||
}
|
||||
|
||||
// 23.1.3.31 Array.prototype.unshift ( ...items ), https://tc39.es/ecma262/#sec-array.prototype.unshift
|
||||
// 23.1.3.32 Array.prototype.unshift ( ...items ), https://tc39.es/ecma262/#sec-array.prototype.unshift
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::unshift)
|
||||
{
|
||||
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
|
||||
|
@ -334,7 +334,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::unshift)
|
|||
return Value(new_length);
|
||||
}
|
||||
|
||||
// 23.1.3.19 Array.prototype.pop ( ), https://tc39.es/ecma262/#sec-array.prototype.pop
|
||||
// 23.1.3.20 Array.prototype.pop ( ), https://tc39.es/ecma262/#sec-array.prototype.pop
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::pop)
|
||||
{
|
||||
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
|
||||
|
@ -350,7 +350,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::pop)
|
|||
return element;
|
||||
}
|
||||
|
||||
// 23.1.3.24 Array.prototype.shift ( ), https://tc39.es/ecma262/#sec-array.prototype.shift
|
||||
// 23.1.3.25 Array.prototype.shift ( ), https://tc39.es/ecma262/#sec-array.prototype.shift
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::shift)
|
||||
{
|
||||
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
|
||||
|
@ -377,7 +377,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::shift)
|
|||
return first;
|
||||
}
|
||||
|
||||
// 23.1.3.30 Array.prototype.toString ( ), https://tc39.es/ecma262/#sec-array.prototype.tostring
|
||||
// 23.1.3.31 Array.prototype.toString ( ), https://tc39.es/ecma262/#sec-array.prototype.tostring
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::to_string)
|
||||
{
|
||||
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
|
||||
|
@ -387,7 +387,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::to_string)
|
|||
return TRY(vm.call(join_function.as_function(), this_object));
|
||||
}
|
||||
|
||||
// 23.1.3.29 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-array.prototype.tolocalestring
|
||||
// 23.1.3.30 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-array.prototype.tolocalestring
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::to_locale_string)
|
||||
{
|
||||
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
|
||||
|
@ -416,7 +416,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::to_locale_string)
|
|||
return js_string(vm, builder.to_string());
|
||||
}
|
||||
|
||||
// 23.1.3.15 Array.prototype.join ( separator ), https://tc39.es/ecma262/#sec-array.prototype.join
|
||||
// 23.1.3.16 Array.prototype.join ( separator ), https://tc39.es/ecma262/#sec-array.prototype.join
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::join)
|
||||
{
|
||||
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
|
||||
|
@ -449,7 +449,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::join)
|
|||
return js_string(vm, builder.to_string());
|
||||
}
|
||||
|
||||
// 23.1.3.1 Array.prototype.concat ( ...items ), https://tc39.es/ecma262/#sec-array.prototype.concat
|
||||
// 23.1.3.2 Array.prototype.concat ( ...items ), https://tc39.es/ecma262/#sec-array.prototype.concat
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::concat)
|
||||
{
|
||||
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
|
||||
|
@ -458,7 +458,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::concat)
|
|||
|
||||
size_t n = 0;
|
||||
|
||||
// 23.1.3.1.1 IsConcatSpreadable ( O ), https://tc39.es/ecma262/#sec-isconcatspreadable
|
||||
// 23.1.3.2.1 IsConcatSpreadable ( O ), https://tc39.es/ecma262/#sec-isconcatspreadable
|
||||
auto is_concat_spreadable = [&vm, &global_object](Value const& val) -> ThrowCompletionOr<bool> {
|
||||
if (!val.is_object())
|
||||
return false;
|
||||
|
@ -507,7 +507,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::concat)
|
|||
return Value(new_array);
|
||||
}
|
||||
|
||||
// 23.1.3.25 Array.prototype.slice ( start, end ), https://tc39.es/ecma262/#sec-array.prototype.slice
|
||||
// 23.1.3.26 Array.prototype.slice ( start, end ), https://tc39.es/ecma262/#sec-array.prototype.slice
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::slice)
|
||||
{
|
||||
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
|
||||
|
@ -563,7 +563,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::slice)
|
|||
return new_array;
|
||||
}
|
||||
|
||||
// 23.1.3.14 Array.prototype.indexOf ( searchElement [ , fromIndex ] ), https://tc39.es/ecma262/#sec-array.prototype.indexof
|
||||
// 23.1.3.15 Array.prototype.indexOf ( searchElement [ , fromIndex ] ), https://tc39.es/ecma262/#sec-array.prototype.indexof
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::index_of)
|
||||
{
|
||||
auto search_element = vm.argument(0);
|
||||
|
@ -635,7 +635,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::index_of)
|
|||
return Value(-1);
|
||||
}
|
||||
|
||||
// 23.1.3.21 Array.prototype.reduce ( callbackfn [ , initialValue ] ), https://tc39.es/ecma262/#sec-array.prototype.reduce
|
||||
// 23.1.3.22 Array.prototype.reduce ( callbackfn [ , initialValue ] ), https://tc39.es/ecma262/#sec-array.prototype.reduce
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::reduce)
|
||||
{
|
||||
auto callback_function = vm.argument(0);
|
||||
|
@ -717,7 +717,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::reduce)
|
|||
return accumulator;
|
||||
}
|
||||
|
||||
// 23.1.3.22 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ), https://tc39.es/ecma262/#sec-array.prototype.reduceright
|
||||
// 23.1.3.23 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ), https://tc39.es/ecma262/#sec-array.prototype.reduceright
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::reduce_right)
|
||||
{
|
||||
auto callback_function = vm.argument(0);
|
||||
|
@ -799,7 +799,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::reduce_right)
|
|||
return accumulator;
|
||||
}
|
||||
|
||||
// 23.1.3.23 Array.prototype.reverse ( ), https://tc39.es/ecma262/#sec-array.prototype.reverse
|
||||
// 23.1.3.24 Array.prototype.reverse ( ), https://tc39.es/ecma262/#sec-array.prototype.reverse
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::reverse)
|
||||
{
|
||||
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
|
||||
|
@ -931,7 +931,7 @@ static ThrowCompletionOr<void> array_merge_sort(VM& vm, GlobalObject& global_obj
|
|||
return {};
|
||||
}
|
||||
|
||||
// 23.1.3.27 Array.prototype.sort ( comparefn ), https://tc39.es/ecma262/#sec-array.prototype.sort
|
||||
// 23.1.3.28 Array.prototype.sort ( comparefn ), https://tc39.es/ecma262/#sec-array.prototype.sort
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::sort)
|
||||
{
|
||||
auto callback = vm.argument(0);
|
||||
|
@ -971,7 +971,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::sort)
|
|||
return object;
|
||||
}
|
||||
|
||||
// 23.1.3.17 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ), https://tc39.es/ecma262/#sec-array.prototype.lastindexof
|
||||
// 23.1.3.18 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ), https://tc39.es/ecma262/#sec-array.prototype.lastindexof
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::last_index_of)
|
||||
{
|
||||
auto search_element = vm.argument(0);
|
||||
|
@ -1039,7 +1039,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::last_index_of)
|
|||
return Value(-1);
|
||||
}
|
||||
|
||||
// 23.1.3.13 Array.prototype.includes ( searchElement [ , fromIndex ] ), https://tc39.es/ecma262/#sec-array.prototype.includes
|
||||
// 23.1.3.14 Array.prototype.includes ( searchElement [ , fromIndex ] ), https://tc39.es/ecma262/#sec-array.prototype.includes
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::includes)
|
||||
{
|
||||
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
|
||||
|
@ -1070,7 +1070,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::includes)
|
|||
return Value(false);
|
||||
}
|
||||
|
||||
// 23.1.3.8 Array.prototype.find ( predicate [ , thisArg ] ), https://tc39.es/ecma262/#sec-array.prototype.find
|
||||
// 23.1.3.9 Array.prototype.find ( predicate [ , thisArg ] ), https://tc39.es/ecma262/#sec-array.prototype.find
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::find)
|
||||
{
|
||||
auto predicate = vm.argument(0);
|
||||
|
@ -1109,7 +1109,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::find)
|
|||
return js_undefined();
|
||||
}
|
||||
|
||||
// 23.1.3.9 Array.prototype.findIndex ( predicate [ , thisArg ] ), https://tc39.es/ecma262/#sec-array.prototype.findindex
|
||||
// 23.1.3.10 Array.prototype.findIndex ( predicate [ , thisArg ] ), https://tc39.es/ecma262/#sec-array.prototype.findindex
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::find_index)
|
||||
{
|
||||
auto predicate = vm.argument(0);
|
||||
|
@ -1226,7 +1226,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::find_last_index)
|
|||
return Value(-1);
|
||||
}
|
||||
|
||||
// 23.1.3.26 Array.prototype.some ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-array.prototype.some
|
||||
// 23.1.3.27 Array.prototype.some ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-array.prototype.some
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::some)
|
||||
{
|
||||
auto callback_function = vm.argument(0);
|
||||
|
@ -1271,7 +1271,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::some)
|
|||
return Value(false);
|
||||
}
|
||||
|
||||
// 23.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-array.prototype.every
|
||||
// 23.1.3.6 Array.prototype.every ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-array.prototype.every
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::every)
|
||||
{
|
||||
auto callback_function = vm.argument(0);
|
||||
|
@ -1316,7 +1316,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::every)
|
|||
return Value(true);
|
||||
}
|
||||
|
||||
// 23.1.3.28 Array.prototype.splice ( start, deleteCount, ...items ), https://tc39.es/ecma262#sec-array.prototype.splice
|
||||
// 23.1.3.29 Array.prototype.splice ( start, deleteCount, ...items ), https://tc39.es/ecma262#sec-array.prototype.splice
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::splice)
|
||||
{
|
||||
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
|
||||
|
@ -1408,7 +1408,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::splice)
|
|||
return removed_elements;
|
||||
}
|
||||
|
||||
// 23.1.3.6 Array.prototype.fill ( value [ , start [ , end ] ] ), https://tc39.es/ecma262/#sec-array.prototype.fill
|
||||
// 23.1.3.7 Array.prototype.fill ( value [ , start [ , end ] ] ), https://tc39.es/ecma262/#sec-array.prototype.fill
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::fill)
|
||||
{
|
||||
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
|
||||
|
@ -1449,7 +1449,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::fill)
|
|||
return this_object;
|
||||
}
|
||||
|
||||
// 23.1.3.32 Array.prototype.values ( ), https://tc39.es/ecma262/#sec-array.prototype.values
|
||||
// 23.1.3.33 Array.prototype.values ( ), https://tc39.es/ecma262/#sec-array.prototype.values
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::values)
|
||||
{
|
||||
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
|
||||
|
@ -1457,7 +1457,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::values)
|
|||
return ArrayIterator::create(global_object, this_object, Object::PropertyKind::Value);
|
||||
}
|
||||
|
||||
// 23.1.3.16 Array.prototype.entries ( ), https://tc39.es/ecma262/#sec-array.prototype.entries
|
||||
// 23.1.3.5 Array.prototype.entries ( ), https://tc39.es/ecma262/#sec-array.prototype.entries
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::entries)
|
||||
{
|
||||
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
|
||||
|
@ -1465,7 +1465,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::entries)
|
|||
return ArrayIterator::create(global_object, this_object, Object::PropertyKind::KeyAndValue);
|
||||
}
|
||||
|
||||
// 23.1.3.16 Array.prototype.keys ( ), https://tc39.es/ecma262/#sec-array.prototype.keys
|
||||
// 23.1.3.17 Array.prototype.keys ( ), https://tc39.es/ecma262/#sec-array.prototype.keys
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::keys)
|
||||
{
|
||||
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
|
||||
|
@ -1473,7 +1473,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::keys)
|
|||
return ArrayIterator::create(global_object, this_object, Object::PropertyKind::Key);
|
||||
}
|
||||
|
||||
// 23.1.3.10.1 FlattenIntoArray ( target, source, sourceLen, start, depth [ , mapperFunction [ , thisArg ] ] ), https://tc39.es/ecma262/#sec-flattenintoarray
|
||||
// 23.1.3.11.1 FlattenIntoArray ( target, source, sourceLen, start, depth [ , mapperFunction [ , thisArg ] ] ), https://tc39.es/ecma262/#sec-flattenintoarray
|
||||
static ThrowCompletionOr<size_t> flatten_into_array(GlobalObject& global_object, Object& new_array, Object& array, size_t array_length, size_t target_index, double depth, FunctionObject* mapper_func = {}, Value this_arg = {})
|
||||
{
|
||||
VERIFY(!mapper_func || (!this_arg.is_empty() && depth == 1));
|
||||
|
@ -1508,7 +1508,7 @@ static ThrowCompletionOr<size_t> flatten_into_array(GlobalObject& global_object,
|
|||
return target_index;
|
||||
}
|
||||
|
||||
// 23.1.3.10 Array.prototype.flat ( [ depth ] ), https://tc39.es/ecma262/#sec-array.prototype.flat
|
||||
// 23.1.3.11 Array.prototype.flat ( [ depth ] ), https://tc39.es/ecma262/#sec-array.prototype.flat
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::flat)
|
||||
{
|
||||
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
|
||||
|
@ -1527,7 +1527,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::flat)
|
|||
return new_array;
|
||||
}
|
||||
|
||||
// 23.1.3.11 Array.prototype.flatMap ( mapperFunction [ , thisArg ] ), https://tc39.es/ecma262/#sec-array.prototype.flatmap
|
||||
// 23.1.3.12 Array.prototype.flatMap ( mapperFunction [ , thisArg ] ), https://tc39.es/ecma262/#sec-array.prototype.flatmap
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::flat_map)
|
||||
{
|
||||
auto mapper_function = vm.argument(0);
|
||||
|
@ -1619,7 +1619,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::copy_within)
|
|||
return this_object;
|
||||
}
|
||||
|
||||
// 1.1 Array.prototype.at ( index ), https://tc39.es/proposal-relative-indexing-method/#sec-array.prototype.at
|
||||
// 23.1.3.1 Array.prototype.at ( index ), https://tc39.es/ecma262/#sec-array.prototype.at
|
||||
JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::at)
|
||||
{
|
||||
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
|
||||
|
|
|
@ -175,7 +175,7 @@ static ThrowCompletionOr<PrimitiveString*> this_string_value(GlobalObject& globa
|
|||
return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "String");
|
||||
}
|
||||
|
||||
// 22.1.3.1 String.prototype.charAt ( pos ), https://tc39.es/ecma262/#sec-string.prototype.charat
|
||||
// 22.1.3.2 String.prototype.charAt ( pos ), https://tc39.es/ecma262/#sec-string.prototype.charat
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::char_at)
|
||||
{
|
||||
auto string = utf16_string_from(vm, global_object);
|
||||
|
@ -188,7 +188,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::char_at)
|
|||
return js_string(vm, string.substring_view(position, 1));
|
||||
}
|
||||
|
||||
// 22.1.3.2 String.prototype.charCodeAt ( pos ), https://tc39.es/ecma262/#sec-string.prototype.charcodeat
|
||||
// 22.1.3.3 String.prototype.charCodeAt ( pos ), https://tc39.es/ecma262/#sec-string.prototype.charcodeat
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::char_code_at)
|
||||
{
|
||||
auto string = utf16_string_from(vm, global_object);
|
||||
|
@ -201,7 +201,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::char_code_at)
|
|||
return Value(string.code_unit_at(position));
|
||||
}
|
||||
|
||||
// 22.1.3.3 String.prototype.codePointAt ( pos ), https://tc39.es/ecma262/#sec-string.prototype.codepointat
|
||||
// 22.1.3.4 String.prototype.codePointAt ( pos ), https://tc39.es/ecma262/#sec-string.prototype.codepointat
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::code_point_at)
|
||||
{
|
||||
auto string = utf16_string_from(vm, global_object);
|
||||
|
@ -215,7 +215,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::code_point_at)
|
|||
return Value(code_point.code_point);
|
||||
}
|
||||
|
||||
// 22.1.3.16 String.prototype.repeat ( count ), https://tc39.es/ecma262/#sec-string.prototype.repeat
|
||||
// 22.1.3.17 String.prototype.repeat ( count ), https://tc39.es/ecma262/#sec-string.prototype.repeat
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::repeat)
|
||||
{
|
||||
auto string = ak_string_from(vm, global_object);
|
||||
|
@ -247,7 +247,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::repeat)
|
|||
return js_string(vm, builder.to_string());
|
||||
}
|
||||
|
||||
// 22.1.3.22 String.prototype.startsWith ( searchString [ , position ] ), https://tc39.es/ecma262/#sec-string.prototype.startswith
|
||||
// 22.1.3.23 String.prototype.startsWith ( searchString [ , position ] ), https://tc39.es/ecma262/#sec-string.prototype.startswith
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::starts_with)
|
||||
{
|
||||
auto string = utf16_string_from(vm, global_object);
|
||||
|
@ -283,7 +283,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::starts_with)
|
|||
return Value(substring_view == search_string.view());
|
||||
}
|
||||
|
||||
// 22.1.3.6 String.prototype.endsWith ( searchString [ , endPosition ] ), https://tc39.es/ecma262/#sec-string.prototype.endswith
|
||||
// 22.1.3.7 String.prototype.endsWith ( searchString [ , endPosition ] ), https://tc39.es/ecma262/#sec-string.prototype.endswith
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::ends_with)
|
||||
{
|
||||
auto string = utf16_string_from(vm, global_object);
|
||||
|
@ -319,7 +319,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::ends_with)
|
|||
return Value(substring_view == search_string.view());
|
||||
}
|
||||
|
||||
// 22.1.3.8 String.prototype.indexOf ( searchString [ , position ] ), https://tc39.es/ecma262/#sec-string.prototype.indexof
|
||||
// 22.1.3.9 String.prototype.indexOf ( searchString [ , position ] ), https://tc39.es/ecma262/#sec-string.prototype.indexof
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::index_of)
|
||||
{
|
||||
auto string = utf16_string_from(vm, global_object);
|
||||
|
@ -406,7 +406,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::to_locale_uppercase)
|
|||
return js_string(vm, move(uppercase));
|
||||
}
|
||||
|
||||
// 22.1.3.26 String.prototype.toLowerCase ( ), https://tc39.es/ecma262/#sec-string.prototype.tolowercase
|
||||
// 22.1.3.27 String.prototype.toLowerCase ( ), https://tc39.es/ecma262/#sec-string.prototype.tolowercase
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::to_lowercase)
|
||||
{
|
||||
auto string = ak_string_from(vm, global_object);
|
||||
|
@ -417,7 +417,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::to_lowercase)
|
|||
return js_string(vm, move(lowercase));
|
||||
}
|
||||
|
||||
// 22.1.3.28 String.prototype.toUpperCase ( ), https://tc39.es/ecma262/#sec-string.prototype.touppercase
|
||||
// 22.1.3.29 String.prototype.toUpperCase ( ), https://tc39.es/ecma262/#sec-string.prototype.touppercase
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::to_uppercase)
|
||||
{
|
||||
auto string = ak_string_from(vm, global_object);
|
||||
|
@ -428,13 +428,13 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::to_uppercase)
|
|||
return js_string(vm, move(uppercase));
|
||||
}
|
||||
|
||||
// 22.1.3.27 String.prototype.toString ( ), https://tc39.es/ecma262/#sec-string.prototype.tostring
|
||||
// 22.1.3.28 String.prototype.toString ( ), https://tc39.es/ecma262/#sec-string.prototype.tostring
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::to_string)
|
||||
{
|
||||
return TRY_OR_DISCARD(this_string_value(global_object, vm.this_value(global_object)));
|
||||
}
|
||||
|
||||
// 22.1.3.32 String.prototype.valueOf ( ), https://tc39.es/ecma262/#sec-string.prototype.valueof
|
||||
// 22.1.3.33 String.prototype.valueOf ( ), https://tc39.es/ecma262/#sec-string.prototype.valueof
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::value_of)
|
||||
{
|
||||
return TRY_OR_DISCARD(this_string_value(global_object, vm.this_value(global_object)));
|
||||
|
@ -445,7 +445,7 @@ enum class PadPlacement {
|
|||
End,
|
||||
};
|
||||
|
||||
// 22.1.3.15.1 StringPad ( O, maxLength, fillString, placement ), https://tc39.es/ecma262/#sec-stringpad
|
||||
// 22.1.3.16.1 StringPad ( O, maxLength, fillString, placement ), https://tc39.es/ecma262/#sec-stringpad
|
||||
static Value pad_string(GlobalObject& global_object, Utf16String string, PadPlacement placement)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
|
@ -478,7 +478,7 @@ static Value pad_string(GlobalObject& global_object, Utf16String string, PadPlac
|
|||
return js_string(vm, move(formatted));
|
||||
}
|
||||
|
||||
// 22.1.3.15 String.prototype.padStart ( maxLength [ , fillString ] ), https://tc39.es/ecma262/#sec-string.prototype.padstart
|
||||
// 22.1.3.16 String.prototype.padStart ( maxLength [ , fillString ] ), https://tc39.es/ecma262/#sec-string.prototype.padstart
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::pad_start)
|
||||
{
|
||||
auto string = utf16_string_from(vm, global_object);
|
||||
|
@ -487,7 +487,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::pad_start)
|
|||
return pad_string(global_object, move(string), PadPlacement::Start);
|
||||
}
|
||||
|
||||
// 22.1.3.14 String.prototype.padEnd ( maxLength [ , fillString ] ), https://tc39.es/ecma262/#sec-string.prototype.padend
|
||||
// 22.1.3.15 String.prototype.padEnd ( maxLength [ , fillString ] ), https://tc39.es/ecma262/#sec-string.prototype.padend
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::pad_end)
|
||||
{
|
||||
auto string = utf16_string_from(vm, global_object);
|
||||
|
@ -498,7 +498,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::pad_end)
|
|||
|
||||
static Utf8View const whitespace_characters = Utf8View("\x09\x0A\x0B\x0C\x0D\x20\xC2\xA0\xE1\x9A\x80\xE2\x80\x80\xE2\x80\x81\xE2\x80\x82\xE2\x80\x83\xE2\x80\x84\xE2\x80\x85\xE2\x80\x86\xE2\x80\x87\xE2\x80\x88\xE2\x80\x89\xE2\x80\x8A\xE2\x80\xAF\xE2\x81\x9F\xE3\x80\x80\xE2\x80\xA8\xE2\x80\xA9\xEF\xBB\xBF"sv);
|
||||
|
||||
// 22.1.3.29 String.prototype.trim ( ), https://tc39.es/ecma262/#sec-string.prototype.trim
|
||||
// 22.1.3.30 String.prototype.trim ( ), https://tc39.es/ecma262/#sec-string.prototype.trim
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::trim)
|
||||
{
|
||||
auto string = ak_string_from(vm, global_object);
|
||||
|
@ -507,7 +507,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::trim)
|
|||
return js_string(vm, Utf8View(*string).trim(whitespace_characters, TrimMode::Both).as_string());
|
||||
}
|
||||
|
||||
// 22.1.3.31 String.prototype.trimStart ( ), https://tc39.es/ecma262/#sec-string.prototype.trimstart
|
||||
// 22.1.3.32 String.prototype.trimStart ( ), https://tc39.es/ecma262/#sec-string.prototype.trimstart
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::trim_start)
|
||||
{
|
||||
auto string = ak_string_from(vm, global_object);
|
||||
|
@ -516,7 +516,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::trim_start)
|
|||
return js_string(vm, Utf8View(*string).trim(whitespace_characters, TrimMode::Left).as_string());
|
||||
}
|
||||
|
||||
// 22.1.3.30 String.prototype.trimEnd ( ), https://tc39.es/ecma262/#sec-string.prototype.trimend
|
||||
// 22.1.3.31 String.prototype.trimEnd ( ), https://tc39.es/ecma262/#sec-string.prototype.trimend
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::trim_end)
|
||||
{
|
||||
auto string = ak_string_from(vm, global_object);
|
||||
|
@ -525,7 +525,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::trim_end)
|
|||
return js_string(vm, Utf8View(*string).trim(whitespace_characters, TrimMode::Right).as_string());
|
||||
}
|
||||
|
||||
// 22.1.3.4 String.prototype.concat ( ...args ), https://tc39.es/ecma262/#sec-string.prototype.concat
|
||||
// 22.1.3.5 String.prototype.concat ( ...args ), https://tc39.es/ecma262/#sec-string.prototype.concat
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::concat)
|
||||
{
|
||||
auto string = ak_string_from(vm, global_object);
|
||||
|
@ -540,7 +540,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::concat)
|
|||
return js_string(vm, builder.to_string());
|
||||
}
|
||||
|
||||
// 22.1.3.23 String.prototype.substring ( start, end ), https://tc39.es/ecma262/#sec-string.prototype.substring
|
||||
// 22.1.3.24 String.prototype.substring ( start, end ), https://tc39.es/ecma262/#sec-string.prototype.substring
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::substring)
|
||||
{
|
||||
auto string = utf16_string_from(vm, global_object);
|
||||
|
@ -590,7 +590,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::substr)
|
|||
return js_string(vm, string.substring_view(int_start, int_end - int_start));
|
||||
}
|
||||
|
||||
// 22.1.3.7 String.prototype.includes ( searchString [ , position ] ), https://tc39.es/ecma262/#sec-string.prototype.includes
|
||||
// 22.1.3.8 String.prototype.includes ( searchString [ , position ] ), https://tc39.es/ecma262/#sec-string.prototype.includes
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::includes)
|
||||
{
|
||||
auto string = utf16_string_from(vm, global_object);
|
||||
|
@ -617,7 +617,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::includes)
|
|||
return Value(index.has_value());
|
||||
}
|
||||
|
||||
// 22.1.3.20 String.prototype.slice ( start, end ), https://tc39.es/ecma262/#sec-string.prototype.slice
|
||||
// 22.1.3.21 String.prototype.slice ( start, end ), https://tc39.es/ecma262/#sec-string.prototype.slice
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::slice)
|
||||
{
|
||||
auto string = utf16_string_from(vm, global_object);
|
||||
|
@ -650,7 +650,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::slice)
|
|||
return js_string(vm, string.substring_view(int_start, int_end - int_start));
|
||||
}
|
||||
|
||||
// 22.1.3.21 String.prototype.split ( separator, limit ), https://tc39.es/ecma262/#sec-string.prototype.split
|
||||
// 22.1.3.22 String.prototype.split ( separator, limit ), https://tc39.es/ecma262/#sec-string.prototype.split
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::split)
|
||||
{
|
||||
auto object = TRY_OR_DISCARD(require_object_coercible(global_object, vm.this_value(global_object)));
|
||||
|
@ -716,7 +716,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::split)
|
|||
return array;
|
||||
}
|
||||
|
||||
// 22.1.3.9 String.prototype.lastIndexOf ( searchString [ , position ] ), https://tc39.es/ecma262/#sec-string.prototype.lastindexof
|
||||
// 22.1.3.10 String.prototype.lastIndexOf ( searchString [ , position ] ), https://tc39.es/ecma262/#sec-string.prototype.lastindexof
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::last_index_of)
|
||||
{
|
||||
auto string = utf16_string_from(vm, global_object);
|
||||
|
@ -750,7 +750,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::last_index_of)
|
|||
return last_index.has_value() ? Value(*last_index) : Value(-1);
|
||||
}
|
||||
|
||||
// 3.1 String.prototype.at ( index ), https://tc39.es/proposal-relative-indexing-method/#sec-string.prototype.at
|
||||
// 22.1.3.1 String.prototype.at ( index ), https://tc39.es/ecma262/#sec-string.prototype.at
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::at)
|
||||
{
|
||||
auto string = utf16_string_from(vm, global_object);
|
||||
|
@ -775,7 +775,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::at)
|
|||
return js_string(vm, string.substring_view(index.value(), 1));
|
||||
}
|
||||
|
||||
// 22.1.3.33 String.prototype [ @@iterator ] ( ), https://tc39.es/ecma262/#sec-string.prototype-@@iterator
|
||||
// 22.1.3.34 String.prototype [ @@iterator ] ( ), https://tc39.es/ecma262/#sec-string.prototype-@@iterator
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::symbol_iterator)
|
||||
{
|
||||
auto this_object = TRY_OR_DISCARD(require_object_coercible(global_object, vm.this_value(global_object)));
|
||||
|
@ -783,7 +783,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::symbol_iterator)
|
|||
return StringIterator::create(global_object, string);
|
||||
}
|
||||
|
||||
// 22.1.3.11 String.prototype.match ( regexp ), https://tc39.es/ecma262/#sec-string.prototype.match
|
||||
// 22.1.3.12 String.prototype.match ( regexp ), https://tc39.es/ecma262/#sec-string.prototype.match
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::match)
|
||||
{
|
||||
auto this_object = TRY_OR_DISCARD(require_object_coercible(global_object, vm.this_value(global_object)));
|
||||
|
@ -801,7 +801,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::match)
|
|||
return TRY_OR_DISCARD(Value(rx).invoke(global_object, *vm.well_known_symbol_match(), js_string(vm, move(string))));
|
||||
}
|
||||
|
||||
// 22.1.3.12 String.prototype.matchAll ( regexp ), https://tc39.es/ecma262/#sec-string.prototype.matchall
|
||||
// 22.1.3.13 String.prototype.matchAll ( regexp ), https://tc39.es/ecma262/#sec-string.prototype.matchall
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::match_all)
|
||||
{
|
||||
auto this_object = TRY_OR_DISCARD(require_object_coercible(global_object, vm.this_value(global_object)));
|
||||
|
@ -829,7 +829,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::match_all)
|
|||
return TRY_OR_DISCARD(Value(rx).invoke(global_object, *vm.well_known_symbol_match_all(), js_string(vm, move(string))));
|
||||
}
|
||||
|
||||
// 22.1.3.17 String.prototype.replace ( searchValue, replaceValue ), https://tc39.es/ecma262/#sec-string.prototype.replace
|
||||
// 22.1.3.18 String.prototype.replace ( searchValue, replaceValue ), https://tc39.es/ecma262/#sec-string.prototype.replace
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::replace)
|
||||
{
|
||||
auto this_object = TRY_OR_DISCARD(require_object_coercible(global_object, vm.this_value(global_object)));
|
||||
|
@ -871,7 +871,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::replace)
|
|||
return js_string(vm, builder.build());
|
||||
}
|
||||
|
||||
// 22.1.3.18 String.prototype.replaceAll ( searchValue, replaceValue ), https://tc39.es/ecma262/#sec-string.prototype.replaceall
|
||||
// 22.1.3.19 String.prototype.replaceAll ( searchValue, replaceValue ), https://tc39.es/ecma262/#sec-string.prototype.replaceall
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::replace_all)
|
||||
{
|
||||
auto this_object = TRY_OR_DISCARD(require_object_coercible(global_object, vm.this_value(global_object)));
|
||||
|
@ -944,7 +944,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::replace_all)
|
|||
return js_string(vm, result.build());
|
||||
}
|
||||
|
||||
// 22.1.3.19 String.prototype.search ( regexp ), https://tc39.es/ecma262/#sec-string.prototype.search
|
||||
// 22.1.3.20 String.prototype.search ( regexp ), https://tc39.es/ecma262/#sec-string.prototype.search
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::search)
|
||||
{
|
||||
auto this_object = TRY_OR_DISCARD(require_object_coercible(global_object, vm.this_value(global_object)));
|
||||
|
@ -1065,7 +1065,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::sup)
|
|||
return create_html(global_object, vm.this_value(global_object), "sup", String::empty(), Value());
|
||||
}
|
||||
|
||||
// 22.1.3.10 String.prototype.localeCompare ( that [ , reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-string.prototype.localecompare
|
||||
// 22.1.3.11 String.prototype.localeCompare ( that [ , reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-string.prototype.localecompare
|
||||
// NOTE: This is the minimum localeCompare implementation for engines without ECMA-402.
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(StringPrototype::locale_compare)
|
||||
{
|
||||
|
|
|
@ -59,7 +59,7 @@ void TypedArrayPrototype::initialize(GlobalObject& object)
|
|||
|
||||
define_old_native_accessor(*vm.well_known_symbol_to_string_tag(), to_string_tag_getter, nullptr, Attribute::Configurable);
|
||||
|
||||
// 23.2.3.29 %TypedArray%.prototype.toString ( ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.tostring
|
||||
// 23.2.3.30 %TypedArray%.prototype.toString ( ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.tostring
|
||||
define_direct_property(vm.names.toString, global_object().array_prototype()->get_without_side_effects(vm.names.toString), attr);
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ static TypedArrayBase* typed_array_species_create(GlobalObject& global_object, T
|
|||
return result;
|
||||
}
|
||||
|
||||
// 23.2.3.18 get %TypedArray%.prototype.length, https://tc39.es/ecma262/#sec-get-%typedarray%.prototype.length
|
||||
// 23.2.3.19 get %TypedArray%.prototype.length, https://tc39.es/ecma262/#sec-get-%typedarray%.prototype.length
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::length_getter)
|
||||
{
|
||||
auto typed_array = typed_array_from_this(global_object);
|
||||
|
@ -200,7 +200,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::length_getter)
|
|||
return Value(typed_array->array_length());
|
||||
}
|
||||
|
||||
// 4.1 %TypedArray%.prototype.at ( index ), https://tc39.es/proposal-relative-indexing-method/#sec-%typedarray%.prototype.at
|
||||
// 23.2.3.1 %TypedArray%.prototype.at ( index ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.at
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::at)
|
||||
{
|
||||
auto* typed_array = validate_typed_array_from_this(global_object);
|
||||
|
@ -222,7 +222,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::at)
|
|||
return TRY_OR_DISCARD(typed_array->get(index.value()));
|
||||
}
|
||||
|
||||
// 23.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.every
|
||||
// 23.2.3.8 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.every
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::every)
|
||||
{
|
||||
auto result = true;
|
||||
|
@ -236,7 +236,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::every)
|
|||
return Value(result);
|
||||
}
|
||||
|
||||
// 23.2.3.8 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.fill
|
||||
// 23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.fill
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::fill)
|
||||
{
|
||||
auto typed_array = validate_typed_array_from_this(global_object);
|
||||
|
@ -286,7 +286,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::fill)
|
|||
return typed_array;
|
||||
}
|
||||
|
||||
// 23.2.3.10 %TypedArray%.prototype.find ( predicate [ , thisArg ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.find
|
||||
// 23.2.3.11 %TypedArray%.prototype.find ( predicate [ , thisArg ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.find
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::find)
|
||||
{
|
||||
auto result = js_undefined();
|
||||
|
@ -300,7 +300,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::find)
|
|||
return result;
|
||||
}
|
||||
|
||||
// 23.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.findindex
|
||||
// 23.2.3.12 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.findindex
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::find_index)
|
||||
{
|
||||
auto result_index = -1;
|
||||
|
@ -342,7 +342,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::find_last_index)
|
|||
return Value(result_index);
|
||||
}
|
||||
|
||||
// 23.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.foreach
|
||||
// 23.2.3.13 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.foreach
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::for_each)
|
||||
{
|
||||
for_each_item(vm, global_object, "forEach", [](auto, auto, auto) {
|
||||
|
@ -351,7 +351,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::for_each)
|
|||
return js_undefined();
|
||||
}
|
||||
|
||||
// 23.2.3.13 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.includes
|
||||
// 23.2.3.14 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.includes
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::includes)
|
||||
{
|
||||
auto typed_array = validate_typed_array_from_this(global_object);
|
||||
|
@ -392,7 +392,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::includes)
|
|||
return Value(false);
|
||||
}
|
||||
|
||||
// 23.2.3.14 %TypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.indexof
|
||||
// 23.2.3.15 %TypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.indexof
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::index_of)
|
||||
{
|
||||
auto typed_array = validate_typed_array_from_this(global_object);
|
||||
|
@ -436,7 +436,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::index_of)
|
|||
return Value(-1);
|
||||
}
|
||||
|
||||
// 23.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.lastindexof
|
||||
// 23.2.3.18 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.lastindexof
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::last_index_of)
|
||||
{
|
||||
auto typed_array = validate_typed_array_from_this(global_object);
|
||||
|
@ -481,7 +481,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::last_index_of)
|
|||
return Value(-1);
|
||||
}
|
||||
|
||||
// 23.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.reduce
|
||||
// 23.2.3.21 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.reduce
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::reduce)
|
||||
{
|
||||
auto* typed_array = validate_typed_array_from_this(global_object);
|
||||
|
@ -517,7 +517,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::reduce)
|
|||
return accumulator;
|
||||
}
|
||||
|
||||
// 23.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.reduce
|
||||
// 23.2.3.22 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.reduce
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::reduce_right)
|
||||
{
|
||||
auto* typed_array = validate_typed_array_from_this(global_object);
|
||||
|
@ -553,7 +553,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::reduce_right)
|
|||
return accumulator;
|
||||
}
|
||||
|
||||
// 23.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.some
|
||||
// 23.2.3.26 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.some
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::some)
|
||||
{
|
||||
auto result = false;
|
||||
|
@ -567,7 +567,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::some)
|
|||
return Value(result);
|
||||
}
|
||||
|
||||
// 23.2.3.15 %TypedArray%.prototype.join ( separator ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.join
|
||||
// 23.2.3.16 %TypedArray%.prototype.join ( separator ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.join
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::join)
|
||||
{
|
||||
auto* typed_array = validate_typed_array_from_this(global_object);
|
||||
|
@ -592,7 +592,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::join)
|
|||
return js_string(vm, builder.to_string());
|
||||
}
|
||||
|
||||
// 23.2.3.16 %TypedArray%.prototype.keys ( ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.keys
|
||||
// 23.2.3.17 %TypedArray%.prototype.keys ( ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.keys
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::keys)
|
||||
{
|
||||
auto* typed_array = validate_typed_array_from_this(global_object);
|
||||
|
@ -601,7 +601,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::keys)
|
|||
return ArrayIterator::create(global_object, typed_array, Object::PropertyKind::Key);
|
||||
}
|
||||
|
||||
// 23.2.3.30 %TypedArray%.prototype.values ( ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.values
|
||||
// 23.2.3.31 %TypedArray%.prototype.values ( ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.values
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::values)
|
||||
{
|
||||
auto* typed_array = typed_array_from_this(global_object);
|
||||
|
@ -610,7 +610,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::values)
|
|||
return ArrayIterator::create(global_object, typed_array, Object::PropertyKind::Value);
|
||||
}
|
||||
|
||||
// 23.2.3.6 %TypedArray%.prototype.entries ( ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.entries
|
||||
// 23.2.3.7 %TypedArray%.prototype.entries ( ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.entries
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::entries)
|
||||
{
|
||||
auto* typed_array = validate_typed_array_from_this(global_object);
|
||||
|
@ -619,7 +619,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::entries)
|
|||
return ArrayIterator::create(global_object, typed_array, Object::PropertyKind::KeyAndValue);
|
||||
}
|
||||
|
||||
// 23.2.3.1 get %TypedArray%.prototype.buffer, https://tc39.es/ecma262/#sec-get-%typedarray%.prototype.buffer
|
||||
// 23.2.3.2 get %TypedArray%.prototype.buffer, https://tc39.es/ecma262/#sec-get-%typedarray%.prototype.buffer
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::buffer_getter)
|
||||
{
|
||||
auto* typed_array = typed_array_from_this(global_object);
|
||||
|
@ -630,7 +630,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::buffer_getter)
|
|||
return Value(array_buffer);
|
||||
}
|
||||
|
||||
// 23.2.3.2 get %TypedArray%.prototype.byteLength, https://tc39.es/ecma262/#sec-get-%typedarray%.prototype.bytelength
|
||||
// 23.2.3.3 get %TypedArray%.prototype.byteLength, https://tc39.es/ecma262/#sec-get-%typedarray%.prototype.bytelength
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::byte_length_getter)
|
||||
{
|
||||
auto* typed_array = typed_array_from_this(global_object);
|
||||
|
@ -643,7 +643,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::byte_length_getter)
|
|||
return Value(typed_array->byte_length());
|
||||
}
|
||||
|
||||
// 23.2.3.3 get %TypedArray%.prototype.byteOffset, https://tc39.es/ecma262/#sec-get-%typedarray%.prototype.byteoffset
|
||||
// 23.2.3.4 get %TypedArray%.prototype.byteOffset, https://tc39.es/ecma262/#sec-get-%typedarray%.prototype.byteoffset
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::byte_offset_getter)
|
||||
{
|
||||
auto* typed_array = typed_array_from_this(global_object);
|
||||
|
@ -656,7 +656,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::byte_offset_getter)
|
|||
return Value(typed_array->byte_offset());
|
||||
}
|
||||
|
||||
// 23.2.3.32 get %TypedArray%.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-get-%typedarray%.prototype-@@tostringtag
|
||||
// 23.2.3.33 get %TypedArray%.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-get-%typedarray%.prototype-@@tostringtag
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::to_string_tag_getter)
|
||||
{
|
||||
auto this_value = vm.this_value(global_object);
|
||||
|
@ -668,7 +668,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::to_string_tag_getter)
|
|||
return js_string(vm, static_cast<TypedArrayBase&>(this_object).element_name());
|
||||
}
|
||||
|
||||
// 23.2.3.23 %TypedArray%.prototype.set ( source [ , offset ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.set
|
||||
// 23.2.3.24 %TypedArray%.prototype.set ( source [ , offset ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.set
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::set)
|
||||
{
|
||||
auto* typed_array = typed_array_from_this(global_object);
|
||||
|
@ -822,7 +822,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::set)
|
|||
return js_undefined();
|
||||
}
|
||||
|
||||
// 23.2.3.24 %TypedArray%.prototype.slice ( start, end ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.slice
|
||||
// 23.2.3.25 %TypedArray%.prototype.slice ( start, end ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.slice
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::slice)
|
||||
{
|
||||
auto* typed_array = validate_typed_array_from_this(global_object);
|
||||
|
@ -1003,7 +1003,7 @@ static void typed_array_merge_sort(GlobalObject& global_object, FunctionObject*
|
|||
}
|
||||
}
|
||||
|
||||
// 23.2.3.26 %TypedArray%.prototype.sort ( comparefn ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.sort
|
||||
// 23.2.3.27 %TypedArray%.prototype.sort ( comparefn ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.sort
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::sort)
|
||||
{
|
||||
auto compare_fn = vm.argument(0);
|
||||
|
@ -1042,7 +1042,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::sort)
|
|||
return typed_array;
|
||||
}
|
||||
|
||||
// 23.2.3.27 %TypedArray%.prototype.subarray ( begin, end ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.subarray
|
||||
// 23.2.3.28 %TypedArray%.prototype.subarray ( begin, end ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.subarray
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::subarray)
|
||||
{
|
||||
auto* typed_array = typed_array_from_this(global_object);
|
||||
|
@ -1092,7 +1092,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::subarray)
|
|||
return typed_array_species_create(global_object, *typed_array, move(arguments));
|
||||
}
|
||||
|
||||
// 23.2.3.22 %TypedArray%.prototype.reverse ( ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.reverse
|
||||
// 23.2.3.23 %TypedArray%.prototype.reverse ( ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.reverse
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::reverse)
|
||||
{
|
||||
// 1. Let O be the this value.
|
||||
|
@ -1134,7 +1134,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::reverse)
|
|||
return typed_array;
|
||||
}
|
||||
|
||||
// 23.2.3.5 %TypedArray%.prototype.copyWithin ( target, start [ , end ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.copywithin
|
||||
// 23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.copywithin
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::copy_within)
|
||||
{
|
||||
// 1. Let O be the this value.
|
||||
|
@ -1306,7 +1306,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::copy_within)
|
|||
return typed_array;
|
||||
}
|
||||
|
||||
// 23.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.filter
|
||||
// 23.2.3.10 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.filter
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::filter)
|
||||
{
|
||||
// 1. Let O be the this value.
|
||||
|
@ -1376,7 +1376,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::filter)
|
|||
return filter_array;
|
||||
}
|
||||
|
||||
// 23.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.map
|
||||
// 23.2.3.20 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.map
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::map)
|
||||
{
|
||||
// 1. Let O be the this value.
|
||||
|
@ -1422,7 +1422,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::map)
|
|||
return return_array;
|
||||
}
|
||||
|
||||
// 23.2.3.28 %TypedArray%.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.tolocalestring
|
||||
// 23.2.3.29 %TypedArray%.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-%typedarray%.prototype.tolocalestring
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(TypedArrayPrototype::to_locale_string)
|
||||
{
|
||||
auto* typed_array = validate_typed_array_from_this(global_object);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue