Remove legacy API on Utf16CharacterStream.
BUG=v8:4947 Review-Url: https://codereview.chromium.org/2347883002 Cr-Commit-Position: refs/heads/master@{#39533}
This commit is contained in:
parent
df9d8c01f2
commit
b36c60cce8
@ -3893,9 +3893,9 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
|
||||
formal_parameters.scope->AllowsLazyParsing());
|
||||
if (is_lazily_parsed) {
|
||||
Scanner::BookmarkScope bookmark(scanner());
|
||||
bool may_abort = bookmark.Set();
|
||||
bookmark.Set();
|
||||
LazyParsingResult result = impl()->SkipLazyFunctionBody(
|
||||
&materialized_literal_count, &expected_property_count, may_abort,
|
||||
&materialized_literal_count, &expected_property_count, true,
|
||||
CHECK_OK);
|
||||
|
||||
if (formal_parameters.materialized_literals_count > 0) {
|
||||
|
@ -3032,10 +3032,10 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
|
||||
// eagerly.
|
||||
if (is_lazily_parsed) {
|
||||
Scanner::BookmarkScope bookmark(scanner());
|
||||
bool may_abort = bookmark.Set();
|
||||
bookmark.Set();
|
||||
LazyParsingResult result =
|
||||
SkipLazyFunctionBody(&materialized_literal_count,
|
||||
&expected_property_count, may_abort, CHECK_OK);
|
||||
&expected_property_count, true, CHECK_OK);
|
||||
|
||||
materialized_literal_count += formals.materialized_literals_count +
|
||||
function_state.materialized_literal_count();
|
||||
|
@ -19,9 +19,6 @@
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
const size_t Utf16CharacterStream::kNoBookmark =
|
||||
std::numeric_limits<size_t>::max();
|
||||
|
||||
Handle<String> Scanner::LiteralBuffer::Internalize(Isolate* isolate) const {
|
||||
if (is_one_byte()) {
|
||||
return isolate->factory()->InternalizeOneByteString(one_byte_literal());
|
||||
@ -30,13 +27,13 @@ Handle<String> Scanner::LiteralBuffer::Internalize(Isolate* isolate) const {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Scanner
|
||||
|
||||
Scanner::Scanner(UnicodeCache* unicode_cache)
|
||||
: unicode_cache_(unicode_cache),
|
||||
bookmark_c0_(kNoBookmark),
|
||||
bookmark_position_(0),
|
||||
octal_pos_(Location::invalid()),
|
||||
decimal_with_leading_zero_pos_(Location::invalid()),
|
||||
found_html_comment_(false) {
|
||||
@ -789,7 +786,7 @@ void Scanner::SeekForward(int pos) {
|
||||
// Positions inside the lookahead token aren't supported.
|
||||
DCHECK(pos >= current_pos);
|
||||
if (pos != current_pos) {
|
||||
source_->SeekForward(pos - source_->pos());
|
||||
source_->Seek(pos);
|
||||
Advance();
|
||||
// This function is only called to seek to the location
|
||||
// of the end of a function (at the "}" token). It doesn't matter
|
||||
@ -1584,23 +1581,20 @@ int Scanner::FindSymbol(DuplicateFinder* finder, int value) {
|
||||
return finder->AddTwoByteSymbol(literal_two_byte_string(), value);
|
||||
}
|
||||
|
||||
|
||||
bool Scanner::SetBookmark() {
|
||||
if (c0_ != kNoBookmark && bookmark_c0_ == kNoBookmark &&
|
||||
next_next_.token == Token::UNINITIALIZED && source_->SetBookmark()) {
|
||||
bookmark_c0_ = c0_;
|
||||
CopyTokenDesc(&bookmark_current_, ¤t_);
|
||||
CopyTokenDesc(&bookmark_next_, &next_);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
void Scanner::SetBookmark() {
|
||||
DCHECK_EQ(bookmark_c0_, kNoBookmark);
|
||||
DCHECK_EQ(next_next_.token, Token::UNINITIALIZED);
|
||||
bookmark_c0_ = c0_;
|
||||
bookmark_position_ = source_->pos();
|
||||
CopyTokenDesc(&bookmark_current_, ¤t_);
|
||||
CopyTokenDesc(&bookmark_next_, &next_);
|
||||
}
|
||||
|
||||
|
||||
void Scanner::ResetToBookmark() {
|
||||
DCHECK(BookmarkHasBeenSet()); // Caller hasn't called SetBookmark.
|
||||
|
||||
source_->ResetToBookmark();
|
||||
source_->Seek(bookmark_position_);
|
||||
c0_ = bookmark_c0_;
|
||||
CopyToNextTokenDesc(&bookmark_current_);
|
||||
current_ = next_;
|
||||
|
@ -92,44 +92,14 @@ class Utf16CharacterStream {
|
||||
}
|
||||
}
|
||||
|
||||
// Legacy API:
|
||||
void SeekForward(size_t code_unit_count) { Seek(pos() + code_unit_count); }
|
||||
void PushBack(int32_t code_unit) {
|
||||
Back();
|
||||
#ifdef DEBUG
|
||||
uc32 t = Advance();
|
||||
DCHECK_EQ(t, code_unit);
|
||||
Back();
|
||||
#endif // DEBUG
|
||||
}
|
||||
void PushBack2(int32_t code_unit_back_1, int32_t code_unit_back_2) {
|
||||
Back2();
|
||||
#ifdef DEBUG
|
||||
DCHECK_EQ(Advance(), code_unit_back_2);
|
||||
DCHECK_EQ(Advance(), code_unit_back_1);
|
||||
Back2();
|
||||
#endif // DEBUG
|
||||
}
|
||||
bool SetBookmark() {
|
||||
bookmark_ = pos();
|
||||
return true;
|
||||
}
|
||||
void ResetToBookmark() {
|
||||
DCHECK_NE(bookmark_, kNoBookmark);
|
||||
Seek(bookmark_);
|
||||
}
|
||||
|
||||
protected:
|
||||
static const size_t kNoBookmark;
|
||||
|
||||
Utf16CharacterStream(const uint16_t* buffer_start,
|
||||
const uint16_t* buffer_cursor,
|
||||
const uint16_t* buffer_end, size_t buffer_pos)
|
||||
: buffer_start_(buffer_start),
|
||||
buffer_cursor_(buffer_cursor),
|
||||
buffer_end_(buffer_end),
|
||||
buffer_pos_(buffer_pos),
|
||||
bookmark_(kNoBookmark) {}
|
||||
buffer_pos_(buffer_pos) {}
|
||||
Utf16CharacterStream() : Utf16CharacterStream(nullptr, nullptr, nullptr, 0) {}
|
||||
|
||||
void ReadBlockAt(size_t new_pos) {
|
||||
@ -173,7 +143,6 @@ class Utf16CharacterStream {
|
||||
const uint16_t* buffer_cursor_;
|
||||
const uint16_t* buffer_end_;
|
||||
size_t buffer_pos_;
|
||||
size_t bookmark_;
|
||||
};
|
||||
|
||||
|
||||
@ -190,7 +159,7 @@ class Scanner {
|
||||
}
|
||||
~BookmarkScope() { scanner_->DropBookmark(); }
|
||||
|
||||
bool Set() { return scanner_->SetBookmark(); }
|
||||
void Set() { scanner_->SetBookmark(); }
|
||||
void Reset() { scanner_->ResetToBookmark(); }
|
||||
bool HasBeenSet() { return scanner_->BookmarkHasBeenSet(); }
|
||||
bool HasBeenReset() { return scanner_->BookmarkHasBeenReset(); }
|
||||
@ -560,7 +529,7 @@ class Scanner {
|
||||
}
|
||||
|
||||
// Support BookmarkScope functionality.
|
||||
bool SetBookmark();
|
||||
void SetBookmark();
|
||||
void ResetToBookmark();
|
||||
bool BookmarkHasBeenSet();
|
||||
bool BookmarkHasBeenReset();
|
||||
@ -649,7 +618,7 @@ class Scanner {
|
||||
if (unibrow::Utf16::IsLeadSurrogate(c0_)) {
|
||||
uc32 c1 = source_->Advance();
|
||||
if (!unibrow::Utf16::IsTrailSurrogate(c1)) {
|
||||
source_->PushBack(c1);
|
||||
source_->Back();
|
||||
} else {
|
||||
c0_ = unibrow::Utf16::CombineSurrogatePair(c0_, c1);
|
||||
}
|
||||
@ -658,10 +627,9 @@ class Scanner {
|
||||
|
||||
void PushBack(uc32 ch) {
|
||||
if (c0_ > static_cast<uc32>(unibrow::Utf16::kMaxNonSurrogateCharCode)) {
|
||||
source_->PushBack(unibrow::Utf16::TrailSurrogate(c0_));
|
||||
source_->PushBack(unibrow::Utf16::LeadSurrogate(c0_));
|
||||
source_->Back2();
|
||||
} else {
|
||||
source_->PushBack(c0_);
|
||||
source_->Back();
|
||||
}
|
||||
c0_ = ch;
|
||||
}
|
||||
@ -845,6 +813,7 @@ class Scanner {
|
||||
static const uc32 kNoBookmark = -2;
|
||||
static const uc32 kBookmarkWasApplied = -3;
|
||||
uc32 bookmark_c0_;
|
||||
size_t bookmark_position_;
|
||||
TokenDesc bookmark_current_;
|
||||
TokenDesc bookmark_next_;
|
||||
LiteralBuffer bookmark_current_literal_;
|
||||
|
@ -184,21 +184,21 @@ void TestCharacterStream(const char* reference, i::Utf16CharacterStream* stream,
|
||||
while (i > end / 4) {
|
||||
int32_t c0 = reference[i - 1];
|
||||
CHECK_EQU(i, stream->pos());
|
||||
stream->PushBack(c0);
|
||||
stream->Back();
|
||||
i--;
|
||||
CHECK_EQU(i, stream->pos());
|
||||
int32_t c1 = stream->Advance();
|
||||
i++;
|
||||
CHECK_EQU(i, stream->pos());
|
||||
CHECK_EQ(c0, c1);
|
||||
stream->PushBack(c0);
|
||||
stream->Back();
|
||||
i--;
|
||||
CHECK_EQU(i, stream->pos());
|
||||
}
|
||||
|
||||
// Seek + read streams one char at a time.
|
||||
unsigned halfway = end / 2;
|
||||
stream->SeekForward(halfway - i);
|
||||
stream->Seek(stream->pos() + halfway - i);
|
||||
for (i = halfway; i < end; i++) {
|
||||
CHECK_EQU(i, stream->pos());
|
||||
CHECK_EQU(reference[i], stream->Advance());
|
||||
|
Loading…
Reference in New Issue
Block a user