| OLD | NEW | 
|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_UTILS_H_ | 5 #ifndef V8_UTILS_H_ | 
| 6 #define V8_UTILS_H_ | 6 #define V8_UTILS_H_ | 
| 7 | 7 | 
| 8 #include <limits.h> | 8 #include <limits.h> | 
| 9 #include <stdlib.h> | 9 #include <stdlib.h> | 
| 10 #include <string.h> | 10 #include <string.h> | 
| (...skipping 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1565   // Add formatted contents to the builder just like printf(). | 1565   // Add formatted contents to the builder just like printf(). | 
| 1566   void AddFormatted(const char* format, ...); | 1566   void AddFormatted(const char* format, ...); | 
| 1567 | 1567 | 
| 1568   // Add formatted contents like printf based on a va_list. | 1568   // Add formatted contents like printf based on a va_list. | 
| 1569   void AddFormattedList(const char* format, va_list list); | 1569   void AddFormattedList(const char* format, va_list list); | 
| 1570  private: | 1570  private: | 
| 1571   DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); | 1571   DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); | 
| 1572 }; | 1572 }; | 
| 1573 | 1573 | 
| 1574 | 1574 | 
|  | 1575 bool DoubleToBoolean(double d); | 
|  | 1576 | 
|  | 1577 template <typename Stream> | 
|  | 1578 bool StringToArrayIndex(Stream* stream, uint32_t* index) { | 
|  | 1579   uint16_t ch = stream->GetNext(); | 
|  | 1580 | 
|  | 1581   // If the string begins with a '0' character, it must only consist | 
|  | 1582   // of it to be a legal array index. | 
|  | 1583   if (ch == '0') { | 
|  | 1584     *index = 0; | 
|  | 1585     return !stream->HasMore(); | 
|  | 1586   } | 
|  | 1587 | 
|  | 1588   // Convert string to uint32 array index; character by character. | 
|  | 1589   int d = ch - '0'; | 
|  | 1590   if (d < 0 || d > 9) return false; | 
|  | 1591   uint32_t result = d; | 
|  | 1592   while (stream->HasMore()) { | 
|  | 1593     d = stream->GetNext() - '0'; | 
|  | 1594     if (d < 0 || d > 9) return false; | 
|  | 1595     // Check that the new result is below the 32 bit limit. | 
|  | 1596     if (result > 429496729U - ((d > 5) ? 1 : 0)) return false; | 
|  | 1597     result = (result * 10) + d; | 
|  | 1598   } | 
|  | 1599 | 
|  | 1600   *index = result; | 
|  | 1601   return true; | 
|  | 1602 } | 
|  | 1603 | 
|  | 1604 | 
| 1575 } }  // namespace v8::internal | 1605 } }  // namespace v8::internal | 
| 1576 | 1606 | 
| 1577 #endif  // V8_UTILS_H_ | 1607 #endif  // V8_UTILS_H_ | 
| OLD | NEW | 
|---|