summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-08-08 18:35:29 +0100
committerLinus Groh <mail@linusgroh.de>2021-08-08 20:14:59 +0100
commit44a8b55c5060e9b2eb0b188b1ec792068571d86d (patch)
treee7f4d2f31d0463e1d86d36953cd3fe3285bef4e3 /Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
parenta37dcf8ca75a4601280d649c4f17c3faeef9c886 (diff)
downloadserenity-44a8b55c5060e9b2eb0b188b1ec792068571d86d.zip
LibJS: Add preparation for Intl constructors and prototypes
Add a JS_ENUMERATE_INTL_OBJECTS macro and use it to generate: - Forward declarations - CommonPropertyNames class name members - Constructor and prototype GlobalObject members, getters, visitors, and initialize_constructor() calls
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/GlobalObject.cpp')
-rw-r--r--Userland/Libraries/LibJS/Runtime/GlobalObject.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
index c6f0439f98..09890aab8c 100644
--- a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
@@ -155,6 +155,18 @@ void GlobalObject::initialize_global_object()
#undef __JS_ENUMERATE
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
+ if (!m_intl_##snake_name##_prototype) \
+ m_intl_##snake_name##_prototype = heap().allocate<Intl::PrototypeName>(*this, *this);
+ JS_ENUMERATE_INTL_OBJECTS
+#undef __JS_ENUMERATE
+
+ // Must be allocated before `Intl::Intl` below.
+#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
+ initialize_constructor(vm.names.ClassName, m_intl_##snake_name##_constructor, m_intl_##snake_name##_prototype);
+ JS_ENUMERATE_INTL_OBJECTS
+#undef __JS_ENUMERATE
+
+#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
if (!m_temporal_##snake_name##_prototype) \
m_temporal_##snake_name##_prototype = heap().allocate<Temporal::PrototypeName>(*this, *this);
JS_ENUMERATE_TEMPORAL_OBJECTS
@@ -277,6 +289,12 @@ void GlobalObject::visit_edges(Visitor& visitor)
#undef __JS_ENUMERATE
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
+ visitor.visit(m_intl_##snake_name##_constructor); \
+ visitor.visit(m_intl_##snake_name##_prototype);
+ JS_ENUMERATE_INTL_OBJECTS
+#undef __JS_ENUMERATE
+
+#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
visitor.visit(m_temporal_##snake_name##_constructor); \
visitor.visit(m_temporal_##snake_name##_prototype);
JS_ENUMERATE_TEMPORAL_OBJECTS