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

Side by Side Diff: src/utils.h

Issue 314603004: Parser: Delay internalizing strings and values. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: More code review (rossberg@). 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
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 1535 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 // Add formatted contents to the builder just like printf(). 1546 // Add formatted contents to the builder just like printf().
1547 void AddFormatted(const char* format, ...); 1547 void AddFormatted(const char* format, ...);
1548 1548
1549 // Add formatted contents like printf based on a va_list. 1549 // Add formatted contents like printf based on a va_list.
1550 void AddFormattedList(const char* format, va_list list); 1550 void AddFormattedList(const char* format, va_list list);
1551 private: 1551 private:
1552 DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); 1552 DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder);
1553 }; 1553 };
1554 1554
1555 1555
1556 bool DoubleToBoolean(double d);
1557
1558 template <typename Stream>
1559 bool StringToArrayIndex(Stream* stream, uint32_t* index) {
1560 uint16_t ch = stream->GetNext();
1561
1562 // If the string begins with a '0' character, it must only consist
1563 // of it to be a legal array index.
1564 if (ch == '0') {
1565 *index = 0;
1566 return !stream->HasMore();
1567 }
1568
1569 // Convert string to uint32 array index; character by character.
1570 int d = ch - '0';
1571 if (d < 0 || d > 9) return false;
1572 uint32_t result = d;
1573 while (stream->HasMore()) {
1574 d = stream->GetNext() - '0';
1575 if (d < 0 || d > 9) return false;
1576 // Check that the new result is below the 32 bit limit.
1577 if (result > 429496729U - ((d > 5) ? 1 : 0)) return false;
1578 result = (result * 10) + d;
1579 }
1580
1581 *index = result;
1582 return true;
1583 }
1584
1585
1556 } } // namespace v8::internal 1586 } } // namespace v8::internal
1557 1587
1558 #endif // V8_UTILS_H_ 1588 #endif // V8_UTILS_H_
OLDNEW
« src/ast-value-factory.h ('K') | « src/scopes.cc ('k') | src/utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698