| 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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 DCHECK(is_one_byte_); | 362 DCHECK(is_one_byte_); |
| 363 DCHECK(IsValidAscii(code_unit)); | 363 DCHECK(IsValidAscii(code_unit)); |
| 364 backing_store_[position_] = static_cast<byte>(code_unit); | 364 backing_store_[position_] = static_cast<byte>(code_unit); |
| 365 position_ += kOneByteSize; | 365 position_ += kOneByteSize; |
| 366 return; | 366 return; |
| 367 } | 367 } |
| 368 | 368 |
| 369 INLINE(void AddChar(uc32 code_unit)) { | 369 INLINE(void AddChar(uc32 code_unit)) { |
| 370 if (position_ >= backing_store_.length()) ExpandBuffer(); | 370 if (position_ >= backing_store_.length()) ExpandBuffer(); |
| 371 if (is_one_byte_) { | 371 if (is_one_byte_) { |
| 372 if (code_unit <= unibrow::Latin1::kMaxChar) { | 372 if (code_unit <= static_cast<uc32>(unibrow::Latin1::kMaxChar)) { |
| 373 backing_store_[position_] = static_cast<byte>(code_unit); | 373 backing_store_[position_] = static_cast<byte>(code_unit); |
| 374 position_ += kOneByteSize; | 374 position_ += kOneByteSize; |
| 375 return; | 375 return; |
| 376 } | 376 } |
| 377 ConvertToTwoByte(); | 377 ConvertToTwoByte(); |
| 378 } | 378 } |
| 379 if (code_unit <= unibrow::Utf16::kMaxNonSurrogateCharCode) { | 379 if (code_unit <= |
| 380 static_cast<uc32>(unibrow::Utf16::kMaxNonSurrogateCharCode)) { |
| 380 *reinterpret_cast<uint16_t*>(&backing_store_[position_]) = code_unit; | 381 *reinterpret_cast<uint16_t*>(&backing_store_[position_]) = code_unit; |
| 381 position_ += kUC16Size; | 382 position_ += kUC16Size; |
| 382 } else { | 383 } else { |
| 383 *reinterpret_cast<uint16_t*>(&backing_store_[position_]) = | 384 *reinterpret_cast<uint16_t*>(&backing_store_[position_]) = |
| 384 unibrow::Utf16::LeadSurrogate(code_unit); | 385 unibrow::Utf16::LeadSurrogate(code_unit); |
| 385 position_ += kUC16Size; | 386 position_ += kUC16Size; |
| 386 if (position_ >= backing_store_.length()) ExpandBuffer(); | 387 if (position_ >= backing_store_.length()) ExpandBuffer(); |
| 387 *reinterpret_cast<uint16_t*>(&backing_store_[position_]) = | 388 *reinterpret_cast<uint16_t*>(&backing_store_[position_]) = |
| 388 unibrow::Utf16::TrailSurrogate(code_unit); | 389 unibrow::Utf16::TrailSurrogate(code_unit); |
| 389 position_ += kUC16Size; | 390 position_ += kUC16Size; |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 bool found_html_comment_; | 805 bool found_html_comment_; |
| 805 | 806 |
| 806 MessageTemplate::Template scanner_error_; | 807 MessageTemplate::Template scanner_error_; |
| 807 Location scanner_error_location_; | 808 Location scanner_error_location_; |
| 808 }; | 809 }; |
| 809 | 810 |
| 810 } // namespace internal | 811 } // namespace internal |
| 811 } // namespace v8 | 812 } // namespace v8 |
| 812 | 813 |
| 813 #endif // V8_PARSING_SCANNER_H_ | 814 #endif // V8_PARSING_SCANNER_H_ |
| OLD | NEW |