BoundFunction.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) 2020, Jack Karamanian <karamanian.jack@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibJS/Runtime/Function.h>
  8. namespace JS {
  9. class BoundFunction final : public Function {
  10. JS_OBJECT(BoundFunction, Function);
  11. public:
  12. BoundFunction(GlobalObject&, Function& target_function, Value bound_this, Vector<Value> arguments, i32 length, Object* constructor_prototype);
  13. virtual void initialize(GlobalObject&) override;
  14. virtual ~BoundFunction();
  15. virtual Value call() override;
  16. virtual Value construct(Function& new_target) override;
  17. virtual FunctionEnvironmentRecord* create_environment_record() override;
  18. virtual void visit_edges(Visitor&) override;
  19. virtual const FlyString& name() const override
  20. {
  21. return m_name;
  22. }
  23. Function& target_function() const
  24. {
  25. return *m_target_function;
  26. }
  27. virtual bool is_strict_mode() const override { return m_target_function->is_strict_mode(); }
  28. private:
  29. Function* m_target_function = nullptr;
  30. Object* m_constructor_prototype = nullptr;
  31. FlyString m_name;
  32. i32 m_length { 0 };
  33. };
  34. }