mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-02 09:18:52 +00:00
LibJS: Move [[Fields]] to ECMAScriptFunctionObject
This commit is contained in:
parent
136451c3af
commit
76eb8fe717
Notes:
sideshowbarker
2024-07-18 03:28:05 +09:00
Author: https://github.com/linusg
Commit: 76eb8fe717
Pull-request: https://github.com/SerenityOS/serenity/pull/10203
Reviewed-by: https://github.com/IdanHo ✅
Reviewed-by: https://github.com/davidot
6 changed files with 33 additions and 39 deletions
|
@ -100,6 +100,11 @@ void ECMAScriptFunctionObject::visit_edges(Visitor& visitor)
|
|||
visitor.visit(m_environment);
|
||||
visitor.visit(m_realm);
|
||||
visitor.visit(m_home_object);
|
||||
|
||||
for (auto& field : m_fields) {
|
||||
field.name.visit_edges(visitor);
|
||||
visitor.visit(field.initializer);
|
||||
}
|
||||
}
|
||||
|
||||
FunctionEnvironment* ECMAScriptFunctionObject::create_environment(FunctionObject& function_being_invoked)
|
||||
|
@ -245,4 +250,17 @@ void ECMAScriptFunctionObject::set_name(const FlyString& name)
|
|||
VERIFY(success);
|
||||
}
|
||||
|
||||
// 7.3.31 DefineField ( receiver, fieldRecord ), https://tc39.es/ecma262/#sec-definefield
|
||||
void ECMAScriptFunctionObject::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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue