summaryrefslogtreecommitdiffstats
path: root/js/src/vm/AsyncIteration.h
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2019-12-14 10:30:54 -0500
committerGaming4JC <g4jc@hyperbola.info>2019-12-17 06:25:29 -0500
commit38c1d558afd03d61bd9932032f47d9c36f177b08 (patch)
treeff90c1f5c04d410a9ff706c3767869de96d3259d /js/src/vm/AsyncIteration.h
parentdd1cbde1569e823e5e76e8c3ef0ecba66408719d (diff)
downloadUXP-38c1d558afd03d61bd9932032f47d9c36f177b08.tar
UXP-38c1d558afd03d61bd9932032f47d9c36f177b08.tar.gz
UXP-38c1d558afd03d61bd9932032f47d9c36f177b08.tar.lz
UXP-38c1d558afd03d61bd9932032f47d9c36f177b08.tar.xz
UXP-38c1d558afd03d61bd9932032f47d9c36f177b08.zip
Bug 1379525 - Part 1: Await on the value before yielding or returning inside async generator.
Tag #1287
Diffstat (limited to 'js/src/vm/AsyncIteration.h')
-rw-r--r--js/src/vm/AsyncIteration.h34
1 files changed, 30 insertions, 4 deletions
diff --git a/js/src/vm/AsyncIteration.h b/js/src/vm/AsyncIteration.h
index 974c209a0..58c43131b 100644
--- a/js/src/vm/AsyncIteration.h
+++ b/js/src/vm/AsyncIteration.h
@@ -38,11 +38,18 @@ GetUnwrappedAsyncGenerator(JSFunction* wrapped);
MOZ_MUST_USE bool
AsyncGeneratorAwaitedFulfilled(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
- HandleValue value);
-
+ HandleValue value);
MOZ_MUST_USE bool
AsyncGeneratorAwaitedRejected(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
- HandleValue reason);
+ HandleValue reason);
+MOZ_MUST_USE bool
+AsyncGeneratorYieldReturnAwaitedFulfilled(JSContext* cx,
+ Handle<AsyncGeneratorObject*> asyncGenObj,
+ HandleValue value);
+MOZ_MUST_USE bool
+AsyncGeneratorYieldReturnAwaitedRejected(JSContext* cx,
+ Handle<AsyncGeneratorObject*> asyncGenObj,
+ HandleValue reason);
class AsyncGeneratorRequest : public NativeObject
{
@@ -97,6 +104,12 @@ class AsyncGeneratorObject : public NativeObject
State_SuspendedStart,
State_SuspendedYield,
State_Executing,
+ // State_AwaitingYieldReturn corresponds to the case that
+ // AsyncGenerator#return is called while State_Executing,
+ // just like the case that AsyncGenerator#return is called
+ // while State_Completed.
+ State_AwaitingYieldReturn,
+ State_AwaitingReturn,
State_Completed
};
@@ -155,6 +168,12 @@ class AsyncGeneratorObject : public NativeObject
bool isExecuting() const {
return state() == State_Executing;
}
+ bool isAwaitingYieldReturn() const {
+ return state() == State_AwaitingYieldReturn;
+ }
+ bool isAwaitingReturn() const {
+ return state() == State_AwaitingReturn;
+ }
bool isCompleted() const {
return state() == State_Completed;
}
@@ -168,6 +187,12 @@ class AsyncGeneratorObject : public NativeObject
void setExecuting() {
setState(State_Executing);
}
+ void setAwaitingYieldReturn() {
+ setState(State_AwaitingYieldReturn);
+ }
+ void setAwaitingReturn() {
+ setState(State_AwaitingReturn);
+ }
void setCompleted() {
setState(State_Completed);
}
@@ -223,7 +248,8 @@ class AsyncFromSyncIteratorObject : public NativeObject
};
MOZ_MUST_USE bool
-AsyncGeneratorResumeNext(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj);
+AsyncGeneratorResume(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
+ CompletionKind completionKind, HandleValue argument);
} // namespace js