1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 06:25:01 +00:00

LibJS: More Interpreter::global_object() removal

Also let's settle on calling the operation of fetching the "this" value
from the Interpreter and converting it to a specific Object pointer
typed_this() since consistency is nice.
This commit is contained in:
Andreas Kling 2020-06-20 16:25:12 +02:00
parent a9e4babdaf
commit cd14ebb11f
7 changed files with 55 additions and 55 deletions

View file

@ -35,9 +35,9 @@
namespace JS {
static ScriptFunction* script_function_from(Interpreter& interpreter)
static ScriptFunction* typed_this(Interpreter& interpreter, GlobalObject& global_object)
{
auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
auto* this_object = interpreter.this_value(global_object).to_object(interpreter);
if (!this_object)
return nullptr;
if (!this_object->is_function()) {
@ -132,7 +132,7 @@ Value ScriptFunction::construct(Interpreter& interpreter)
JS_DEFINE_NATIVE_GETTER(ScriptFunction::length_getter)
{
auto* function = script_function_from(interpreter);
auto* function = typed_this(interpreter, global_object);
if (!function)
return {};
return Value(static_cast<i32>(function->m_function_length));
@ -140,7 +140,7 @@ JS_DEFINE_NATIVE_GETTER(ScriptFunction::length_getter)
JS_DEFINE_NATIVE_GETTER(ScriptFunction::name_getter)
{
auto* function = script_function_from(interpreter);
auto* function = typed_this(interpreter, global_object);
if (!function)
return {};
return js_string(interpreter, function->name().is_null() ? "" : function->name());