1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 11:47:34 +00:00

LibJS: Remove GlobalObject from VM::this_value()

This is a continuation of the previous six commits.

The global object is only needed to return it if the execution context
stack is empty, but that doesn't seem like a useful thing to allow in
the first place - if you're not currently executing JS, and the
execution context stack is empty, there is no this value to retrieve.
This commit is contained in:
Linus Groh 2022-08-20 09:48:43 +01:00
parent f3117d46dc
commit 999da617c5
36 changed files with 208 additions and 206 deletions

View file

@ -76,7 +76,7 @@ AK::URL LocationObject::url() const
static JS::ThrowCompletionOr<LocationObject*> typed_this_value(JS::GlobalObject& global_object)
{
auto& vm = global_object.vm();
auto this_value = vm.this_value(global_object);
auto this_value = vm.this_value();
if (!this_value.is_object() || !is<LocationObject>(this_value.as_object()))
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "Location");
return static_cast<LocationObject*>(&this_value.as_object());

View file

@ -7,7 +7,7 @@
#pragma once
#define REPLACEABLE_PROPERTY_SETTER(ObjectType, property) \
auto this_value = vm.this_value(global_object); \
auto this_value = vm.this_value(); \
if (!this_value.is_object() || !is<ObjectType>(this_value.as_object())) \
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, #ObjectType); \
TRY(this_value.as_object().internal_define_own_property( \

View file

@ -180,7 +180,7 @@ static JS::ThrowCompletionOr<HTML::Window*> impl_from(JS::VM& vm, JS::GlobalObje
// this_value to a specific object type in the bindings. But since window is
// the global object we make an exception here.
// This allows calls like `setTimeout(f, 10)` to work.
auto this_value = vm.this_value(global_object);
auto this_value = vm.this_value();
if (this_value.is_nullish())
this_value = &global_object;