double JSValue::toIntegerPreserveNaN(ExecState *exec) const { int32_t i; if (getTruncatedInt32(i)) return i; return trunc(toNumber(exec)); }
UString JSImmediate::toString(JSValuePtr v) { ASSERT(isImmediate(v)); if (isIntegerNumber(v)) return UString::from(getTruncatedInt32(v)); #if USE(ALTERNATE_JSIMMEDIATE) if (isNumber(v)) { ASSERT(isDoubleNumber(v)); double value = doubleValue(v); if (value == 0.0) // +0.0 or -0.0 return "0"; return UString::from(value); } #else ASSERT(!isNumber(v)); #endif if (jsBoolean(false) == v) return "false"; if (jsBoolean(true) == v) return "true"; if (v.isNull()) return "null"; ASSERT(v.isUndefined()); return "undefined"; }
// ECMA 9.4 double JSValue::toInteger(ExecState *exec) const { int32_t i; if (getTruncatedInt32(i)) return i; double d = toNumber(exec); return isNaN(d) ? 0.0 : trunc(d); }
UString JSImmediate::toString(JSValue* v) { ASSERT(isImmediate(v)); if (isNumber(v)) return UString::from(getTruncatedInt32(v)); if (v == jsBoolean(false)) return "false"; if (v == jsBoolean(true)) return "true"; if (v->isNull()) return "null"; ASSERT(v == jsUndefined()); return "undefined"; }