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 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1591 } | 1591 } |
1592 return false; | 1592 return false; |
1593 } | 1593 } |
1594 | 1594 |
1595 | 1595 |
1596 void Scanner::ResetToBookmark() { | 1596 void Scanner::ResetToBookmark() { |
1597 DCHECK(BookmarkHasBeenSet()); // Caller hasn't called SetBookmark. | 1597 DCHECK(BookmarkHasBeenSet()); // Caller hasn't called SetBookmark. |
1598 | 1598 |
1599 source_->ResetToBookmark(); | 1599 source_->ResetToBookmark(); |
1600 c0_ = bookmark_c0_; | 1600 c0_ = bookmark_c0_; |
1601 StartLiteral(); | 1601 CopyToNextTokenDesc(&bookmark_current_); |
1602 StartRawLiteral(); | |
1603 CopyTokenDesc(&next_, &bookmark_current_); | |
1604 current_ = next_; | 1602 current_ = next_; |
1605 StartLiteral(); | 1603 CopyToNextTokenDesc(&bookmark_next_); |
1606 StartRawLiteral(); | |
1607 CopyTokenDesc(&next_, &bookmark_next_); | |
1608 | |
1609 bookmark_c0_ = kBookmarkWasApplied; | 1604 bookmark_c0_ = kBookmarkWasApplied; |
1610 } | 1605 } |
1611 | 1606 |
1612 | 1607 |
1613 bool Scanner::BookmarkHasBeenSet() { return bookmark_c0_ >= 0; } | 1608 bool Scanner::BookmarkHasBeenSet() { return bookmark_c0_ >= 0; } |
1614 | 1609 |
1615 | 1610 |
1616 bool Scanner::BookmarkHasBeenReset() { | 1611 bool Scanner::BookmarkHasBeenReset() { |
1617 return bookmark_c0_ == kBookmarkWasApplied; | 1612 return bookmark_c0_ == kBookmarkWasApplied; |
1618 } | 1613 } |
1619 | 1614 |
1620 | 1615 |
1621 void Scanner::DropBookmark() { bookmark_c0_ = kNoBookmark; } | 1616 void Scanner::DropBookmark() { bookmark_c0_ = kNoBookmark; } |
1622 | 1617 |
| 1618 void Scanner::CopyToNextTokenDesc(TokenDesc* from) { |
| 1619 StartLiteral(); |
| 1620 StartRawLiteral(); |
| 1621 CopyTokenDesc(&next_, from); |
| 1622 if (next_.literal_chars->length() == 0) next_.literal_chars = nullptr; |
| 1623 if (next_.raw_literal_chars->length() == 0) next_.raw_literal_chars = nullptr; |
| 1624 } |
1623 | 1625 |
1624 void Scanner::CopyTokenDesc(TokenDesc* to, TokenDesc* from) { | 1626 void Scanner::CopyTokenDesc(TokenDesc* to, TokenDesc* from) { |
1625 DCHECK_NOT_NULL(to); | 1627 DCHECK_NOT_NULL(to); |
1626 DCHECK_NOT_NULL(from); | 1628 DCHECK_NOT_NULL(from); |
1627 to->token = from->token; | 1629 to->token = from->token; |
1628 to->location = from->location; | 1630 to->location = from->location; |
1629 to->literal_chars->CopyFrom(from->literal_chars); | 1631 to->literal_chars->CopyFrom(from->literal_chars); |
1630 to->raw_literal_chars->CopyFrom(from->raw_literal_chars); | 1632 to->raw_literal_chars->CopyFrom(from->raw_literal_chars); |
1631 } | 1633 } |
1632 | 1634 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1765 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); | 1767 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); |
1766 } | 1768 } |
1767 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); | 1769 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); |
1768 | 1770 |
1769 backing_store_.AddBlock(bytes); | 1771 backing_store_.AddBlock(bytes); |
1770 return backing_store_.EndSequence().start(); | 1772 return backing_store_.EndSequence().start(); |
1771 } | 1773 } |
1772 | 1774 |
1773 } // namespace internal | 1775 } // namespace internal |
1774 } // namespace v8 | 1776 } // namespace v8 |
OLD | NEW |