Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LibJS: Implement %IteratorHelperPrototype%.return #20057

Merged
merged 7 commits into from
Jul 16, 2023

Conversation

trflynn89
Copy link
Member

This is the last piece of the Iterator Helpers proposal.

Diff Tests:
+20 βœ…  -20 πŸ“ 

This was missing its Base invocation. But since this override is not
doing anything anyways, just remove it.
This optional parameter is not currently set by any caller, but will be
for the Iterator Helpers proposal. In all specs, this parameter is a
static string, so we can just use a StringView rather than allocating a
(Deprecated)String on each invocation.

This also changes this optional parameter to be passed by const-ref, as
it does not need to be copied.
In the Iterator Helpers proposal, we must create a generator object with
additional internal slots and behavior differences.

GeneratorObject is currently implemented assuming it wraps around an
ECMAScriptFunctionObject with generated bytecode. In this proposal, we
instead have "Abstract Closure" blocks. So this marks the `execute`
method as virtual, to allow the future subclass to essentially just
invoke those closures.

We will also require mutable access to the [[GeneratorState]] internal
slot.
This is required for %IteratorHelperPrototype%.return, which needs to
operate on the internal slots of the base GeneratorObject. Doing so also
provides us with the appropriate VM to be used in invocations to the
overridden IteratorHelper::execute.
This is in preparation of implementing %IteratorHelperPrototype%.return.
That will invoke GeneratorResumeAbrupt, which will execute the generator
with an abrupt completion. At that time, we must take care to close the
current inner iterator.
@trflynn89 trflynn89 requested a review from linusg as a code owner July 16, 2023 20:07
@github-actions github-actions bot added the πŸ‘€ pr-needs-review PR needs review from a maintainer or community member label Jul 16, 2023
@linusg linusg merged commit 0e63d04 into SerenityOS:master Jul 16, 2023
@github-actions github-actions bot removed the πŸ‘€ pr-needs-review PR needs review from a maintainer or community member label Jul 16, 2023
@trflynn89 trflynn89 deleted the iterator_helpers_return branch July 16, 2023 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants