diff options
author | Gaming4JC <g4jc@hyperbola.info> | 2019-12-14 10:30:54 -0500 |
---|---|---|
committer | Gaming4JC <g4jc@hyperbola.info> | 2019-12-17 06:25:29 -0500 |
commit | 38c1d558afd03d61bd9932032f47d9c36f177b08 (patch) | |
tree | ff90c1f5c04d410a9ff706c3767869de96d3259d /js/src/vm/AsyncIteration.h | |
parent | dd1cbde1569e823e5e76e8c3ef0ecba66408719d (diff) | |
download | uxp-38c1d558afd03d61bd9932032f47d9c36f177b08.tar.gz |
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.h | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/js/src/vm/AsyncIteration.h b/js/src/vm/AsyncIteration.h index 974c209a01..58c43131b4 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 |