Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(972)

Side by Side Diff: src/utils.h

Issue 345513003: Revert "Parser: Delay internalizing strings and values." (r21841) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/scopes.cc ('k') | src/utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 // Add formatted contents to the builder just like printf(). 1571 // Add formatted contents to the builder just like printf().
1572 void AddFormatted(const char* format, ...); 1572 void AddFormatted(const char* format, ...);
1573 1573
1574 // Add formatted contents like printf based on a va_list. 1574 // Add formatted contents like printf based on a va_list.
1575 void AddFormattedList(const char* format, va_list list); 1575 void AddFormattedList(const char* format, va_list list);
1576 private: 1576 private:
1577 DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); 1577 DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder);
1578 }; 1578 };
1579 1579
1580 1580
1581 bool DoubleToBoolean(double d);
1582
1583 template <typename Stream>
1584 bool StringToArrayIndex(Stream* stream, uint32_t* index) {
1585 uint16_t ch = stream->GetNext();
1586
1587 // If the string begins with a '0' character, it must only consist
1588 // of it to be a legal array index.
1589 if (ch == '0') {
1590 *index = 0;
1591 return !stream->HasMore();
1592 }
1593
1594 // Convert string to uint32 array index; character by character.
1595 int d = ch - '0';
1596 if (d < 0 || d > 9) return false;
1597 uint32_t result = d;
1598 while (stream->HasMore()) {
1599 d = stream->GetNext() - '0';
1600 if (d < 0 || d > 9) return false;
1601 // Check that the new result is below the 32 bit limit.
1602 if (result > 429496729U - ((d > 5) ? 1 : 0)) return false;
1603 result = (result * 10) + d;
1604 }
1605
1606 *index = result;
1607 return true;
1608 }
1609
1610
1611 } } // namespace v8::internal 1581 } } // namespace v8::internal
1612 1582
1613 #endif // V8_UTILS_H_ 1583 #endif // V8_UTILS_H_
OLDNEW
« no previous file with comments | « src/scopes.cc ('k') | src/utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698