FunctionConstructor.h 930 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (c) 2020, Linus Groh <linusg@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibJS/Runtime/FunctionKind.h>
  8. #include <LibJS/Runtime/NativeFunction.h>
  9. namespace JS {
  10. class FunctionConstructor final : public NativeFunction {
  11. JS_OBJECT(FunctionConstructor, NativeFunction);
  12. public:
  13. static ThrowCompletionOr<ECMAScriptFunctionObject*> create_dynamic_function(GlobalObject& global_object, FunctionObject& constructor, FunctionObject* new_target, FunctionKind kind, MarkedVector<Value> const& args);
  14. explicit FunctionConstructor(Realm&);
  15. virtual void initialize(Realm&) override;
  16. virtual ~FunctionConstructor() override = default;
  17. virtual ThrowCompletionOr<Value> call() override;
  18. virtual ThrowCompletionOr<Object*> construct(FunctionObject& new_target) override;
  19. private:
  20. virtual bool has_constructor() const override { return true; }
  21. };
  22. }