LibJS: Remove unused BoundFunction::m_constructor_prototype

This was not being used anywhere, and the way we determined it was not
matching the spec at all, so let's remove it and do it properly.
This commit is contained in:
Linus Groh 2022-02-09 19:19:26 +00:00
parent c6c3e2a7fd
commit f663c7d6da
Notes: sideshowbarker 2024-07-17 19:05:06 +09:00
3 changed files with 3 additions and 12 deletions

View file

@ -11,12 +11,11 @@
namespace JS {
BoundFunction::BoundFunction(GlobalObject& global_object, FunctionObject& bound_target_function, Value bound_this, Vector<Value> bound_arguments, i32 length, Object* constructor_prototype)
BoundFunction::BoundFunction(GlobalObject& global_object, FunctionObject& bound_target_function, Value bound_this, Vector<Value> bound_arguments, i32 length)
: FunctionObject(*global_object.function_prototype())
, m_bound_target_function(&bound_target_function)
, m_bound_this(bound_this)
, m_bound_arguments(move(bound_arguments))
, m_constructor_prototype(constructor_prototype)
, m_name(String::formatted("bound {}", bound_target_function.name()))
, m_length(length)
{
@ -88,8 +87,6 @@ void BoundFunction::visit_edges(Visitor& visitor)
visitor.visit(m_bound_this);
for (auto argument : m_bound_arguments)
visitor.visit(argument);
visitor.visit(m_constructor_prototype);
}
}

View file

@ -14,7 +14,7 @@ class BoundFunction final : public FunctionObject {
JS_OBJECT(BoundFunction, FunctionObject);
public:
BoundFunction(GlobalObject&, FunctionObject& target_function, Value bound_this, Vector<Value> bound_arguments, i32 length, Object* constructor_prototype);
BoundFunction(GlobalObject&, FunctionObject& target_function, Value bound_this, Vector<Value> bound_arguments, i32 length);
virtual void initialize(GlobalObject&) override;
virtual ~BoundFunction();
@ -36,7 +36,6 @@ private:
Value m_bound_this; // [[BoundThis]]
Vector<Value> m_bound_arguments; // [[BoundArguments]]
Object* m_constructor_prototype { nullptr };
FlyString m_name;
i32 m_length { 0 };
};

View file

@ -117,17 +117,12 @@ ThrowCompletionOr<BoundFunction*> FunctionObject::bind(Value bound_this_value, V
if (length_property.is_number())
computed_length = max(0, length_property.as_i32() - static_cast<i32>(arguments.size()));
Object* constructor_prototype = nullptr;
auto prototype_property = TRY(target_function.get(vm.names.prototype));
if (prototype_property.is_object())
constructor_prototype = &prototype_property.as_object();
Vector<Value> all_bound_arguments;
if (is<BoundFunction>(*this))
all_bound_arguments.extend(static_cast<BoundFunction&>(*this).bound_arguments());
all_bound_arguments.extend(move(arguments));
return heap().allocate<BoundFunction>(global_object(), global_object(), target_function, bound_this_object, move(all_bound_arguments), computed_length, constructor_prototype);
return heap().allocate<BoundFunction>(global_object(), global_object(), target_function, bound_this_object, move(all_bound_arguments), computed_length);
}
}