]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - runtime/JSValueInlineMethods.h
JavaScriptCore-1097.3.tar.gz
[apple/javascriptcore.git] / runtime / JSValueInlineMethods.h
index b4f6f80a502917c5001b6fb18737e416ef55570d..1373558f7af9b7216be2d056bfc9c2564b2f61df 100644 (file)
@@ -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<double>::quiet_NaN());
     }
 
     inline JSValue::JSValue(char i)
@@ -228,9 +196,6 @@ namespace JSC {
         else
             u.asBits.tag = EmptyValueTag;
         u.asBits.payload = reinterpret_cast<int32_t>(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<int32_t>(const_cast<JSCell*>(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<JSCell*>(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);
     }