Chromium Code Reviews| 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 #ifndef V8_PARSING_SCANNER_H_ | 7 #ifndef V8_PARSING_SCANNER_H_ |
| 8 #define V8_PARSING_SCANNER_H_ | 8 #define V8_PARSING_SCANNER_H_ |
| 9 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 | 151 |
| 152 // ---------------------------------------------------------------------------- | 152 // ---------------------------------------------------------------------------- |
| 153 // LiteralBuffer - Collector of chars of literals. | 153 // LiteralBuffer - Collector of chars of literals. |
| 154 | 154 |
| 155 class LiteralBuffer { | 155 class LiteralBuffer { |
| 156 public: | 156 public: |
| 157 LiteralBuffer() : is_one_byte_(true), position_(0), backing_store_() { } | 157 LiteralBuffer() : is_one_byte_(true), position_(0), backing_store_() { } |
| 158 | 158 |
| 159 ~LiteralBuffer() { backing_store_.Dispose(); } | 159 ~LiteralBuffer() { backing_store_.Dispose(); } |
| 160 | 160 |
| 161 INLINE(void AddChar(uint32_t code_unit)) { | 161 INLINE(void AddChar(char code_unit)) { |
| 162 if (position_ >= backing_store_.length()) ExpandBuffer(); | |
| 163 DCHECK(is_one_byte_); | |
|
vogelheim
2016/06/09 12:05:15
Maybe also dcheck whether code_unit is actually as
| |
| 164 backing_store_[position_] = static_cast<byte>(code_unit); | |
| 165 position_ += kOneByteSize; | |
| 166 return; | |
| 167 } | |
| 168 | |
| 169 INLINE(void AddChar(uc32 code_unit)) { | |
| 162 if (position_ >= backing_store_.length()) ExpandBuffer(); | 170 if (position_ >= backing_store_.length()) ExpandBuffer(); |
| 163 if (is_one_byte_) { | 171 if (is_one_byte_) { |
| 164 if (code_unit <= unibrow::Latin1::kMaxChar) { | 172 if (code_unit <= unibrow::Latin1::kMaxChar) { |
| 165 backing_store_[position_] = static_cast<byte>(code_unit); | 173 backing_store_[position_] = static_cast<byte>(code_unit); |
| 166 position_ += kOneByteSize; | 174 position_ += kOneByteSize; |
| 167 return; | 175 return; |
| 168 } | 176 } |
| 169 ConvertToTwoByte(); | 177 ConvertToTwoByte(); |
| 170 } | 178 } |
| 171 if (code_unit <= unibrow::Utf16::kMaxNonSurrogateCharCode) { | 179 if (code_unit <= unibrow::Utf16::kMaxNonSurrogateCharCode) { |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 550 : &raw_literal_buffer0_; | 558 : &raw_literal_buffer0_; |
| 551 free_buffer->Reset(); | 559 free_buffer->Reset(); |
| 552 next_.raw_literal_chars = free_buffer; | 560 next_.raw_literal_chars = free_buffer; |
| 553 } | 561 } |
| 554 | 562 |
| 555 INLINE(void AddLiteralChar(uc32 c)) { | 563 INLINE(void AddLiteralChar(uc32 c)) { |
| 556 DCHECK_NOT_NULL(next_.literal_chars); | 564 DCHECK_NOT_NULL(next_.literal_chars); |
| 557 next_.literal_chars->AddChar(c); | 565 next_.literal_chars->AddChar(c); |
| 558 } | 566 } |
| 559 | 567 |
| 568 INLINE(void AddLiteralChar(char c)) { | |
| 569 DCHECK_NOT_NULL(next_.literal_chars); | |
| 570 next_.literal_chars->AddChar(c); | |
| 571 } | |
| 572 | |
| 560 INLINE(void AddRawLiteralChar(uc32 c)) { | 573 INLINE(void AddRawLiteralChar(uc32 c)) { |
| 561 DCHECK_NOT_NULL(next_.raw_literal_chars); | 574 DCHECK_NOT_NULL(next_.raw_literal_chars); |
| 562 next_.raw_literal_chars->AddChar(c); | 575 next_.raw_literal_chars->AddChar(c); |
| 563 } | 576 } |
| 564 | 577 |
| 565 INLINE(void ReduceRawLiteralLength(int delta)) { | 578 INLINE(void ReduceRawLiteralLength(int delta)) { |
| 566 DCHECK_NOT_NULL(next_.raw_literal_chars); | 579 DCHECK_NOT_NULL(next_.raw_literal_chars); |
| 567 next_.raw_literal_chars->ReduceLength(delta); | 580 next_.raw_literal_chars->ReduceLength(delta); |
| 568 } | 581 } |
| 569 | 582 |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 807 bool allow_harmony_exponentiation_operator_; | 820 bool allow_harmony_exponentiation_operator_; |
| 808 | 821 |
| 809 MessageTemplate::Template scanner_error_; | 822 MessageTemplate::Template scanner_error_; |
| 810 Location scanner_error_location_; | 823 Location scanner_error_location_; |
| 811 }; | 824 }; |
| 812 | 825 |
| 813 } // namespace internal | 826 } // namespace internal |
| 814 } // namespace v8 | 827 } // namespace v8 |
| 815 | 828 |
| 816 #endif // V8_PARSING_SCANNER_H_ | 829 #endif // V8_PARSING_SCANNER_H_ |
| OLD | NEW |