mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 20:18:12 +00:00
LibJS: Simplify Is{Accessor,Data,Generic}Descriptor AOs
This is an editorial change in the ECMA-262 spec.
See: 1c7ae4b
This commit is contained in:
parent
07ac8b7021
commit
8cbd25f553
1 changed files with 27 additions and 15 deletions
|
@ -18,12 +18,16 @@ bool PropertyDescriptor::is_accessor_descriptor() const
|
|||
{
|
||||
// 1. If Desc is undefined, return false.
|
||||
|
||||
// 2. If Desc does not have a [[Get]] field and Desc does not have a [[Set]] field, return false.
|
||||
if (!get.has_value() && !set.has_value())
|
||||
return false;
|
||||
// 2. If Desc has a [[Get]] field, return true.
|
||||
if (get.has_value())
|
||||
return true;
|
||||
|
||||
// 3. Return true.
|
||||
return true;
|
||||
// 3. If Desc has a [[Set]] field, return true.
|
||||
if (set.has_value())
|
||||
return true;
|
||||
|
||||
// 4. Return false.
|
||||
return false;
|
||||
}
|
||||
|
||||
// 6.2.5.2 IsDataDescriptor ( Desc ), https://tc39.es/ecma262/#sec-isdatadescriptor
|
||||
|
@ -31,12 +35,16 @@ bool PropertyDescriptor::is_data_descriptor() const
|
|||
{
|
||||
// 1. If Desc is undefined, return false.
|
||||
|
||||
// 2. If Desc does not have a [[Value]] field and Desc does not have a [[Writable]] field, return false.
|
||||
if (!value.has_value() && !writable.has_value())
|
||||
return false;
|
||||
// 2. If Desc has a [[Value]] field, return true.
|
||||
if (value.has_value())
|
||||
return true;
|
||||
|
||||
// 3. Return true.
|
||||
return true;
|
||||
// 3. If Desc has a [[Writable]] field, return true.
|
||||
if (writable.has_value())
|
||||
return true;
|
||||
|
||||
// 4. Return false.
|
||||
return false;
|
||||
}
|
||||
|
||||
// 6.2.5.3 IsGenericDescriptor ( Desc ), https://tc39.es/ecma262/#sec-isgenericdescriptor
|
||||
|
@ -44,12 +52,16 @@ bool PropertyDescriptor::is_generic_descriptor() const
|
|||
{
|
||||
// 1. If Desc is undefined, return false.
|
||||
|
||||
// 2. If IsAccessorDescriptor(Desc) and IsDataDescriptor(Desc) are both false, return true.
|
||||
if (!is_accessor_descriptor() && !is_data_descriptor())
|
||||
return true;
|
||||
// 2. If IsAccessorDescriptor(Desc) is true, return false.
|
||||
if (is_accessor_descriptor())
|
||||
return false;
|
||||
|
||||
// 3. Return false.
|
||||
return false;
|
||||
// 3. If IsDataDescriptor(Desc) is true, return false.
|
||||
if (is_data_descriptor())
|
||||
return false;
|
||||
|
||||
// 4. Return true.
|
||||
return true;
|
||||
}
|
||||
|
||||
// 6.2.5.4 FromPropertyDescriptor ( Desc ), https://tc39.es/ecma262/#sec-frompropertydescriptor
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue