mirror of
https://github.com/RGBCube/serenity
synced 2025-05-21 15:35:07 +00:00
LibJS: Make ExecutionContext::function_name a GCPtr<PrimitiveString>
This required setting things up so that all function objects can plop a PrimitiveString there instead of an AK string. This is a step towards making ExecutionContext easier to allocate.
This commit is contained in:
parent
eda2a6d9f7
commit
845da3901d
9 changed files with 34 additions and 16 deletions
|
@ -333,8 +333,10 @@ void ECMAScriptFunctionObject::initialize(Realm& realm)
|
|||
// which must give the properties in chronological order which in this case is the order they
|
||||
// are defined in the spec.
|
||||
|
||||
m_name_string = PrimitiveString::create(vm, m_name);
|
||||
|
||||
MUST(define_property_or_throw(vm.names.length, { .value = Value(m_function_length), .writable = false, .enumerable = false, .configurable = true }));
|
||||
MUST(define_property_or_throw(vm.names.name, { .value = PrimitiveString::create(vm, m_name.is_null() ? "" : m_name), .writable = false, .enumerable = false, .configurable = true }));
|
||||
MUST(define_property_or_throw(vm.names.name, { .value = m_name_string, .writable = false, .enumerable = false, .configurable = true }));
|
||||
|
||||
if (!m_is_arrow_function) {
|
||||
Object* prototype = nullptr;
|
||||
|
@ -936,7 +938,7 @@ ThrowCompletionOr<void> ECMAScriptFunctionObject::prepare_for_ordinary_call(Exec
|
|||
|
||||
// 3. Set the Function of calleeContext to F.
|
||||
callee_context.function = this;
|
||||
callee_context.function_name = m_name;
|
||||
callee_context.function_name = m_name_string;
|
||||
|
||||
// 4. Let calleeRealm be F.[[Realm]].
|
||||
auto callee_realm = m_realm;
|
||||
|
@ -1243,6 +1245,7 @@ void ECMAScriptFunctionObject::set_name(DeprecatedFlyString const& name)
|
|||
VERIFY(!name.is_null());
|
||||
auto& vm = this->vm();
|
||||
m_name = name;
|
||||
MUST(define_property_or_throw(vm.names.name, { .value = PrimitiveString::create(vm, m_name), .writable = false, .enumerable = false, .configurable = true }));
|
||||
m_name_string = PrimitiveString::create(vm, m_name);
|
||||
MUST(define_property_or_throw(vm.names.name, { .value = m_name_string, .writable = false, .enumerable = false, .configurable = true }));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue