Skip to content

Commit cec10f5

Browse files
committed
Updated comments
1 parent 0224744 commit cec10f5

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

nova_vm/src/ecmascript/builtins/control_abstraction_objects/promise_objects/promise_constructor.rs

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ impl PromiseConstructor {
416416

417417
let iterator = iterator.scope(agent, gc.nogc());
418418

419-
// 7. Let result be Completion(PerformPromiseAll(iteratorRecord, C, promiseCapability, promiseResolve)).
419+
// 7. Let result be Completion(PerformPromiseAllSettled(iteratorRecord, C, promiseCapability, promiseResolve)).
420420
let mut iterator_done = false;
421421
let result = perform_promise_all_settled(
422422
agent,
@@ -451,9 +451,7 @@ impl PromiseConstructor {
451451
promise: promise.get(agent).bind(gc.nogc()),
452452
must_be_unresolved: true,
453453
};
454-
// a. Perform ? Call(capability.[[Reject]], undefined, « value.[[Value]] »).
455454
promise_capability.reject(agent, result.value().unbind(), gc.nogc());
456-
// b. Return capability.[[Promise]].
457455
promise_capability.promise()
458456
}
459457
Ok(result) => result,
@@ -1020,22 +1018,32 @@ fn perform_promise_all_settled<'gc>(
10201018
_ => Promise::new_resolved(agent, call_result),
10211019
};
10221020

1023-
// e. Let steps be the algorithm steps defined in Promise.all Resolve Element Functions.
1024-
// f. Let length be the number of non-optional parameters of the function definition in Promise.all Resolve Element Functions.
1025-
// g. Let onFulfilled be CreateBuiltinFunction(steps, length, "", « [[AlreadyCalled]], [[Index]], [[Values]], [[Capability]], [[RemainingElements]] »).
1026-
// h. Set onFulfilled.[[AlreadyCalled]] to false.
1027-
// i. Set onFulfilled.[[Index]] to index.
1028-
// j. Set onFulfilled.[[Values]] to values.
1021+
// e. Let stepsFulfilled be the algorithm steps defined in Promise.allSettled Resolve Element Functions.
1022+
// f. Let lengthFulfilled be the number of non-optional parameters of the function definition in Promise.allSettled Resolve Element Functions.
1023+
// g. Let onFulfilled be CreateBuiltinFunction(stepsFulfilled, lengthFulfilled, "", « [[AlreadyCalled]], [[Index]], [[Values]], [[Capability]], [[RemainingElements]] »).
1024+
// h. Let alreadyCalled be the Record { [[Value]]: false }.
1025+
// i. Set onFulfilled.[[AlreadyCalled]] to alreadyCalled.
1026+
// j. Set onFulfilled.[[Index]] to index.
1027+
// k. Set onFulfilled.[[Values]] to values.
1028+
// l. Set onFulfilled.[[Capability]] to resultCapability.
1029+
// m. Set onFulfilled.[[RemainingElements]] to remainingElementsCount.
1030+
// n. Let stepsRejected be the algorithm steps defined in Promise.allSettled Reject Element Functions.
1031+
// o. Let lengthRejected be the number of non-optional parameters of the function definition in Promise.allSettled Reject Element Functions.
1032+
// p. Let onRejected be CreateBuiltinFunction(stepsRejected, lengthRejected, "", « [[AlreadyCalled]], [[Index]], [[Values]], [[Capability]], [[RemainingElements]] »).
1033+
// q. Set onRejected.[[AlreadyCalled]] to alreadyCalled.
1034+
// r. Set onRejected.[[Index]] to index.
1035+
// s. Set onRejected.[[Values]] to values.
1036+
// t. Set onRejected.[[Capability]] to resultCapability.
1037+
// u. Set onRejected.[[RemainingElements]] to remainingElementsCount.
10291038
let promise_all_settled = promise_all_settled_reference.get(agent).bind(gc.nogc());
10301039
let reaction = PromiseReactionHandler::PromiseAllSettled {
10311040
index,
10321041
promise_all_settled,
10331042
};
1034-
// k. Set onFulfilled.[[Capability]] to resultCapability.
1035-
// l. Set onFulfilled.[[RemainingElements]] to remainingElementsCount.
1036-
// m. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] + 1.
1043+
1044+
// v. Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] + 1.
10371045
promise_all_settled.get_mut(agent).remaining_elements_count += 1;
1038-
// n. Perform ? Invoke(nextPromise, "then", « onFulfilled, resultCapability.[[Reject]] »).
1046+
// w. Perform ? Invoke(nextPromise, "then", « onFulfilled, onRejected »).
10391047
inner_promise_then(
10401048
agent,
10411049
next_promise.unbind(),
@@ -1045,7 +1053,7 @@ fn perform_promise_all_settled<'gc>(
10451053
gc.nogc(),
10461054
);
10471055

1048-
// o. Set index to index + 1.
1056+
// x. Set index to index + 1.
10491057
index += 1;
10501058
}
10511059
}

0 commit comments

Comments
 (0)