OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 #include "src/type-hints.h" | 5 #include "src/type-hints.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 | 9 |
10 std::ostream& operator<<(std::ostream& os, BinaryOperationHint hint) { | 10 std::ostream& operator<<(std::ostream& os, BinaryOperationHint hint) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 return os << "SimdValue"; | 69 return os << "SimdValue"; |
70 case ToBooleanHint::kAny: | 70 case ToBooleanHint::kAny: |
71 return os << "Any"; | 71 return os << "Any"; |
72 case ToBooleanHint::kNeedsMap: | 72 case ToBooleanHint::kNeedsMap: |
73 return os << "NeedsMap"; | 73 return os << "NeedsMap"; |
74 } | 74 } |
75 UNREACHABLE(); | 75 UNREACHABLE(); |
76 return os; | 76 return os; |
77 } | 77 } |
78 | 78 |
| 79 std::string ToString(ToBooleanHint hint) { |
| 80 switch (hint) { |
| 81 case ToBooleanHint::kNone: |
| 82 return "None"; |
| 83 case ToBooleanHint::kUndefined: |
| 84 return "Undefined"; |
| 85 case ToBooleanHint::kBoolean: |
| 86 return "Boolean"; |
| 87 case ToBooleanHint::kNull: |
| 88 return "Null"; |
| 89 case ToBooleanHint::kSmallInteger: |
| 90 return "SmallInteger"; |
| 91 case ToBooleanHint::kReceiver: |
| 92 return "Receiver"; |
| 93 case ToBooleanHint::kString: |
| 94 return "String"; |
| 95 case ToBooleanHint::kSymbol: |
| 96 return "Symbol"; |
| 97 case ToBooleanHint::kHeapNumber: |
| 98 return "HeapNumber"; |
| 99 case ToBooleanHint::kSimdValue: |
| 100 return "SimdValue"; |
| 101 case ToBooleanHint::kAny: |
| 102 return "Any"; |
| 103 case ToBooleanHint::kNeedsMap: |
| 104 return "NeedsMap"; |
| 105 } |
| 106 UNREACHABLE(); |
| 107 return ""; |
| 108 } |
| 109 |
79 std::ostream& operator<<(std::ostream& os, ToBooleanHints hints) { | 110 std::ostream& operator<<(std::ostream& os, ToBooleanHints hints) { |
80 if (hints == ToBooleanHint::kAny) return os << "Any"; | 111 if (hints == ToBooleanHint::kAny) return os << "Any"; |
81 if (hints == ToBooleanHint::kNone) return os << "None"; | 112 if (hints == ToBooleanHint::kNone) return os << "None"; |
82 bool first = true; | 113 bool first = true; |
83 for (ToBooleanHints::mask_type i = 0; i < sizeof(i) * 8; ++i) { | 114 for (ToBooleanHints::mask_type i = 0; i < sizeof(i) * 8; ++i) { |
84 ToBooleanHint const hint = static_cast<ToBooleanHint>(1u << i); | 115 ToBooleanHint const hint = static_cast<ToBooleanHint>(1u << i); |
85 if (hints & hint) { | 116 if (hints & hint) { |
86 if (!first) os << "|"; | 117 if (!first) os << "|"; |
87 first = false; | 118 first = false; |
88 os << hint; | 119 os << hint; |
89 } | 120 } |
90 } | 121 } |
91 return os; | 122 return os; |
92 } | 123 } |
93 | 124 |
| 125 std::string ToString(ToBooleanHints hints) { |
| 126 if (hints == ToBooleanHint::kAny) return "Any"; |
| 127 if (hints == ToBooleanHint::kNone) return "None"; |
| 128 std::string ret; |
| 129 bool first = true; |
| 130 for (ToBooleanHints::mask_type i = 0; i < sizeof(i) * 8; ++i) { |
| 131 ToBooleanHint const hint = static_cast<ToBooleanHint>(1u << i); |
| 132 if (hints & hint) { |
| 133 if (!first) ret += "|"; |
| 134 first = false; |
| 135 ret += ToString(hint); |
| 136 } |
| 137 } |
| 138 return ret; |
| 139 } |
| 140 |
94 std::ostream& operator<<(std::ostream& os, const StringAddFlags& flags) { | 141 std::ostream& operator<<(std::ostream& os, const StringAddFlags& flags) { |
95 switch (flags) { | 142 switch (flags) { |
96 case STRING_ADD_CHECK_NONE: | 143 case STRING_ADD_CHECK_NONE: |
97 return os << "CheckNone"; | 144 return os << "CheckNone"; |
98 case STRING_ADD_CHECK_LEFT: | 145 case STRING_ADD_CHECK_LEFT: |
99 return os << "CheckLeft"; | 146 return os << "CheckLeft"; |
100 case STRING_ADD_CHECK_RIGHT: | 147 case STRING_ADD_CHECK_RIGHT: |
101 return os << "CheckRight"; | 148 return os << "CheckRight"; |
102 case STRING_ADD_CHECK_BOTH: | 149 case STRING_ADD_CHECK_BOTH: |
103 return os << "CheckBoth"; | 150 return os << "CheckBoth"; |
104 case STRING_ADD_CONVERT_LEFT: | 151 case STRING_ADD_CONVERT_LEFT: |
105 return os << "ConvertLeft"; | 152 return os << "ConvertLeft"; |
106 case STRING_ADD_CONVERT_RIGHT: | 153 case STRING_ADD_CONVERT_RIGHT: |
107 return os << "ConvertRight"; | 154 return os << "ConvertRight"; |
108 case STRING_ADD_CONVERT: | 155 case STRING_ADD_CONVERT: |
109 break; | 156 break; |
110 } | 157 } |
111 UNREACHABLE(); | 158 UNREACHABLE(); |
112 return os; | 159 return os; |
113 } | 160 } |
114 | 161 |
115 } // namespace internal | 162 } // namespace internal |
116 } // namespace v8 | 163 } // namespace v8 |
OLD | NEW |