1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:48:11 +00:00

LibJS: Change Value::to_object(Heap& -> Interpreter&)

Passing a Heap& to it only to then call interpreter() on that is weird.
Let's just give it the Interpreter& directly, like some of the other
to_something() functions.
This commit is contained in:
Linus Groh 2020-05-17 21:38:47 +01:00 committed by Andreas Kling
parent b8b7f84547
commit 1a1394f7a2
26 changed files with 56 additions and 57 deletions

View file

@ -96,7 +96,7 @@ CallExpression::ThisAndCallee CallExpression::compute_this_and_callee(Interprete
auto object_value = member_expression.object().execute(interpreter); auto object_value = member_expression.object().execute(interpreter);
if (interpreter.exception()) if (interpreter.exception())
return {}; return {};
auto* this_value = object_value.to_object(interpreter.heap()); auto* this_value = object_value.to_object(interpreter);
if (interpreter.exception()) if (interpreter.exception())
return {}; return {};
auto callee = this_value->get(member_expression.computed_property_name(interpreter)).value_or(js_undefined()); auto callee = this_value->get(member_expression.computed_property_name(interpreter)).value_or(js_undefined());
@ -431,7 +431,7 @@ Reference MemberExpression::to_reference(Interpreter& interpreter) const
auto object_value = m_object->execute(interpreter); auto object_value = m_object->execute(interpreter);
if (object_value.is_empty()) if (object_value.is_empty())
return {}; return {};
auto* object = object_value.to_object(interpreter.heap()); auto* object = object_value.to_object(interpreter);
if (!object) if (!object)
return {}; return {};
auto property_name = computed_property_name(interpreter); auto property_name = computed_property_name(interpreter);
@ -452,7 +452,7 @@ Value UnaryExpression::execute(Interpreter& interpreter) const
ASSERT(!reference.is_local_variable()); ASSERT(!reference.is_local_variable());
if (reference.is_global_variable()) if (reference.is_global_variable())
return interpreter.global_object().delete_property(reference.name()); return interpreter.global_object().delete_property(reference.name());
auto* base_object = reference.base().to_object(interpreter.heap()); auto* base_object = reference.base().to_object(interpreter);
if (!base_object) if (!base_object)
return {}; return {};
return base_object->delete_property(reference.name()); return base_object->delete_property(reference.name());
@ -1213,7 +1213,7 @@ Value MemberExpression::execute(Interpreter& interpreter) const
auto object_value = m_object->execute(interpreter); auto object_value = m_object->execute(interpreter);
if (interpreter.exception()) if (interpreter.exception())
return {}; return {};
auto* object_result = object_value.to_object(interpreter.heap()); auto* object_result = object_value.to_object(interpreter);
if (interpreter.exception()) if (interpreter.exception())
return {}; return {};
return object_result->get(computed_property_name(interpreter)).value_or(js_undefined()); return object_result->get(computed_property_name(interpreter)).value_or(js_undefined());

View file

@ -51,7 +51,7 @@ Array::~Array()
Array* array_from(Interpreter& interpreter) Array* array_from(Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return {}; return {};
if (!this_object->is_array()) { if (!this_object->is_array()) {

View file

@ -38,7 +38,7 @@ namespace JS {
static Date* this_date_from_interpreter(Interpreter& interpreter) static Date* this_date_from_interpreter(Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return nullptr; return nullptr;
if (!this_object->is_date()) { if (!this_object->is_date()) {

View file

@ -50,7 +50,7 @@ ErrorPrototype::~ErrorPrototype()
Value ErrorPrototype::name_getter(Interpreter& interpreter) Value ErrorPrototype::name_getter(Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return {}; return {};
if (!this_object->is_error()) if (!this_object->is_error())
@ -60,7 +60,7 @@ Value ErrorPrototype::name_getter(Interpreter& interpreter)
void ErrorPrototype::name_setter(Interpreter& interpreter, Value value) void ErrorPrototype::name_setter(Interpreter& interpreter, Value value)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return; return;
if (!this_object->is_error()) { if (!this_object->is_error()) {
@ -75,7 +75,7 @@ void ErrorPrototype::name_setter(Interpreter& interpreter, Value value)
Value ErrorPrototype::message_getter(Interpreter& interpreter) Value ErrorPrototype::message_getter(Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return {}; return {};
if (!this_object->is_error()) if (!this_object->is_error())

View file

@ -60,7 +60,7 @@ BoundFunction* Function::bind(Value bound_this_value, Vector<Value> arguments)
// FIXME: Null or undefined should be passed through in strict mode. // FIXME: Null or undefined should be passed through in strict mode.
return &interpreter().global_object(); return &interpreter().global_object();
default: default:
return bound_this_value.to_object(interpreter().heap()); return bound_this_value.to_object(interpreter());
} }
}(); }();

View file

@ -60,7 +60,7 @@ FunctionPrototype::~FunctionPrototype()
Value FunctionPrototype::apply(Interpreter& interpreter) Value FunctionPrototype::apply(Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return {}; return {};
if (!this_object->is_function()) if (!this_object->is_function())
@ -86,7 +86,7 @@ Value FunctionPrototype::apply(Interpreter& interpreter)
Value FunctionPrototype::bind(Interpreter& interpreter) Value FunctionPrototype::bind(Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return {}; return {};
if (!this_object->is_function()) if (!this_object->is_function())
@ -106,7 +106,7 @@ Value FunctionPrototype::bind(Interpreter& interpreter)
Value FunctionPrototype::call(Interpreter& interpreter) Value FunctionPrototype::call(Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return {}; return {};
if (!this_object->is_function()) if (!this_object->is_function())
@ -123,7 +123,7 @@ Value FunctionPrototype::call(Interpreter& interpreter)
Value FunctionPrototype::to_string(Interpreter& interpreter) Value FunctionPrototype::to_string(Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return {}; return {};
if (!this_object->is_function()) if (!this_object->is_function())

View file

@ -71,7 +71,7 @@ Value ObjectConstructor::get_own_property_names(Interpreter& interpreter)
{ {
if (!interpreter.argument_count()) if (!interpreter.argument_count())
return {}; return {};
auto* object = interpreter.argument(0).to_object(interpreter.heap()); auto* object = interpreter.argument(0).to_object(interpreter);
if (interpreter.exception()) if (interpreter.exception())
return {}; return {};
auto* result = Array::create(interpreter.global_object()); auto* result = Array::create(interpreter.global_object());
@ -90,7 +90,7 @@ Value ObjectConstructor::get_prototype_of(Interpreter& interpreter)
{ {
if (!interpreter.argument_count()) if (!interpreter.argument_count())
return {}; return {};
auto* object = interpreter.argument(0).to_object(interpreter.heap()); auto* object = interpreter.argument(0).to_object(interpreter);
if (interpreter.exception()) if (interpreter.exception())
return {}; return {};
return object->prototype(); return object->prototype();
@ -100,7 +100,7 @@ Value ObjectConstructor::set_prototype_of(Interpreter& interpreter)
{ {
if (interpreter.argument_count() < 2) if (interpreter.argument_count() < 2)
return {}; return {};
auto* object = interpreter.argument(0).to_object(interpreter.heap()); auto* object = interpreter.argument(0).to_object(interpreter);
if (interpreter.exception()) if (interpreter.exception())
return {}; return {};
object->set_prototype(&const_cast<Object&>(interpreter.argument(1).as_object())); object->set_prototype(&const_cast<Object&>(interpreter.argument(1).as_object()));
@ -109,7 +109,7 @@ Value ObjectConstructor::set_prototype_of(Interpreter& interpreter)
Value ObjectConstructor::get_own_property_descriptor(Interpreter& interpreter) Value ObjectConstructor::get_own_property_descriptor(Interpreter& interpreter)
{ {
auto* object = interpreter.argument(0).to_object(interpreter.heap()); auto* object = interpreter.argument(0).to_object(interpreter);
if (interpreter.exception()) if (interpreter.exception())
return {}; return {};
auto property_key = interpreter.argument(1).to_string(interpreter); auto property_key = interpreter.argument(1).to_string(interpreter);
@ -143,7 +143,7 @@ Value ObjectConstructor::keys(Interpreter& interpreter)
if (!interpreter.argument_count()) if (!interpreter.argument_count())
return interpreter.throw_exception<TypeError>("Can't convert undefined to object"); return interpreter.throw_exception<TypeError>("Can't convert undefined to object");
auto* obj_arg = interpreter.argument(0).to_object(interpreter.heap()); auto* obj_arg = interpreter.argument(0).to_object(interpreter);
if (interpreter.exception()) if (interpreter.exception())
return {}; return {};
@ -155,7 +155,7 @@ Value ObjectConstructor::values(Interpreter& interpreter)
if (!interpreter.argument_count()) if (!interpreter.argument_count())
return interpreter.throw_exception<TypeError>("Can't convert undefined to object"); return interpreter.throw_exception<TypeError>("Can't convert undefined to object");
auto* obj_arg = interpreter.argument(0).to_object(interpreter.heap()); auto* obj_arg = interpreter.argument(0).to_object(interpreter);
if (interpreter.exception()) if (interpreter.exception())
return {}; return {};
@ -167,7 +167,7 @@ Value ObjectConstructor::entries(Interpreter& interpreter)
if (!interpreter.argument_count()) if (!interpreter.argument_count())
return interpreter.throw_exception<TypeError>("Can't convert undefined to object"); return interpreter.throw_exception<TypeError>("Can't convert undefined to object");
auto* obj_arg = interpreter.argument(0).to_object(interpreter.heap()); auto* obj_arg = interpreter.argument(0).to_object(interpreter);
if (interpreter.exception()) if (interpreter.exception())
return {}; return {};

View file

@ -54,7 +54,7 @@ ObjectPrototype::~ObjectPrototype()
Value ObjectPrototype::has_own_property(Interpreter& interpreter) Value ObjectPrototype::has_own_property(Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return {}; return {};
auto name = interpreter.argument(0).to_string(interpreter); auto name = interpreter.argument(0).to_string(interpreter);
@ -65,7 +65,7 @@ Value ObjectPrototype::has_own_property(Interpreter& interpreter)
Value ObjectPrototype::to_string(Interpreter& interpreter) Value ObjectPrototype::to_string(Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return {}; return {};
return js_string(interpreter, String::format("[object %s]", this_object->class_name())); return js_string(interpreter, String::format("[object %s]", this_object->class_name()));
@ -73,7 +73,7 @@ Value ObjectPrototype::to_string(Interpreter& interpreter)
Value ObjectPrototype::value_of(Interpreter& interpreter) Value ObjectPrototype::value_of(Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return {}; return {};
return this_object->value_of(); return this_object->value_of();

View file

@ -50,7 +50,7 @@ void Reference::put(Interpreter& interpreter, Value value)
return; return;
} }
auto* object = base().to_object(interpreter.heap()); auto* object = base().to_object(interpreter);
if (!object) if (!object)
return; return;
@ -92,7 +92,7 @@ Value Reference::get(Interpreter& interpreter)
return value; return value;
} }
auto* object = base().to_object(interpreter.heap()); auto* object = base().to_object(interpreter);
if (!object) if (!object)
return {}; return {};

View file

@ -37,7 +37,7 @@ namespace JS {
static ScriptFunction* script_function_from(Interpreter& interpreter) static ScriptFunction* script_function_from(Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return nullptr; return nullptr;
if (!this_object->is_function()) { if (!this_object->is_function()) {

View file

@ -71,7 +71,7 @@ Value StringConstructor::construct(Interpreter& interpreter)
Value StringConstructor::raw(Interpreter& interpreter) Value StringConstructor::raw(Interpreter& interpreter)
{ {
auto* template_object = interpreter.argument(0).to_object(interpreter.heap()); auto* template_object = interpreter.argument(0).to_object(interpreter);
if (interpreter.exception()) if (interpreter.exception())
return {}; return {};
@ -83,7 +83,7 @@ Value StringConstructor::raw(Interpreter& interpreter)
if (!raw.is_array()) if (!raw.is_array())
return js_string(interpreter, ""); return js_string(interpreter, "");
auto& raw_array_elements = static_cast<Array*>(raw.to_object(interpreter.heap()))->elements(); auto& raw_array_elements = static_cast<Array*>(raw.to_object(interpreter))->elements();
StringBuilder builder; StringBuilder builder;
for (size_t i = 0; i < raw_array_elements.size(); ++i) { for (size_t i = 0; i < raw_array_elements.size(); ++i) {

View file

@ -41,7 +41,7 @@ namespace JS {
static StringObject* string_object_from(Interpreter& interpreter) static StringObject* string_object_from(Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return nullptr; return nullptr;
if (!this_object->is_string_object()) { if (!this_object->is_string_object()) {
@ -53,7 +53,7 @@ static StringObject* string_object_from(Interpreter& interpreter)
static String string_from(Interpreter& interpreter) static String string_from(Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return {}; return {};
return Value(this_object).to_string(interpreter); return Value(this_object).to_string(interpreter);

View file

@ -54,7 +54,7 @@ SymbolPrototype::~SymbolPrototype()
static SymbolObject* this_symbol_from_interpreter(Interpreter& interpreter) static SymbolObject* this_symbol_from_interpreter(Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return nullptr; return nullptr;
if (!this_object->is_symbol_object()) { if (!this_object->is_symbol_object()) {

View file

@ -57,7 +57,7 @@ Uint8ClampedArray::~Uint8ClampedArray()
Value Uint8ClampedArray::length_getter(Interpreter& interpreter) Value Uint8ClampedArray::length_getter(Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return {}; return {};
if (StringView(this_object->class_name()) != "Uint8ClampedArray") if (StringView(this_object->class_name()) != "Uint8ClampedArray")

View file

@ -176,25 +176,25 @@ Value Value::to_primitive(Interpreter&) const
return *this; return *this;
} }
Object* Value::to_object(Heap& heap) const Object* Value::to_object(Interpreter& interpreter) const
{ {
if (is_object()) if (is_object())
return &const_cast<Object&>(as_object()); return &const_cast<Object&>(as_object());
if (is_string()) if (is_string())
return StringObject::create(heap.interpreter().global_object(), *m_value.as_string); return StringObject::create(interpreter.global_object(), *m_value.as_string);
if (is_symbol()) if (is_symbol())
return SymbolObject::create(heap.interpreter().global_object(), *m_value.as_symbol); return SymbolObject::create(interpreter.global_object(), *m_value.as_symbol);
if (is_number()) if (is_number())
return NumberObject::create(heap.interpreter().global_object(), m_value.as_double); return NumberObject::create(interpreter.global_object(), m_value.as_double);
if (is_boolean()) if (is_boolean())
return BooleanObject::create(heap.interpreter().global_object(), m_value.as_bool); return BooleanObject::create(interpreter.global_object(), m_value.as_bool);
if (is_null() || is_undefined()) { if (is_null() || is_undefined()) {
heap.interpreter().throw_exception<TypeError>("ToObject on null or undefined."); interpreter.throw_exception<TypeError>("ToObject on null or undefined.");
return nullptr; return nullptr;
} }

View file

@ -186,14 +186,13 @@ public:
String to_string(Interpreter&) const; String to_string(Interpreter&) const;
PrimitiveString* to_primitive_string(Interpreter&); PrimitiveString* to_primitive_string(Interpreter&);
Value to_primitive(Interpreter&) const;
Object* to_object(Interpreter&) const;
bool to_boolean() const; bool to_boolean() const;
Value to_number() const; Value to_number() const;
i32 to_i32() const; i32 to_i32() const;
double to_double() const; double to_double() const;
size_t to_size_t() const; size_t to_size_t() const;
Value to_primitive(Interpreter&) const;
Object* to_object(Heap&) const;
Value value_or(Value fallback) const Value value_or(Value fallback) const
{ {

View file

@ -78,7 +78,7 @@ CanvasRenderingContext2DWrapper::~CanvasRenderingContext2DWrapper()
static CanvasRenderingContext2D* impl_from(JS::Interpreter& interpreter) static CanvasRenderingContext2D* impl_from(JS::Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return nullptr; return nullptr;
// FIXME: Verify that it's a CanvasRenderingContext2DWrapper somehow! // FIXME: Verify that it's a CanvasRenderingContext2DWrapper somehow!
@ -116,7 +116,7 @@ JS::Value CanvasRenderingContext2DWrapper::draw_image(JS::Interpreter& interpret
if (arguments.size() < 3) if (arguments.size() < 3)
return interpreter.throw_exception<JS::TypeError>("drawImage() needs more arguments"); return interpreter.throw_exception<JS::TypeError>("drawImage() needs more arguments");
auto* image_argument = arguments[0].to_object(interpreter.heap()); auto* image_argument = arguments[0].to_object(interpreter);
if (!image_argument) if (!image_argument)
return {}; return {};
if (StringView(image_argument->class_name()) != "HTMLImageElementWrapper") if (StringView(image_argument->class_name()) != "HTMLImageElementWrapper")
@ -307,7 +307,7 @@ JS::Value CanvasRenderingContext2DWrapper::put_image_data(JS::Interpreter& inter
if (!impl) if (!impl)
return {}; return {};
auto* image_data_object = interpreter.argument(0).to_object(interpreter.heap()); auto* image_data_object = interpreter.argument(0).to_object(interpreter);
if (!image_data_object) if (!image_data_object)
return {}; return {};

View file

@ -60,7 +60,7 @@ const Document& DocumentWrapper::node() const
static Document* document_from(JS::Interpreter& interpreter) static Document* document_from(JS::Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return {}; return {};
if (StringView("DocumentWrapper") != this_object->class_name()) { if (StringView("DocumentWrapper") != this_object->class_name()) {

View file

@ -58,7 +58,7 @@ const Element& ElementWrapper::node() const
static Element* impl_from(JS::Interpreter& interpreter) static Element* impl_from(JS::Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return nullptr; return nullptr;
// FIXME: Verify that it's an ElementWrapper somehow! // FIXME: Verify that it's an ElementWrapper somehow!

View file

@ -50,7 +50,7 @@ EventTargetWrapper::~EventTargetWrapper()
JS::Value EventTargetWrapper::add_event_listener(JS::Interpreter& interpreter) JS::Value EventTargetWrapper::add_event_listener(JS::Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return {}; return {};
auto& arguments = interpreter.call_frame().arguments; auto& arguments = interpreter.call_frame().arguments;

View file

@ -62,7 +62,7 @@ const HTMLCanvasElement& HTMLCanvasElementWrapper::node() const
static HTMLCanvasElement* impl_from(JS::Interpreter& interpreter) static HTMLCanvasElement* impl_from(JS::Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return nullptr; return nullptr;
// FIXME: Verify that it's a HTMLCanvasElementWrapper somehow! // FIXME: Verify that it's a HTMLCanvasElementWrapper somehow!

View file

@ -55,7 +55,7 @@ ImageDataWrapper::~ImageDataWrapper()
static ImageData* impl_from(JS::Interpreter& interpreter) static ImageData* impl_from(JS::Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) { if (!this_object) {
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
return nullptr; return nullptr;

View file

@ -57,7 +57,7 @@ MouseEvent& MouseEventWrapper::event()
static MouseEvent* impl_from(JS::Interpreter& interpreter) static MouseEvent* impl_from(JS::Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return nullptr; return nullptr;
// FIXME: Verify that it's a CanvasRenderingContext2DWrapper somehow! // FIXME: Verify that it's a CanvasRenderingContext2DWrapper somehow!

View file

@ -80,7 +80,7 @@ void WindowObject::visit_children(Visitor& visitor)
static Window* impl_from(JS::Interpreter& interpreter) static Window* impl_from(JS::Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) { if (!this_object) {
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
return nullptr; return nullptr;
@ -129,7 +129,7 @@ JS::Value WindowObject::set_interval(JS::Interpreter& interpreter)
auto& arguments = interpreter.call_frame().arguments; auto& arguments = interpreter.call_frame().arguments;
if (arguments.size() < 2) if (arguments.size() < 2)
return {}; return {};
auto* callback_object = arguments[0].to_object(interpreter.heap()); auto* callback_object = arguments[0].to_object(interpreter);
if (!callback_object) if (!callback_object)
return {}; return {};
if (!callback_object->is_function()) if (!callback_object->is_function())
@ -146,7 +146,7 @@ JS::Value WindowObject::set_timeout(JS::Interpreter& interpreter)
auto& arguments = interpreter.call_frame().arguments; auto& arguments = interpreter.call_frame().arguments;
if (arguments.size() < 1) if (arguments.size() < 1)
return {}; return {};
auto* callback_object = arguments[0].to_object(interpreter.heap()); auto* callback_object = arguments[0].to_object(interpreter);
if (!callback_object) if (!callback_object)
return {}; return {};
if (!callback_object->is_function()) if (!callback_object->is_function())
@ -168,7 +168,7 @@ JS::Value WindowObject::request_animation_frame(JS::Interpreter& interpreter)
auto& arguments = interpreter.call_frame().arguments; auto& arguments = interpreter.call_frame().arguments;
if (arguments.size() < 1) if (arguments.size() < 1)
return {}; return {};
auto* callback_object = arguments[0].to_object(interpreter.heap()); auto* callback_object = arguments[0].to_object(interpreter);
if (!callback_object) if (!callback_object)
return {}; return {};
if (!callback_object->is_function()) if (!callback_object->is_function())

View file

@ -56,7 +56,7 @@ XMLHttpRequestPrototype::~XMLHttpRequestPrototype()
static XMLHttpRequest* impl_from(JS::Interpreter& interpreter) static XMLHttpRequest* impl_from(JS::Interpreter& interpreter)
{ {
auto* this_object = interpreter.this_value().to_object(interpreter.heap()); auto* this_object = interpreter.this_value().to_object(interpreter);
if (!this_object) if (!this_object)
return nullptr; return nullptr;
if (StringView("XMLHttpRequestWrapper") != this_object->class_name()) { if (StringView("XMLHttpRequestWrapper") != this_object->class_name()) {

View file

@ -701,7 +701,7 @@ int main(int argc, char** argv)
if (!variable.is_object()) if (!variable.is_object())
return {}; return {};
const auto* object = variable.to_object(interpreter->heap()); const auto* object = variable.to_object(*interpreter);
const auto& shape = object->shape(); const auto& shape = object->shape();
list_all_properties(shape, property_pattern); list_all_properties(shape, property_pattern);
if (results.size()) if (results.size())