mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:37:35 +00:00
LibJS: Remove GlobalObject from VM::throw_completion()
This is a continuation of the previous five commits. A first big step into the direction of no longer having to pass a realm (or currently, a global object) trough layers upon layers of AOs! Unlike the create() APIs we can safely assume that this is only ever called when a running execution context and therefore current realm exists. If not, you can always manually allocate the Error and put it in a Completion :^) In the spec, throw exceptions implicitly use the current realm's intrinsics as well: https://tc39.es/ecma262/#sec-throw-an-exception
This commit is contained in:
parent
5398dcc55e
commit
f3117d46dc
165 changed files with 892 additions and 900 deletions
|
@ -94,7 +94,7 @@ ThrowCompletionOr<PropertyDescriptor> to_property_descriptor(GlobalObject& globa
|
|||
|
||||
// 1. If Type(Obj) is not Object, throw a TypeError exception.
|
||||
if (!argument.is_object())
|
||||
return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, argument.to_string_without_side_effects());
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, argument.to_string_without_side_effects());
|
||||
|
||||
auto& object = argument.as_object();
|
||||
|
||||
|
@ -159,7 +159,7 @@ ThrowCompletionOr<PropertyDescriptor> to_property_descriptor(GlobalObject& globa
|
|||
|
||||
// b. If IsCallable(getter) is false and getter is not undefined, throw a TypeError exception.
|
||||
if (!getter.is_function() && !getter.is_undefined())
|
||||
return vm.throw_completion<TypeError>(global_object, ErrorType::AccessorBadField, "get");
|
||||
return vm.throw_completion<TypeError>(ErrorType::AccessorBadField, "get");
|
||||
|
||||
// c. Set desc.[[Get]] to getter.
|
||||
descriptor.get = getter.is_function() ? &getter.as_function() : nullptr;
|
||||
|
@ -175,7 +175,7 @@ ThrowCompletionOr<PropertyDescriptor> to_property_descriptor(GlobalObject& globa
|
|||
|
||||
// b. If IsCallable(setter) is false and setter is not undefined, throw a TypeError exception.
|
||||
if (!setter.is_function() && !setter.is_undefined())
|
||||
return vm.throw_completion<TypeError>(global_object, ErrorType::AccessorBadField, "set");
|
||||
return vm.throw_completion<TypeError>(ErrorType::AccessorBadField, "set");
|
||||
|
||||
// c. Set desc.[[Set]] to setter.
|
||||
descriptor.set = setter.is_function() ? &setter.as_function() : nullptr;
|
||||
|
@ -185,7 +185,7 @@ ThrowCompletionOr<PropertyDescriptor> to_property_descriptor(GlobalObject& globa
|
|||
if (descriptor.get.has_value() || descriptor.set.has_value()) {
|
||||
// a. If desc has a [[Value]] field or desc has a [[Writable]] field, throw a TypeError exception.
|
||||
if (descriptor.value.has_value() || descriptor.writable.has_value())
|
||||
return vm.throw_completion<TypeError>(global_object, ErrorType::AccessorValueOrWritable);
|
||||
return vm.throw_completion<TypeError>(ErrorType::AccessorValueOrWritable);
|
||||
}
|
||||
|
||||
// 16. Return desc.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue