LibJS: Rename GeneratorObjectPrototype to GeneratorPrototype
Given we usually call objects Foo{Object,Constructor,Prototype} or Foo{,Constructor,Prototype}, this name was an odd choice. The new one matches the spec better, which calls it the "Generator Prototype Object", so we simply omit the Object suffix as usual as it's implied.
This commit is contained in:
parent
b76c66a9ed
commit
4ed49e05a9
Notes:
sideshowbarker
2024-07-17 20:45:16 +09:00
10 changed files with 30 additions and 30 deletions
|
@ -82,7 +82,7 @@ set(SOURCES
|
|||
Runtime/GeneratorFunctionConstructor.cpp
|
||||
Runtime/GeneratorFunctionPrototype.cpp
|
||||
Runtime/GeneratorObject.cpp
|
||||
Runtime/GeneratorObjectPrototype.cpp
|
||||
Runtime/GeneratorPrototype.cpp
|
||||
Runtime/GlobalEnvironment.cpp
|
||||
Runtime/GlobalObject.cpp
|
||||
Runtime/IndexedProperties.cpp
|
||||
|
|
|
@ -185,7 +185,7 @@ class ProxyObject;
|
|||
class ProxyConstructor;
|
||||
|
||||
// Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct constructor
|
||||
class GeneratorObjectPrototype;
|
||||
class GeneratorPrototype;
|
||||
class AsyncFromSyncIteratorPrototype;
|
||||
|
||||
class TypedArrayConstructor;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <LibJS/Runtime/ExecutionContext.h>
|
||||
#include <LibJS/Runtime/FunctionEnvironment.h>
|
||||
#include <LibJS/Runtime/GeneratorObject.h>
|
||||
#include <LibJS/Runtime/GeneratorObjectPrototype.h>
|
||||
#include <LibJS/Runtime/GeneratorPrototype.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/NativeFunction.h>
|
||||
#include <LibJS/Runtime/PromiseConstructor.h>
|
||||
|
@ -111,7 +111,7 @@ void ECMAScriptFunctionObject::initialize(GlobalObject& global_object)
|
|||
break;
|
||||
case FunctionKind::Generator:
|
||||
// prototype is "g1.prototype" in figure-2 (https://tc39.es/ecma262/img/figure-2.png)
|
||||
prototype = global_object.generator_object_prototype();
|
||||
prototype = global_object.generator_prototype();
|
||||
break;
|
||||
case FunctionKind::Async:
|
||||
break;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <LibJS/Runtime/Error.h>
|
||||
#include <LibJS/Runtime/FunctionConstructor.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibJS/Runtime/GeneratorObjectPrototype.h>
|
||||
#include <LibJS/Runtime/GeneratorPrototype.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
|
||||
|
@ -242,7 +242,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic
|
|||
// 33. If kind is generator, then
|
||||
if (kind == FunctionKind::Generator) {
|
||||
// a. Let prototype be ! OrdinaryObjectCreate(%GeneratorFunction.prototype.prototype%).
|
||||
prototype = Object::create(global_object, global_object.generator_object_prototype());
|
||||
prototype = Object::create(global_object, global_object.generator_prototype());
|
||||
|
||||
// b. Perform DefinePropertyOrThrow(F, "prototype", PropertyDescriptor { [[Value]]: prototype, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }).
|
||||
function->define_direct_property(vm.names.prototype, prototype, Attribute::Writable);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <LibJS/Runtime/GeneratorFunctionConstructor.h>
|
||||
#include <LibJS/Runtime/GeneratorFunctionPrototype.h>
|
||||
#include <LibJS/Runtime/GeneratorObjectPrototype.h>
|
||||
#include <LibJS/Runtime/GeneratorPrototype.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
|
@ -20,9 +20,9 @@ void GeneratorFunctionPrototype::initialize(GlobalObject& global_object)
|
|||
auto& vm = this->vm();
|
||||
Object::initialize(global_object);
|
||||
|
||||
// 27.3.3.2 %GeneratorFunction.prototype% prototype, https://tc39.es/ecma262/#sec-generatorfunction.prototype.prototype
|
||||
define_direct_property(vm.names.prototype, global_object.generator_object_prototype(), Attribute::Configurable);
|
||||
// 27.3.3.3 %GeneratorFunction.prototype% [ @@toStringTag ], https://tc39.es/ecma262/#sec-generatorfunction.prototype-@@tostringtag
|
||||
// 27.3.3.2 GeneratorFunction.prototype.prototype, https://tc39.es/ecma262/#sec-generatorfunction.prototype.prototype
|
||||
define_direct_property(vm.names.prototype, global_object.generator_prototype(), Attribute::Configurable);
|
||||
// 27.3.3.3 GeneratorFunction.prototype [ @@toStringTag ], https://tc39.es/ecma262/#sec-generatorfunction.prototype-@@tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "GeneratorFunction"), Attribute::Configurable);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <LibJS/Bytecode/Generator.h>
|
||||
#include <LibJS/Bytecode/Interpreter.h>
|
||||
#include <LibJS/Runtime/GeneratorObject.h>
|
||||
#include <LibJS/Runtime/GeneratorObjectPrototype.h>
|
||||
#include <LibJS/Runtime/GeneratorPrototype.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
|
||||
namespace JS {
|
||||
|
@ -21,7 +21,7 @@ ThrowCompletionOr<GeneratorObject*> GeneratorObject::create(GlobalObject& global
|
|||
// We implement async functions by transforming them to generator function in the bytecode
|
||||
// interpreter. However an async function does not have a prototype and should not be
|
||||
// changed thus we hardcode the prototype.
|
||||
generating_function_prototype = global_object.generator_object_prototype();
|
||||
generating_function_prototype = global_object.generator_prototype();
|
||||
} else {
|
||||
generating_function_prototype = TRY(generating_function->get(global_object.vm().names.prototype));
|
||||
}
|
||||
|
|
|
@ -4,17 +4,17 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/GeneratorObjectPrototype.h>
|
||||
#include <LibJS/Runtime/GeneratorPrototype.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
GeneratorObjectPrototype::GeneratorObjectPrototype(GlobalObject& global_object)
|
||||
GeneratorPrototype::GeneratorPrototype(GlobalObject& global_object)
|
||||
: PrototypeObject(*global_object.iterator_prototype())
|
||||
{
|
||||
}
|
||||
|
||||
void GeneratorObjectPrototype::initialize(GlobalObject& global_object)
|
||||
void GeneratorPrototype::initialize(GlobalObject& global_object)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
Object::initialize(global_object);
|
||||
|
@ -27,19 +27,19 @@ void GeneratorObjectPrototype::initialize(GlobalObject& global_object)
|
|||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Generator"), Attribute::Configurable);
|
||||
}
|
||||
|
||||
GeneratorObjectPrototype::~GeneratorObjectPrototype()
|
||||
GeneratorPrototype::~GeneratorPrototype()
|
||||
{
|
||||
}
|
||||
|
||||
// 27.5.1.2 Generator.prototype.next ( value ), https://tc39.es/ecma262/#sec-generator.prototype.next
|
||||
JS_DEFINE_NATIVE_FUNCTION(GeneratorObjectPrototype::next)
|
||||
JS_DEFINE_NATIVE_FUNCTION(GeneratorPrototype::next)
|
||||
{
|
||||
auto* generator_object = TRY(typed_this_object(global_object));
|
||||
return generator_object->next_impl(vm, global_object, vm.argument(0), {});
|
||||
}
|
||||
|
||||
// 27.5.1.3 Generator.prototype.next ( value ), https://tc39.es/ecma262/#sec-generator.prototype.return
|
||||
JS_DEFINE_NATIVE_FUNCTION(GeneratorObjectPrototype::return_)
|
||||
JS_DEFINE_NATIVE_FUNCTION(GeneratorPrototype::return_)
|
||||
{
|
||||
auto* generator_object = TRY(typed_this_object(global_object));
|
||||
generator_object->set_done();
|
||||
|
@ -47,7 +47,7 @@ JS_DEFINE_NATIVE_FUNCTION(GeneratorObjectPrototype::return_)
|
|||
}
|
||||
|
||||
// 27.5.1.4 Generator.prototype.next ( value ), https://tc39.es/ecma262/#sec-generator.prototype.throw
|
||||
JS_DEFINE_NATIVE_FUNCTION(GeneratorObjectPrototype::throw_)
|
||||
JS_DEFINE_NATIVE_FUNCTION(GeneratorPrototype::throw_)
|
||||
{
|
||||
auto* generator_object = TRY(typed_this_object(global_object));
|
||||
return generator_object->next_impl(vm, global_object, {}, vm.argument(0));
|
|
@ -11,14 +11,14 @@
|
|||
|
||||
namespace JS {
|
||||
|
||||
// 27.5.1 %GeneratorFunction.prototype.prototype%, https://tc39.es/ecma262/#sec-properties-of-generator-prototype
|
||||
class GeneratorObjectPrototype final : public PrototypeObject<GeneratorObjectPrototype, GeneratorObject> {
|
||||
JS_PROTOTYPE_OBJECT(GeneratorObjectPrototype, GeneratorObject, Generator);
|
||||
// 27.5.1 Properties of the Generator Prototype Object, https://tc39.es/ecma262/#sec-properties-of-generator-prototype
|
||||
class GeneratorPrototype final : public PrototypeObject<GeneratorPrototype, GeneratorObject> {
|
||||
JS_PROTOTYPE_OBJECT(GeneratorPrototype, GeneratorObject, Generator);
|
||||
|
||||
public:
|
||||
explicit GeneratorObjectPrototype(GlobalObject&);
|
||||
explicit GeneratorPrototype(GlobalObject&);
|
||||
virtual void initialize(GlobalObject&) override;
|
||||
virtual ~GeneratorObjectPrototype() override;
|
||||
virtual ~GeneratorPrototype() override;
|
||||
|
||||
private:
|
||||
JS_DECLARE_NATIVE_FUNCTION(next);
|
|
@ -46,7 +46,7 @@
|
|||
#include <LibJS/Runtime/FunctionPrototype.h>
|
||||
#include <LibJS/Runtime/GeneratorFunctionConstructor.h>
|
||||
#include <LibJS/Runtime/GeneratorFunctionPrototype.h>
|
||||
#include <LibJS/Runtime/GeneratorObjectPrototype.h>
|
||||
#include <LibJS/Runtime/GeneratorPrototype.h>
|
||||
#include <LibJS/Runtime/GlobalEnvironment.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/Intl/DateTimeFormatConstructor.h>
|
||||
|
@ -168,8 +168,8 @@ void GlobalObject::initialize_global_object()
|
|||
|
||||
// %GeneratorFunction.prototype.prototype% must be initialized separately as it has no
|
||||
// companion constructor
|
||||
m_generator_object_prototype = heap().allocate<GeneratorObjectPrototype>(*this, *this);
|
||||
m_generator_object_prototype->define_direct_property(vm.names.constructor, m_generator_function_constructor, Attribute::Configurable);
|
||||
m_generator_prototype = heap().allocate<GeneratorPrototype>(*this, *this);
|
||||
m_generator_prototype->define_direct_property(vm.names.constructor, m_generator_function_constructor, Attribute::Configurable);
|
||||
|
||||
m_async_from_sync_iterator_prototype = heap().allocate<AsyncFromSyncIteratorPrototype>(*this, *this);
|
||||
|
||||
|
@ -305,7 +305,7 @@ 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_object_prototype);
|
||||
visitor.visit(m_generator_prototype);
|
||||
visitor.visit(m_array_prototype_values_function);
|
||||
visitor.visit(m_date_constructor_now_function);
|
||||
visitor.visit(m_eval_function);
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
ProxyConstructor* proxy_constructor() { return m_proxy_constructor; }
|
||||
|
||||
// Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct constructor
|
||||
GeneratorObjectPrototype* generator_object_prototype() { return m_generator_object_prototype; }
|
||||
GeneratorPrototype* generator_prototype() { return m_generator_prototype; }
|
||||
AsyncFromSyncIteratorPrototype* async_from_sync_iterator_prototype() { return m_async_from_sync_iterator_prototype; }
|
||||
|
||||
FunctionObject* array_prototype_values_function() const { return m_array_prototype_values_function; }
|
||||
|
@ -102,7 +102,7 @@ private:
|
|||
ProxyConstructor* m_proxy_constructor { nullptr };
|
||||
|
||||
// Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct constructor
|
||||
GeneratorObjectPrototype* m_generator_object_prototype { nullptr };
|
||||
GeneratorPrototype* m_generator_prototype { nullptr };
|
||||
AsyncFromSyncIteratorPrototype* m_async_from_sync_iterator_prototype { nullptr };
|
||||
|
||||
FunctionObject* m_array_prototype_values_function { nullptr };
|
||||
|
|
Loading…
Add table
Reference in a new issue