mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:27:45 +00:00
LibJS: Add spec comments to Value::to_numeric()
This commit is contained in:
parent
63f6099cc3
commit
9a406ccba6
1 changed files with 9 additions and 4 deletions
|
@ -561,10 +561,15 @@ ThrowCompletionOr<Object*> Value::to_object(VM& vm) const
|
||||||
// 7.1.3 ToNumeric ( value ), https://tc39.es/ecma262/#sec-tonumeric
|
// 7.1.3 ToNumeric ( value ), https://tc39.es/ecma262/#sec-tonumeric
|
||||||
FLATTEN ThrowCompletionOr<Value> Value::to_numeric(VM& vm) const
|
FLATTEN ThrowCompletionOr<Value> Value::to_numeric(VM& vm) const
|
||||||
{
|
{
|
||||||
auto primitive = TRY(to_primitive(vm, Value::PreferredType::Number));
|
// 1. Let primValue be ? ToPrimitive(value, number).
|
||||||
if (primitive.is_bigint())
|
auto primitive_value = TRY(to_primitive(vm, Value::PreferredType::Number));
|
||||||
return primitive;
|
|
||||||
return primitive.to_number(vm);
|
// 2. If primValue is a BigInt, return primValue.
|
||||||
|
if (primitive_value.is_bigint())
|
||||||
|
return primitive_value;
|
||||||
|
|
||||||
|
// 3. Return ? ToNumber(primValue).
|
||||||
|
return primitive_value.to_number(vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr bool is_ascii_number(u32 code_point)
|
constexpr bool is_ascii_number(u32 code_point)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue