2020-04-04 10:34:31 -03:00
|
|
|
/*
|
2022-08-21 16:38:35 -03:00
|
|
|
* Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
|
2020-04-04 10:34:31 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-04-04 10:34:31 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-01-15 13:26:06 -03:00
|
|
|
#include <LibJS/Runtime/FunctionKind.h>
|
2020-04-04 10:34:31 -03:00
|
|
|
#include <LibJS/Runtime/NativeFunction.h>
|
|
|
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
|
|
|
|
|
class FunctionConstructor final : public NativeFunction {
|
2020-06-21 10:14:02 -03:00
|
|
|
JS_OBJECT(FunctionConstructor, NativeFunction);
|
|
|
|
|
|
2020-04-04 10:34:31 -03:00
|
|
|
public:
|
2022-08-21 16:38:35 -03:00
|
|
|
static ThrowCompletionOr<ECMAScriptFunctionObject*> create_dynamic_function(VM&, FunctionObject& constructor, FunctionObject* new_target, FunctionKind kind, MarkedVector<Value> const& args);
|
2021-06-16 14:52:48 -03:00
|
|
|
|
2022-08-15 20:20:49 -03:00
|
|
|
virtual void initialize(Realm&) override;
|
2022-03-14 13:25:06 -03:00
|
|
|
virtual ~FunctionConstructor() override = default;
|
2020-04-04 10:34:31 -03:00
|
|
|
|
2021-10-20 17:16:30 -03:00
|
|
|
virtual ThrowCompletionOr<Value> call() override;
|
|
|
|
|
virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
|
2020-04-04 10:34:31 -03:00
|
|
|
|
|
|
|
|
private:
|
2022-08-28 18:51:28 -03:00
|
|
|
explicit FunctionConstructor(Realm&);
|
|
|
|
|
|
2020-04-04 10:34:31 -03:00
|
|
|
virtual bool has_constructor() const override { return true; }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|