OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 V8_CONVERSIONS_H_ | 5 #ifndef V8_CONVERSIONS_H_ |
6 #define V8_CONVERSIONS_H_ | 6 #define V8_CONVERSIONS_H_ |
7 | 7 |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "src/base/logging.h" | 10 #include "src/base/logging.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 // Integer32 is an integer that can be represented as a signed 32-bit | 160 // Integer32 is an integer that can be represented as a signed 32-bit |
161 // integer. It has to be in the range [-2^31, 2^31 - 1]. | 161 // integer. It has to be in the range [-2^31, 2^31 - 1]. |
162 // We also have to check for negative 0 as it is not an Integer32. | 162 // We also have to check for negative 0 as it is not an Integer32. |
163 inline bool IsInt32Double(double value); | 163 inline bool IsInt32Double(double value); |
164 | 164 |
165 // UInteger32 is an integer that can be represented as an unsigned 32-bit | 165 // UInteger32 is an integer that can be represented as an unsigned 32-bit |
166 // integer. It has to be in the range [0, 2^32 - 1]. | 166 // integer. It has to be in the range [0, 2^32 - 1]. |
167 // We also have to check for negative 0 as it is not a UInteger32. | 167 // We also have to check for negative 0 as it is not a UInteger32. |
168 inline bool IsUint32Double(double value); | 168 inline bool IsUint32Double(double value); |
169 | 169 |
| 170 // Tries to convert |value| to a uint32, setting the result in |uint32_value|. |
| 171 // If the output does not compare equal to the input, returns false and the |
| 172 // value in |uint32_value| is left unspecified. |
| 173 // Used for conversions such as in ECMA-262 15.4.2.2, which check "ToUint32(len) |
| 174 // is equal to len". |
| 175 inline bool DoubleToUint32IfEqualToSelf(double value, uint32_t* uint32_value); |
| 176 |
170 // Convert from Number object to C integer. | 177 // Convert from Number object to C integer. |
171 inline uint32_t PositiveNumberToUint32(Object* number); | 178 inline uint32_t PositiveNumberToUint32(Object* number); |
172 inline int32_t NumberToInt32(Object* number); | 179 inline int32_t NumberToInt32(Object* number); |
173 inline uint32_t NumberToUint32(Object* number); | 180 inline uint32_t NumberToUint32(Object* number); |
174 inline int64_t NumberToInt64(Object* number); | 181 inline int64_t NumberToInt64(Object* number); |
175 | 182 |
176 double StringToDouble(UnicodeCache* unicode_cache, Handle<String> string, | 183 double StringToDouble(UnicodeCache* unicode_cache, Handle<String> string, |
177 int flags, double empty_string_val = 0.0); | 184 int flags, double empty_string_val = 0.0); |
178 | 185 |
179 inline bool TryNumberToSize(Object* number, size_t* result); | 186 inline bool TryNumberToSize(Object* number, size_t* result); |
180 | 187 |
181 // Converts a number into size_t. | 188 // Converts a number into size_t. |
182 inline size_t NumberToSize(Object* number); | 189 inline size_t NumberToSize(Object* number); |
183 | 190 |
184 // returns DoubleToString(StringToDouble(string)) == string | 191 // returns DoubleToString(StringToDouble(string)) == string |
185 bool IsSpecialIndex(UnicodeCache* unicode_cache, String* string); | 192 bool IsSpecialIndex(UnicodeCache* unicode_cache, String* string); |
186 | 193 |
187 } // namespace internal | 194 } // namespace internal |
188 } // namespace v8 | 195 } // namespace v8 |
189 | 196 |
190 #endif // V8_CONVERSIONS_H_ | 197 #endif // V8_CONVERSIONS_H_ |
OLD | NEW |