OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** \mainpage V8 API Reference Guide | 5 /** \mainpage V8 API Reference Guide |
6 * | 6 * |
7 * V8 is Google's open source JavaScript engine. | 7 * V8 is Google's open source JavaScript engine. |
8 * | 8 * |
9 * This set of documents provides reference material generated from the | 9 * This set of documents provides reference material generated from the |
10 * V8 header file, include/v8.h. | 10 * V8 header file, include/v8.h. |
(...skipping 1903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1914 * 4.3.10. | 1914 * 4.3.10. |
1915 */ | 1915 */ |
1916 V8_INLINE bool IsUndefined() const; | 1916 V8_INLINE bool IsUndefined() const; |
1917 | 1917 |
1918 /** | 1918 /** |
1919 * Returns true if this value is the null value. See ECMA-262 | 1919 * Returns true if this value is the null value. See ECMA-262 |
1920 * 4.3.11. | 1920 * 4.3.11. |
1921 */ | 1921 */ |
1922 V8_INLINE bool IsNull() const; | 1922 V8_INLINE bool IsNull() const; |
1923 | 1923 |
1924 /** | 1924 /** |
1925 * Returns true if this value is true. | 1925 * Returns true if this value is either the null or the undefined value. |
| 1926 * See ECMA-262 |
| 1927 * 4.3.11. and 4.3.12 |
1926 */ | 1928 */ |
| 1929 V8_INLINE bool IsNullOrUndefined() const; |
| 1930 |
| 1931 /** |
| 1932 * Returns true if this value is true. |
| 1933 */ |
1927 bool IsTrue() const; | 1934 bool IsTrue() const; |
1928 | 1935 |
1929 /** | 1936 /** |
1930 * Returns true if this value is false. | 1937 * Returns true if this value is false. |
1931 */ | 1938 */ |
1932 bool IsFalse() const; | 1939 bool IsFalse() const; |
1933 | 1940 |
1934 /** | 1941 /** |
1935 * Returns true if this value is a symbol or a string. | 1942 * Returns true if this value is a symbol or a string. |
1936 */ | 1943 */ |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2236 bool StrictEquals(Local<Value> that) const; | 2243 bool StrictEquals(Local<Value> that) const; |
2237 bool SameValue(Local<Value> that) const; | 2244 bool SameValue(Local<Value> that) const; |
2238 | 2245 |
2239 template <class T> V8_INLINE static Value* Cast(T* value); | 2246 template <class T> V8_INLINE static Value* Cast(T* value); |
2240 | 2247 |
2241 Local<String> TypeOf(Isolate*); | 2248 Local<String> TypeOf(Isolate*); |
2242 | 2249 |
2243 private: | 2250 private: |
2244 V8_INLINE bool QuickIsUndefined() const; | 2251 V8_INLINE bool QuickIsUndefined() const; |
2245 V8_INLINE bool QuickIsNull() const; | 2252 V8_INLINE bool QuickIsNull() const; |
| 2253 V8_INLINE bool QuickIsNullOrUndefined() const; |
2246 V8_INLINE bool QuickIsString() const; | 2254 V8_INLINE bool QuickIsString() const; |
2247 bool FullIsUndefined() const; | 2255 bool FullIsUndefined() const; |
2248 bool FullIsNull() const; | 2256 bool FullIsNull() const; |
2249 bool FullIsString() const; | 2257 bool FullIsString() const; |
2250 }; | 2258 }; |
2251 | 2259 |
2252 | 2260 |
2253 /** | 2261 /** |
2254 * The superclass of primitive values. See ECMA-262 4.3.2. | 2262 * The superclass of primitive values. See ECMA-262 4.3.2. |
2255 */ | 2263 */ |
(...skipping 6881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9137 | 9145 |
9138 bool Value::QuickIsNull() const { | 9146 bool Value::QuickIsNull() const { |
9139 typedef internal::Object O; | 9147 typedef internal::Object O; |
9140 typedef internal::Internals I; | 9148 typedef internal::Internals I; |
9141 O* obj = *reinterpret_cast<O* const*>(this); | 9149 O* obj = *reinterpret_cast<O* const*>(this); |
9142 if (!I::HasHeapObjectTag(obj)) return false; | 9150 if (!I::HasHeapObjectTag(obj)) return false; |
9143 if (I::GetInstanceType(obj) != I::kOddballType) return false; | 9151 if (I::GetInstanceType(obj) != I::kOddballType) return false; |
9144 return (I::GetOddballKind(obj) == I::kNullOddballKind); | 9152 return (I::GetOddballKind(obj) == I::kNullOddballKind); |
9145 } | 9153 } |
9146 | 9154 |
| 9155 bool Value::IsNullOrUndefined() const { |
| 9156 #ifdef V8_ENABLE_CHECKS |
| 9157 return FullIsNull() || FullIsUndefined(); |
| 9158 #else |
| 9159 return QuickIsNullOrUndefined(); |
| 9160 #endif |
| 9161 } |
| 9162 |
| 9163 bool Value::QuickIsNullOrUndefined() const { |
| 9164 typedef internal::Object O; |
| 9165 typedef internal::Internals I; |
| 9166 O* obj = *reinterpret_cast<O* const*>(this); |
| 9167 if (!I::HasHeapObjectTag(obj)) return false; |
| 9168 if (I::GetInstanceType(obj) != I::kOddballType) return false; |
| 9169 int kind = I::GetOddballKind(obj); |
| 9170 return kind == I::kNullOddballKind || kind == I::kUndefinedOddballKind; |
| 9171 } |
9147 | 9172 |
9148 bool Value::IsString() const { | 9173 bool Value::IsString() const { |
9149 #ifdef V8_ENABLE_CHECKS | 9174 #ifdef V8_ENABLE_CHECKS |
9150 return FullIsString(); | 9175 return FullIsString(); |
9151 #else | 9176 #else |
9152 return QuickIsString(); | 9177 return QuickIsString(); |
9153 #endif | 9178 #endif |
9154 } | 9179 } |
9155 | 9180 |
9156 bool Value::QuickIsString() const { | 9181 bool Value::QuickIsString() const { |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9775 */ | 9800 */ |
9776 | 9801 |
9777 | 9802 |
9778 } // namespace v8 | 9803 } // namespace v8 |
9779 | 9804 |
9780 | 9805 |
9781 #undef TYPE_CHECK | 9806 #undef TYPE_CHECK |
9782 | 9807 |
9783 | 9808 |
9784 #endif // INCLUDE_V8_H_ | 9809 #endif // INCLUDE_V8_H_ |
OLD | NEW |