зеркало из https://github.com/mozilla/gecko-dev.git
Minor long/ulong tweaks.
This commit is contained in:
Родитель
2bbee4845c
Коммит
05311863ab
|
@ -388,7 +388,7 @@ static js2val Date_makeTime(JS2Metadata *meta, const js2val thisValue, js2val *a
|
|||
argc = maxargs; /* clamp argc */
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
float64 f = meta->engine->toNumber(argv[i]);
|
||||
float64 f = meta->engine->toFloat64(argv[i]);
|
||||
if (JSDOUBLE_IS_NaN(f)) {
|
||||
*date = nan;
|
||||
return meta->engine->nanValue;
|
||||
|
@ -454,7 +454,7 @@ static js2val Date_makeDate(JS2Metadata *meta, const js2val thisValue, js2val *a
|
|||
argc = maxargs; /* clamp argc */
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
float64 f = meta->engine->toNumber(argv[i]);
|
||||
float64 f = meta->engine->toFloat64(argv[i]);
|
||||
if (JSDOUBLE_IS_NaN(f)) {
|
||||
*date = nan;
|
||||
return meta->engine->nanValue;
|
||||
|
@ -874,7 +874,7 @@ js2val Date_Constructor(JS2Metadata *meta, const js2val thisValue, js2val *argv,
|
|||
if (argc == 1) {
|
||||
if (!JS2VAL_IS_STRING(argv[0])) {
|
||||
/* the argument is a millisecond number */
|
||||
float64 d = meta->engine->toNumber(argv[0]);
|
||||
float64 d = meta->engine->toFloat64(argv[0]);
|
||||
thisInst->ms = TIMECLIP(d);
|
||||
} else {
|
||||
/* the argument is a string; parse it. */
|
||||
|
@ -891,7 +891,7 @@ js2val Date_Constructor(JS2Metadata *meta, const js2val thisValue, js2val *argv,
|
|||
|
||||
for (loop = 0; loop < MAXARGS; loop++) {
|
||||
if (loop < argc) {
|
||||
float64 double_arg = meta->engine->toNumber(argv[loop]);
|
||||
float64 double_arg = meta->engine->toFloat64(argv[loop]);
|
||||
/* if any arg is NaN, make a NaN date object
|
||||
and return */
|
||||
if (!JSDOUBLE_IS_FINITE(double_arg)) {
|
||||
|
@ -938,7 +938,7 @@ js2val Date_UTC(JS2Metadata *meta, const js2val /*thisValue*/, js2val *argv, uin
|
|||
|
||||
for (loop = 0; loop < MAXARGS; loop++) {
|
||||
if (loop < argc) {
|
||||
d = meta->engine->toNumber(argv[loop]);
|
||||
d = meta->engine->toFloat64(argv[loop]);
|
||||
if (!JSDOUBLE_IS_FINITE(d))
|
||||
return meta->engine->allocNumber(d);
|
||||
array[loop] = floor(d);
|
||||
|
@ -1272,7 +1272,7 @@ static js2val Date_getUTCMilliseconds(JS2Metadata *meta, const js2val thisValue,
|
|||
static js2val Date_setTime(JS2Metadata *meta, const js2val thisValue, js2val argv[], uint32 /*argc*/)
|
||||
{
|
||||
float64 *date = Date_getProlog(meta, thisValue);
|
||||
float64 result = meta->engine->toNumber(argv[0]);
|
||||
float64 result = meta->engine->toFloat64(argv[0]);
|
||||
*date = TIMECLIP(result);
|
||||
return meta->engine->allocNumber(*date);
|
||||
}
|
||||
|
@ -1286,7 +1286,7 @@ static js2val Date_setYear(JS2Metadata *meta, const js2val thisValue, js2val arg
|
|||
|
||||
float64 *date = Date_getProlog(meta, thisValue);
|
||||
result = *date;
|
||||
year = meta->engine->toNumber(argv[0]);
|
||||
year = meta->engine->toFloat64(argv[0]);
|
||||
if (!JSDOUBLE_IS_FINITE(year)) {
|
||||
*date = nan;
|
||||
return meta->engine->allocNumber(*date);
|
||||
|
|
|
@ -237,14 +237,14 @@ namespace MetaData {
|
|||
char16 *numEnd;
|
||||
return stringToDouble(str->data(), str->data() + str->length(), numEnd);
|
||||
}
|
||||
return toNumber(toPrimitive(x));
|
||||
return toFloat64(toPrimitive(x));
|
||||
}
|
||||
|
||||
// x is not a number, convert it to one
|
||||
js2val JS2Engine::convertValueToGeneralNumber(js2val x)
|
||||
{
|
||||
// XXX Assuming convert to float64, rather than long/ulong
|
||||
return allocNumber(toNumber(x));
|
||||
return allocNumber(toFloat64(x));
|
||||
}
|
||||
|
||||
// x is a Number, validate that it has no fractional component
|
||||
|
@ -283,7 +283,7 @@ namespace MetaData {
|
|||
}
|
||||
|
||||
// x is any js2val
|
||||
float64 JS2Engine::toNumber(js2val x)
|
||||
float64 JS2Engine::toFloat64(js2val x)
|
||||
{
|
||||
if (JS2VAL_IS_INT(x))
|
||||
return JS2VAL_TO_INT(x);
|
||||
|
|
|
@ -161,7 +161,7 @@ public:
|
|||
|
||||
String *toString(js2val x) { if (JS2VAL_IS_STRING(x)) return JS2VAL_TO_STRING(x); else return convertValueToString(x); }
|
||||
js2val toPrimitive(js2val x) { if (JS2VAL_IS_PRIMITIVE(x)) return x; else return convertValueToPrimitive(x); }
|
||||
float64 toNumber(js2val x);
|
||||
float64 toFloat64(js2val x);
|
||||
js2val toGeneralNumber(js2val x){ if (JS2VAL_IS_NUMBER(x)) return x; else return convertValueToGeneralNumber(x); }
|
||||
bool toBoolean(js2val x) { if (JS2VAL_IS_BOOLEAN(x)) return JS2VAL_TO_BOOLEAN(x); else return convertValueToBoolean(x); }
|
||||
int32 toInteger(js2val x) { if (JS2VAL_IS_INT(x)) return JS2VAL_TO_INT(x); else return convertValueToInteger(x); }
|
||||
|
|
|
@ -92,73 +92,73 @@ static js2val Math_abs(JS2Metadata *meta, const js2val /*thisValue*/, js2val *ar
|
|||
if (argc == 0)
|
||||
return meta->engine->nanValue;
|
||||
else
|
||||
return meta->engine->allocNumber(fd::fabs(meta->engine->toNumber(argv[0])));
|
||||
return meta->engine->allocNumber(fd::fabs(meta->engine->toFloat64(argv[0])));
|
||||
}
|
||||
static js2val Math_acos(JS2Metadata *meta, const js2val /*thisValue*/, js2val *argv, uint32 argc)
|
||||
{
|
||||
if (argc == 0)
|
||||
return meta->engine->nanValue;
|
||||
return meta->engine->allocNumber(fd::acos(meta->engine->toNumber(argv[0])));
|
||||
return meta->engine->allocNumber(fd::acos(meta->engine->toFloat64(argv[0])));
|
||||
}
|
||||
static js2val Math_asin(JS2Metadata *meta, const js2val /*thisValue*/, js2val *argv, uint32 argc)
|
||||
{
|
||||
if (argc == 0)
|
||||
return meta->engine->nanValue;
|
||||
return meta->engine->allocNumber(fd::asin(meta->engine->toNumber(argv[0])));
|
||||
return meta->engine->allocNumber(fd::asin(meta->engine->toFloat64(argv[0])));
|
||||
}
|
||||
static js2val Math_atan(JS2Metadata *meta, const js2val /*thisValue*/, js2val *argv, uint32 argc)
|
||||
{
|
||||
if (argc == 0)
|
||||
return meta->engine->nanValue;
|
||||
return meta->engine->allocNumber(fd::atan(meta->engine->toNumber(argv[0])));
|
||||
return meta->engine->allocNumber(fd::atan(meta->engine->toFloat64(argv[0])));
|
||||
}
|
||||
static js2val Math_atan2(JS2Metadata *meta, const js2val /*thisValue*/, js2val *argv, uint32 argc)
|
||||
{
|
||||
if (argc <= 1)
|
||||
return meta->engine->nanValue;
|
||||
float64 y = meta->engine->toNumber(argv[0]);
|
||||
float64 x = meta->engine->toNumber(argv[1]);
|
||||
float64 y = meta->engine->toFloat64(argv[0]);
|
||||
float64 x = meta->engine->toFloat64(argv[1]);
|
||||
return meta->engine->allocNumber(fd::atan2(y, x));
|
||||
}
|
||||
static js2val Math_ceil(JS2Metadata *meta, const js2val /*thisValue*/, js2val *argv, uint32 argc)
|
||||
{
|
||||
if (argc == 0)
|
||||
return meta->engine->nanValue;
|
||||
return meta->engine->allocNumber(fd::ceil(meta->engine->toNumber(argv[0])));
|
||||
return meta->engine->allocNumber(fd::ceil(meta->engine->toFloat64(argv[0])));
|
||||
}
|
||||
static js2val Math_cos(JS2Metadata *meta, const js2val /*thisValue*/, js2val *argv, uint32 argc)
|
||||
{
|
||||
if (argc == 0)
|
||||
return meta->engine->nanValue;
|
||||
return meta->engine->allocNumber(fd::cos(meta->engine->toNumber(argv[0])));
|
||||
return meta->engine->allocNumber(fd::cos(meta->engine->toFloat64(argv[0])));
|
||||
}
|
||||
static js2val Math_exp(JS2Metadata *meta, const js2val /*thisValue*/, js2val *argv, uint32 argc)
|
||||
{
|
||||
if (argc == 0)
|
||||
return meta->engine->nanValue;
|
||||
return meta->engine->allocNumber(fd::exp(meta->engine->toNumber(argv[0])));
|
||||
return meta->engine->allocNumber(fd::exp(meta->engine->toFloat64(argv[0])));
|
||||
}
|
||||
static js2val Math_floor(JS2Metadata *meta, const js2val /*thisValue*/, js2val *argv, uint32 argc)
|
||||
{
|
||||
if (argc == 0)
|
||||
return meta->engine->nanValue;
|
||||
else
|
||||
return meta->engine->allocNumber(fd::floor(meta->engine->toNumber(argv[0])));
|
||||
return meta->engine->allocNumber(fd::floor(meta->engine->toFloat64(argv[0])));
|
||||
}
|
||||
static js2val Math_log(JS2Metadata *meta, const js2val /*thisValue*/, js2val *argv, uint32 argc)
|
||||
{
|
||||
if (argc == 0)
|
||||
return meta->engine->nanValue;
|
||||
return meta->engine->allocNumber(fd::log(meta->engine->toNumber(argv[0])));
|
||||
return meta->engine->allocNumber(fd::log(meta->engine->toFloat64(argv[0])));
|
||||
}
|
||||
static js2val Math_max(JS2Metadata *meta, const js2val /*thisValue*/, js2val *argv, uint32 argc)
|
||||
{
|
||||
if (argc == 0)
|
||||
return meta->engine->negInfValue;
|
||||
float64 result = meta->engine->toNumber(argv[0]);
|
||||
float64 result = meta->engine->toFloat64(argv[0]);
|
||||
if (JSDOUBLE_IS_NaN(result)) return meta->engine->nanValue;
|
||||
for (uint32 i = 1; i < argc; ++i) {
|
||||
float64 arg = meta->engine->toNumber(argv[i]);
|
||||
float64 arg = meta->engine->toFloat64(argv[i]);
|
||||
if (JSDOUBLE_IS_NaN(arg)) return meta->engine->nanValue;
|
||||
if (arg > result)
|
||||
result = arg;
|
||||
|
@ -169,10 +169,10 @@ static js2val Math_min(JS2Metadata *meta, const js2val /*thisValue*/, js2val *ar
|
|||
{
|
||||
if (argc == 0)
|
||||
return meta->engine->posInfValue;
|
||||
float64 result = meta->engine->toNumber(argv[0]);
|
||||
float64 result = meta->engine->toFloat64(argv[0]);
|
||||
if (JSDOUBLE_IS_NaN(result)) return meta->engine->nanValue;
|
||||
for (uint32 i = 1; i < argc; ++i) {
|
||||
float64 arg = meta->engine->toNumber(argv[i]);
|
||||
float64 arg = meta->engine->toFloat64(argv[i]);
|
||||
if (JSDOUBLE_IS_NaN(arg)) return meta->engine->nanValue;
|
||||
if ((arg < result) || (JSDOUBLE_IS_POSZERO(result) && JSDOUBLE_IS_NEGZERO(arg)))
|
||||
result = arg;
|
||||
|
@ -183,7 +183,7 @@ static js2val Math_pow(JS2Metadata *meta, const js2val /*thisValue*/, js2val *ar
|
|||
{
|
||||
if (argc < 1)
|
||||
return meta->engine->nanValue;
|
||||
return meta->engine->allocNumber(fd::pow(meta->engine->toNumber(argv[0]), meta->engine->toNumber(argv[1])));
|
||||
return meta->engine->allocNumber(fd::pow(meta->engine->toFloat64(argv[0]), meta->engine->toFloat64(argv[1])));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -265,26 +265,26 @@ static js2val Math_round(JS2Metadata *meta, const js2val /*thisValue*/, js2val *
|
|||
{
|
||||
if (argc == 0)
|
||||
return meta->engine->nanValue;
|
||||
float64 x = meta->engine->toNumber(argv[0]);
|
||||
float64 x = meta->engine->toFloat64(argv[0]);
|
||||
return meta->engine->allocNumber( fd::copysign( fd::floor(x + 0.5), x ) );
|
||||
}
|
||||
static js2val Math_sin(JS2Metadata *meta, const js2val /*thisValue*/, js2val *argv, uint32 argc)
|
||||
{
|
||||
if (argc == 0)
|
||||
return meta->engine->nanValue;
|
||||
return meta->engine->allocNumber(fd::sin(meta->engine->toNumber(argv[0])));
|
||||
return meta->engine->allocNumber(fd::sin(meta->engine->toFloat64(argv[0])));
|
||||
}
|
||||
static js2val Math_sqrt(JS2Metadata *meta, const js2val /*thisValue*/, js2val *argv, uint32 argc)
|
||||
{
|
||||
if (argc == 0)
|
||||
return meta->engine->nanValue;
|
||||
return meta->engine->allocNumber(fd::sqrt(meta->engine->toNumber(argv[0])));
|
||||
return meta->engine->allocNumber(fd::sqrt(meta->engine->toFloat64(argv[0])));
|
||||
}
|
||||
static js2val Math_tan(JS2Metadata *meta, const js2val /*thisValue*/, js2val *argv, uint32 argc)
|
||||
{
|
||||
if (argc == 0)
|
||||
return meta->engine->nanValue;
|
||||
return meta->engine->allocNumber(fd::tan(meta->engine->toNumber(argv[0])));
|
||||
return meta->engine->allocNumber(fd::tan(meta->engine->toFloat64(argv[0])));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
* file under either the NPL or the GPL.
|
||||
*/
|
||||
|
||||
|
||||
// XXX need to check for Long/ULong overflow throughout XXX
|
||||
|
||||
case eMinus:
|
||||
{
|
||||
a = pop();
|
||||
|
@ -52,21 +55,37 @@
|
|||
pushLong(v);
|
||||
}
|
||||
else
|
||||
pushNumber(-toNumber(a));
|
||||
pushNumber(-toFloat64(a));
|
||||
}
|
||||
break;
|
||||
|
||||
case ePlus:
|
||||
{
|
||||
a = pop();
|
||||
pushNumber(toNumber(a));
|
||||
a = toGeneralNumber(a);
|
||||
push(toGeneralNumber(a));
|
||||
}
|
||||
break;
|
||||
|
||||
case eComplement:
|
||||
{
|
||||
a = pop();
|
||||
pushNumber(~toInteger(a));
|
||||
a = toGeneralNumber(a);
|
||||
if (JS2VAL_IS_LONG(a)) {
|
||||
int64 i = *JS2VAL_TO_LONG(a);
|
||||
JSLL_NOT(i, i);
|
||||
pushLong(i);
|
||||
}
|
||||
else {
|
||||
if (JS2VAL_IS_ULONG(a)) {
|
||||
uint64 i = *JS2VAL_TO_ULONG(a);
|
||||
JSLL_NOT(i, i);
|
||||
pushULong(i);
|
||||
}
|
||||
else {
|
||||
pushNumber(~toInteger(a));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case eLeftShift:
|
||||
|
@ -170,8 +189,8 @@
|
|||
push(STRING_TO_JS2VAL(c));
|
||||
}
|
||||
else {
|
||||
float64 anum = toNumber(a);
|
||||
float64 bnum = toNumber(b);
|
||||
float64 anum = toFloat64(a);
|
||||
float64 bnum = toFloat64(b);
|
||||
pushNumber(anum + bnum);
|
||||
}
|
||||
}
|
||||
|
@ -181,8 +200,8 @@
|
|||
{
|
||||
b = pop();
|
||||
a = pop();
|
||||
float64 anum = toNumber(a);
|
||||
float64 bnum = toNumber(b);
|
||||
float64 anum = toFloat64(a);
|
||||
float64 bnum = toFloat64(b);
|
||||
pushNumber(anum - bnum);
|
||||
}
|
||||
break;
|
||||
|
@ -193,28 +212,61 @@
|
|||
a = pop();
|
||||
a = toGeneralNumber(a);
|
||||
b = toGeneralNumber(b);
|
||||
if (JS2VAL_IS_LONG(a) || JS2VAL_IS_ULONG(a) || JS2VAL_IS_LONG(b) || JS2VAL_IS_ULONG(b)) {
|
||||
int64 x = checkInteger(a);
|
||||
int64 y = checkInteger(b);
|
||||
int64 z;
|
||||
JSLL_MUL(z, x, y);
|
||||
// XXX need to check that z didn't overflow
|
||||
if (JS2VAL_IS_ULONG(a) || JS2VAL_IS_ULONG(b)) {
|
||||
pushULong(z);
|
||||
if (JS2VAL_IS_LONG(a)) {
|
||||
int64 x = *JS2VAL_TO_LONG(a);
|
||||
if (JS2VAL_IS_LONG(b)) {
|
||||
int64 z;
|
||||
int64 y = *JS2VAL_TO_LONG(b);
|
||||
JSLL_MUL(z, x, y);
|
||||
pushLong(z);
|
||||
}
|
||||
else {
|
||||
pushLong(z);
|
||||
if (JS2VAL_IS_ULONG(b)) {
|
||||
uint64 z;
|
||||
uint64 y = *JS2VAL_TO_ULONG(b);
|
||||
JSLL_MUL(z, x, y);
|
||||
pushULong(z);
|
||||
}
|
||||
else {
|
||||
int64 y = checkInteger(b);
|
||||
int64 z;
|
||||
JSLL_MUL(z, x, y);
|
||||
pushLong(z);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
float64 x = toNumber(a);
|
||||
float64 y = toNumber(b);
|
||||
float64 z = x * y;
|
||||
if (JS2VAL_IS_FLOAT(a) || JS2VAL_IS_FLOAT(b)) {
|
||||
pushFloat(z);
|
||||
if (JS2VAL_IS_ULONG(a)) {
|
||||
uint64 x = *JS2VAL_TO_ULONG(a);
|
||||
if (JS2VAL_IS_LONG(b)) {
|
||||
uint64 z;
|
||||
int64 y = *JS2VAL_TO_LONG(b);
|
||||
JSLL_MUL(z, x, y);
|
||||
pushULong(z);
|
||||
}
|
||||
else {
|
||||
if (JS2VAL_IS_ULONG(b)) {
|
||||
uint64 z;
|
||||
uint64 y = *JS2VAL_TO_ULONG(b);
|
||||
JSLL_MUL(z, x, y);
|
||||
pushULong(z);
|
||||
}
|
||||
else {
|
||||
uint64 y = checkInteger(b);
|
||||
uint64 z;
|
||||
JSLL_MUL(z, x, y);
|
||||
pushULong(z);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
pushNumber(z);
|
||||
float64 x = toFloat64(a);
|
||||
float64 y = toFloat64(b);
|
||||
float64 z = x * y;
|
||||
if (JS2VAL_IS_FLOAT(a) || JS2VAL_IS_FLOAT(b))
|
||||
pushFloat(z);
|
||||
else
|
||||
pushNumber(z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -224,8 +276,8 @@
|
|||
{
|
||||
b = pop();
|
||||
a = pop();
|
||||
float64 anum = toNumber(a);
|
||||
float64 bnum = toNumber(b);
|
||||
float64 anum = toFloat64(a);
|
||||
float64 bnum = toFloat64(b);
|
||||
pushNumber(anum / bnum);
|
||||
}
|
||||
break;
|
||||
|
@ -234,8 +286,8 @@
|
|||
{
|
||||
b = pop();
|
||||
a = pop();
|
||||
float64 anum = toNumber(a);
|
||||
float64 bnum = toNumber(b);
|
||||
float64 anum = toFloat64(a);
|
||||
float64 bnum = toFloat64(b);
|
||||
#ifdef XP_PC
|
||||
/* Workaround MS fmod bug where 42 % (1/0) => NaN, not 42. */
|
||||
if (JSDOUBLE_IS_FINITE(anum) && JSDOUBLE_IS_INFINITE(bnum))
|
||||
|
@ -264,7 +316,7 @@
|
|||
if (JS2VAL_IS_STRING(a) && JS2VAL_IS_STRING(b))
|
||||
rval = (*JS2VAL_TO_STRING(a) < *JS2VAL_TO_STRING(b));
|
||||
else
|
||||
rval = toNumber(a) < toNumber(b);
|
||||
rval = toFloat64(a) < toFloat64(b);
|
||||
push(BOOLEAN_TO_JS2VAL(rval));
|
||||
}
|
||||
break;
|
||||
|
@ -279,7 +331,7 @@
|
|||
if (JS2VAL_IS_STRING(a) && JS2VAL_IS_STRING(b))
|
||||
rval = (*JS2VAL_TO_STRING(a) <= *JS2VAL_TO_STRING(b));
|
||||
else
|
||||
rval = toNumber(a) <= toNumber(b);
|
||||
rval = toFloat64(a) <= toFloat64(b);
|
||||
push(BOOLEAN_TO_JS2VAL(rval));
|
||||
}
|
||||
break;
|
||||
|
@ -294,7 +346,7 @@
|
|||
if (JS2VAL_IS_STRING(a) && JS2VAL_IS_STRING(b))
|
||||
rval = (*JS2VAL_TO_STRING(a) > *JS2VAL_TO_STRING(b));
|
||||
else
|
||||
rval = toNumber(a) > toNumber(b);
|
||||
rval = toFloat64(a) > toFloat64(b);
|
||||
push(BOOLEAN_TO_JS2VAL(rval));
|
||||
}
|
||||
break;
|
||||
|
@ -309,7 +361,7 @@
|
|||
if (JS2VAL_IS_STRING(a) && JS2VAL_IS_STRING(b))
|
||||
rval = (*JS2VAL_TO_STRING(a) >= *JS2VAL_TO_STRING(b));
|
||||
else
|
||||
rval = toNumber(a) >= toNumber(b);
|
||||
rval = toFloat64(a) >= toFloat64(b);
|
||||
push(BOOLEAN_TO_JS2VAL(rval));
|
||||
}
|
||||
break;
|
||||
|
@ -331,7 +383,7 @@
|
|||
if (JS2VAL_IS_NULL(b) || JS2VAL_IS_UNDEFINED(b))
|
||||
rval = false;
|
||||
else
|
||||
rval = (toNumber(a) == toNumber(b));
|
||||
rval = (toFloat64(a) == toFloat64(b));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -340,7 +392,7 @@
|
|||
if (JS2VAL_IS_NULL(b) || JS2VAL_IS_UNDEFINED(b))
|
||||
rval = false;
|
||||
else
|
||||
rval = (toNumber(a) == toNumber(b));
|
||||
rval = (toFloat64(a) == toFloat64(b));
|
||||
}
|
||||
else
|
||||
if (JS2VAL_IS_STRING(a)) {
|
||||
|
@ -349,7 +401,7 @@
|
|||
rval = false;
|
||||
else
|
||||
if (JS2VAL_IS_BOOLEAN(b) || JS2VAL_IS_NUMBER(b))
|
||||
rval = (toNumber(a) == toNumber(b));
|
||||
rval = (toFloat64(a) == toFloat64(b));
|
||||
else
|
||||
rval = (*JS2VAL_TO_STRING(a) == *JS2VAL_TO_STRING(b));
|
||||
}
|
||||
|
@ -365,7 +417,7 @@
|
|||
if (JS2VAL_IS_BOOLEAN(a))
|
||||
rval = (JS2VAL_TO_BOOLEAN(a) == JS2VAL_TO_BOOLEAN(b));
|
||||
else
|
||||
rval = (toNumber(a) == toNumber(b));
|
||||
rval = (toFloat64(a) == toFloat64(b));
|
||||
}
|
||||
else
|
||||
if (JS2VAL_IS_NUMBER(b)) {
|
||||
|
@ -373,7 +425,7 @@
|
|||
if (JS2VAL_IS_NULL(a) || JS2VAL_IS_UNDEFINED(a))
|
||||
rval = false;
|
||||
else
|
||||
rval = (toNumber(a) == toNumber(b));
|
||||
rval = (toFloat64(a) == toFloat64(b));
|
||||
}
|
||||
else
|
||||
if (JS2VAL_IS_STRING(b)) {
|
||||
|
@ -382,7 +434,7 @@
|
|||
rval = false;
|
||||
else
|
||||
if (JS2VAL_IS_BOOLEAN(a) || JS2VAL_IS_NUMBER(a))
|
||||
rval = (toNumber(a) == toNumber(b));
|
||||
rval = (toFloat64(a) == toFloat64(b));
|
||||
else
|
||||
rval = (*JS2VAL_TO_STRING(a) == *JS2VAL_TO_STRING(b));
|
||||
}
|
||||
|
@ -416,39 +468,39 @@
|
|||
a = STRING_TO_JS2VAL(c);
|
||||
}
|
||||
else {
|
||||
float64 anum = toNumber(a);
|
||||
float64 bnum = toNumber(b);
|
||||
float64 anum = toFloat64(a);
|
||||
float64 bnum = toFloat64(b);
|
||||
a = allocNumber(anum + bnum);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case eSubtract:
|
||||
{
|
||||
float64 anum = toNumber(a);
|
||||
float64 bnum = toNumber(b);
|
||||
float64 anum = toFloat64(a);
|
||||
float64 bnum = toFloat64(b);
|
||||
a = allocNumber(anum - bnum);
|
||||
}
|
||||
break;
|
||||
case eMultiply:
|
||||
{
|
||||
float64 anum = toNumber(a);
|
||||
float64 bnum = toNumber(b);
|
||||
float64 anum = toFloat64(a);
|
||||
float64 bnum = toFloat64(b);
|
||||
a = allocNumber(anum * bnum);
|
||||
}
|
||||
break;
|
||||
|
||||
case eDivide:
|
||||
{
|
||||
float64 anum = toNumber(a);
|
||||
float64 bnum = toNumber(b);
|
||||
float64 anum = toFloat64(a);
|
||||
float64 bnum = toFloat64(b);
|
||||
a = allocNumber(anum / bnum);
|
||||
}
|
||||
break;
|
||||
|
||||
case eModulo:
|
||||
{
|
||||
float64 anum = toNumber(a);
|
||||
float64 bnum = toNumber(b);
|
||||
float64 anum = toFloat64(a);
|
||||
float64 bnum = toFloat64(b);
|
||||
#ifdef XP_PC
|
||||
/* Workaround MS fmod bug where 42 % (1/0) => NaN, not 42. */
|
||||
if (JSDOUBLE_IS_FINITE(anum) && JSDOUBLE_IS_INFINITE(bnum))
|
||||
|
@ -508,7 +560,7 @@
|
|||
Multiname *mn = bCon->mMultinameList[BytecodeContainer::getShort(pc)];
|
||||
pc += sizeof(short);
|
||||
a = meta->env.lexicalRead(meta, mn, phase);
|
||||
float64 num = toNumber(a);
|
||||
float64 num = toFloat64(a);
|
||||
meta->env.lexicalWrite(meta, mn, allocNumber(num + 1.0), true, phase);
|
||||
pushNumber(num);
|
||||
}
|
||||
|
@ -518,7 +570,7 @@
|
|||
Multiname *mn = bCon->mMultinameList[BytecodeContainer::getShort(pc)];
|
||||
pc += sizeof(short);
|
||||
a = meta->env.lexicalRead(meta, mn, phase);
|
||||
float64 num = toNumber(a);
|
||||
float64 num = toFloat64(a);
|
||||
meta->env.lexicalWrite(meta, mn, allocNumber(num - 1.0), true, phase);
|
||||
pushNumber(num);
|
||||
}
|
||||
|
@ -528,7 +580,7 @@
|
|||
Multiname *mn = bCon->mMultinameList[BytecodeContainer::getShort(pc)];
|
||||
pc += sizeof(short);
|
||||
a = meta->env.lexicalRead(meta, mn, phase);
|
||||
float64 num = toNumber(a);
|
||||
float64 num = toFloat64(a);
|
||||
a = pushNumber(num + 1.0);
|
||||
meta->env.lexicalWrite(meta, mn, a, true, phase);
|
||||
}
|
||||
|
@ -538,7 +590,7 @@
|
|||
Multiname *mn = bCon->mMultinameList[BytecodeContainer::getShort(pc)];
|
||||
pc += sizeof(short);
|
||||
a = meta->env.lexicalRead(meta, mn, phase);
|
||||
float64 num = toNumber(a);
|
||||
float64 num = toFloat64(a);
|
||||
a = pushNumber(num - 1.0);
|
||||
meta->env.lexicalWrite(meta, mn, a, true, phase);
|
||||
}
|
||||
|
@ -567,39 +619,39 @@
|
|||
a = STRING_TO_JS2VAL(c);
|
||||
}
|
||||
else {
|
||||
float64 anum = toNumber(a);
|
||||
float64 bnum = toNumber(b);
|
||||
float64 anum = toFloat64(a);
|
||||
float64 bnum = toFloat64(b);
|
||||
a = allocNumber(anum + bnum);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case eSubtract:
|
||||
{
|
||||
float64 anum = toNumber(a);
|
||||
float64 bnum = toNumber(b);
|
||||
float64 anum = toFloat64(a);
|
||||
float64 bnum = toFloat64(b);
|
||||
a = allocNumber(anum - bnum);
|
||||
}
|
||||
break;
|
||||
case eMultiply:
|
||||
{
|
||||
float64 anum = toNumber(a);
|
||||
float64 bnum = toNumber(b);
|
||||
float64 anum = toFloat64(a);
|
||||
float64 bnum = toFloat64(b);
|
||||
a = allocNumber(anum * bnum);
|
||||
}
|
||||
break;
|
||||
|
||||
case eDivide:
|
||||
{
|
||||
float64 anum = toNumber(a);
|
||||
float64 bnum = toNumber(b);
|
||||
float64 anum = toFloat64(a);
|
||||
float64 bnum = toFloat64(b);
|
||||
a = allocNumber(anum / bnum);
|
||||
}
|
||||
break;
|
||||
|
||||
case eModulo:
|
||||
{
|
||||
float64 anum = toNumber(a);
|
||||
float64 bnum = toNumber(b);
|
||||
float64 anum = toFloat64(a);
|
||||
float64 bnum = toFloat64(b);
|
||||
#ifdef XP_PC
|
||||
/* Workaround MS fmod bug where 42 % (1/0) => NaN, not 42. */
|
||||
if (JSDOUBLE_IS_FINITE(anum) && JSDOUBLE_IS_INFINITE(bnum))
|
||||
|
@ -663,7 +715,7 @@
|
|||
baseVal = pop();
|
||||
if (!meta->readProperty(baseVal, mn, &lookup, RunPhase, &a))
|
||||
meta->reportError(Exception::propertyAccessError, "No property named {0}", errorPos(), mn->name);
|
||||
float64 num = toNumber(a);
|
||||
float64 num = toFloat64(a);
|
||||
meta->writeProperty(baseVal, mn, &lookup, true, allocNumber(num + 1.0), RunPhase);
|
||||
pushNumber(num);
|
||||
baseVal = JS2VAL_VOID;
|
||||
|
@ -677,7 +729,7 @@
|
|||
baseVal = pop();
|
||||
if (!meta->readProperty(baseVal, mn, &lookup, RunPhase, &a))
|
||||
meta->reportError(Exception::propertyAccessError, "No property named {0}", errorPos(), mn->name);
|
||||
float64 num = toNumber(a);
|
||||
float64 num = toFloat64(a);
|
||||
meta->writeProperty(baseVal, mn, &lookup, true, allocNumber(num - 1.0), RunPhase);
|
||||
pushNumber(num);
|
||||
baseVal = JS2VAL_VOID;
|
||||
|
@ -691,7 +743,7 @@
|
|||
baseVal = pop();
|
||||
if (!meta->readProperty(baseVal, mn, &lookup, RunPhase, &a))
|
||||
meta->reportError(Exception::propertyAccessError, "No property named {0}", errorPos(), mn->name);
|
||||
float64 num = toNumber(a);
|
||||
float64 num = toFloat64(a);
|
||||
a = pushNumber(num + 1.0);
|
||||
meta->writeProperty(baseVal, mn, &lookup, true, a, RunPhase);
|
||||
baseVal = JS2VAL_VOID;
|
||||
|
@ -705,7 +757,7 @@
|
|||
baseVal = pop();
|
||||
if (!meta->readProperty(baseVal, mn, &lookup, RunPhase, &a))
|
||||
meta->reportError(Exception::propertyAccessError, "No property named {0}", errorPos(), mn->name);
|
||||
float64 num = toNumber(a);
|
||||
float64 num = toFloat64(a);
|
||||
a = pushNumber(num - 1.0);
|
||||
meta->writeProperty(baseVal, mn, &lookup, true, a, RunPhase);
|
||||
baseVal = JS2VAL_VOID;
|
||||
|
@ -736,39 +788,39 @@
|
|||
a = STRING_TO_JS2VAL(c);
|
||||
}
|
||||
else {
|
||||
float64 anum = toNumber(a);
|
||||
float64 bnum = toNumber(b);
|
||||
float64 anum = toFloat64(a);
|
||||
float64 bnum = toFloat64(b);
|
||||
a = allocNumber(anum + bnum);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case eSubtract:
|
||||
{
|
||||
float64 anum = toNumber(a);
|
||||
float64 bnum = toNumber(b);
|
||||
float64 anum = toFloat64(a);
|
||||
float64 bnum = toFloat64(b);
|
||||
a = allocNumber(anum - bnum);
|
||||
}
|
||||
break;
|
||||
case eMultiply:
|
||||
{
|
||||
float64 anum = toNumber(a);
|
||||
float64 bnum = toNumber(b);
|
||||
float64 anum = toFloat64(a);
|
||||
float64 bnum = toFloat64(b);
|
||||
a = allocNumber(anum * bnum);
|
||||
}
|
||||
break;
|
||||
|
||||
case eDivide:
|
||||
{
|
||||
float64 anum = toNumber(a);
|
||||
float64 bnum = toNumber(b);
|
||||
float64 anum = toFloat64(a);
|
||||
float64 bnum = toFloat64(b);
|
||||
a = allocNumber(anum / bnum);
|
||||
}
|
||||
break;
|
||||
|
||||
case eModulo:
|
||||
{
|
||||
float64 anum = toNumber(a);
|
||||
float64 bnum = toNumber(b);
|
||||
float64 anum = toFloat64(a);
|
||||
float64 bnum = toFloat64(b);
|
||||
#ifdef XP_PC
|
||||
/* Workaround MS fmod bug where 42 % (1/0) => NaN, not 42. */
|
||||
if (JSDOUBLE_IS_FINITE(anum) && JSDOUBLE_IS_INFINITE(bnum))
|
||||
|
@ -834,7 +886,7 @@ case eBracketPostInc:
|
|||
Multiname mn(meta->world.identifiers[*indexStr], meta->publicNamespace);
|
||||
if (!meta->readProperty(baseVal, &mn, &lookup, RunPhase, &a))
|
||||
meta->reportError(Exception::propertyAccessError, "No property named {0}", errorPos(), mn.name);
|
||||
float64 num = toNumber(a);
|
||||
float64 num = toFloat64(a);
|
||||
meta->writeProperty(baseVal, &mn, &lookup, true, allocNumber(num + 1.0), RunPhase);
|
||||
pushNumber(num);
|
||||
baseVal = JS2VAL_VOID;
|
||||
|
@ -850,7 +902,7 @@ case eBracketPostInc:
|
|||
Multiname mn(meta->world.identifiers[*indexStr], meta->publicNamespace);
|
||||
if (!meta->readProperty(baseVal, &mn, &lookup, RunPhase, &a))
|
||||
meta->reportError(Exception::propertyAccessError, "No property named {0}", errorPos(), mn.name);
|
||||
float64 num = toNumber(a);
|
||||
float64 num = toFloat64(a);
|
||||
meta->writeProperty(baseVal, &mn, &lookup, true, allocNumber(num - 1.0), RunPhase);
|
||||
pushNumber(num);
|
||||
baseVal = JS2VAL_VOID;
|
||||
|
@ -866,7 +918,7 @@ case eBracketPostInc:
|
|||
Multiname mn(meta->world.identifiers[*indexStr], meta->publicNamespace);
|
||||
if (!meta->readProperty(baseVal, &mn, &lookup, RunPhase, &a))
|
||||
meta->reportError(Exception::propertyAccessError, "No property named {0}", errorPos(), mn.name);
|
||||
float64 num = toNumber(a);
|
||||
float64 num = toFloat64(a);
|
||||
a = pushNumber(num + 1.0);
|
||||
meta->writeProperty(baseVal, &mn, &lookup, true, a, RunPhase);
|
||||
baseVal = JS2VAL_VOID;
|
||||
|
@ -882,7 +934,7 @@ case eBracketPostInc:
|
|||
Multiname mn(meta->world.identifiers[*indexStr], meta->publicNamespace);
|
||||
if (!meta->readProperty(baseVal, &mn, &lookup, RunPhase, &a))
|
||||
meta->reportError(Exception::propertyAccessError, "No property named {0}", errorPos(), mn.name);
|
||||
float64 num = toNumber(a);
|
||||
float64 num = toFloat64(a);
|
||||
a = pushNumber(num - 1.0);
|
||||
meta->writeProperty(baseVal, &mn, &lookup, true, a, RunPhase);
|
||||
baseVal = JS2VAL_VOID;
|
||||
|
|
|
@ -527,7 +527,7 @@ static js2val String_indexOf(JS2Metadata *meta, const js2val thisValue, js2val *
|
|||
uint32 pos = 0;
|
||||
|
||||
if (argc > 1) {
|
||||
float64 fpos = meta->engine->toNumber(argv[1]);
|
||||
float64 fpos = meta->engine->toFloat64(argv[1]);
|
||||
if (JSDOUBLE_IS_NaN(fpos))
|
||||
pos = 0;
|
||||
if (fpos < 0)
|
||||
|
@ -554,7 +554,7 @@ static js2val String_lastIndexOf(JS2Metadata *meta, const js2val thisValue, js2v
|
|||
uint32 pos = str->size();
|
||||
|
||||
if (argc > 1) {
|
||||
float64 fpos = meta->engine->toNumber(argv[1]);
|
||||
float64 fpos = meta->engine->toFloat64(argv[1]);
|
||||
if (JSDOUBLE_IS_NaN(fpos))
|
||||
pos = str->size();
|
||||
else {
|
||||
|
@ -701,7 +701,7 @@ static js2val String_substring(JS2Metadata *meta, const js2val thisValue, js2val
|
|||
uint32 start, end;
|
||||
|
||||
if (argc > 0) {
|
||||
float64 farg0 = meta->engine->toNumber(argv[0]);
|
||||
float64 farg0 = meta->engine->toFloat64(argv[0]);
|
||||
if (JSDOUBLE_IS_NaN(farg0) || (farg0 < 0))
|
||||
start = 0;
|
||||
else {
|
||||
|
@ -718,7 +718,7 @@ static js2val String_substring(JS2Metadata *meta, const js2val thisValue, js2val
|
|||
start = 0;
|
||||
|
||||
if (argc > 1) {
|
||||
float64 farg1 = meta->engine->toNumber(argv[1]);
|
||||
float64 farg1 = meta->engine->toFloat64(argv[1]);
|
||||
if (JSDOUBLE_IS_NaN(farg1) || (farg1 < 0))
|
||||
end = 0;
|
||||
else {
|
||||
|
|
Загрузка…
Ссылка в новой задаче