1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:18:11 +00:00

LibJS: Move [[Fields]] to ECMAScriptFunctionObject

This commit is contained in:
Linus Groh 2021-09-25 00:01:09 +02:00
parent 136451c3af
commit 76eb8fe717
6 changed files with 33 additions and 39 deletions

View file

@ -66,24 +66,6 @@ BoundFunction* FunctionObject::bind(Value bound_this_value, Vector<Value> argume
return heap().allocate<BoundFunction>(global_object(), global_object(), target_function, bound_this_object, move(all_bound_arguments), computed_length, constructor_prototype);
}
void FunctionObject::add_field(StringOrSymbol property_key, FunctionObject* initializer)
{
m_fields.empend(property_key, initializer);
}
// 7.3.31 DefineField ( receiver, fieldRecord ), https://tc39.es/ecma262/#sec-definefield
void FunctionObject::InstanceField::define_field(VM& vm, Object& receiver) const
{
Value init_value = js_undefined();
if (initializer) {
auto init_value_or_error = vm.call(*initializer, receiver.value_of());
if (init_value_or_error.is_error())
return;
init_value = init_value_or_error.release_value();
}
receiver.create_data_property_or_throw(name, init_value);
}
void FunctionObject::visit_edges(Visitor& visitor)
{
Base::visit_edges(visitor);
@ -92,11 +74,6 @@ void FunctionObject::visit_edges(Visitor& visitor)
for (auto argument : m_bound_arguments)
visitor.visit(argument);
for (auto& field : m_fields) {
field.name.visit_edges(visitor);
visitor.visit(field.initializer);
}
}
}