FunctionConstructor.h 925 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Copyright (c) 2020-2022, 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(VM&, FunctionObject& constructor, FunctionObject* new_target, FunctionKind kind, MarkedVector<Value> const& args);
  14. virtual void initialize(Realm&) override;
  15. virtual ~FunctionConstructor() override = default;
  16. virtual ThrowCompletionOr<Value> call() override;
  17. virtual ThrowCompletionOr<NonnullGCPtr<Object>> construct(FunctionObject& new_target) override;
  18. private:
  19. explicit FunctionConstructor(Realm&);
  20. virtual bool has_constructor() const override { return true; }
  21. };
  22. }