OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef HYDROGEN_TYPES_H_ | 5 #ifndef HYDROGEN_TYPES_H_ |
6 #define HYDROGEN_TYPES_H_ | 6 #define HYDROGEN_TYPES_H_ |
7 | 7 |
8 #include <climits> | 8 #include <climits> |
9 | 9 |
10 #include "src/base/macros.h" | 10 #include "src/base/macros.h" |
| 11 #include "src/ostreams.h" |
11 | 12 |
12 namespace v8 { | 13 namespace v8 { |
13 namespace internal { | 14 namespace internal { |
14 | 15 |
15 // Forward declarations. | 16 // Forward declarations. |
16 template <typename T> class Handle; | 17 template <typename T> class Handle; |
17 class Object; | 18 class Object; |
18 | 19 |
19 #define HTYPE_LIST(V) \ | 20 #define HTYPE_LIST(V) \ |
20 V(Any, 0x0) /* 0000 0000 0000 0000 */ \ | 21 V(Any, 0x0) /* 0000 0000 0000 0000 */ \ |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 bool Is##Name() const V8_WARN_UNUSED_RESULT { \ | 58 bool Is##Name() const V8_WARN_UNUSED_RESULT { \ |
58 return IsSubtypeOf(HType::Name()); \ | 59 return IsSubtypeOf(HType::Name()); \ |
59 } | 60 } |
60 HTYPE_LIST(DECLARE_IS_TYPE) | 61 HTYPE_LIST(DECLARE_IS_TYPE) |
61 #undef DECLARE_IS_TYPE | 62 #undef DECLARE_IS_TYPE |
62 | 63 |
63 template <class T> | 64 template <class T> |
64 static HType FromType(typename T::TypeHandle type) V8_WARN_UNUSED_RESULT; | 65 static HType FromType(typename T::TypeHandle type) V8_WARN_UNUSED_RESULT; |
65 static HType FromValue(Handle<Object> value) V8_WARN_UNUSED_RESULT; | 66 static HType FromValue(Handle<Object> value) V8_WARN_UNUSED_RESULT; |
66 | 67 |
67 const char* ToString() const V8_WARN_UNUSED_RESULT; | 68 friend OStream& operator<<(OStream& os, const HType& t); |
68 | 69 |
69 private: | 70 private: |
70 enum Kind { | 71 enum Kind { |
71 #define DECLARE_TYPE(Name, mask) k##Name = mask, | 72 #define DECLARE_TYPE(Name, mask) k##Name = mask, |
72 HTYPE_LIST(DECLARE_TYPE) | 73 HTYPE_LIST(DECLARE_TYPE) |
73 #undef DECLARE_TYPE | 74 #undef DECLARE_TYPE |
74 LAST_KIND = kNone | 75 LAST_KIND = kNone |
75 }; | 76 }; |
76 | 77 |
77 // Make sure type fits in int16. | 78 // Make sure type fits in int16. |
78 STATIC_ASSERT(LAST_KIND < (1 << (CHAR_BIT * sizeof(int16_t)))); | 79 STATIC_ASSERT(LAST_KIND < (1 << (CHAR_BIT * sizeof(int16_t)))); |
79 | 80 |
80 explicit HType(Kind kind) : kind_(kind) { } | 81 explicit HType(Kind kind) : kind_(kind) { } |
81 | 82 |
82 int16_t kind_; | 83 int16_t kind_; |
83 }; | 84 }; |
84 | 85 |
| 86 |
| 87 OStream& operator<<(OStream& os, const HType& t); |
85 } } // namespace v8::internal | 88 } } // namespace v8::internal |
86 | 89 |
87 #endif // HYDROGEN_TYPES_H_ | 90 #endif // HYDROGEN_TYPES_H_ |
OLD | NEW |