use of com.github.anba.es6draft.runtime.objects.promise.PromiseAbstractOperations.CreateResolvingFunctions in project es6draft by anba.
the class PromiseConstructor method construct.
/**
* 25.4.3.1 Promise ( executor )
*/
@Override
public PromiseObject construct(ExecutionContext callerContext, Constructor newTarget, Object... args) {
ExecutionContext calleeContext = calleeContext();
Object executor = argument(args, 0);
/* step 2 */
if (!IsCallable(executor)) {
throw newTypeError(calleeContext, Messages.Key.NotCallable);
}
/* steps 3-7 */
PromiseObject promise = OrdinaryCreateFromConstructor(calleeContext, newTarget, Intrinsics.PromisePrototype, GetPromiseAllocator(calleeContext.getRealm()));
/* step 8 */
ResolvingFunctions resolvingFunctions = CreateResolvingFunctions(calleeContext, promise);
/* steps 9-10 */
try {
/* step 9 */
((Callable) executor).call(calleeContext, UNDEFINED, resolvingFunctions.getResolve(), resolvingFunctions.getReject());
} catch (ScriptException e) {
/* step 10 */
resolvingFunctions.getReject().call(calleeContext, UNDEFINED, e.getValue());
}
/* step 11 */
return promise;
}
Aggregations