1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:28:12 +00:00

LibJS: Allow GeneratorObject to be subclassed

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 commit is contained in:
Timothy Flynn 2023-07-16 14:37:35 -04:00 committed by Linus Groh
parent 60adeb11c9
commit 566a8dfd93
3 changed files with 14 additions and 10 deletions

View file

@ -35,9 +35,10 @@ ThrowCompletionOr<NonnullGCPtr<GeneratorObject>> GeneratorObject::create(Realm&
return object;
}
GeneratorObject::GeneratorObject(Realm&, Object& prototype, ExecutionContext context)
GeneratorObject::GeneratorObject(Realm&, Object& prototype, ExecutionContext context, Optional<StringView> generator_brand)
: Object(ConstructWithPrototypeTag::Tag, prototype)
, m_execution_context(move(context))
, m_generator_brand(move(generator_brand))
{
}