WrappedFunction.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibJS/Runtime/FunctionObject.h>
  8. #include <LibJS/Runtime/Realm.h>
  9. namespace JS {
  10. class WrappedFunction final : public FunctionObject {
  11. JS_OBJECT(WrappedFunction, FunctionObject);
  12. public:
  13. static WrappedFunction* create(GlobalObject&, Realm& caller_realm, FunctionObject& target_function);
  14. WrappedFunction(Realm&, FunctionObject&, Object& prototype);
  15. virtual ~WrappedFunction() = default;
  16. virtual ThrowCompletionOr<Value> internal_call(Value this_argument, MarkedValueList arguments_list) override;
  17. // FIXME: Remove this (and stop inventing random internal slots that shouldn't exist, jeez)
  18. virtual FlyString const& name() const override { return m_wrapped_target_function.name(); }
  19. virtual Realm* realm() const override { return &m_realm; }
  20. private:
  21. virtual void visit_edges(Visitor&) override;
  22. // Internal Slots of Wrapped Function Exotic Objects, https://tc39.es/proposal-shadowrealm/#table-internal-slots-of-wrapped-function-exotic-objects
  23. FunctionObject& m_wrapped_target_function; // [[WrappedTargetFunction]]
  24. Realm& m_realm; // [[Realm]]
  25. };
  26. }