2020-04-19 15:03:02 -05:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Jack Karamanian <karamanian.jack@gmail.com>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-04-19 15:03:02 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-06-27 21:48:34 +02:00
|
|
|
#include <LibJS/Runtime/FunctionObject.h>
|
2020-04-19 15:03:02 -05:00
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
2021-06-27 21:48:34 +02:00
|
|
|
class BoundFunction final : public FunctionObject {
|
|
|
|
JS_OBJECT(BoundFunction, FunctionObject);
|
2020-06-21 15:14:02 +02:00
|
|
|
|
2020-04-19 15:03:02 -05:00
|
|
|
public:
|
2021-06-27 21:48:34 +02:00
|
|
|
BoundFunction(GlobalObject&, FunctionObject& target_function, Value bound_this, Vector<Value> arguments, i32 length, Object* constructor_prototype);
|
2020-07-22 17:50:18 +02:00
|
|
|
virtual void initialize(GlobalObject&) override;
|
2020-04-19 15:03:02 -05:00
|
|
|
virtual ~BoundFunction();
|
|
|
|
|
2020-09-27 17:24:14 +02:00
|
|
|
virtual Value call() override;
|
2020-04-19 15:03:02 -05:00
|
|
|
|
2021-06-27 21:48:34 +02:00
|
|
|
virtual Value construct(FunctionObject& new_target) override;
|
2020-04-19 15:03:02 -05:00
|
|
|
|
2021-07-01 12:24:46 +02:00
|
|
|
virtual FunctionEnvironment* create_environment(FunctionObject&) override;
|
2020-04-19 15:03:02 -05:00
|
|
|
|
2020-11-28 14:33:36 +01:00
|
|
|
virtual void visit_edges(Visitor&) override;
|
2020-04-19 15:03:02 -05:00
|
|
|
|
|
|
|
virtual const FlyString& name() const override
|
|
|
|
{
|
|
|
|
return m_name;
|
|
|
|
}
|
|
|
|
|
2021-06-27 21:48:34 +02:00
|
|
|
FunctionObject& target_function() const
|
2020-04-19 15:03:02 -05:00
|
|
|
{
|
|
|
|
return *m_target_function;
|
|
|
|
}
|
|
|
|
|
2020-10-04 13:54:44 +02:00
|
|
|
virtual bool is_strict_mode() const override { return m_target_function->is_strict_mode(); }
|
|
|
|
|
2020-04-19 15:03:02 -05:00
|
|
|
private:
|
2021-06-27 21:48:34 +02:00
|
|
|
FunctionObject* m_target_function { nullptr };
|
|
|
|
Object* m_constructor_prototype { nullptr };
|
2020-04-19 15:03:02 -05:00
|
|
|
FlyString m_name;
|
2020-06-20 17:11:11 +02:00
|
|
|
i32 m_length { 0 };
|
2020-04-19 15:03:02 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|