Index: include/v8.h |
diff --git a/include/v8.h b/include/v8.h |
index 334a6e16bfe69367c93ff8647ed3bc2c579a6d0d..fa238742d5d4f16f68f0816c850f58cc275b284a 100644 |
--- a/include/v8.h |
+++ b/include/v8.h |
@@ -1921,9 +1921,16 @@ class V8_EXPORT Value : public Data { |
*/ |
V8_INLINE bool IsNull() const; |
- /** |
- * Returns true if this value is true. |
+ /** |
+ * Returns true if this value is either the null or the undefined value. |
+ * See ECMA-262 |
+ * 4.3.11. and 4.3.12 |
*/ |
+ V8_INLINE bool IsNullOrUndefined() const; |
+ |
+ /** |
+ * Returns true if this value is true. |
+ */ |
bool IsTrue() const; |
/** |
@@ -2243,6 +2250,7 @@ class V8_EXPORT Value : public Data { |
private: |
V8_INLINE bool QuickIsUndefined() const; |
V8_INLINE bool QuickIsNull() const; |
+ V8_INLINE bool QuickIsNullOrUndefined() const; |
V8_INLINE bool QuickIsString() const; |
bool FullIsUndefined() const; |
bool FullIsNull() const; |
@@ -9144,6 +9152,23 @@ bool Value::QuickIsNull() const { |
return (I::GetOddballKind(obj) == I::kNullOddballKind); |
} |
+bool Value::IsNullOrUndefined() const { |
+#ifdef V8_ENABLE_CHECKS |
+ return FullIsNull() || FullIsUndefined(); |
+#else |
+ return QuickIsNullOrUndefined(); |
+#endif |
+} |
+ |
+bool Value::QuickIsNullOrUndefined() const { |
+ typedef internal::Object O; |
+ typedef internal::Internals I; |
+ O* obj = *reinterpret_cast<O* const*>(this); |
+ if (!I::HasHeapObjectTag(obj)) return false; |
+ if (I::GetInstanceType(obj) != I::kOddballType) return false; |
+ int kind = I::GetOddballKind(obj); |
+ return kind == I::kNullOddballKind || kind == I::kUndefinedOddballKind; |
+} |
bool Value::IsString() const { |
#ifdef V8_ENABLE_CHECKS |