diff --git a/Libraries/LibJS/Runtime/BooleanConstructor.cpp b/Libraries/LibJS/Runtime/BooleanConstructor.cpp index 64910080c1e..e7b5eb8d7ff 100644 --- a/Libraries/LibJS/Runtime/BooleanConstructor.cpp +++ b/Libraries/LibJS/Runtime/BooleanConstructor.cpp @@ -51,7 +51,7 @@ Value BooleanConstructor::call(Interpreter& interpreter) Value BooleanConstructor::construct(Interpreter& interpreter) { - return BooleanObject::create(interpreter.global_object(), interpreter.argument(0).to_boolean()); + return BooleanObject::create(global_object(), interpreter.argument(0).to_boolean()); } } diff --git a/Libraries/LibJS/Runtime/DateConstructor.cpp b/Libraries/LibJS/Runtime/DateConstructor.cpp index cff912c2fa8..a76db80b5ea 100644 --- a/Libraries/LibJS/Runtime/DateConstructor.cpp +++ b/Libraries/LibJS/Runtime/DateConstructor.cpp @@ -55,14 +55,14 @@ Value DateConstructor::call(Interpreter& interpreter) return js_string(interpreter, static_cast(date.as_object()).string()); } -Value DateConstructor::construct(Interpreter& interpreter) +Value DateConstructor::construct(Interpreter&) { // TODO: Support args struct timeval tv; gettimeofday(&tv, nullptr); auto datetime = Core::DateTime::now(); auto milliseconds = static_cast(tv.tv_usec / 1000); - return Date::create(interpreter.global_object(), datetime, milliseconds); + return Date::create(global_object(), datetime, milliseconds); } Value DateConstructor::now(Interpreter&) diff --git a/Libraries/LibJS/Runtime/ErrorConstructor.cpp b/Libraries/LibJS/Runtime/ErrorConstructor.cpp index 91d96b9bf1f..f308f64a2ad 100644 --- a/Libraries/LibJS/Runtime/ErrorConstructor.cpp +++ b/Libraries/LibJS/Runtime/ErrorConstructor.cpp @@ -55,7 +55,7 @@ Value ErrorConstructor::construct(Interpreter& interpreter) if (interpreter.exception()) return {}; } - return Error::create(interpreter.global_object(), "Error", message); + return Error::create(global_object(), "Error", message); } #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \ diff --git a/Libraries/LibJS/Runtime/Function.cpp b/Libraries/LibJS/Runtime/Function.cpp index c7c1df8c173..c6329cf2c34 100644 --- a/Libraries/LibJS/Runtime/Function.cpp +++ b/Libraries/LibJS/Runtime/Function.cpp @@ -59,7 +59,7 @@ BoundFunction* Function::bind(Value bound_this_value, Vector arguments) case Value::Type::Null: if (interpreter().in_strict_mode()) return bound_this_value; - return &interpreter().global_object(); + return &global_object(); default: return bound_this_value.to_object(interpreter()); } diff --git a/Libraries/LibJS/Runtime/NumberConstructor.cpp b/Libraries/LibJS/Runtime/NumberConstructor.cpp index a37c913bbfa..0733b9c59aa 100644 --- a/Libraries/LibJS/Runtime/NumberConstructor.cpp +++ b/Libraries/LibJS/Runtime/NumberConstructor.cpp @@ -75,7 +75,7 @@ Value NumberConstructor::construct(Interpreter& interpreter) if (interpreter.exception()) return {}; } - return NumberObject::create(interpreter.global_object(), number); + return NumberObject::create(global_object(), number); } Value NumberConstructor::is_finite(Interpreter& interpreter) diff --git a/Libraries/LibJS/Runtime/Object.cpp b/Libraries/LibJS/Runtime/Object.cpp index 866f86b65a0..dff49c1706e 100644 --- a/Libraries/LibJS/Runtime/Object.cpp +++ b/Libraries/LibJS/Runtime/Object.cpp @@ -91,7 +91,8 @@ Object::Object(Object* prototype) m_shape = interpreter().global_object().empty_object_shape(); set_prototype(prototype); } else { - m_shape = interpreter().heap().allocate(interpreter().global_object()); + // This is the global object + m_shape = interpreter().heap().allocate(static_cast(*this)); } } @@ -167,7 +168,7 @@ Value Object::get_own_property(const Object& this_object, PropertyName property_ Value Object::get_own_properties(const Object& this_object, GetOwnPropertyMode kind, bool only_enumerable_properties) const { - auto* properties_array = Array::create(interpreter().global_object()); + auto* properties_array = Array::create(global_object()); // FIXME: Support generic iterables if (this_object.is_string_object()) { @@ -179,7 +180,7 @@ Value Object::get_own_properties(const Object& this_object, GetOwnPropertyMode k } else if (kind == GetOwnPropertyMode::Value) { properties_array->define_property(i, js_string(interpreter(), String::format("%c", str[i]))); } else { - auto* entry_array = Array::create(interpreter().global_object()); + auto* entry_array = Array::create(global_object()); entry_array->define_property(0, js_string(interpreter(), String::number(i))); if (interpreter().exception()) return {}; @@ -206,7 +207,7 @@ Value Object::get_own_properties(const Object& this_object, GetOwnPropertyMode k } else if (kind == GetOwnPropertyMode::Value) { properties_array->define_property(property_index, value_and_attributes.value); } else { - auto* entry_array = Array::create(interpreter().global_object()); + auto* entry_array = Array::create(global_object()); entry_array->define_property(0, js_string(interpreter(), String::number(entry.index()))); if (interpreter().exception()) return {}; @@ -232,7 +233,7 @@ Value Object::get_own_properties(const Object& this_object, GetOwnPropertyMode k } else if (kind == GetOwnPropertyMode::Value) { properties_array->define_property(offset, this_object.get(it.key)); } else { - auto* entry_array = Array::create(interpreter().global_object()); + auto* entry_array = Array::create(global_object()); entry_array->define_property(0, js_string(interpreter(), it.key)); if (interpreter().exception()) return {}; @@ -294,7 +295,7 @@ Value Object::get_own_property_descriptor_object(PropertyName property_name) con return js_undefined(); auto descriptor = descriptor_opt.value(); - auto* descriptor_object = Object::create_empty(interpreter(), interpreter().global_object()); + auto* descriptor_object = Object::create_empty(interpreter(), global_object()); descriptor_object->define_property("enumerable", Value(descriptor.attributes.is_enumerable())); if (interpreter().exception()) return {}; @@ -685,7 +686,7 @@ bool Object::put(PropertyName property_name, Value value) bool Object::define_native_function(const FlyString& property_name, AK::Function native_function, i32 length, PropertyAttributes attribute) { - auto* function = NativeFunction::create(interpreter(), interpreter().global_object(), property_name, move(native_function)); + auto* function = NativeFunction::create(interpreter(), global_object(), property_name, move(native_function)); function->define_property("length", Value(length), Attribute::Configurable); if (interpreter().exception()) return {}; diff --git a/Libraries/LibJS/Runtime/ObjectConstructor.cpp b/Libraries/LibJS/Runtime/ObjectConstructor.cpp index 88ae0832efb..979b26a980c 100644 --- a/Libraries/LibJS/Runtime/ObjectConstructor.cpp +++ b/Libraries/LibJS/Runtime/ObjectConstructor.cpp @@ -61,7 +61,7 @@ ObjectConstructor::~ObjectConstructor() Value ObjectConstructor::call(Interpreter& interpreter) { - return Object::create_empty(interpreter, interpreter.global_object()); + return Object::create_empty(interpreter, global_object()); } Value ObjectConstructor::construct(Interpreter& interpreter) diff --git a/Libraries/LibJS/Runtime/ProxyConstructor.cpp b/Libraries/LibJS/Runtime/ProxyConstructor.cpp index 9181f637b7f..1d039597051 100644 --- a/Libraries/LibJS/Runtime/ProxyConstructor.cpp +++ b/Libraries/LibJS/Runtime/ProxyConstructor.cpp @@ -62,7 +62,7 @@ Value ProxyConstructor::construct(Interpreter& interpreter) if (!handler.is_object()) return interpreter.throw_exception(String::format("Expected handler argument of Proxy constructor to be object, got %s", handler.to_string_without_side_effects().characters())); - return ProxyObject::create(interpreter.global_object(), target.as_object(), handler.as_object()); + return ProxyObject::create(global_object(), target.as_object(), handler.as_object()); } } diff --git a/Libraries/LibJS/Runtime/RegExpConstructor.cpp b/Libraries/LibJS/Runtime/RegExpConstructor.cpp index 9a2198a3f24..78a81d8f905 100644 --- a/Libraries/LibJS/Runtime/RegExpConstructor.cpp +++ b/Libraries/LibJS/Runtime/RegExpConstructor.cpp @@ -51,14 +51,14 @@ Value RegExpConstructor::call(Interpreter& interpreter) Value RegExpConstructor::construct(Interpreter& interpreter) { if (!interpreter.argument_count()) - return RegExpObject::create(interpreter.global_object(), "(?:)", ""); + return RegExpObject::create(global_object(), "(?:)", ""); auto contents = interpreter.argument(0).to_string(interpreter); if (interpreter.exception()) return {}; auto flags = interpreter.argument_count() > 1 ? interpreter.argument(1).to_string(interpreter) : ""; if (interpreter.exception()) return {}; - return RegExpObject::create(interpreter.global_object(), contents, flags); + return RegExpObject::create(global_object(), contents, flags); } } diff --git a/Libraries/LibJS/Runtime/ScriptFunction.cpp b/Libraries/LibJS/Runtime/ScriptFunction.cpp index fddee25d2ad..6a7c6c390d9 100644 --- a/Libraries/LibJS/Runtime/ScriptFunction.cpp +++ b/Libraries/LibJS/Runtime/ScriptFunction.cpp @@ -104,7 +104,7 @@ Value ScriptFunction::call(Interpreter& interpreter) auto parameter = parameters()[i]; auto value = js_undefined(); if (parameter.is_rest) { - auto* array = Array::create(interpreter.global_object()); + auto* array = Array::create(global_object()); for (size_t rest_index = i; rest_index < argument_values.size(); ++rest_index) array->indexed_properties().append(argument_values[rest_index]); value = Value(array); diff --git a/Libraries/LibJS/Runtime/StringConstructor.cpp b/Libraries/LibJS/Runtime/StringConstructor.cpp index d5a633306e5..f9a5d346313 100644 --- a/Libraries/LibJS/Runtime/StringConstructor.cpp +++ b/Libraries/LibJS/Runtime/StringConstructor.cpp @@ -69,7 +69,7 @@ Value StringConstructor::construct(Interpreter& interpreter) primitive_string = interpreter.argument(0).to_primitive_string(interpreter); if (!primitive_string) return {}; - return StringObject::create(interpreter.global_object(), *primitive_string); + return StringObject::create(global_object(), *primitive_string); } Value StringConstructor::raw(Interpreter& interpreter) diff --git a/Libraries/LibWeb/Bindings/XMLHttpRequestConstructor.cpp b/Libraries/LibWeb/Bindings/XMLHttpRequestConstructor.cpp index 3ad31504124..413d5b94fd8 100644 --- a/Libraries/LibWeb/Bindings/XMLHttpRequestConstructor.cpp +++ b/Libraries/LibWeb/Bindings/XMLHttpRequestConstructor.cpp @@ -59,7 +59,7 @@ JS::Value XMLHttpRequestConstructor::call(JS::Interpreter& interpreter) JS::Value XMLHttpRequestConstructor::construct(JS::Interpreter& interpreter) { - auto& window = static_cast(interpreter.global_object()); + auto& window = static_cast(global_object()); return interpreter.heap().allocate(XMLHttpRequest::create(window.impl())); }