mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:17:35 +00:00
LibJS: Port this_bigint_value() to NonnullGCPtr
This commit is contained in:
parent
d8ee4c0e7d
commit
9c6eba771a
1 changed files with 5 additions and 5 deletions
|
@ -38,17 +38,17 @@ ThrowCompletionOr<void> BigIntPrototype::initialize(Realm& realm)
|
||||||
}
|
}
|
||||||
|
|
||||||
// thisBigIntValue ( value ), https://tc39.es/ecma262/#thisbigintvalue
|
// thisBigIntValue ( value ), https://tc39.es/ecma262/#thisbigintvalue
|
||||||
static ThrowCompletionOr<BigInt*> this_bigint_value(VM& vm, Value value)
|
static ThrowCompletionOr<NonnullGCPtr<BigInt>> this_bigint_value(VM& vm, Value value)
|
||||||
{
|
{
|
||||||
// 1. If value is a BigInt, return value.
|
// 1. If value is a BigInt, return value.
|
||||||
if (value.is_bigint())
|
if (value.is_bigint())
|
||||||
return &value.as_bigint();
|
return value.as_bigint();
|
||||||
|
|
||||||
// 2. If value is an Object and value has a [[BigIntData]] internal slot, then
|
// 2. If value is an Object and value has a [[BigIntData]] internal slot, then
|
||||||
if (value.is_object() && is<BigIntObject>(value.as_object())) {
|
if (value.is_object() && is<BigIntObject>(value.as_object())) {
|
||||||
// a. Assert: value.[[BigIntData]] is a BigInt.
|
// a. Assert: value.[[BigIntData]] is a BigInt.
|
||||||
// b. Return value.[[BigIntData]].
|
// b. Return value.[[BigIntData]].
|
||||||
return &static_cast<BigIntObject&>(value.as_object()).bigint();
|
return static_cast<BigIntObject&>(value.as_object()).bigint();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Throw a TypeError exception.
|
// 3. Throw a TypeError exception.
|
||||||
|
@ -59,7 +59,7 @@ static ThrowCompletionOr<BigInt*> this_bigint_value(VM& vm, Value value)
|
||||||
JS_DEFINE_NATIVE_FUNCTION(BigIntPrototype::to_string)
|
JS_DEFINE_NATIVE_FUNCTION(BigIntPrototype::to_string)
|
||||||
{
|
{
|
||||||
// 1. Let x be ? thisBigIntValue(this value).
|
// 1. Let x be ? thisBigIntValue(this value).
|
||||||
auto* bigint = TRY(this_bigint_value(vm, vm.this_value()));
|
auto bigint = TRY(this_bigint_value(vm, vm.this_value()));
|
||||||
|
|
||||||
// 2. If radix is undefined, let radixMV be 10.
|
// 2. If radix is undefined, let radixMV be 10.
|
||||||
double radix = 10;
|
double radix = 10;
|
||||||
|
@ -87,7 +87,7 @@ JS_DEFINE_NATIVE_FUNCTION(BigIntPrototype::to_locale_string)
|
||||||
auto options = vm.argument(1);
|
auto options = vm.argument(1);
|
||||||
|
|
||||||
// 1. Let x be ? thisBigIntValue(this value).
|
// 1. Let x be ? thisBigIntValue(this value).
|
||||||
auto* bigint = TRY(this_bigint_value(vm, vm.this_value()));
|
auto bigint = TRY(this_bigint_value(vm, vm.this_value()));
|
||||||
|
|
||||||
// 2. Let numberFormat be ? Construct(%NumberFormat%, « locales, options »).
|
// 2. Let numberFormat be ? Construct(%NumberFormat%, « locales, options »).
|
||||||
auto* number_format = static_cast<Intl::NumberFormat*>(TRY(construct(vm, realm.intrinsics().intl_number_format_constructor(), locales, options)).ptr());
|
auto* number_format = static_cast<Intl::NumberFormat*>(TRY(construct(vm, realm.intrinsics().intl_number_format_constructor(), locales, options)).ptr());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue