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

Unified Diff: src/scanner.h

Issue 372059: Revert 3245 and 3246 because they cause valgrind failures. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/scanner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scanner.h
===================================================================
--- src/scanner.h (revision 3253)
+++ src/scanner.h (working copy)
@@ -41,7 +41,6 @@
~UTF8Buffer();
void AddChar(uc32 c) {
- ASSERT_NOT_NULL(data_);
if (cursor_ <= limit_ &&
static_cast<unsigned>(c) <= unibrow::Utf8::kMaxOneByteChar) {
*cursor_++ = static_cast<char>(c);
@@ -50,29 +49,16 @@
}
}
- void Reset() {
- if (data_ == NULL) {
- data_ = NewArray<char>(kInitialCapacity);
- limit_ = ComputeLimit(data_, kInitialCapacity);
- }
- cursor_ = data_;
- }
-
- int pos() const {
- ASSERT_NOT_NULL(data_);
- return cursor_ - data_;
- }
-
+ void Reset() { cursor_ = data_; }
+ int pos() const { return cursor_ - data_; }
char* data() const { return data_; }
private:
- static const int kInitialCapacity = 256;
char* data_;
char* cursor_;
char* limit_;
int Capacity() const {
- ASSERT_NOT_NULL(data_);
return (limit_ - data_) + unibrow::Utf8::kMaxEncodedSize;
}
@@ -292,32 +278,28 @@
// token returned by Next()). The string is 0-terminated and in
// UTF-8 format; they may contain 0-characters. Literal strings are
// collected for identifiers, strings, and numbers.
- // These functions only give the correct result if the literal
- // was scanned between calls to StartLiteral() and TerminateLiteral().
const char* literal_string() const {
- return current_.literal_buffer->data();
+ return &literals_.data()[current_.literal_pos];
}
int literal_length() const {
- // Excluding terminal '\0' added by TerminateLiteral().
- return current_.literal_buffer->pos() - 1;
+ return current_.literal_end - current_.literal_pos;
}
+ Vector<const char> next_literal() const {
+ return Vector<const char>(next_literal_string(), next_literal_length());
+ }
+
// Returns the literal string for the next token (the token that
// would be returned if Next() were called).
const char* next_literal_string() const {
- return next_.literal_buffer->data();
+ return &literals_.data()[next_.literal_pos];
}
// Returns the length of the next token (that would be returned if
// Next() were called).
int next_literal_length() const {
- return next_.literal_buffer->pos() - 1;
+ return next_.literal_end - next_.literal_pos;
}
- Vector<const char> next_literal() const {
- return Vector<const char>(next_literal_string(),
- next_literal_length());
- }
-
// Scans the input as a regular expression pattern, previous
// character(s) must be /(=). Returns true if a pattern is scanned.
bool ScanRegExpPattern(bool seen_equal);
@@ -357,8 +339,7 @@
// Buffer to hold literal values (identifiers, strings, numbers)
// using 0-terminated UTF-8 encoding.
- UTF8Buffer literal_buffer_1_;
- UTF8Buffer literal_buffer_2_;
+ UTF8Buffer literals_;
bool stack_overflow_;
static StaticResource<Utf8Decoder> utf8_decoder_;
@@ -370,7 +351,7 @@
struct TokenDesc {
Token::Value token;
Location location;
- UTF8Buffer* literal_buffer;
+ int literal_pos, literal_end;
};
TokenDesc current_; // desc for current token (as returned by Next())
« no previous file with comments | « no previous file | src/scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698