mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:48:11 +00:00
LibJS+LibWeb: Remove a bunch of calls to Interpreter::global_object()
Objects should get the GlobalObject from themselves instead. However, it's not yet available during construction so this only switches code that happens after construction. To support multiple global objects, Interpreter needs to stop holding on to "the" global object and let each object graph own their global.
This commit is contained in:
parent
ff8bb962b6
commit
affc479e83
12 changed files with 21 additions and 20 deletions
|
@ -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<Shape>(interpreter().global_object());
|
||||
// This is the global object
|
||||
m_shape = interpreter().heap().allocate<Shape>(static_cast<GlobalObject&>(*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<Value(Interpreter&)> 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 {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue