mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-02 01:08:48 +00:00
LibJS: Convert define_property_or_throw() to ThrowCompletionOr
This commit is contained in:
parent
ebf57df431
commit
fe86b04b42
Notes:
sideshowbarker
2024-07-18 03:07:18 +09:00
Author: https://github.com/linusg
Commit: fe86b04b42
Pull-request: https://github.com/SerenityOS/serenity/pull/10327
Reviewed-by: https://github.com/IdanHo ✅
12 changed files with 31 additions and 58 deletions
|
@ -78,7 +78,7 @@ void ECMAScriptFunctionObject::initialize(GlobalObject& global_object)
|
|||
auto* prototype = vm.heap().allocate<Object>(global_object, *global_object.new_ordinary_function_prototype_object_shape());
|
||||
switch (m_kind) {
|
||||
case FunctionKind::Regular:
|
||||
prototype->define_property_or_throw(vm.names.constructor, { .value = this, .writable = true, .enumerable = false, .configurable = true });
|
||||
MUST(prototype->define_property_or_throw(vm.names.constructor, { .value = this, .writable = true, .enumerable = false, .configurable = true }));
|
||||
break;
|
||||
case FunctionKind::Generator:
|
||||
// prototype is "g1.prototype" in figure-2 (https://tc39.es/ecma262/img/figure-2.png)
|
||||
|
@ -87,8 +87,8 @@ void ECMAScriptFunctionObject::initialize(GlobalObject& global_object)
|
|||
}
|
||||
define_direct_property(vm.names.prototype, prototype, Attribute::Writable);
|
||||
}
|
||||
define_property_or_throw(vm.names.length, { .value = Value(m_function_length), .writable = false, .enumerable = false, .configurable = true });
|
||||
define_property_or_throw(vm.names.name, { .value = js_string(vm, m_name.is_null() ? "" : m_name), .writable = false, .enumerable = false, .configurable = true });
|
||||
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 = js_string(vm, m_name.is_null() ? "" : m_name), .writable = false, .enumerable = false, .configurable = true }));
|
||||
}
|
||||
|
||||
ECMAScriptFunctionObject::~ECMAScriptFunctionObject()
|
||||
|
@ -428,7 +428,7 @@ void ECMAScriptFunctionObject::set_name(const FlyString& name)
|
|||
VERIFY(!name.is_null());
|
||||
auto& vm = this->vm();
|
||||
m_name = name;
|
||||
auto success = define_property_or_throw(vm.names.name, { .value = js_string(vm, m_name), .writable = false, .enumerable = false, .configurable = true });
|
||||
auto success = MUST(define_property_or_throw(vm.names.name, { .value = js_string(vm, m_name), .writable = false, .enumerable = false, .configurable = true }));
|
||||
VERIFY(success);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue