#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;
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;