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

Side by Side Diff: src/parsing/scanner.cc

Issue 2345053003: Behold, a unit test for Scanner::BookmarkScope (& scanner bookmarking). (Closed)
Patch Set: Rebase & fix .gyp file. Created 4 years, 3 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
« no previous file with comments | « src/parsing/scanner.h ('k') | test/cctest/BUILD.gn » ('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 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 1590 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 DCHECK(BookmarkHasBeenSet()); // Caller hasn't called SetBookmark. 1601 DCHECK(BookmarkHasBeenSet()); // Caller hasn't called SetBookmark.
1602 1602
1603 source_->ResetToBookmark(); 1603 source_->ResetToBookmark();
1604 c0_ = bookmark_c0_; 1604 c0_ = bookmark_c0_;
1605 CopyToNextTokenDesc(&bookmark_current_); 1605 CopyToNextTokenDesc(&bookmark_current_);
1606 current_ = next_; 1606 current_ = next_;
1607 CopyToNextTokenDesc(&bookmark_next_); 1607 CopyToNextTokenDesc(&bookmark_next_);
1608 bookmark_c0_ = kBookmarkWasApplied; 1608 bookmark_c0_ = kBookmarkWasApplied;
1609 } 1609 }
1610 1610
1611 1611 bool Scanner::BookmarkHasBeenSet() {
1612 bool Scanner::BookmarkHasBeenSet() { return bookmark_c0_ >= 0; } 1612 return bookmark_c0_ != kNoBookmark && bookmark_c0_ != kBookmarkWasApplied;
1613 1613 }
1614 1614
1615 bool Scanner::BookmarkHasBeenReset() { 1615 bool Scanner::BookmarkHasBeenReset() {
1616 return bookmark_c0_ == kBookmarkWasApplied; 1616 return bookmark_c0_ == kBookmarkWasApplied;
1617 } 1617 }
1618 1618
1619 1619
1620 void Scanner::DropBookmark() { bookmark_c0_ = kNoBookmark; } 1620 void Scanner::DropBookmark() { bookmark_c0_ = kNoBookmark; }
1621 1621
1622 void Scanner::CopyToNextTokenDesc(TokenDesc* from) { 1622 void Scanner::CopyToNextTokenDesc(TokenDesc* from) {
1623 StartLiteral(); 1623 StartLiteral();
1624 StartRawLiteral(); 1624 StartRawLiteral();
1625 CopyTokenDesc(&next_, from); 1625 CopyTokenDesc(&next_, from);
1626 if (next_.literal_chars->length() == 0) next_.literal_chars = nullptr; 1626 if (next_.literal_chars->length() == 0) next_.literal_chars = nullptr;
1627 if (next_.raw_literal_chars->length() == 0) next_.raw_literal_chars = nullptr; 1627 if (next_.raw_literal_chars->length() == 0) next_.raw_literal_chars = nullptr;
1628 } 1628 }
1629 1629
1630 void Scanner::CopyTokenDesc(TokenDesc* to, TokenDesc* from) { 1630 void Scanner::CopyTokenDesc(TokenDesc* to, TokenDesc* from) {
1631 DCHECK_NOT_NULL(to); 1631 DCHECK_NOT_NULL(to);
1632 DCHECK_NOT_NULL(from); 1632 DCHECK_NOT_NULL(from);
1633 to->token = from->token; 1633 to->token = from->token;
1634 to->location = from->location; 1634 to->location = from->location;
1635 to->literal_chars->CopyFrom(from->literal_chars); 1635 to->literal_chars->CopyFrom(from->literal_chars);
1636 to->raw_literal_chars->CopyFrom(from->raw_literal_chars); 1636 to->raw_literal_chars->CopyFrom(from->raw_literal_chars);
1637 } 1637 }
1638 1638
1639 1639
1640 1640
1641 } // namespace internal 1641 } // namespace internal
1642 } // namespace v8 1642 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/scanner.h ('k') | test/cctest/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698