mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 08:38:10 +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:
parent
f3117d46dc
commit
999da617c5
36 changed files with 208 additions and 206 deletions
|
@ -3368,7 +3368,7 @@ void @prototype_class@::initialize(JS::Realm& realm)
|
|||
generator.append(R"~~~(
|
||||
static JS::ThrowCompletionOr<@fully_qualified_name@*> impl_from(JS::VM& vm, JS::GlobalObject& global_object)
|
||||
{
|
||||
auto this_value = vm.this_value(global_object);
|
||||
auto this_value = vm.this_value();
|
||||
JS::Object* this_object = nullptr;
|
||||
if (this_value.is_nullish())
|
||||
this_object = &vm.current_realm()->global_object();
|
||||
|
@ -3540,7 +3540,7 @@ JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::for_each)
|
|||
if (!callback.is_function())
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAFunction, callback.to_string_without_side_effects());
|
||||
|
||||
auto this_value = vm.this_value(global_object);
|
||||
auto this_value = vm.this_value();
|
||||
TRY(impl->for_each([&](auto key, auto value) -> JS::ThrowCompletionOr<void> {
|
||||
)~~~");
|
||||
generate_variable_statement(iterator_generator, "wrapped_key", interface.pair_iterator_types->get<0>(), "key", interface);
|
||||
|
@ -3807,7 +3807,7 @@ void @prototype_class@::initialize(JS::Realm& realm)
|
|||
|
||||
static JS::ThrowCompletionOr<@fully_qualified_name@*> impl_from(JS::VM& vm, JS::GlobalObject& 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<@wrapper_class@>(this_object))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "@fully_qualified_name@");
|
||||
return &static_cast<@wrapper_class@*>(this_object)->impl();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue