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

Unified Diff: src/scanner.cc

Issue 1315673009: Sloppy-mode let parsing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: clarify comment Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/scanner.h ('k') | src/token.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scanner.cc
diff --git a/src/scanner.cc b/src/scanner.cc
index cebb5870f22dee984dee96e80ee61933574af587..944613081c012dfd14d52f39885151951ea62ca8 100644
--- a/src/scanner.cc
+++ b/src/scanner.cc
@@ -237,6 +237,11 @@ Token::Value Scanner::Next() {
next_.location.end_pos = current_.location.end_pos;
}
current_ = next_;
+ if (V8_UNLIKELY(next_next_.token != Token::UNINITIALIZED)) {
+ next_ = next_next_;
+ next_next_.token = Token::UNINITIALIZED;
+ return current_.token;
+ }
has_line_terminator_before_next_ = false;
has_multiline_comment_before_next_ = false;
if (static_cast<unsigned>(c0_) <= 0x7f) {
@@ -255,6 +260,20 @@ Token::Value Scanner::Next() {
}
+Token::Value Scanner::PeekAhead() {
+ if (next_next_.token != Token::UNINITIALIZED) {
+ return next_next_.token;
+ }
+ TokenDesc prev = current_;
+ Next();
+ Token::Value ret = next_.token;
+ next_next_ = next_;
+ next_ = current_;
+ current_ = prev;
+ return ret;
+}
+
+
// TODO(yangguo): check whether this is actually necessary.
static inline bool IsLittleEndianByteOrderMark(uc32 c) {
// The Unicode value U+FFFE is guaranteed never to be assigned as a
@@ -1432,7 +1451,7 @@ int Scanner::FindSymbol(DuplicateFinder* finder, int value) {
bool Scanner::SetBookmark() {
if (c0_ != kNoBookmark && bookmark_c0_ == kNoBookmark &&
- source_->SetBookmark()) {
+ next_next_.token == Token::UNINITIALIZED && source_->SetBookmark()) {
bookmark_c0_ = c0_;
CopyTokenDesc(&bookmark_current_, &current_);
CopyTokenDesc(&bookmark_next_, &next_);
« no previous file with comments | « src/scanner.h ('k') | src/token.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698