1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:57:35 +00:00

LibJS: Add ECMA-262 section/title/URL comments almost everywhere

As mentioned on Discord earlier, we'll add these to all new functions
going forward - this is the backfill. Reasons:

- It makes you look at the spec, implementing based on MDN or V8
  behavior is a no-go
- It makes finding the various functions that are non-compliant easier,
  in the future everything should either have such a comment or, if it's
  not from the spec at all, a comment explaining why that is the case
- It makes it easier to check whether a certain abstract operation is
  implemented in LibJS, not all of them use the same name as the spec.
  E.g. RejectPromise() is Promise::reject()
- It makes it easier to reason about vm.arguments(), e.g. when the
  function has a rest parameter
- It makes it easier to see whether a certain function is from a
  proposal or Annex B

Also:

- Add arguments to all functions and abstract operations that already
  had a comment
- Fix some outdated section numbers
- Replace some ecma-international.org URLs with tc39.es
This commit is contained in:
Linus Groh 2021-06-13 00:22:35 +01:00
parent 322c8a3995
commit 7327a28ccc
52 changed files with 480 additions and 101 deletions

View file

@ -111,7 +111,7 @@ const Object* Object::prototype() const
return shape().prototype();
}
// 10.1.2.1 OrdinarySetPrototypeOf, https://tc39.es/ecma262/#sec-ordinarysetprototypeof
// 10.1.2.1 OrdinarySetPrototypeOf ( O, V ), https://tc39.es/ecma262/#sec-ordinarysetprototypeof
bool Object::set_prototype(Object* new_prototype)
{
if (prototype() == new_prototype)
@ -157,7 +157,7 @@ bool Object::prevent_extensions()
return true;
}
// 7.3.15 SetIntegrityLevel, https://tc39.es/ecma262/#sec-setintegritylevel
// 7.3.15 SetIntegrityLevel ( O, level ), https://tc39.es/ecma262/#sec-setintegritylevel
bool Object::set_integrity_level(IntegrityLevel level)
{
// FIXME: This feels clunky and should get nicer abstractions.
@ -225,7 +225,7 @@ bool Object::set_integrity_level(IntegrityLevel level)
return true;
}
// 7.3.16 TestIntegrityLevel, https://tc39.es/ecma262/#sec-testintegritylevel
// 7.3.16 TestIntegrityLevel ( O, level ), https://tc39.es/ecma262/#sec-testintegritylevel
bool Object::test_integrity_level(IntegrityLevel level)
{
auto& vm = this->vm();
@ -369,7 +369,7 @@ MarkedValueList Object::get_own_properties(PropertyKind kind, bool only_enumerab
return properties;
}
// 7.3.23 EnumerableOwnPropertyNames, https://tc39.es/ecma262/#sec-enumerableownpropertynames
// 7.3.23 EnumerableOwnPropertyNames ( O, kind ), https://tc39.es/ecma262/#sec-enumerableownpropertynames
MarkedValueList Object::get_enumerable_own_property_names(PropertyKind kind) const
{
return get_own_properties(kind, true, Object::GetOwnPropertyReturnType::StringOnly);
@ -419,7 +419,7 @@ Optional<PropertyDescriptor> Object::get_own_property_descriptor(const PropertyN
}
// Equivalent to:
// 6.2.5.4 FromPropertyDescriptor, https://tc39.es/ecma262/#sec-frompropertydescriptor
// 6.2.5.4 FromPropertyDescriptor ( Desc ), https://tc39.es/ecma262/#sec-frompropertydescriptor
Value Object::get_own_property_descriptor_object(const PropertyName& property_name) const
{
VERIFY(property_name.is_valid());
@ -934,7 +934,7 @@ bool Object::define_native_property(const StringOrSymbol& property_name, AK::Fun
return define_property(property_name, heap().allocate_without_global_object<NativeProperty>(move(getter), move(setter)), attribute);
}
// 20.1.2.3.1 ObjectDefineProperties, https://tc39.es/ecma262/#sec-objectdefineproperties
// 20.1.2.3.1 ObjectDefineProperties ( O, Properties ), https://tc39.es/ecma262/#sec-objectdefineproperties
void Object::define_properties(Value properties)
{
auto& vm = this->vm();
@ -1051,7 +1051,7 @@ Value Object::ordinary_to_primitive(Value::PreferredType preferred_type) const
return {};
}
// 20.5.8.1 InstallErrorCause, https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause
// 20.5.8.1 InstallErrorCause ( O, options ), https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause
void Object::install_error_cause(Value options)
{
auto& vm = this->vm();