1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 13:07:46 +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

@ -18,7 +18,7 @@ void WebAssemblyInstancePrototype::initialize(JS::Realm& realm)
JS_DEFINE_NATIVE_FUNCTION(WebAssemblyInstancePrototype::exports_getter)
{
auto this_value = vm.this_value(global_object);
auto this_value = vm.this_value();
auto* this_object = TRY(this_value.to_object(global_object));
if (!is<WebAssemblyInstanceObject>(this_object))
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "WebAssembly.Instance");

View file

@ -20,7 +20,7 @@ void WebAssemblyMemoryPrototype::initialize(JS::Realm& realm)
JS_DEFINE_NATIVE_FUNCTION(WebAssemblyMemoryPrototype::grow)
{
auto page_count = TRY(vm.argument(0).to_u32(global_object));
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
auto* this_object = TRY(vm.this_value().to_object(global_object));
if (!is<WebAssemblyMemoryObject>(this_object))
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "WebAssembly.Memory");
auto* memory_object = static_cast<WebAssemblyMemoryObject*>(this_object);
@ -40,7 +40,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyMemoryPrototype::buffer_getter)
{
auto& realm = *global_object.associated_realm();
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
auto* this_object = TRY(vm.this_value().to_object(global_object));
if (!is<WebAssemblyMemoryObject>(this_object))
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "WebAssembly.Memory");
auto* memory_object = static_cast<WebAssemblyMemoryObject*>(this_object);

View file

@ -23,7 +23,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyTablePrototype::grow)
{
auto delta = TRY(vm.argument(0).to_u32(global_object));
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
auto* this_object = TRY(vm.this_value().to_object(global_object));
if (!is<WebAssemblyTableObject>(this_object))
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "WebAssembly.Table");
auto* table_object = static_cast<WebAssemblyTableObject*>(this_object);
@ -53,7 +53,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyTablePrototype::get)
{
auto index = TRY(vm.argument(0).to_u32(global_object));
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
auto* this_object = TRY(vm.this_value().to_object(global_object));
if (!is<WebAssemblyTableObject>(this_object))
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "WebAssembly.Table");
auto* table_object = static_cast<WebAssemblyTableObject*>(this_object);
@ -77,7 +77,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyTablePrototype::set)
{
auto index = TRY(vm.argument(0).to_u32(global_object));
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
auto* this_object = TRY(vm.this_value().to_object(global_object));
if (!is<WebAssemblyTableObject>(this_object))
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "WebAssembly.Table");
auto* table_object = static_cast<WebAssemblyTableObject*>(this_object);
@ -105,7 +105,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyTablePrototype::set)
JS_DEFINE_NATIVE_FUNCTION(WebAssemblyTablePrototype::length_getter)
{
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
auto* this_object = TRY(vm.this_value().to_object(global_object));
if (!is<WebAssemblyTableObject>(this_object))
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "WebAssembly.Table");
auto* table_object = static_cast<WebAssemblyTableObject*>(this_object);