| 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_SCANNER_H_ | 7 #ifndef V8_SCANNER_H_ |
| 8 #define V8_SCANNER_H_ | 8 #define V8_SCANNER_H_ |
| 9 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 next_.literal_chars = NULL; | 558 next_.literal_chars = NULL; |
| 559 next_.raw_literal_chars = NULL; | 559 next_.raw_literal_chars = NULL; |
| 560 } | 560 } |
| 561 | 561 |
| 562 inline void AddLiteralCharAdvance() { | 562 inline void AddLiteralCharAdvance() { |
| 563 AddLiteralChar(c0_); | 563 AddLiteralChar(c0_); |
| 564 Advance(); | 564 Advance(); |
| 565 } | 565 } |
| 566 | 566 |
| 567 // Low-level scanning support. | 567 // Low-level scanning support. |
| 568 template <bool capture_raw = false> | 568 template <bool capture_raw = false, bool check_surrogate = true> |
| 569 void Advance() { | 569 void Advance() { |
| 570 if (capture_raw) { | 570 if (capture_raw) { |
| 571 AddRawLiteralChar(c0_); | 571 AddRawLiteralChar(c0_); |
| 572 } | 572 } |
| 573 c0_ = source_->Advance(); | 573 c0_ = source_->Advance(); |
| 574 if (check_surrogate) HandleLeadSurrugate(); |
| 575 } |
| 576 |
| 577 void HandleLeadSurrugate() { |
| 574 if (unibrow::Utf16::IsLeadSurrogate(c0_)) { | 578 if (unibrow::Utf16::IsLeadSurrogate(c0_)) { |
| 575 uc32 c1 = source_->Advance(); | 579 uc32 c1 = source_->Advance(); |
| 576 if (!unibrow::Utf16::IsTrailSurrogate(c1)) { | 580 if (!unibrow::Utf16::IsTrailSurrogate(c1)) { |
| 577 source_->PushBack(c1); | 581 source_->PushBack(c1); |
| 578 } else { | 582 } else { |
| 579 c0_ = unibrow::Utf16::CombineSurrogatePair(c0_, c1); | 583 c0_ = unibrow::Utf16::CombineSurrogatePair(c0_, c1); |
| 580 } | 584 } |
| 581 } | 585 } |
| 582 } | 586 } |
| 583 | 587 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 bool harmony_classes_; | 752 bool harmony_classes_; |
| 749 // Whether we scan TEMPLATE_SPAN and TEMPLATE_TAIL | 753 // Whether we scan TEMPLATE_SPAN and TEMPLATE_TAIL |
| 750 bool harmony_templates_; | 754 bool harmony_templates_; |
| 751 // Whether we allow \u{xxxxx}. | 755 // Whether we allow \u{xxxxx}. |
| 752 bool harmony_unicode_; | 756 bool harmony_unicode_; |
| 753 }; | 757 }; |
| 754 | 758 |
| 755 } } // namespace v8::internal | 759 } } // namespace v8::internal |
| 756 | 760 |
| 757 #endif // V8_SCANNER_H_ | 761 #endif // V8_SCANNER_H_ |
| OLD | NEW |