diff options
Diffstat (limited to 'deps/v8/src/parsing/scanner.h')
-rw-r--r-- | deps/v8/src/parsing/scanner.h | 90 |
1 files changed, 20 insertions, 70 deletions
diff --git a/deps/v8/src/parsing/scanner.h b/deps/v8/src/parsing/scanner.h index 6f6fab5543..075b9ca6b2 100644 --- a/deps/v8/src/parsing/scanner.h +++ b/deps/v8/src/parsing/scanner.h @@ -268,20 +268,17 @@ class Scanner { return false; } - int FindSymbol(DuplicateFinder* finder, int value); + bool FindSymbol(DuplicateFinder* finder); UnicodeCache* unicode_cache() { return unicode_cache_; } // Returns the location of the last seen octal literal. Location octal_position() const { return octal_pos_; } - void clear_octal_position() { octal_pos_ = Location::invalid(); } - // Returns the location of the last seen decimal literal with a leading zero. - Location decimal_with_leading_zero_position() const { - return decimal_with_leading_zero_pos_; - } - void clear_decimal_with_leading_zero_position() { - decimal_with_leading_zero_pos_ = Location::invalid(); + void clear_octal_position() { + octal_pos_ = Location::invalid(); + octal_message_ = MessageTemplate::kNone; } + MessageTemplate::Template octal_message() const { return octal_message_; } // Returns the value of the last smi that was scanned. uint32_t smi_value() const { return current_.smi_value_; } @@ -328,8 +325,6 @@ class Scanner { return tmp; } - bool IdentifierIsFutureStrictReserved(const AstRawString* string) const; - bool FoundHtmlComment() const { return found_html_comment_; } private: @@ -358,36 +353,16 @@ class Scanner { ~LiteralBuffer() { backing_store_.Dispose(); } INLINE(void AddChar(char code_unit)) { - if (position_ >= backing_store_.length()) ExpandBuffer(); - DCHECK(is_one_byte_); DCHECK(IsValidAscii(code_unit)); - backing_store_[position_] = static_cast<byte>(code_unit); - position_ += kOneByteSize; - return; + AddOneByteChar(static_cast<byte>(code_unit)); } INLINE(void AddChar(uc32 code_unit)) { - if (position_ >= backing_store_.length()) ExpandBuffer(); - if (is_one_byte_) { - if (code_unit <= static_cast<uc32>(unibrow::Latin1::kMaxChar)) { - backing_store_[position_] = static_cast<byte>(code_unit); - position_ += kOneByteSize; - return; - } - ConvertToTwoByte(); - } - if (code_unit <= - static_cast<uc32>(unibrow::Utf16::kMaxNonSurrogateCharCode)) { - *reinterpret_cast<uint16_t*>(&backing_store_[position_]) = code_unit; - position_ += kUC16Size; + if (is_one_byte_ && + code_unit <= static_cast<uc32>(unibrow::Latin1::kMaxChar)) { + AddOneByteChar(static_cast<byte>(code_unit)); } else { - *reinterpret_cast<uint16_t*>(&backing_store_[position_]) = - unibrow::Utf16::LeadSurrogate(code_unit); - position_ += kUC16Size; - if (position_ >= backing_store_.length()) ExpandBuffer(); - *reinterpret_cast<uint16_t*>(&backing_store_[position_]) = - unibrow::Utf16::TrailSurrogate(code_unit); - position_ += kUC16Size; + AddCharSlow(code_unit); } } @@ -439,43 +414,18 @@ class Scanner { return iscntrl(code_unit) || isprint(code_unit); } - inline int NewCapacity(int min_capacity) { - int capacity = Max(min_capacity, backing_store_.length()); - int new_capacity = Min(capacity * kGrowthFactory, capacity + kMaxGrowth); - return new_capacity; - } - - void ExpandBuffer() { - Vector<byte> new_store = Vector<byte>::New(NewCapacity(kInitialCapacity)); - MemCopy(new_store.start(), backing_store_.start(), position_); - backing_store_.Dispose(); - backing_store_ = new_store; - } - - void ConvertToTwoByte() { + INLINE(void AddOneByteChar(byte one_byte_char)) { DCHECK(is_one_byte_); - Vector<byte> new_store; - int new_content_size = position_ * kUC16Size; - if (new_content_size >= backing_store_.length()) { - // Ensure room for all currently read code units as UC16 as well - // as the code unit about to be stored. - new_store = Vector<byte>::New(NewCapacity(new_content_size)); - } else { - new_store = backing_store_; - } - uint8_t* src = backing_store_.start(); - uint16_t* dst = reinterpret_cast<uint16_t*>(new_store.start()); - for (int i = position_ - 1; i >= 0; i--) { - dst[i] = src[i]; - } - if (new_store.start() != backing_store_.start()) { - backing_store_.Dispose(); - backing_store_ = new_store; - } - position_ = new_content_size; - is_one_byte_ = false; + if (position_ >= backing_store_.length()) ExpandBuffer(); + backing_store_[position_] = one_byte_char; + position_ += kOneByteSize; } + void AddCharSlow(uc32 code_unit); + int NewCapacity(int min_capacity); + void ExpandBuffer(); + void ConvertToTwoByte(); + bool is_one_byte_; int position_; Vector<byte> backing_store_; @@ -787,7 +737,7 @@ class Scanner { // Last-seen positions of potentially problematic tokens. Location octal_pos_; - Location decimal_with_leading_zero_pos_; + MessageTemplate::Template octal_message_; // One Unicode character look-ahead; c0_ < 0 at the end of the input. uc32 c0_; |