| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 // Features shared by parsing and pre-parsing scanners. | 5 // Features shared by parsing and pre-parsing scanners. |
| 6 | 6 |
| 7 #include "src/parsing/scanner.h" | 7 #include "src/parsing/scanner.h" |
| 8 | 8 |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 : scanner_->location().beg_pos; | 52 : scanner_->location().beg_pos; |
| 53 } | 53 } |
| 54 | 54 |
| 55 void Scanner::BookmarkScope::Apply() { | 55 void Scanner::BookmarkScope::Apply() { |
| 56 DCHECK(HasBeenSet()); // Caller hasn't called SetBookmark. | 56 DCHECK(HasBeenSet()); // Caller hasn't called SetBookmark. |
| 57 if (bookmark_ == kBookmarkAtFirstPos) { | 57 if (bookmark_ == kBookmarkAtFirstPos) { |
| 58 scanner_->SeekNext(0); | 58 scanner_->SeekNext(0); |
| 59 } else { | 59 } else { |
| 60 scanner_->SeekNext(bookmark_); | 60 scanner_->SeekNext(bookmark_); |
| 61 scanner_->Next(); | 61 scanner_->Next(); |
| 62 DCHECK_EQ(scanner_->location().beg_pos, bookmark_); | 62 DCHECK_EQ(scanner_->location().beg_pos, static_cast<int>(bookmark_)); |
| 63 } | 63 } |
| 64 bookmark_ = kBookmarkWasApplied; | 64 bookmark_ = kBookmarkWasApplied; |
| 65 } | 65 } |
| 66 | 66 |
| 67 bool Scanner::BookmarkScope::HasBeenSet() { | 67 bool Scanner::BookmarkScope::HasBeenSet() { |
| 68 return bookmark_ != kNoBookmark && bookmark_ != kBookmarkWasApplied; | 68 return bookmark_ != kNoBookmark && bookmark_ != kBookmarkWasApplied; |
| 69 } | 69 } |
| 70 | 70 |
| 71 bool Scanner::BookmarkScope::HasBeenApplied() { | 71 bool Scanner::BookmarkScope::HasBeenApplied() { |
| 72 return bookmark_ == kBookmarkWasApplied; | 72 return bookmark_ == kBookmarkWasApplied; |
| (...skipping 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1631 // (next_ + next_next_ will be overwrittem by Next(), | 1631 // (next_ + next_next_ will be overwrittem by Next(), |
| 1632 // current_ will remain unchanged, so overwrite it fully.) | 1632 // current_ will remain unchanged, so overwrite it fully.) |
| 1633 current_ = {{0, 0}, nullptr, nullptr, 0, Token::UNINITIALIZED}; | 1633 current_ = {{0, 0}, nullptr, nullptr, 0, Token::UNINITIALIZED}; |
| 1634 next_.token = Token::UNINITIALIZED; | 1634 next_.token = Token::UNINITIALIZED; |
| 1635 next_next_.token = Token::UNINITIALIZED; | 1635 next_next_.token = Token::UNINITIALIZED; |
| 1636 // 2, reset the source to the desired position, | 1636 // 2, reset the source to the desired position, |
| 1637 source_->Seek(position); | 1637 source_->Seek(position); |
| 1638 // 3, re-scan, by scanning the look-ahead char + 1 token (next_). | 1638 // 3, re-scan, by scanning the look-ahead char + 1 token (next_). |
| 1639 c0_ = source_->Advance(); | 1639 c0_ = source_->Advance(); |
| 1640 Next(); | 1640 Next(); |
| 1641 DCHECK_EQ(next_.location.beg_pos, position); | 1641 DCHECK_EQ(next_.location.beg_pos, static_cast<int>(position)); |
| 1642 } | 1642 } |
| 1643 | 1643 |
| 1644 } // namespace internal | 1644 } // namespace internal |
| 1645 } // namespace v8 | 1645 } // namespace v8 |
| OLD | NEW |