mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 10:48:41 +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:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user