]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - runtime/DateInstance.cpp
JavaScriptCore-7600.1.4.11.8.tar.gz
[apple/javascriptcore.git] / runtime / DateInstance.cpp
index d8ca072491b8583dfc81e1295a2d8b392a6447df..d0317c2edb891520ceef376ddb52c25ec25fe663 100644 (file)
 #include "config.h"
 #include "DateInstance.h"
 
+#include "JSDateMath.h"
 #include "JSGlobalObject.h"
-
+#include "JSCInlines.h"
 #include <math.h>
-#include <wtf/DateMath.h>
 #include <wtf/MathExtras.h>
 
 using namespace WTF;
 
 namespace JSC {
 
-const ClassInfo DateInstance::s_info = {"Date", &JSWrapperObject::s_info, 0, 0};
+const ClassInfo DateInstance::s_info = {"Date", &JSWrapperObject::s_info, 0, 0, CREATE_METHOD_TABLE(DateInstance)};
+
+DateInstance::DateInstance(VM& vm, Structure* structure)
+    : JSWrapperObject(vm, structure)
+{
+}
+
+void DateInstance::finishCreation(VM& vm)
+{
+    Base::finishCreation(vm);
+    ASSERT(inherits(info()));
+    setInternalValue(vm, jsNaN());
+}
 
-DateInstance::DateInstance(ExecState* exec, Structure* structure)
-    : JSWrapperObject(exec->globalData(), structure)
+void DateInstance::finishCreation(VM& vm, double time)
 {
-    ASSERT(inherits(&s_info));
-    setInternalValue(exec->globalData(), jsNaN());
+    Base::finishCreation(vm);
+    ASSERT(inherits(info()));
+    setInternalValue(vm, jsNumber(timeClip(time)));
 }
 
-DateInstance::DateInstance(ExecState* exec, Structure* structure, double time)
-    : JSWrapperObject(exec->globalData(), structure)
+void DateInstance::destroy(JSCell* cell)
 {
-    ASSERT(inherits(&s_info));
-    setInternalValue(exec->globalData(), jsNumber(timeClip(time)));
+    static_cast<DateInstance*>(cell)->DateInstance::~DateInstance();
 }
 
 const GregorianDateTime* DateInstance::calculateGregorianDateTime(ExecState* exec) const
 {
     double milli = internalNumber();
-    if (isnan(milli))
+    if (std::isnan(milli))
         return 0;
 
+    VM& vm = exec->vm();
     if (!m_data)
-        m_data = exec->globalData().dateInstanceCache.add(milli);
+        m_data = vm.dateInstanceCache.add(milli);
 
     if (m_data->m_gregorianDateTimeCachedForMS != milli) {
-        msToGregorianDateTime(exec, milli, false, m_data->m_cachedGregorianDateTime);
+        msToGregorianDateTime(vm, milli, false, m_data->m_cachedGregorianDateTime);
         m_data->m_gregorianDateTimeCachedForMS = milli;
     }
     return &m_data->m_cachedGregorianDateTime;
@@ -67,14 +78,15 @@ const GregorianDateTime* DateInstance::calculateGregorianDateTime(ExecState* exe
 const GregorianDateTime* DateInstance::calculateGregorianDateTimeUTC(ExecState* exec) const
 {
     double milli = internalNumber();
-    if (isnan(milli))
+    if (std::isnan(milli))
         return 0;
 
+    VM& vm = exec->vm();
     if (!m_data)
-        m_data = exec->globalData().dateInstanceCache.add(milli);
+        m_data = vm.dateInstanceCache.add(milli);
 
     if (m_data->m_gregorianDateTimeUTCCachedForMS != milli) {
-        msToGregorianDateTime(exec, milli, true, m_data->m_cachedGregorianDateTimeUTC);
+        msToGregorianDateTime(vm, milli, true, m_data->m_cachedGregorianDateTimeUTC);
         m_data->m_gregorianDateTimeUTCCachedForMS = milli;
     }
     return &m_data->m_cachedGregorianDateTimeUTC;