1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:57:46 +00:00

LibJS: Implement Function.prototype.bind() according to the spec :^)

This commit is contained in:
Linus Groh 2022-02-09 19:41:23 +00:00
parent 87b9fa2636
commit 898ad7c682
4 changed files with 66 additions and 20 deletions

View file

@ -6,6 +6,7 @@
#pragma once
#include <LibJS/Runtime/Completion.h>
#include <LibJS/Runtime/FunctionObject.h>
namespace JS {
@ -14,8 +15,9 @@ class BoundFunction final : public FunctionObject {
JS_OBJECT(BoundFunction, FunctionObject);
public:
BoundFunction(GlobalObject&, FunctionObject& target_function, Value bound_this, Vector<Value> bound_arguments, i32 length);
virtual void initialize(GlobalObject&) override;
static ThrowCompletionOr<BoundFunction*> create(GlobalObject&, FunctionObject& target_function, Value bound_this, Vector<Value> bound_arguments);
BoundFunction(GlobalObject&, FunctionObject& target_function, Value bound_this, Vector<Value> bound_arguments, Object* prototype);
virtual ~BoundFunction();
virtual ThrowCompletionOr<Value> internal_call(Value this_argument, MarkedVector<Value> arguments_list) override;
@ -37,7 +39,6 @@ private:
Vector<Value> m_bound_arguments; // [[BoundArguments]]
FlyString m_name;
i32 m_length { 0 };
};
}