X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/14957cd040308e3eeec43d26bae5d76da13fcd85..1981f5dfe8d77d97469d20652f712a09400c48ed:/runtime/JSValueInlineMethods.h diff --git a/runtime/JSValueInlineMethods.h b/runtime/JSValueInlineMethods.h index b4f6f80..1373558 100644 --- a/runtime/JSValueInlineMethods.h +++ b/runtime/JSValueInlineMethods.h @@ -54,47 +54,15 @@ namespace JSC { return asInt32(); } - inline double JSValue::uncheckedGetNumber() const + inline double JSValue::asNumber() const { ASSERT(isNumber()); return isInt32() ? asInt32() : asDouble(); } - ALWAYS_INLINE JSValue JSValue::toJSNumber(ExecState* exec) const - { - return isNumber() ? asValue() : jsNumber(this->toNumber(exec)); - } - inline JSValue jsNaN() { - return JSValue(nonInlineNaN()); - } - - inline bool JSValue::getNumber(double& result) const - { - if (isInt32()) { - result = asInt32(); - return true; - } - if (isDouble()) { - result = asDouble(); - return true; - } - return false; - } - - inline bool JSValue::getBoolean(bool& v) const - { - if (isTrue()) { - v = true; - return true; - } - if (isFalse()) { - v = false; - return true; - } - - return false; + return JSValue(std::numeric_limits::quiet_NaN()); } inline JSValue::JSValue(char i) @@ -228,9 +196,6 @@ namespace JSC { else u.asBits.tag = EmptyValueTag; u.asBits.payload = reinterpret_cast(ptr); -#if ENABLE(JSC_ZOMBIES) - ASSERT(!isZombie()); -#endif } inline JSValue::JSValue(const JSCell* ptr) @@ -240,9 +205,6 @@ namespace JSC { else u.asBits.tag = EmptyValueTag; u.asBits.payload = reinterpret_cast(const_cast(ptr)); -#if ENABLE(JSC_ZOMBIES) - ASSERT(!isZombie()); -#endif } inline JSValue::operator bool() const @@ -261,6 +223,11 @@ namespace JSC { return u.asInt64 != other.u.asInt64; } + inline bool JSValue::isEmpty() const + { + return tag() == EmptyValueTag; + } + inline bool JSValue::isUndefined() const { return tag() == UndefinedTag; @@ -350,7 +317,7 @@ namespace JSC { return isTrue() || isFalse(); } - inline bool JSValue::getBoolean() const + inline bool JSValue::asBoolean() const { ASSERT(isBoolean()); return payload(); @@ -384,17 +351,11 @@ namespace JSC { inline JSValue::JSValue(JSCell* ptr) { u.ptr = ptr; -#if ENABLE(JSC_ZOMBIES) - ASSERT(!isZombie()); -#endif } inline JSValue::JSValue(const JSCell* ptr) { u.ptr = const_cast(ptr); -#if ENABLE(JSC_ZOMBIES) - ASSERT(!isZombie()); -#endif } inline JSValue::operator bool() const @@ -412,14 +373,19 @@ namespace JSC { return u.ptr != other.u.ptr; } + inline bool JSValue::isEmpty() const + { + return u.asInt64 == ValueEmpty; + } + inline bool JSValue::isUndefined() const { - return asValue() == jsUndefined(); + return asValue() == JSValue(JSUndefined); } inline bool JSValue::isNull() const { - return asValue() == jsNull(); + return asValue() == JSValue(JSNull); } inline bool JSValue::isTrue() const @@ -432,10 +398,10 @@ namespace JSC { return asValue() == JSValue(JSFalse); } - inline bool JSValue::getBoolean() const + inline bool JSValue::asBoolean() const { - ASSERT(asValue() == jsBoolean(true) || asValue() == jsBoolean(false)); - return asValue() == jsBoolean(true); + ASSERT(isBoolean()); + return asValue() == JSValue(JSTrue); } inline int32_t JSValue::asInt32() const @@ -511,6 +477,7 @@ namespace JSC { inline double JSValue::asDouble() const { + ASSERT(isDouble()); return reinterpretIntptrToDouble(u.asInt64 - DoubleEncodeOffset); }