mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:57:43 +00:00
LibJS: Convert typed_array_from to ThrowCompletionOr
This commit is contained in:
parent
50698a0db4
commit
3edf86462b
3 changed files with 14 additions and 34 deletions
|
@ -164,9 +164,7 @@ void AtomicsObject::initialize(GlobalObject& global_object)
|
|||
// 25.4.3 Atomics.add ( typedArray, index, value ), https://tc39.es/ecma262/#sec-atomics.add
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(AtomicsObject::add)
|
||||
{
|
||||
auto* typed_array = typed_array_from(global_object, vm.argument(0));
|
||||
if (!typed_array)
|
||||
return {};
|
||||
auto* typed_array = TRY_OR_DISCARD(typed_array_from(global_object, vm.argument(0)));
|
||||
|
||||
auto atomic_add = [](auto* storage, auto value) { return AK::atomic_fetch_add(storage, value); };
|
||||
|
||||
|
@ -182,9 +180,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(AtomicsObject::add)
|
|||
// 25.4.4 Atomics.and ( typedArray, index, value ), https://tc39.es/ecma262/#sec-atomics.and
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(AtomicsObject::and_)
|
||||
{
|
||||
auto* typed_array = typed_array_from(global_object, vm.argument(0));
|
||||
if (!typed_array)
|
||||
return {};
|
||||
auto* typed_array = TRY_OR_DISCARD(typed_array_from(global_object, vm.argument(0)));
|
||||
|
||||
auto atomic_and = [](auto* storage, auto value) { return AK::atomic_fetch_and(storage, value); };
|
||||
|
||||
|
@ -280,9 +276,7 @@ static ThrowCompletionOr<Value> atomic_compare_exchange_impl(GlobalObject& globa
|
|||
// 25.4.5 Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue ), https://tc39.es/ecma262/#sec-atomics.compareexchange
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(AtomicsObject::compare_exchange)
|
||||
{
|
||||
auto* typed_array = typed_array_from(global_object, vm.argument(0));
|
||||
if (!typed_array)
|
||||
return {};
|
||||
auto* typed_array = TRY_OR_DISCARD(typed_array_from(global_object, vm.argument(0)));
|
||||
|
||||
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, Type) \
|
||||
if (is<ClassName>(typed_array)) \
|
||||
|
@ -296,9 +290,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(AtomicsObject::compare_exchange)
|
|||
// 25.4.6 Atomics.exchange ( typedArray, index, value ), https://tc39.es/ecma262/#sec-atomics.exchange
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(AtomicsObject::exchange)
|
||||
{
|
||||
auto* typed_array = typed_array_from(global_object, vm.argument(0));
|
||||
if (!typed_array)
|
||||
return {};
|
||||
auto* typed_array = TRY_OR_DISCARD(typed_array_from(global_object, vm.argument(0)));
|
||||
|
||||
auto atomic_exchange = [](auto* storage, auto value) { return AK::atomic_exchange(storage, value); };
|
||||
|
||||
|
@ -329,9 +321,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(AtomicsObject::is_lock_free)
|
|||
// 25.4.8 Atomics.load ( typedArray, index ), https://tc39.es/ecma262/#sec-atomics.load
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(AtomicsObject::load)
|
||||
{
|
||||
auto* typed_array = typed_array_from(global_object, vm.argument(0));
|
||||
if (!typed_array)
|
||||
return {};
|
||||
auto* typed_array = TRY_OR_DISCARD(typed_array_from(global_object, vm.argument(0)));
|
||||
|
||||
TRY_OR_DISCARD(validate_integer_typed_array(global_object, *typed_array));
|
||||
|
||||
|
@ -348,9 +338,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(AtomicsObject::load)
|
|||
// 25.4.9 Atomics.or ( typedArray, index, value ), https://tc39.es/ecma262/#sec-atomics.or
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(AtomicsObject::or_)
|
||||
{
|
||||
auto* typed_array = typed_array_from(global_object, vm.argument(0));
|
||||
if (!typed_array)
|
||||
return {};
|
||||
auto* typed_array = TRY_OR_DISCARD(typed_array_from(global_object, vm.argument(0)));
|
||||
|
||||
auto atomic_or = [](auto* storage, auto value) { return AK::atomic_fetch_or(storage, value); };
|
||||
|
||||
|
@ -366,9 +354,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(AtomicsObject::or_)
|
|||
// 25.4.10 Atomics.store ( typedArray, index, value ), https://tc39.es/ecma262/#sec-atomics.store
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(AtomicsObject::store)
|
||||
{
|
||||
auto* typed_array = typed_array_from(global_object, vm.argument(0));
|
||||
if (!typed_array)
|
||||
return {};
|
||||
auto* typed_array = TRY_OR_DISCARD(typed_array_from(global_object, vm.argument(0)));
|
||||
|
||||
TRY_OR_DISCARD(validate_integer_typed_array(global_object, *typed_array));
|
||||
|
||||
|
@ -393,9 +379,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(AtomicsObject::store)
|
|||
// 25.4.11 Atomics.sub ( typedArray, index, value ), https://tc39.es/ecma262/#sec-atomics.sub
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(AtomicsObject::sub)
|
||||
{
|
||||
auto* typed_array = typed_array_from(global_object, vm.argument(0));
|
||||
if (!typed_array)
|
||||
return {};
|
||||
auto* typed_array = TRY_OR_DISCARD(typed_array_from(global_object, vm.argument(0)));
|
||||
|
||||
auto atomic_sub = [](auto* storage, auto value) { return AK::atomic_fetch_sub(storage, value); };
|
||||
|
||||
|
@ -411,9 +395,7 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(AtomicsObject::sub)
|
|||
// 25.4.14 Atomics.xor ( typedArray, index, value ), https://tc39.es/ecma262/#sec-atomics.xor
|
||||
JS_DEFINE_OLD_NATIVE_FUNCTION(AtomicsObject::xor_)
|
||||
{
|
||||
auto* typed_array = typed_array_from(global_object, vm.argument(0));
|
||||
if (!typed_array)
|
||||
return {};
|
||||
auto* typed_array = TRY_OR_DISCARD(typed_array_from(global_object, vm.argument(0)));
|
||||
|
||||
auto atomic_xor = [](auto* storage, auto value) { return AK::atomic_fetch_xor(storage, value); };
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue