mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1021963 - Self host isNaN and isFinite. r=jwalden
--HG-- extra : rebase_source : 263a62a38ddfa782ece8d0217dc973d66a98e92b
This commit is contained in:
parent
ce6b54b741
commit
82d6edcee6
@ -18,7 +18,7 @@ var dateTimeFormatCache = new Record();
|
||||
function Date_toLocaleString() {
|
||||
// Steps 1-2. Note that valueOf enforces "this time value" restrictions.
|
||||
var x = callFunction(std_Date_valueOf, this);
|
||||
if (std_isNaN(x))
|
||||
if (Number_isNaN(x))
|
||||
return "Invalid Date";
|
||||
|
||||
// Steps 3-4.
|
||||
@ -55,7 +55,7 @@ function Date_toLocaleString() {
|
||||
function Date_toLocaleDateString() {
|
||||
// Steps 1-2. Note that valueOf enforces "this time value" restrictions.
|
||||
var x = callFunction(std_Date_valueOf, this);
|
||||
if (std_isNaN(x))
|
||||
if (Number_isNaN(x))
|
||||
return "Invalid Date";
|
||||
|
||||
// Steps 3-4.
|
||||
@ -92,7 +92,7 @@ function Date_toLocaleDateString() {
|
||||
function Date_toLocaleTimeString() {
|
||||
// Steps 1-2. Note that valueOf enforces "this time value" restrictions.
|
||||
var x = callFunction(std_Date_valueOf, this);
|
||||
if (std_isNaN(x))
|
||||
if (Number_isNaN(x))
|
||||
return "Invalid Date";
|
||||
|
||||
// Steps 3-4.
|
||||
|
@ -878,7 +878,7 @@ function GetNumberOption(options, property, minimum, maximum, fallback) {
|
||||
// Step 2.
|
||||
if (value !== undefined) {
|
||||
value = ToNumber(value);
|
||||
if (std_isNaN(value) || value < minimum || value > maximum)
|
||||
if (Number_isNaN(value) || value < minimum || value > maximum)
|
||||
ThrowError(JSMSG_INVALID_DIGITS_VALUE, value);
|
||||
return std_Math_floor(value);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ function Number_isSafeInteger(number) {
|
||||
return false;
|
||||
|
||||
// Step 2.
|
||||
if (!std_isFinite(number))
|
||||
if (!Number_isFinite(number))
|
||||
return false;
|
||||
|
||||
// Step 3.
|
||||
@ -77,3 +77,11 @@ function Number_isSafeInteger(number) {
|
||||
// Step 6.
|
||||
return false;
|
||||
}
|
||||
|
||||
function Global_isNaN(number) {
|
||||
return Number_isNaN(ToNumber(number));
|
||||
}
|
||||
|
||||
function Global_isFinite(number){
|
||||
return Number_isFinite(ToNumber(number));
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ function String_static_fromCodePoint() {
|
||||
var nextCP = ToNumber(next);
|
||||
|
||||
// Step 5d.
|
||||
if (nextCP !== ToInteger(nextCP) || std_isNaN(nextCP))
|
||||
if (nextCP !== ToInteger(nextCP) || Number_isNaN(nextCP))
|
||||
ThrowError(JSMSG_NOT_A_CODEPOINT, ToString(nextCP));
|
||||
|
||||
// Step 5e.
|
||||
|
@ -35,8 +35,6 @@ Object.defineProperty = null; // See bug 988416.
|
||||
// Object) below. Setting `var std_Array = Array;`, for instance, would cause
|
||||
// the entire Array constructor, including its prototype and methods, to be
|
||||
// cloned into content compartments.
|
||||
var std_isFinite = isFinite;
|
||||
var std_isNaN = isNaN;
|
||||
var std_Array_indexOf = ArrayIndexOf;
|
||||
var std_Array_iterator = Array.prototype.iterator;
|
||||
var std_Array_join = Array.prototype.join;
|
||||
|
@ -280,42 +280,6 @@ js::GetDecimalInteger(ExclusiveContext *cx, const jschar *start, const jschar *e
|
||||
return ComputeAccurateDecimalInteger(cx, start, s, dp);
|
||||
}
|
||||
|
||||
static bool
|
||||
num_isNaN(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
if (args.length() == 0) {
|
||||
args.rval().setBoolean(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
double x;
|
||||
if (!ToNumber(cx, args[0], &x))
|
||||
return false;
|
||||
|
||||
args.rval().setBoolean(mozilla::IsNaN(x));
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
num_isFinite(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
if (args.length() == 0) {
|
||||
args.rval().setBoolean(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
double x;
|
||||
if (!ToNumber(cx, args[0], &x))
|
||||
return false;
|
||||
|
||||
args.rval().setBoolean(mozilla::IsFinite(x));
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
num_parseFloat(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
@ -489,8 +453,8 @@ js::num_parseInt(JSContext *cx, unsigned argc, Value *vp)
|
||||
}
|
||||
|
||||
static const JSFunctionSpec number_functions[] = {
|
||||
JS_FN(js_isNaN_str, num_isNaN, 1,0),
|
||||
JS_FN(js_isFinite_str, num_isFinite, 1,0),
|
||||
JS_SELF_HOSTED_FN(js_isNaN_str, "Global_isNaN", 1,0),
|
||||
JS_SELF_HOSTED_FN(js_isFinite_str, "Global_isFinite", 1,0),
|
||||
JS_FN(js_parseFloat_str, num_parseFloat, 1,0),
|
||||
JS_FN(js_parseInt_str, num_parseInt, 2,0),
|
||||
JS_FS_END
|
||||
|
Loading…
Reference in New Issue
Block a user