mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 16:38:10 +00:00
LibJS: Add the remaining generator objects
- %GeneratorFunction% - %GeneratorFunction.prototype% - %GeneratorFunction.prototype.prototype% - %Generator%.prototype
This commit is contained in:
parent
b205c9814a
commit
22b17219ff
14 changed files with 302 additions and 67 deletions
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Matthew Olsson <mattco@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/FunctionConstructor.h>
|
||||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/GeneratorFunctionConstructor.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
GeneratorFunctionConstructor::GeneratorFunctionConstructor(GlobalObject& global_object)
|
||||
: NativeFunction(*static_cast<Object*>(global_object.function_constructor()))
|
||||
{
|
||||
}
|
||||
|
||||
void GeneratorFunctionConstructor::initialize(GlobalObject& global_object)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
NativeFunction::initialize(global_object);
|
||||
|
||||
// 27.3.2.1 GeneratorFunction.length, https://tc39.es/ecma262/#sec-generatorfunction.length
|
||||
define_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
// 27.3.2.2 GeneratorFunction.prototype, https://tc39.es/ecma262/#sec-generatorfunction.length
|
||||
define_property(vm.names.prototype, global_object.generator_function_prototype(), 0);
|
||||
}
|
||||
|
||||
GeneratorFunctionConstructor::~GeneratorFunctionConstructor()
|
||||
{
|
||||
}
|
||||
|
||||
// 27.3.1.1 GeneratorFunction ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-generatorfunction
|
||||
Value GeneratorFunctionConstructor::call()
|
||||
{
|
||||
return construct(*this);
|
||||
}
|
||||
|
||||
// 27.3.1.1 GeneratorFunction ( p1, p2, … , pn, body ), https://tc39.es/ecma262/#sec-generatorfunction
|
||||
Value GeneratorFunctionConstructor::construct(Function&)
|
||||
{
|
||||
TODO();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue