mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-23 15:47:30 +09:00
Bug 1343481 - Part 5: Rename AsyncFunction-related names in Promise.cpp to explicitly say Async Function.
Tag #1287
This commit is contained in:
parent
bc80cb0d51
commit
04ec8aaf1c
1 changed files with 18 additions and 18 deletions
|
|
@ -34,8 +34,8 @@ MillisecondsSinceStartup()
|
||||||
enum PromiseHandler {
|
enum PromiseHandler {
|
||||||
PromiseHandlerIdentity = 0,
|
PromiseHandlerIdentity = 0,
|
||||||
PromiseHandlerThrower,
|
PromiseHandlerThrower,
|
||||||
PromiseHandlerAwaitFulfilled,
|
PromiseHandlerAsyncFunctionAwaitFulfilled,
|
||||||
PromiseHandlerAwaitRejected,
|
PromiseHandlerAsyncFunctionAwaitRejected,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ResolutionMode {
|
enum ResolutionMode {
|
||||||
|
|
@ -184,7 +184,7 @@ enum ReactionRecordSlots {
|
||||||
#define REACTION_FLAG_RESOLVED 0x1
|
#define REACTION_FLAG_RESOLVED 0x1
|
||||||
#define REACTION_FLAG_FULFILLED 0x2
|
#define REACTION_FLAG_FULFILLED 0x2
|
||||||
#define REACTION_FLAG_IGNORE_DEFAULT_RESOLUTION 0x4
|
#define REACTION_FLAG_IGNORE_DEFAULT_RESOLUTION 0x4
|
||||||
#define REACTION_FLAG_AWAIT 0x8
|
#define REACTION_FLAG_ASYNC_FUNCTION_AWAIT 0x8
|
||||||
|
|
||||||
// ES2016, 25.4.1.2.
|
// ES2016, 25.4.1.2.
|
||||||
class PromiseReactionRecord : public NativeObject
|
class PromiseReactionRecord : public NativeObject
|
||||||
|
|
@ -211,14 +211,14 @@ class PromiseReactionRecord : public NativeObject
|
||||||
flags |= REACTION_FLAG_FULFILLED;
|
flags |= REACTION_FLAG_FULFILLED;
|
||||||
setFixedSlot(ReactionRecordSlot_Flags, Int32Value(flags));
|
setFixedSlot(ReactionRecordSlot_Flags, Int32Value(flags));
|
||||||
}
|
}
|
||||||
void setIsAwait() {
|
void setIsAsyncFunctionAwait() {
|
||||||
int32_t flags = this->flags();
|
int32_t flags = this->flags();
|
||||||
flags |= REACTION_FLAG_AWAIT;
|
flags |= REACTION_FLAG_ASYNC_FUNCTION_AWAIT;
|
||||||
setFixedSlot(ReactionRecordSlot_Flags, Int32Value(flags));
|
setFixedSlot(ReactionRecordSlot_Flags, Int32Value(flags));
|
||||||
}
|
}
|
||||||
bool isAwait() {
|
bool isAsyncFunctionAwait() {
|
||||||
int32_t flags = this->flags();
|
int32_t flags = this->flags();
|
||||||
return flags & REACTION_FLAG_AWAIT;
|
return flags & REACTION_FLAG_ASYNC_FUNCTION_AWAIT;
|
||||||
}
|
}
|
||||||
Value handler() {
|
Value handler() {
|
||||||
MOZ_ASSERT(targetState() != JS::PromiseState::Pending);
|
MOZ_ASSERT(targetState() != JS::PromiseState::Pending);
|
||||||
|
|
@ -820,10 +820,10 @@ TriggerPromiseReactions(JSContext* cx, HandleValue reactionsVal, JS::PromiseStat
|
||||||
}
|
}
|
||||||
|
|
||||||
static MOZ_MUST_USE bool
|
static MOZ_MUST_USE bool
|
||||||
AwaitPromiseReactionJob(JSContext* cx, Handle<PromiseReactionRecord*> reaction,
|
AsyncFunctionAwaitPromiseReactionJob(JSContext* cx, Handle<PromiseReactionRecord*> reaction,
|
||||||
MutableHandleValue rval)
|
MutableHandleValue rval)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(reaction->isAwait());
|
MOZ_ASSERT(reaction->isAsyncFunctionAwait());
|
||||||
|
|
||||||
RootedValue handlerVal(cx, reaction->handler());
|
RootedValue handlerVal(cx, reaction->handler());
|
||||||
RootedValue argument(cx, reaction->handlerArg());
|
RootedValue argument(cx, reaction->handlerArg());
|
||||||
|
|
@ -831,12 +831,12 @@ AwaitPromiseReactionJob(JSContext* cx, Handle<PromiseReactionRecord*> reaction,
|
||||||
RootedValue generatorVal(cx, resultPromise->getFixedSlot(PromiseSlot_AwaitGenerator));
|
RootedValue generatorVal(cx, resultPromise->getFixedSlot(PromiseSlot_AwaitGenerator));
|
||||||
|
|
||||||
int32_t handlerNum = int32_t(handlerVal.toNumber());
|
int32_t handlerNum = int32_t(handlerVal.toNumber());
|
||||||
MOZ_ASSERT(handlerNum == PromiseHandlerAwaitFulfilled
|
MOZ_ASSERT(handlerNum == PromiseHandlerAsyncFunctionAwaitFulfilled ||
|
||||||
|| handlerNum == PromiseHandlerAwaitRejected);
|
handlerNum == PromiseHandlerAsyncFunctionAwaitRejected);
|
||||||
|
|
||||||
// Await's handlers don't return a value, nor throw exception.
|
// Await's handlers don't return a value, nor throw exception.
|
||||||
// They fail only on OOM.
|
// They fail only on OOM.
|
||||||
if (handlerNum == PromiseHandlerAwaitFulfilled) {
|
if (handlerNum == PromiseHandlerAsyncFunctionAwaitFulfilled) {
|
||||||
if (!AsyncFunctionAwaitedFulfilled(cx, resultPromise, generatorVal, argument))
|
if (!AsyncFunctionAwaitedFulfilled(cx, resultPromise, generatorVal, argument))
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -891,8 +891,8 @@ PromiseReactionJob(JSContext* cx, unsigned argc, Value* vp)
|
||||||
|
|
||||||
// Steps 1-2.
|
// Steps 1-2.
|
||||||
Rooted<PromiseReactionRecord*> reaction(cx, &reactionObj->as<PromiseReactionRecord>());
|
Rooted<PromiseReactionRecord*> reaction(cx, &reactionObj->as<PromiseReactionRecord>());
|
||||||
if (reaction->isAwait())
|
if (reaction->isAsyncFunctionAwait())
|
||||||
return AwaitPromiseReactionJob(cx, reaction, args.rval());
|
return AsyncFunctionAwaitPromiseReactionJob(cx, reaction, args.rval());
|
||||||
|
|
||||||
// Step 3.
|
// Step 3.
|
||||||
RootedValue handlerVal(cx, reaction->handler());
|
RootedValue handlerVal(cx, reaction->handler());
|
||||||
|
|
@ -2202,8 +2202,8 @@ js::AsyncFunctionAwait(JSContext* cx, Handle<PromiseObject*> resultPromise, Hand
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Steps 4-5.
|
// Steps 4-5.
|
||||||
RootedValue onFulfilled(cx, Int32Value(PromiseHandlerAwaitFulfilled));
|
RootedValue onFulfilled(cx, Int32Value(PromiseHandlerAsyncFunctionAwaitFulfilled));
|
||||||
RootedValue onRejected(cx, Int32Value(PromiseHandlerAwaitRejected));
|
RootedValue onRejected(cx, Int32Value(PromiseHandlerAsyncFunctionAwaitRejected));
|
||||||
|
|
||||||
RootedObject incumbentGlobal(cx);
|
RootedObject incumbentGlobal(cx);
|
||||||
if (!GetObjectFromIncumbentGlobal(cx, &incumbentGlobal))
|
if (!GetObjectFromIncumbentGlobal(cx, &incumbentGlobal))
|
||||||
|
|
@ -2217,7 +2217,7 @@ js::AsyncFunctionAwait(JSContext* cx, Handle<PromiseObject*> resultPromise, Hand
|
||||||
if (!reaction)
|
if (!reaction)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
reaction->setIsAwait();
|
reaction->setIsAsyncFunctionAwait();
|
||||||
|
|
||||||
// Step 8.
|
// Step 8.
|
||||||
return PerformPromiseThenWithReaction(cx, promise, reaction);
|
return PerformPromiseThenWithReaction(cx, promise, reaction);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue