mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:07: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:
parent
322c8a3995
commit
7327a28ccc
52 changed files with 480 additions and 101 deletions
|
@ -17,7 +17,7 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
// 27.2.4.7.1 PromiseResolve, https://tc39.es/ecma262/#sec-promise-resolve
|
||||
// 27.2.4.7.1 PromiseResolve ( C, x ), https://tc39.es/ecma262/#sec-promise-resolve
|
||||
Object* promise_resolve(GlobalObject& global_object, Object& constructor, Value value)
|
||||
{
|
||||
auto& vm = global_object.vm();
|
||||
|
@ -47,7 +47,7 @@ Promise::Promise(Object& prototype)
|
|||
{
|
||||
}
|
||||
|
||||
// 27.2.1.3 CreateResolvingFunctions, https://tc39.es/ecma262/#sec-createresolvingfunctions
|
||||
// 27.2.1.3 CreateResolvingFunctions ( promise ), https://tc39.es/ecma262/#sec-createresolvingfunctions
|
||||
Promise::ResolvingFunctions Promise::create_resolving_functions()
|
||||
{
|
||||
dbgln_if(PROMISE_DEBUG, "[Promise @ {} / create_resolving_functions()]", this);
|
||||
|
@ -107,7 +107,7 @@ Promise::ResolvingFunctions Promise::create_resolving_functions()
|
|||
return { *resolve_function, *reject_function };
|
||||
}
|
||||
|
||||
// 27.2.1.4 FulfillPromise, https://tc39.es/ecma262/#sec-fulfillpromise
|
||||
// 27.2.1.4 FulfillPromise ( promise, value ), https://tc39.es/ecma262/#sec-fulfillpromise
|
||||
Value Promise::fulfill(Value value)
|
||||
{
|
||||
dbgln_if(PROMISE_DEBUG, "[Promise @ {} / fulfill()]: Fulfilling promise with value {}", this, value);
|
||||
|
@ -121,7 +121,7 @@ Value Promise::fulfill(Value value)
|
|||
return js_undefined();
|
||||
}
|
||||
|
||||
// 27.2.1.7 RejectPromise, https://tc39.es/ecma262/#sec-rejectpromise
|
||||
// 27.2.1.7 RejectPromise ( promise, reason ), https://tc39.es/ecma262/#sec-rejectpromise
|
||||
Value Promise::reject(Value reason)
|
||||
{
|
||||
dbgln_if(PROMISE_DEBUG, "[Promise @ {} / reject()]: Rejecting promise with reason {}", this, reason);
|
||||
|
@ -138,7 +138,7 @@ Value Promise::reject(Value reason)
|
|||
return js_undefined();
|
||||
}
|
||||
|
||||
// 27.2.1.8 TriggerPromiseReactions, https://tc39.es/ecma262/#sec-triggerpromisereactions
|
||||
// 27.2.1.8 TriggerPromiseReactions ( reactions, argument ), https://tc39.es/ecma262/#sec-triggerpromisereactions
|
||||
void Promise::trigger_reactions() const
|
||||
{
|
||||
VERIFY(is_settled());
|
||||
|
@ -158,7 +158,7 @@ void Promise::trigger_reactions() const
|
|||
}
|
||||
}
|
||||
|
||||
// 27.2.5.4.1 PerformPromiseThen, https://tc39.es/ecma262/#sec-performpromisethen
|
||||
// 27.2.5.4.1 PerformPromiseThen ( promise, onFulfilled, onRejected [ , resultCapability ] ), https://tc39.es/ecma262/#sec-performpromisethen
|
||||
Value Promise::perform_then(Value on_fulfilled, Value on_rejected, Optional<PromiseCapability> result_capability)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue