mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:07:34 +00:00
LibJS: Don't require Interpreter& for constructing an Accessor
This commit is contained in:
parent
c59a8d84d3
commit
a61ede51e2
3 changed files with 8 additions and 8 deletions
|
@ -27,16 +27,16 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibJS/Interpreter.h>
|
|
||||||
#include <LibJS/Runtime/Function.h>
|
#include <LibJS/Runtime/Function.h>
|
||||||
|
#include <LibJS/Runtime/VM.h>
|
||||||
|
|
||||||
namespace JS {
|
namespace JS {
|
||||||
|
|
||||||
class Accessor final : public Cell {
|
class Accessor final : public Cell {
|
||||||
public:
|
public:
|
||||||
static Accessor* create(Interpreter& interpreter, Function* getter, Function* setter)
|
static Accessor* create(VM& vm, Function* getter, Function* setter)
|
||||||
{
|
{
|
||||||
return interpreter.heap().allocate_without_global_object<Accessor>(getter, setter);
|
return vm.heap().allocate_without_global_object<Accessor>(getter, setter);
|
||||||
}
|
}
|
||||||
|
|
||||||
Accessor(Function* getter, Function* setter)
|
Accessor(Function* getter, Function* setter)
|
||||||
|
@ -55,7 +55,7 @@ public:
|
||||||
{
|
{
|
||||||
if (!m_getter)
|
if (!m_getter)
|
||||||
return js_undefined();
|
return js_undefined();
|
||||||
return interpreter().call(*m_getter, this_value);
|
return vm().call(*m_getter, this_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void call_setter(Value this_value, Value setter_value)
|
void call_setter(Value this_value, Value setter_value)
|
||||||
|
@ -63,7 +63,7 @@ public:
|
||||||
if (!m_setter)
|
if (!m_setter)
|
||||||
return;
|
return;
|
||||||
// FIXME: It might be nice if we had a way to communicate to our caller if an exception happened after this.
|
// FIXME: It might be nice if we had a way to communicate to our caller if an exception happened after this.
|
||||||
(void)interpreter().call(*m_setter, this_value, setter_value);
|
(void)vm().call(*m_setter, this_value, setter_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void visit_children(Cell::Visitor& visitor) override
|
void visit_children(Cell::Visitor& visitor) override
|
||||||
|
|
|
@ -341,7 +341,7 @@ void IndexedProperties::append_all(Object* this_object, const IndexedProperties&
|
||||||
|
|
||||||
for (auto it = properties.begin(false); it != properties.end(); ++it) {
|
for (auto it = properties.begin(false); it != properties.end(); ++it) {
|
||||||
const auto& element = it.value_and_attributes(this_object, evaluate_accessors);
|
const auto& element = it.value_and_attributes(this_object, evaluate_accessors);
|
||||||
if (this_object && this_object->interpreter().exception())
|
if (this_object && this_object->vm().exception())
|
||||||
return;
|
return;
|
||||||
m_storage->put(m_storage->array_like_size(), element.value, element.attributes);
|
m_storage->put(m_storage->array_like_size(), element.value, element.attributes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -392,7 +392,7 @@ bool Object::define_property(const StringOrSymbol& property_name, const Object&
|
||||||
<< "setter=" << setter.to_string_without_side_effects() << "}";
|
<< "setter=" << setter.to_string_without_side_effects() << "}";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return define_property(property_name, Accessor::create(interpreter(), getter_function, setter_function), attributes, throw_exceptions);
|
return define_property(property_name, Accessor::create(vm(), getter_function, setter_function), attributes, throw_exceptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto value = descriptor.get("value");
|
auto value = descriptor.get("value");
|
||||||
|
@ -438,7 +438,7 @@ bool Object::define_accessor(const PropertyName& property_name, Function& getter
|
||||||
accessor = &existing_property.as_accessor();
|
accessor = &existing_property.as_accessor();
|
||||||
}
|
}
|
||||||
if (!accessor) {
|
if (!accessor) {
|
||||||
accessor = Accessor::create(interpreter(), nullptr, nullptr);
|
accessor = Accessor::create(vm(), nullptr, nullptr);
|
||||||
bool definition_success = define_property(property_name, accessor, attributes, throw_exceptions);
|
bool definition_success = define_property(property_name, accessor, attributes, throw_exceptions);
|
||||||
if (vm().exception())
|
if (vm().exception())
|
||||||
return {};
|
return {};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue