1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:54:58 +00:00

LibJS: Add AsyncGenerator / AsyncGeneratorPrototype

Not implementing any prototype functions yet, but stubbing out async
generator infrastructure will allow us to make some progress in that
direction.
This commit is contained in:
Linus Groh 2022-05-05 08:47:36 +02:00
parent 2c68ec9097
commit 0c65624a32
10 changed files with 162 additions and 9 deletions

View file

@ -28,6 +28,7 @@
#include <LibJS/Runtime/AsyncFunctionPrototype.h>
#include <LibJS/Runtime/AsyncGeneratorFunctionConstructor.h>
#include <LibJS/Runtime/AsyncGeneratorFunctionPrototype.h>
#include <LibJS/Runtime/AsyncGeneratorPrototype.h>
#include <LibJS/Runtime/AsyncIteratorPrototype.h>
#include <LibJS/Runtime/AtomicsObject.h>
#include <LibJS/Runtime/BigIntConstructor.h>
@ -177,12 +178,10 @@ void GlobalObject::initialize_global_object()
JS_ENUMERATE_ITERATOR_PROTOTYPES
#undef __JS_ENUMERATE
// %GeneratorFunction.prototype.prototype% must be initialized separately as it has no
// companion constructor
m_generator_prototype = heap().allocate<GeneratorPrototype>(*this, *this);
// These must be initialized separately as they have no companion constructor
m_async_from_sync_iterator_prototype = heap().allocate<AsyncFromSyncIteratorPrototype>(*this, *this);
m_async_generator_prototype = heap().allocate<AsyncGeneratorPrototype>(*this, *this);
m_generator_prototype = heap().allocate<GeneratorPrototype>(*this, *this);
m_intl_segments_prototype = heap().allocate<Intl::SegmentsPrototype>(*this, *this);
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
@ -298,6 +297,9 @@ void GlobalObject::initialize_global_object()
// 27.5.1.1 Generator.prototype.constructor, https://tc39.es/ecma262/#sec-generator.prototype.constructor
m_generator_prototype->define_direct_property(vm.names.constructor, m_generator_function_prototype, Attribute::Configurable);
// 27.6.1.1 AsyncGenerator.prototype.constructor, https://tc39.es/ecma262/#sec-asyncgenerator-prototype-constructor
m_async_generator_prototype->define_direct_property(vm.names.constructor, m_async_generator_function_prototype, Attribute::Configurable);
m_array_prototype_values_function = &m_array_prototype->get_without_side_effects(vm.names.values).as_function();
m_date_constructor_now_function = &m_date_constructor->get_without_side_effects(vm.names.now).as_function();
m_eval_function = &get_without_side_effects(vm.names.eval).as_function();
@ -315,8 +317,9 @@ void GlobalObject::visit_edges(Visitor& visitor)
visitor.visit(m_new_object_shape);
visitor.visit(m_new_ordinary_function_prototype_object_shape);
visitor.visit(m_proxy_constructor);
visitor.visit(m_generator_prototype);
visitor.visit(m_async_from_sync_iterator_prototype);
visitor.visit(m_async_generator_prototype);
visitor.visit(m_generator_prototype);
visitor.visit(m_intl_segments_prototype);
visitor.visit(m_array_prototype_values_function);
visitor.visit(m_date_constructor_now_function);