Bug 918350 - SpiderMonkey: Remove js_NaN in favor of a new mozilla::GenericNaN() function. r=waldo
This commit is contained in:
@@ -50,6 +50,7 @@ using namespace js::types;
|
||||
using mozilla::ArrayLength;
|
||||
using mozilla::IsFinite;
|
||||
using mozilla::IsNaN;
|
||||
using JS::GenericNaN;
|
||||
|
||||
/*
|
||||
* The JS 'Date' object is patterned after the Java 'Date' object.
|
||||
@@ -126,7 +127,7 @@ inline double
|
||||
DaysInYear(double year)
|
||||
{
|
||||
if (!IsFinite(year))
|
||||
return js_NaN;
|
||||
return GenericNaN();
|
||||
return IsLeapYear(year) ? 366 : 365;
|
||||
}
|
||||
|
||||
@@ -149,7 +150,7 @@ static double
|
||||
YearFromTime(double t)
|
||||
{
|
||||
if (!IsFinite(t))
|
||||
return js_NaN;
|
||||
return GenericNaN();
|
||||
|
||||
JS_ASSERT(ToInteger(t) == t);
|
||||
|
||||
@@ -188,7 +189,7 @@ static double
|
||||
MonthFromTime(double t)
|
||||
{
|
||||
if (!IsFinite(t))
|
||||
return js_NaN;
|
||||
return GenericNaN();
|
||||
|
||||
double year = YearFromTime(t);
|
||||
double d = DayWithinYear(t, year);
|
||||
@@ -224,7 +225,7 @@ static double
|
||||
DateFromTime(double t)
|
||||
{
|
||||
if (!IsFinite(t))
|
||||
return js_NaN;
|
||||
return GenericNaN();
|
||||
|
||||
double year = YearFromTime(t);
|
||||
double d = DayWithinYear(t, year);
|
||||
@@ -307,7 +308,7 @@ MakeDay(double year, double month, double date)
|
||||
{
|
||||
/* Step 1. */
|
||||
if (!IsFinite(year) || !IsFinite(month) || !IsFinite(date))
|
||||
return js_NaN;
|
||||
return GenericNaN();
|
||||
|
||||
/* Steps 2-4. */
|
||||
double y = ToInteger(year);
|
||||
@@ -337,7 +338,7 @@ MakeDate(double day, double time)
|
||||
{
|
||||
/* Step 1. */
|
||||
if (!IsFinite(day) || !IsFinite(time))
|
||||
return js_NaN;
|
||||
return GenericNaN();
|
||||
|
||||
/* Step 2. */
|
||||
return day * msPerDay + time;
|
||||
@@ -403,7 +404,7 @@ static double
|
||||
DaylightSavingTA(double t, DateTimeInfo *dtInfo)
|
||||
{
|
||||
if (!IsFinite(t))
|
||||
return js_NaN;
|
||||
return GenericNaN();
|
||||
|
||||
/*
|
||||
* If earlier than 1970 or after 2038, potentially beyond the ken of
|
||||
@@ -488,7 +489,7 @@ MakeTime(double hour, double min, double sec, double ms)
|
||||
!IsFinite(sec) ||
|
||||
!IsFinite(ms))
|
||||
{
|
||||
return js_NaN;
|
||||
return GenericNaN();
|
||||
}
|
||||
|
||||
/* Step 2. */
|
||||
@@ -617,7 +618,7 @@ date_msecFromArgs(JSContext *cx, CallArgs args, double *rval)
|
||||
return false;
|
||||
/* return NaN if any arg is not finite */
|
||||
if (!IsFinite(d)) {
|
||||
*rval = js_NaN;
|
||||
*rval = GenericNaN();
|
||||
return true;
|
||||
}
|
||||
array[loop] = ToInteger(d);
|
||||
@@ -1201,7 +1202,7 @@ date_parse(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
if (args.length() == 0) {
|
||||
vp->setDouble(js_NaN);
|
||||
vp->setNaN();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1215,7 +1216,7 @@ date_parse(JSContext *cx, unsigned argc, Value *vp)
|
||||
|
||||
double result;
|
||||
if (!date_parseString(linearStr, &result, &cx->runtime()->dateTimeInfo)) {
|
||||
vp->setDouble(js_NaN);
|
||||
vp->setNaN();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1708,7 +1709,7 @@ date_setTime_impl(JSContext *cx, CallArgs args)
|
||||
{
|
||||
Rooted<DateObject*> dateObj(cx, &args.thisv().toObject().as<DateObject>());
|
||||
if (args.length() == 0) {
|
||||
dateObj->setUTCTime(js_NaN, args.rval().address());
|
||||
dateObj->setUTCTime(GenericNaN(), args.rval().address());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2343,7 +2344,7 @@ date_setYear_impl(JSContext *cx, CallArgs args)
|
||||
|
||||
/* Step 3. */
|
||||
if (IsNaN(y)) {
|
||||
dateObj->setUTCTime(js_NaN, args.rval().address());
|
||||
dateObj->setUTCTime(GenericNaN(), args.rval().address());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2997,7 +2998,7 @@ js_Date(JSContext *cx, unsigned argc, Value *vp)
|
||||
return false;
|
||||
|
||||
if (!date_parseString(linearStr, &d, &cx->runtime()->dateTimeInfo))
|
||||
d = js_NaN;
|
||||
d = GenericNaN();
|
||||
else
|
||||
d = TimeClip(d);
|
||||
} else {
|
||||
@@ -3036,7 +3037,7 @@ js_InitDateClass(JSContext *cx, HandleObject obj)
|
||||
RootedObject dateProto(cx, global->createBlankPrototype(cx, &DateObject::class_));
|
||||
if (!dateProto)
|
||||
return NULL;
|
||||
dateProto->as<DateObject>().setUTCTime(js_NaN);
|
||||
dateProto->as<DateObject>().setUTCTime(GenericNaN());
|
||||
|
||||
RootedFunction ctor(cx);
|
||||
ctor = global->createConstructor(cx, js_Date, cx->names().Date, MAXARGS);
|
||||
|
||||
Reference in New Issue
Block a user