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

LibJS: Add preparation for Temporal constructors and prototypes

Add a JS_ENUMERATE_TEMPORAL_OBJECTS macro and use it to generate:

- Forward declarations
- CommonPropertyNames class name members
- Constructor and prototype GlobalObject members, getters, visitors,
  and initialize_constructor() calls
This commit is contained in:
Linus Groh 2021-07-06 20:39:55 +01:00
parent 7da1fcb2ef
commit 6735353b96
4 changed files with 44 additions and 0 deletions

View file

@ -133,6 +133,18 @@ void GlobalObject::initialize_global_object()
JS_ENUMERATE_BUILTIN_TYPES
#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
#undef __JS_ENUMERATE
// Must be allocated before `Temporal::Temporal` below.
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName) \
initialize_constructor(vm.names.ClassName, m_temporal_##snake_name##_constructor, m_temporal_##snake_name##_prototype);
JS_ENUMERATE_TEMPORAL_OBJECTS
#undef __JS_ENUMERATE
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(vm.names.gc, gc, 0, attr);
define_native_function(vm.names.isNaN, is_nan, 1, attr);
@ -235,6 +247,12 @@ void GlobalObject::visit_edges(Visitor& visitor)
JS_ENUMERATE_BUILTIN_TYPES
#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
#undef __JS_ENUMERATE
#define __JS_ENUMERATE(ClassName, snake_name) \
visitor.visit(m_##snake_name##_prototype);
JS_ENUMERATE_ITERATOR_PROTOTYPES