mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:37:35 +00:00
LibJS: Convert create_non_enum_data_p_or_throw() to ThrowCompletionOr
The actual name is a bit longer, but you know what I mean :^)
This commit is contained in:
parent
364dd42fc8
commit
ebf57df431
5 changed files with 55 additions and 51 deletions
|
@ -45,7 +45,7 @@ Value ErrorConstructor::construct(FunctionObject& new_target)
|
|||
auto message = vm.argument(0).to_string(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
error->create_non_enumerable_data_property_or_throw(vm.names.message, js_string(vm, message));
|
||||
MUST(error->create_non_enumerable_data_property_or_throw(vm.names.message, js_string(vm, message)));
|
||||
}
|
||||
|
||||
TRY_OR_DISCARD(error->install_error_cause(vm.argument(1)));
|
||||
|
@ -53,51 +53,51 @@ Value ErrorConstructor::construct(FunctionObject& new_target)
|
|||
return error;
|
||||
}
|
||||
|
||||
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
|
||||
ConstructorName::ConstructorName(GlobalObject& global_object) \
|
||||
: NativeFunction(*static_cast<Object*>(global_object.error_constructor())) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
void ConstructorName::initialize(GlobalObject& global_object) \
|
||||
{ \
|
||||
auto& vm = this->vm(); \
|
||||
NativeFunction::initialize(global_object); \
|
||||
\
|
||||
/* 20.5.6.2.1 NativeError.prototype, \
|
||||
https://tc39.es/ecma262/#sec-nativeerror.prototype */ \
|
||||
define_direct_property(vm.names.prototype, global_object.snake_name##_prototype(), 0); \
|
||||
\
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable); \
|
||||
} \
|
||||
\
|
||||
ConstructorName::~ConstructorName() { } \
|
||||
\
|
||||
/* 20.5.6.1.1 NativeError ( message ), https://tc39.es/ecma262/#sec-nativeerror */ \
|
||||
Value ConstructorName::call() \
|
||||
{ \
|
||||
return construct(*this); \
|
||||
} \
|
||||
\
|
||||
/* 20.5.6.1.1 NativeError ( message ), https://tc39.es/ecma262/#sec-nativeerror */ \
|
||||
Value ConstructorName::construct(FunctionObject& new_target) \
|
||||
{ \
|
||||
auto& vm = this->vm(); \
|
||||
auto& global_object = this->global_object(); \
|
||||
\
|
||||
auto* error = TRY_OR_DISCARD(ordinary_create_from_constructor<ClassName>( \
|
||||
global_object, new_target, &GlobalObject::snake_name##_prototype)); \
|
||||
\
|
||||
if (!vm.argument(0).is_undefined()) { \
|
||||
auto message = vm.argument(0).to_string(global_object); \
|
||||
if (vm.exception()) \
|
||||
return {}; \
|
||||
error->create_non_enumerable_data_property_or_throw(vm.names.message, js_string(vm, message)); \
|
||||
} \
|
||||
\
|
||||
TRY_OR_DISCARD(error->install_error_cause(vm.argument(1))); \
|
||||
\
|
||||
return error; \
|
||||
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
|
||||
ConstructorName::ConstructorName(GlobalObject& global_object) \
|
||||
: NativeFunction(*static_cast<Object*>(global_object.error_constructor())) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
void ConstructorName::initialize(GlobalObject& global_object) \
|
||||
{ \
|
||||
auto& vm = this->vm(); \
|
||||
NativeFunction::initialize(global_object); \
|
||||
\
|
||||
/* 20.5.6.2.1 NativeError.prototype, \
|
||||
https://tc39.es/ecma262/#sec-nativeerror.prototype */ \
|
||||
define_direct_property(vm.names.prototype, global_object.snake_name##_prototype(), 0); \
|
||||
\
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable); \
|
||||
} \
|
||||
\
|
||||
ConstructorName::~ConstructorName() { } \
|
||||
\
|
||||
/* 20.5.6.1.1 NativeError ( message ), https://tc39.es/ecma262/#sec-nativeerror */ \
|
||||
Value ConstructorName::call() \
|
||||
{ \
|
||||
return construct(*this); \
|
||||
} \
|
||||
\
|
||||
/* 20.5.6.1.1 NativeError ( message ), https://tc39.es/ecma262/#sec-nativeerror */ \
|
||||
Value ConstructorName::construct(FunctionObject& new_target) \
|
||||
{ \
|
||||
auto& vm = this->vm(); \
|
||||
auto& global_object = this->global_object(); \
|
||||
\
|
||||
auto* error = TRY_OR_DISCARD(ordinary_create_from_constructor<ClassName>( \
|
||||
global_object, new_target, &GlobalObject::snake_name##_prototype)); \
|
||||
\
|
||||
if (!vm.argument(0).is_undefined()) { \
|
||||
auto message = vm.argument(0).to_string(global_object); \
|
||||
if (vm.exception()) \
|
||||
return {}; \
|
||||
MUST(error->create_non_enumerable_data_property_or_throw(vm.names.message, js_string(vm, message))); \
|
||||
} \
|
||||
\
|
||||
TRY_OR_DISCARD(error->install_error_cause(vm.argument(1))); \
|
||||
\
|
||||
return error; \
|
||||
}
|
||||
|
||||
JS_ENUMERATE_NATIVE_ERRORS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue