| 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 return DoubleToInt32(number->Number()); | 191 return DoubleToInt32(number->Number()); |
| 192 } | 192 } |
| 193 | 193 |
| 194 | 194 |
| 195 inline uint32_t NumberToUint32(Object* number) { | 195 inline uint32_t NumberToUint32(Object* number) { |
| 196 if (number->IsSmi()) return Smi::cast(number)->value(); | 196 if (number->IsSmi()) return Smi::cast(number)->value(); |
| 197 return DoubleToUint32(number->Number()); | 197 return DoubleToUint32(number->Number()); |
| 198 } | 198 } |
| 199 | 199 |
| 200 | 200 |
| 201 double StringToDouble(UnicodeCache* unicode_cache, | 201 double StringToDouble(UnicodeCache* unicode_cache, Handle<String> string, |
| 202 String* string, | 202 int flags, double empty_string_val = 0.0); |
| 203 int flags, | |
| 204 double empty_string_val = 0.0); | |
| 205 | 203 |
| 206 | 204 |
| 207 inline bool TryNumberToSize(Isolate* isolate, | 205 inline bool TryNumberToSize(Isolate* isolate, |
| 208 Object* number, size_t* result) { | 206 Object* number, size_t* result) { |
| 209 SealHandleScope shs(isolate); | 207 SealHandleScope shs(isolate); |
| 210 if (number->IsSmi()) { | 208 if (number->IsSmi()) { |
| 211 int value = Smi::cast(number)->value(); | 209 int value = Smi::cast(number)->value(); |
| 212 DCHECK(static_cast<unsigned>(Smi::kMaxValue) | 210 DCHECK(static_cast<unsigned>(Smi::kMaxValue) |
| 213 <= std::numeric_limits<size_t>::max()); | 211 <= std::numeric_limits<size_t>::max()); |
| 214 if (value >= 0) { | 212 if (value >= 0) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 234 Object* number) { | 232 Object* number) { |
| 235 size_t result = 0; | 233 size_t result = 0; |
| 236 bool is_valid = TryNumberToSize(isolate, number, &result); | 234 bool is_valid = TryNumberToSize(isolate, number, &result); |
| 237 CHECK(is_valid); | 235 CHECK(is_valid); |
| 238 return result; | 236 return result; |
| 239 } | 237 } |
| 240 | 238 |
| 241 } } // namespace v8::internal | 239 } } // namespace v8::internal |
| 242 | 240 |
| 243 #endif // V8_CONVERSIONS_H_ | 241 #endif // V8_CONVERSIONS_H_ |
| OLD | NEW |