| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 return DoubleToInt32(number->Number()); | 57 return DoubleToInt32(number->Number()); |
| 58 } | 58 } |
| 59 | 59 |
| 60 | 60 |
| 61 inline uint32_t NumberToUint32(Object* number) { | 61 inline uint32_t NumberToUint32(Object* number) { |
| 62 if (number->IsSmi()) return Smi::cast(number)->value(); | 62 if (number->IsSmi()) return Smi::cast(number)->value(); |
| 63 return DoubleToUint32(number->Number()); | 63 return DoubleToUint32(number->Number()); |
| 64 } | 64 } |
| 65 | 65 |
| 66 | 66 |
| 67 // Converts a string into a double value according to ECMA-262 9.3.1 | 67 // Converts a string into an integer. |
| 68 double StringToDouble(UnicodeCache* unicode_cache, | 68 double StringToInt(UnicodeCache* unicode_cache, |
| 69 String* str, | 69 Vector<const uint8_t> vector, |
| 70 int flags, | 70 int radix); |
| 71 double empty_string_val = 0); | |
| 72 | 71 |
| 73 // Converts a string into an integer. | 72 |
| 74 double StringToInt(UnicodeCache* unicode_cache, String* str, int radix); | 73 double StringToInt(UnicodeCache* unicode_cache, |
| 74 Vector<const uc16> vector, |
| 75 int radix); |
| 76 |
| 75 | 77 |
| 76 inline bool TryNumberToSize(Isolate* isolate, | 78 inline bool TryNumberToSize(Isolate* isolate, |
| 77 Object* number, size_t* result) { | 79 Object* number, size_t* result) { |
| 78 SealHandleScope shs(isolate); | 80 SealHandleScope shs(isolate); |
| 79 if (number->IsSmi()) { | 81 if (number->IsSmi()) { |
| 80 int value = Smi::cast(number)->value(); | 82 int value = Smi::cast(number)->value(); |
| 81 ASSERT( | 83 ASSERT( |
| 82 static_cast<unsigned>(Smi::kMaxValue) | 84 static_cast<unsigned>(Smi::kMaxValue) |
| 83 <= std::numeric_limits<size_t>::max()); | 85 <= std::numeric_limits<size_t>::max()); |
| 84 if (value >= 0) { | 86 if (value >= 0) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 104 Object* number) { | 106 Object* number) { |
| 105 size_t result = 0; | 107 size_t result = 0; |
| 106 bool is_valid = TryNumberToSize(isolate, number, &result); | 108 bool is_valid = TryNumberToSize(isolate, number, &result); |
| 107 CHECK(is_valid); | 109 CHECK(is_valid); |
| 108 return result; | 110 return result; |
| 109 } | 111 } |
| 110 | 112 |
| 111 } } // namespace v8::internal | 113 } } // namespace v8::internal |
| 112 | 114 |
| 113 #endif // V8_V8CONVERSIONS_H_ | 115 #endif // V8_V8CONVERSIONS_H_ |
| OLD | NEW |