浏览代码

LibJS: Add an accessor for the %Date.now% instrinsic property

Timothy Flynn 3 年之前
父节点
当前提交
4cc8cf9233
共有 2 个文件被更改,包括 4 次插入0 次删除
  1. 2 0
      Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
  2. 2 0
      Userland/Libraries/LibJS/Runtime/GlobalObject.h

+ 2 - 0
Userland/Libraries/LibJS/Runtime/GlobalObject.cpp

@@ -287,6 +287,7 @@ void GlobalObject::initialize_global_object()
     m_async_generator_function_prototype->define_direct_property(vm.names.constructor, m_async_generator_function_constructor, Attribute::Configurable);
 
     m_array_prototype_values_function = &m_array_prototype->get_without_side_effects(vm.names.values).as_function();
+    m_date_constructor_now_function = &m_date_constructor->get_without_side_effects(vm.names.now).as_function();
     m_eval_function = &get_without_side_effects(vm.names.eval).as_function();
 }
 
@@ -304,6 +305,7 @@ void GlobalObject::visit_edges(Visitor& visitor)
     visitor.visit(m_proxy_constructor);
     visitor.visit(m_generator_object_prototype);
     visitor.visit(m_array_prototype_values_function);
+    visitor.visit(m_date_constructor_now_function);
     visitor.visit(m_eval_function);
     visitor.visit(m_throw_type_error_function);
 

+ 2 - 0
Userland/Libraries/LibJS/Runtime/GlobalObject.h

@@ -39,6 +39,7 @@ public:
     AsyncFromSyncIteratorPrototype* async_from_sync_iterator_prototype() { return m_async_from_sync_iterator_prototype; }
 
     FunctionObject* array_prototype_values_function() const { return m_array_prototype_values_function; }
+    FunctionObject* date_constructor_now_function() const { return m_date_constructor_now_function; }
     FunctionObject* eval_function() const { return m_eval_function; }
     FunctionObject* throw_type_error_function() const { return m_throw_type_error_function; }
 
@@ -105,6 +106,7 @@ private:
     AsyncFromSyncIteratorPrototype* m_async_from_sync_iterator_prototype { nullptr };
 
     FunctionObject* m_array_prototype_values_function { nullptr };
+    FunctionObject* m_date_constructor_now_function { nullptr };
     FunctionObject* m_eval_function { nullptr };
     FunctionObject* m_throw_type_error_function { nullptr };