summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Libraries/LibJS/AST.cpp4
-rw-r--r--Libraries/LibJS/Interpreter.h4
-rw-r--r--Libraries/LibJS/Runtime/Array.cpp8
-rw-r--r--Libraries/LibJS/Runtime/Array.h2
-rw-r--r--Libraries/LibJS/Runtime/ArrayPrototype.cpp56
-rw-r--r--Libraries/LibJS/Runtime/BigIntPrototype.cpp8
-rw-r--r--Libraries/LibJS/Runtime/BooleanPrototype.cpp4
-rw-r--r--Libraries/LibJS/Runtime/BoundFunction.cpp2
-rw-r--r--Libraries/LibJS/Runtime/DatePrototype.cpp2
-rw-r--r--Libraries/LibJS/Runtime/ErrorPrototype.cpp10
-rw-r--r--Libraries/LibJS/Runtime/FunctionPrototype.cpp8
-rw-r--r--Libraries/LibJS/Runtime/ObjectPrototype.cpp9
-rw-r--r--Libraries/LibJS/Runtime/ScriptFunction.cpp4
-rw-r--r--Libraries/LibJS/Runtime/StringPrototype.cpp4
-rw-r--r--Libraries/LibJS/Runtime/SymbolPrototype.cpp2
-rw-r--r--Libraries/LibJS/Runtime/Uint8ClampedArray.cpp2
-rw-r--r--Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.cpp2
-rw-r--r--Libraries/LibWeb/Bindings/DocumentWrapper.cpp3
-rw-r--r--Libraries/LibWeb/Bindings/ElementWrapper.cpp3
-rw-r--r--Libraries/LibWeb/Bindings/EventTargetWrapper.cpp2
-rw-r--r--Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.cpp3
-rw-r--r--Libraries/LibWeb/Bindings/ImageDataWrapper.cpp2
-rw-r--r--Libraries/LibWeb/Bindings/MouseEventWrapper.cpp3
-rw-r--r--Libraries/LibWeb/Bindings/WindowObject.cpp2
-rw-r--r--Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.cpp2
25 files changed, 78 insertions, 73 deletions
diff --git a/Libraries/LibJS/AST.cpp b/Libraries/LibJS/AST.cpp
index 83cf1104ac..4adf7ba620 100644
--- a/Libraries/LibJS/AST.cpp
+++ b/Libraries/LibJS/AST.cpp
@@ -1006,9 +1006,9 @@ Value SpreadExpression::execute(Interpreter& interpreter, GlobalObject& global_o
return m_target->execute(interpreter, global_object);
}
-Value ThisExpression::execute(Interpreter& interpreter, GlobalObject&) const
+Value ThisExpression::execute(Interpreter& interpreter, GlobalObject& global_object) const
{
- return interpreter.this_value();
+ return interpreter.this_value(global_object);
}
void ThisExpression::dump(int indent) const
diff --git a/Libraries/LibJS/Interpreter.h b/Libraries/LibJS/Interpreter.h
index 9219ea6d39..7efc30c5b5 100644
--- a/Libraries/LibJS/Interpreter.h
+++ b/Libraries/LibJS/Interpreter.h
@@ -150,10 +150,10 @@ public:
return index < arguments.size() ? arguments[index] : js_undefined();
}
- Value this_value() const
+ Value this_value(Object& global_object) const
{
if (m_call_stack.is_empty())
- return m_global_object;
+ return &global_object;
return m_call_stack.last().this_value;
}
diff --git a/Libraries/LibJS/Runtime/Array.cpp b/Libraries/LibJS/Runtime/Array.cpp
index 8c28966236..70ee69c077 100644
--- a/Libraries/LibJS/Runtime/Array.cpp
+++ b/Libraries/LibJS/Runtime/Array.cpp
@@ -49,9 +49,9 @@ Array::~Array()
{
}
-Array* array_from(Interpreter& interpreter)
+Array* array_from(Interpreter& interpreter, GlobalObject& global_object)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(global_object).to_object(interpreter);
if (!this_object)
return {};
if (!this_object->is_array()) {
@@ -63,7 +63,7 @@ Array* array_from(Interpreter& interpreter)
Value Array::length_getter(Interpreter& interpreter)
{
- auto* array = array_from(interpreter);
+ auto* array = array_from(interpreter, interpreter.global_object());
if (!array)
return {};
return Value(static_cast<i32>(array->indexed_properties().array_like_size()));
@@ -71,7 +71,7 @@ Value Array::length_getter(Interpreter& interpreter)
void Array::length_setter(Interpreter& interpreter, Value value)
{
- auto* array = array_from(interpreter);
+ auto* array = array_from(interpreter, interpreter.global_object());
if (!array)
return;
auto length = value.to_number(interpreter);
diff --git a/Libraries/LibJS/Runtime/Array.h b/Libraries/LibJS/Runtime/Array.h
index a45ac0e9eb..7a62080287 100644
--- a/Libraries/LibJS/Runtime/Array.h
+++ b/Libraries/LibJS/Runtime/Array.h
@@ -30,7 +30,7 @@
namespace JS {
-Array* array_from(Interpreter&);
+Array* array_from(Interpreter&, GlobalObject&);
class Array final : public Object {
public:
diff --git a/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Libraries/LibJS/Runtime/ArrayPrototype.cpp
index 4d103fa47f..ed5d7a3611 100644
--- a/Libraries/LibJS/Runtime/ArrayPrototype.cpp
+++ b/Libraries/LibJS/Runtime/ArrayPrototype.cpp
@@ -99,9 +99,9 @@ static size_t get_length(Interpreter& interpreter, Object& object)
return length_property.to_size_t(interpreter);
}
-static void for_each_item(Interpreter& interpreter, const String& name, AK::Function<IterationDecision(size_t index, Value value, Value callback_result)> callback, bool skip_empty = true)
+static void for_each_item(Interpreter& interpreter, GlobalObject& global_object, const String& name, AK::Function<IterationDecision(size_t index, Value value, Value callback_result)> callback, bool skip_empty = true)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(global_object).to_object(interpreter);
if (!this_object)
return;
@@ -142,7 +142,7 @@ static void for_each_item(Interpreter& interpreter, const String& name, AK::Func
Value ArrayPrototype::filter(Interpreter& interpreter)
{
auto* new_array = Array::create(interpreter.global_object());
- for_each_item(interpreter, "filter", [&](auto, auto value, auto callback_result) {
+ for_each_item(interpreter, interpreter.global_object(), "filter", [&](auto, auto value, auto callback_result) {
if (callback_result.to_boolean())
new_array->indexed_properties().append(value);
return IterationDecision::Continue;
@@ -152,7 +152,7 @@ Value ArrayPrototype::filter(Interpreter& interpreter)
Value ArrayPrototype::for_each(Interpreter& interpreter)
{
- for_each_item(interpreter, "forEach", [](auto, auto, auto) {
+ for_each_item(interpreter, interpreter.global_object(), "forEach", [](auto, auto, auto) {
return IterationDecision::Continue;
});
return js_undefined();
@@ -160,7 +160,7 @@ Value ArrayPrototype::for_each(Interpreter& interpreter)
Value ArrayPrototype::map(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
auto initial_length = get_length(interpreter, *this_object);
@@ -168,7 +168,7 @@ Value ArrayPrototype::map(Interpreter& interpreter)
return {};
auto* new_array = Array::create(interpreter.global_object());
new_array->indexed_properties().set_array_like_size(initial_length);
- for_each_item(interpreter, "map", [&](auto index, auto, auto callback_result) {
+ for_each_item(interpreter, interpreter.global_object(), "map", [&](auto index, auto, auto callback_result) {
new_array->put(index, callback_result);
if (interpreter.exception())
return IterationDecision::Break;
@@ -179,7 +179,7 @@ Value ArrayPrototype::map(Interpreter& interpreter)
Value ArrayPrototype::push(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
if (this_object->is_array()) {
@@ -209,7 +209,7 @@ Value ArrayPrototype::push(Interpreter& interpreter)
Value ArrayPrototype::unshift(Interpreter& interpreter)
{
- auto* array = array_from(interpreter);
+ auto* array = array_from(interpreter, interpreter.global_object());
if (!array)
return {};
for (size_t i = 0; i < interpreter.argument_count(); ++i)
@@ -219,7 +219,7 @@ Value ArrayPrototype::unshift(Interpreter& interpreter)
Value ArrayPrototype::pop(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
if (this_object->is_array()) {
@@ -248,7 +248,7 @@ Value ArrayPrototype::pop(Interpreter& interpreter)
Value ArrayPrototype::shift(Interpreter& interpreter)
{
- auto* array = array_from(interpreter);
+ auto* array = array_from(interpreter, interpreter.global_object());
if (!array)
return {};
if (array->indexed_properties().is_empty())
@@ -261,7 +261,7 @@ Value ArrayPrototype::shift(Interpreter& interpreter)
Value ArrayPrototype::to_string(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
auto join_function = this_object->get("join");
@@ -274,10 +274,10 @@ Value ArrayPrototype::to_string(Interpreter& interpreter)
Value ArrayPrototype::to_locale_string(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
- String separator = ","; // NOTE: This is implementation-specific.
+ String separator = ","; // NOTE: This is implementation-specific.
auto length = get_length(interpreter, *this_object);
if (interpreter.exception())
return {};
@@ -305,7 +305,7 @@ Value ArrayPrototype::to_locale_string(Interpreter& interpreter)
Value ArrayPrototype::join(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
String separator = ",";
@@ -336,7 +336,7 @@ Value ArrayPrototype::join(Interpreter& interpreter)
Value ArrayPrototype::concat(Interpreter& interpreter)
{
- auto* array = array_from(interpreter);
+ auto* array = array_from(interpreter, interpreter.global_object());
if (!array)
return {};
@@ -362,7 +362,7 @@ Value ArrayPrototype::concat(Interpreter& interpreter)
Value ArrayPrototype::slice(Interpreter& interpreter)
{
- auto* array = array_from(interpreter);
+ auto* array = array_from(interpreter, interpreter.global_object());
if (!array)
return {};
@@ -407,7 +407,7 @@ Value ArrayPrototype::slice(Interpreter& interpreter)
Value ArrayPrototype::index_of(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
i32 length = get_length(interpreter, *this_object);
@@ -438,7 +438,7 @@ Value ArrayPrototype::index_of(Interpreter& interpreter)
Value ArrayPrototype::reduce(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
@@ -497,7 +497,7 @@ Value ArrayPrototype::reduce(Interpreter& interpreter)
Value ArrayPrototype::reduce_right(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
@@ -556,7 +556,7 @@ Value ArrayPrototype::reduce_right(Interpreter& interpreter)
Value ArrayPrototype::reverse(Interpreter& interpreter)
{
- auto* array = array_from(interpreter);
+ auto* array = array_from(interpreter, interpreter.global_object());
if (!array)
return {};
@@ -580,7 +580,7 @@ Value ArrayPrototype::reverse(Interpreter& interpreter)
Value ArrayPrototype::last_index_of(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
i32 length = get_length(interpreter, *this_object);
@@ -611,7 +611,7 @@ Value ArrayPrototype::last_index_of(Interpreter& interpreter)
Value ArrayPrototype::includes(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
i32 length = get_length(interpreter, *this_object);
@@ -644,7 +644,7 @@ Value ArrayPrototype::find(Interpreter& interpreter)
{
auto result = js_undefined();
for_each_item(
- interpreter, "find", [&](auto, auto value, auto callback_result) {
+ interpreter, interpreter.global_object(), "find", [&](auto, auto value, auto callback_result) {
if (callback_result.to_boolean()) {
result = value;
return IterationDecision::Break;
@@ -659,7 +659,7 @@ Value ArrayPrototype::find_index(Interpreter& interpreter)
{
auto result_index = -1;
for_each_item(
- interpreter, "findIndex", [&](auto index, auto, auto callback_result) {
+ interpreter, interpreter.global_object(), "findIndex", [&](auto index, auto, auto callback_result) {
if (callback_result.to_boolean()) {
result_index = index;
return IterationDecision::Break;
@@ -673,7 +673,7 @@ Value ArrayPrototype::find_index(Interpreter& interpreter)
Value ArrayPrototype::some(Interpreter& interpreter)
{
auto result = false;
- for_each_item(interpreter, "some", [&](auto, auto, auto callback_result) {
+ for_each_item(interpreter, interpreter.global_object(), "some", [&](auto, auto, auto callback_result) {
if (callback_result.to_boolean()) {
result = true;
return IterationDecision::Break;
@@ -686,7 +686,7 @@ Value ArrayPrototype::some(Interpreter& interpreter)
Value ArrayPrototype::every(Interpreter& interpreter)
{
auto result = true;
- for_each_item(interpreter, "every", [&](auto, auto, auto callback_result) {
+ for_each_item(interpreter, interpreter.global_object(), "every", [&](auto, auto, auto callback_result) {
if (!callback_result.to_boolean()) {
result = false;
return IterationDecision::Break;
@@ -698,7 +698,7 @@ Value ArrayPrototype::every(Interpreter& interpreter)
Value ArrayPrototype::splice(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
@@ -801,7 +801,7 @@ Value ArrayPrototype::splice(Interpreter& interpreter)
Value ArrayPrototype::fill(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
diff --git a/Libraries/LibJS/Runtime/BigIntPrototype.cpp b/Libraries/LibJS/Runtime/BigIntPrototype.cpp
index a271ca0b8c..9a4498ec38 100644
--- a/Libraries/LibJS/Runtime/BigIntPrototype.cpp
+++ b/Libraries/LibJS/Runtime/BigIntPrototype.cpp
@@ -45,9 +45,9 @@ BigIntPrototype::~BigIntPrototype()
{
}
-static BigIntObject* bigint_object_from(Interpreter& interpreter)
+static BigIntObject* bigint_object_from(Interpreter& interpreter, GlobalObject& global_object)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(global_object).to_object(interpreter);
if (!this_object)
return nullptr;
if (!this_object->is_bigint_object()) {
@@ -59,7 +59,7 @@ static BigIntObject* bigint_object_from(Interpreter& interpreter)
Value BigIntPrototype::to_string(Interpreter& interpreter)
{
- auto* bigint_object = bigint_object_from(interpreter);
+ auto* bigint_object = bigint_object_from(interpreter, interpreter.global_object());
if (!bigint_object)
return {};
return js_string(interpreter, bigint_object->bigint().big_integer().to_base10());
@@ -72,7 +72,7 @@ Value BigIntPrototype::to_locale_string(Interpreter& interpreter)
Value BigIntPrototype::value_of(Interpreter& interpreter)
{
- auto* bigint_object = bigint_object_from(interpreter);
+ auto* bigint_object = bigint_object_from(interpreter, interpreter.global_object());
if (!bigint_object)
return {};
return bigint_object->value_of();
diff --git a/Libraries/LibJS/Runtime/BooleanPrototype.cpp b/Libraries/LibJS/Runtime/BooleanPrototype.cpp
index 6fcf08ed95..1fbf50742c 100644
--- a/Libraries/LibJS/Runtime/BooleanPrototype.cpp
+++ b/Libraries/LibJS/Runtime/BooleanPrototype.cpp
@@ -43,7 +43,7 @@ BooleanPrototype::~BooleanPrototype() { }
Value BooleanPrototype::to_string(Interpreter& interpreter)
{
- auto this_object = interpreter.this_value();
+ auto this_object = interpreter.this_value(interpreter.global_object());
if (this_object.is_boolean()) {
return js_string(interpreter.heap(), this_object.as_bool() ? "true" : "false");
}
@@ -58,7 +58,7 @@ Value BooleanPrototype::to_string(Interpreter& interpreter)
Value BooleanPrototype::value_of(Interpreter& interpreter)
{
- auto this_object = interpreter.this_value();
+ auto this_object = interpreter.this_value(interpreter.global_object());
if (this_object.is_boolean()) {
return this_object;
}
diff --git a/Libraries/LibJS/Runtime/BoundFunction.cpp b/Libraries/LibJS/Runtime/BoundFunction.cpp
index 55e4a5c53c..090f4d6e48 100644
--- a/Libraries/LibJS/Runtime/BoundFunction.cpp
+++ b/Libraries/LibJS/Runtime/BoundFunction.cpp
@@ -50,7 +50,7 @@ Value BoundFunction::call(Interpreter& interpreter)
Value BoundFunction::construct(Interpreter& interpreter)
{
- if (auto this_value = interpreter.this_value(); m_constructor_prototype && this_value.is_object()) {
+ if (auto this_value = interpreter.this_value(global_object()); m_constructor_prototype && this_value.is_object()) {
this_value.as_object().set_prototype(m_constructor_prototype);
if (interpreter.exception())
return {};
diff --git a/Libraries/LibJS/Runtime/DatePrototype.cpp b/Libraries/LibJS/Runtime/DatePrototype.cpp
index 546cefa78d..e112be27c0 100644
--- a/Libraries/LibJS/Runtime/DatePrototype.cpp
+++ b/Libraries/LibJS/Runtime/DatePrototype.cpp
@@ -38,7 +38,7 @@ namespace JS {
static Date* this_date_from_interpreter(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return nullptr;
if (!this_object->is_date()) {
diff --git a/Libraries/LibJS/Runtime/ErrorPrototype.cpp b/Libraries/LibJS/Runtime/ErrorPrototype.cpp
index 8febdc320c..e6f0e14434 100644
--- a/Libraries/LibJS/Runtime/ErrorPrototype.cpp
+++ b/Libraries/LibJS/Runtime/ErrorPrototype.cpp
@@ -50,7 +50,7 @@ ErrorPrototype::~ErrorPrototype()
Value ErrorPrototype::name_getter(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
if (!this_object->is_error())
@@ -60,7 +60,7 @@ Value ErrorPrototype::name_getter(Interpreter& interpreter)
void ErrorPrototype::name_setter(Interpreter& interpreter, Value value)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return;
if (!this_object->is_error()) {
@@ -75,7 +75,7 @@ void ErrorPrototype::name_setter(Interpreter& interpreter, Value value)
Value ErrorPrototype::message_getter(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
if (!this_object->is_error())
@@ -85,9 +85,9 @@ Value ErrorPrototype::message_getter(Interpreter& interpreter)
Value ErrorPrototype::to_string(Interpreter& interpreter)
{
- if (!interpreter.this_value().is_object())
+ if (!interpreter.this_value(interpreter.global_object()).is_object())
return interpreter.throw_exception<TypeError>("Not an object");
- auto& this_object = interpreter.this_value().as_object();
+ auto& this_object = interpreter.this_value(interpreter.global_object()).as_object();
String name = "Error";
auto name_property = this_object.get("name");
diff --git a/Libraries/LibJS/Runtime/FunctionPrototype.cpp b/Libraries/LibJS/Runtime/FunctionPrototype.cpp
index 88a4aca167..dea52b19ef 100644
--- a/Libraries/LibJS/Runtime/FunctionPrototype.cpp
+++ b/Libraries/LibJS/Runtime/FunctionPrototype.cpp
@@ -60,7 +60,7 @@ FunctionPrototype::~FunctionPrototype()
Value FunctionPrototype::apply(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
if (!this_object->is_function())
@@ -90,7 +90,7 @@ Value FunctionPrototype::apply(Interpreter& interpreter)
Value FunctionPrototype::bind(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
if (!this_object->is_function())
@@ -110,7 +110,7 @@ Value FunctionPrototype::bind(Interpreter& interpreter)
Value FunctionPrototype::call(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
if (!this_object->is_function())
@@ -127,7 +127,7 @@ Value FunctionPrototype::call(Interpreter& interpreter)
Value FunctionPrototype::to_string(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
if (!this_object->is_function())
diff --git a/Libraries/LibJS/Runtime/ObjectPrototype.cpp b/Libraries/LibJS/Runtime/ObjectPrototype.cpp
index 6a4b4a7efb..b790a608f1 100644
--- a/Libraries/LibJS/Runtime/ObjectPrototype.cpp
+++ b/Libraries/LibJS/Runtime/ObjectPrototype.cpp
@@ -28,6 +28,7 @@
#include <AK/String.h>
#include <LibJS/Heap/Heap.h>
#include <LibJS/Interpreter.h>
+#include <LibJS/Runtime/GlobalObject.h>
#include <LibJS/Runtime/ObjectPrototype.h>
#include <LibJS/Runtime/Value.h>
@@ -55,7 +56,7 @@ ObjectPrototype::~ObjectPrototype()
Value ObjectPrototype::has_own_property(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
auto name = interpreter.argument(0).to_string(interpreter);
@@ -66,7 +67,7 @@ Value ObjectPrototype::has_own_property(Interpreter& interpreter)
Value ObjectPrototype::to_string(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
return js_string(interpreter, String::format("[object %s]", this_object->class_name()));
@@ -74,7 +75,7 @@ Value ObjectPrototype::to_string(Interpreter& interpreter)
Value ObjectPrototype::to_locale_string(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
return this_object->invoke("toString");
@@ -82,7 +83,7 @@ Value ObjectPrototype::to_locale_string(Interpreter& interpreter)
Value ObjectPrototype::value_of(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
return this_object->value_of();
diff --git a/Libraries/LibJS/Runtime/ScriptFunction.cpp b/Libraries/LibJS/Runtime/ScriptFunction.cpp
index 38104249f8..262f9b288d 100644
--- a/Libraries/LibJS/Runtime/ScriptFunction.cpp
+++ b/Libraries/LibJS/Runtime/ScriptFunction.cpp
@@ -37,7 +37,7 @@ namespace JS {
static ScriptFunction* script_function_from(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return nullptr;
if (!this_object->is_function()) {
@@ -53,7 +53,7 @@ ScriptFunction* ScriptFunction::create(GlobalObject& global_object, const FlyStr
}
ScriptFunction::ScriptFunction(const FlyString& name, const Statement& body, Vector<FunctionNode::Parameter> parameters, i32 m_function_length, LexicalEnvironment* parent_environment, Object& prototype, bool is_arrow_function)
- : Function(prototype, is_arrow_function ? interpreter().this_value() : Value(), {})
+ : Function(prototype, is_arrow_function ? interpreter().this_value(interpreter().global_object()) : Value(), {})
, m_name(name)
, m_body(body)
, m_parameters(move(parameters))
diff --git a/Libraries/LibJS/Runtime/StringPrototype.cpp b/Libraries/LibJS/Runtime/StringPrototype.cpp
index b52d2f56bd..cf97e00c3d 100644
--- a/Libraries/LibJS/Runtime/StringPrototype.cpp
+++ b/Libraries/LibJS/Runtime/StringPrototype.cpp
@@ -41,7 +41,7 @@ namespace JS {
static StringObject* string_object_from(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return nullptr;
if (!this_object->is_string_object()) {
@@ -53,7 +53,7 @@ static StringObject* string_object_from(Interpreter& interpreter)
static String string_from(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
return Value(this_object).to_string(interpreter);
diff --git a/Libraries/LibJS/Runtime/SymbolPrototype.cpp b/Libraries/LibJS/Runtime/SymbolPrototype.cpp
index f97470c7d4..641f365e77 100644
--- a/Libraries/LibJS/Runtime/SymbolPrototype.cpp
+++ b/Libraries/LibJS/Runtime/SymbolPrototype.cpp
@@ -54,7 +54,7 @@ SymbolPrototype::~SymbolPrototype()
static SymbolObject* this_symbol_from_interpreter(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return nullptr;
if (!this_object->is_symbol_object()) {
diff --git a/Libraries/LibJS/Runtime/Uint8ClampedArray.cpp b/Libraries/LibJS/Runtime/Uint8ClampedArray.cpp
index 3553f50a9a..5761020781 100644
--- a/Libraries/LibJS/Runtime/Uint8ClampedArray.cpp
+++ b/Libraries/LibJS/Runtime/Uint8ClampedArray.cpp
@@ -55,7 +55,7 @@ Uint8ClampedArray::~Uint8ClampedArray()
Value Uint8ClampedArray::length_getter(Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
if (StringView(this_object->class_name()) != "Uint8ClampedArray")
diff --git a/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.cpp b/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.cpp
index 9b89801a89..4312aed643 100644
--- a/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.cpp
+++ b/Libraries/LibWeb/Bindings/CanvasRenderingContext2DWrapper.cpp
@@ -78,7 +78,7 @@ CanvasRenderingContext2DWrapper::~CanvasRenderingContext2DWrapper()
static CanvasRenderingContext2D* impl_from(JS::Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return nullptr;
// FIXME: Verify that it's a CanvasRenderingContext2DWrapper somehow!
diff --git a/Libraries/LibWeb/Bindings/DocumentWrapper.cpp b/Libraries/LibWeb/Bindings/DocumentWrapper.cpp
index ced42bac05..4fd473a5ad 100644
--- a/Libraries/LibWeb/Bindings/DocumentWrapper.cpp
+++ b/Libraries/LibWeb/Bindings/DocumentWrapper.cpp
@@ -28,6 +28,7 @@
#include <LibJS/Interpreter.h>
#include <LibJS/Runtime/Array.h>
#include <LibJS/Runtime/Error.h>
+#include <LibJS/Runtime/GlobalObject.h>
#include <LibJS/Runtime/PrimitiveString.h>
#include <LibJS/Runtime/Value.h>
#include <LibWeb/Bindings/DocumentWrapper.h>
@@ -61,7 +62,7 @@ const Document& DocumentWrapper::node() const
static Document* document_from(JS::Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
if (StringView("DocumentWrapper") != this_object->class_name()) {
diff --git a/Libraries/LibWeb/Bindings/ElementWrapper.cpp b/Libraries/LibWeb/Bindings/ElementWrapper.cpp
index 3028d44a77..8ef89e7fa7 100644
--- a/Libraries/LibWeb/Bindings/ElementWrapper.cpp
+++ b/Libraries/LibWeb/Bindings/ElementWrapper.cpp
@@ -28,6 +28,7 @@
#include <AK/Function.h>
#include <LibJS/Interpreter.h>
#include <LibJS/Runtime/Error.h>
+#include <LibJS/Runtime/GlobalObject.h>
#include <LibJS/Runtime/PrimitiveString.h>
#include <LibJS/Runtime/Value.h>
#include <LibWeb/Bindings/ElementWrapper.h>
@@ -64,7 +65,7 @@ const Element& ElementWrapper::node() const
static Element* impl_from(JS::Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return nullptr;
// FIXME: Verify that it's an ElementWrapper somehow!
diff --git a/Libraries/LibWeb/Bindings/EventTargetWrapper.cpp b/Libraries/LibWeb/Bindings/EventTargetWrapper.cpp
index 79711295d2..b37a96d226 100644
--- a/Libraries/LibWeb/Bindings/EventTargetWrapper.cpp
+++ b/Libraries/LibWeb/Bindings/EventTargetWrapper.cpp
@@ -51,7 +51,7 @@ EventTargetWrapper::~EventTargetWrapper()
JS::Value EventTargetWrapper::add_event_listener(JS::Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return {};
if (interpreter.argument_count() < 2)
diff --git a/Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.cpp b/Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.cpp
index 12f14ff46c..f194b38019 100644
--- a/Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.cpp
+++ b/Libraries/LibWeb/Bindings/HTMLCanvasElementWrapper.cpp
@@ -27,6 +27,7 @@
#include <AK/FlyString.h>
#include <AK/Function.h>
#include <LibJS/Interpreter.h>
+#include <LibJS/Runtime/GlobalObject.h>
#include <LibJS/Runtime/PrimitiveString.h>
#include <LibJS/Runtime/Value.h>
#include <LibWeb/Bindings/CanvasRenderingContext2DWrapper.h>
@@ -62,7 +63,7 @@ const HTMLCanvasElement& HTMLCanvasElementWrapper::node() const
static HTMLCanvasElement* impl_from(JS::Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return nullptr;
// FIXME: Verify that it's a HTMLCanvasElementWrapper somehow!
diff --git a/Libraries/LibWeb/Bindings/ImageDataWrapper.cpp b/Libraries/LibWeb/Bindings/ImageDataWrapper.cpp
index f3e7cbad3e..6378e7318f 100644
--- a/Libraries/LibWeb/Bindings/ImageDataWrapper.cpp
+++ b/Libraries/LibWeb/Bindings/ImageDataWrapper.cpp
@@ -55,7 +55,7 @@ ImageDataWrapper::~ImageDataWrapper()
static ImageData* impl_from(JS::Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object) {
ASSERT_NOT_REACHED();
return nullptr;
diff --git a/Libraries/LibWeb/Bindings/MouseEventWrapper.cpp b/Libraries/LibWeb/Bindings/MouseEventWrapper.cpp
index 8cabc9ee76..57ec50b853 100644
--- a/Libraries/LibWeb/Bindings/MouseEventWrapper.cpp
+++ b/Libraries/LibWeb/Bindings/MouseEventWrapper.cpp
@@ -28,6 +28,7 @@
#include <AK/Function.h>
#include <LibJS/Interpreter.h>
#include <LibJS/Runtime/Function.h>
+#include <LibJS/Runtime/GlobalObject.h>
#include <LibWeb/Bindings/MouseEventWrapper.h>
#include <LibWeb/DOM/MouseEvent.h>
@@ -57,7 +58,7 @@ MouseEvent& MouseEventWrapper::event()
static MouseEvent* impl_from(JS::Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return nullptr;
// FIXME: Verify that it's a CanvasRenderingContext2DWrapper somehow!
diff --git a/Libraries/LibWeb/Bindings/WindowObject.cpp b/Libraries/LibWeb/Bindings/WindowObject.cpp
index 6c6adaa4c9..0234e5e97a 100644
--- a/Libraries/LibWeb/Bindings/WindowObject.cpp
+++ b/Libraries/LibWeb/Bindings/WindowObject.cpp
@@ -82,7 +82,7 @@ void WindowObject::visit_children(Visitor& visitor)
static Window* impl_from(JS::Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object) {
ASSERT_NOT_REACHED();
return nullptr;
diff --git a/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.cpp b/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.cpp
index aefe1a4abb..f668f5b114 100644
--- a/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.cpp
+++ b/Libraries/LibWeb/Bindings/XMLHttpRequestPrototype.cpp
@@ -56,7 +56,7 @@ XMLHttpRequestPrototype::~XMLHttpRequestPrototype()
static XMLHttpRequest* impl_from(JS::Interpreter& interpreter)
{
- auto* this_object = interpreter.this_value().to_object(interpreter);
+ auto* this_object = interpreter.this_value(interpreter.global_object()).to_object(interpreter);
if (!this_object)
return nullptr;
if (StringView("XMLHttpRequestWrapper") != this_object->class_name()) {