summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Libraries/LibJS/Cell.cpp8
-rw-r--r--Libraries/LibJS/Cell.h2
-rw-r--r--Libraries/LibJS/Object.cpp6
3 files changed, 12 insertions, 4 deletions
diff --git a/Libraries/LibJS/Cell.cpp b/Libraries/LibJS/Cell.cpp
index 3aedb7cb66..8e0744ea0b 100644
--- a/Libraries/LibJS/Cell.cpp
+++ b/Libraries/LibJS/Cell.cpp
@@ -26,9 +26,17 @@
#include <AK/LogStream.h>
#include <LibJS/Cell.h>
+#include <LibJS/Object.h>
+#include <LibJS/Value.h>
namespace JS {
+void Cell::Visitor::visit(Value value)
+{
+ if (value.is_object())
+ visit(value.as_object());
+}
+
const LogStream& operator<<(const LogStream& stream, const Cell* cell)
{
if (!cell)
diff --git a/Libraries/LibJS/Cell.h b/Libraries/LibJS/Cell.h
index d4e347a1af..274e41cb4f 100644
--- a/Libraries/LibJS/Cell.h
+++ b/Libraries/LibJS/Cell.h
@@ -27,6 +27,7 @@
#pragma once
#include <AK/Forward.h>
+#include <LibJS/Forward.h>
namespace JS {
@@ -45,6 +46,7 @@ public:
class Visitor {
public:
virtual void visit(Cell*) = 0;
+ void visit(Value);
};
virtual void visit_children(Visitor&) {}
diff --git a/Libraries/LibJS/Object.cpp b/Libraries/LibJS/Object.cpp
index 53f010681d..2d4f021a9f 100644
--- a/Libraries/LibJS/Object.cpp
+++ b/Libraries/LibJS/Object.cpp
@@ -51,10 +51,8 @@ void Object::put(String property_name, Value value)
void Object::visit_children(Cell::Visitor& visitor)
{
Cell::visit_children(visitor);
- for (auto& it : m_properties) {
- if (it.value.is_object())
- visitor.visit(it.value.as_object());
- }
+ for (auto& it : m_properties)
+ visitor.visit(it.value);
}
}