Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: src/scanner.h

Issue 640193002: Allow identifier code points from supplementary multilingual planes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/char-predicates.cc ('k') | test/intl/general/smp-identifier.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 INLINE(void AddChar(uint32_t code_unit)) { 205 INLINE(void AddChar(uint32_t code_unit)) {
206 if (position_ >= backing_store_.length()) ExpandBuffer(); 206 if (position_ >= backing_store_.length()) ExpandBuffer();
207 if (is_one_byte_) { 207 if (is_one_byte_) {
208 if (code_unit <= unibrow::Latin1::kMaxChar) { 208 if (code_unit <= unibrow::Latin1::kMaxChar) {
209 backing_store_[position_] = static_cast<byte>(code_unit); 209 backing_store_[position_] = static_cast<byte>(code_unit);
210 position_ += kOneByteSize; 210 position_ += kOneByteSize;
211 return; 211 return;
212 } 212 }
213 ConvertToTwoByte(); 213 ConvertToTwoByte();
214 } 214 }
215 DCHECK(code_unit < 0x10000u); 215 if (code_unit <= unibrow::Utf16::kMaxNonSurrogateCharCode) {
216 *reinterpret_cast<uint16_t*>(&backing_store_[position_]) = code_unit; 216 *reinterpret_cast<uint16_t*>(&backing_store_[position_]) = code_unit;
217 position_ += kUC16Size; 217 position_ += kUC16Size;
218 } else {
219 *reinterpret_cast<uint16_t*>(&backing_store_[position_]) =
220 unibrow::Utf16::LeadSurrogate(code_unit);
221 position_ += kUC16Size;
222 *reinterpret_cast<uint16_t*>(&backing_store_[position_]) =
223 unibrow::Utf16::TrailSurrogate(code_unit);
224 position_ += kUC16Size;
225 }
218 } 226 }
219 227
220 bool is_one_byte() const { return is_one_byte_; } 228 bool is_one_byte() const { return is_one_byte_; }
221 229
222 bool is_contextual_keyword(Vector<const char> keyword) const { 230 bool is_contextual_keyword(Vector<const char> keyword) const {
223 return is_one_byte() && keyword.length() == position_ && 231 return is_one_byte() && keyword.length() == position_ &&
224 (memcmp(keyword.start(), backing_store_.start(), position_) == 0); 232 (memcmp(keyword.start(), backing_store_.start(), position_) == 0);
225 } 233 }
226 234
227 Vector<const uint16_t> two_byte_literal() const { 235 Vector<const uint16_t> two_byte_literal() const {
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 inline void DropLiteral() { 520 inline void DropLiteral() {
513 next_.literal_chars = NULL; 521 next_.literal_chars = NULL;
514 } 522 }
515 523
516 inline void AddLiteralCharAdvance() { 524 inline void AddLiteralCharAdvance() {
517 AddLiteralChar(c0_); 525 AddLiteralChar(c0_);
518 Advance(); 526 Advance();
519 } 527 }
520 528
521 // Low-level scanning support. 529 // Low-level scanning support.
522 void Advance() { c0_ = source_->Advance(); } 530 void Advance() {
531 c0_ = source_->Advance();
532 if (unibrow::Utf16::IsLeadSurrogate(c0_)) {
marja 2015/01/29 15:39:38 Looks like code load doesn't like adding this bran
533 uc32 c1 = source_->Advance();
534 if (!unibrow::Utf16::IsTrailSurrogate(c1)) {
535 source_->PushBack(c1);
536 } else {
537 c0_ = unibrow::Utf16::CombineSurrogatePair(c0_, c1);
538 }
539 }
540 }
541
523 void PushBack(uc32 ch) { 542 void PushBack(uc32 ch) {
524 source_->PushBack(c0_); 543 if (ch > static_cast<uc32>(unibrow::Utf16::kMaxNonSurrogateCharCode)) {
544 source_->PushBack(unibrow::Utf16::TrailSurrogate(c0_));
545 source_->PushBack(unibrow::Utf16::LeadSurrogate(c0_));
546 } else {
547 source_->PushBack(c0_);
548 }
525 c0_ = ch; 549 c0_ = ch;
526 } 550 }
527 551
528 inline Token::Value Select(Token::Value tok) { 552 inline Token::Value Select(Token::Value tok) {
529 Advance(); 553 Advance();
530 return tok; 554 return tok;
531 } 555 }
532 556
533 inline Token::Value Select(uc32 next, Token::Value then, Token::Value else_) { 557 inline Token::Value Select(uc32 next, Token::Value then, Token::Value else_) {
534 Advance(); 558 Advance();
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 bool harmony_modules_; 678 bool harmony_modules_;
655 // Whether we scan 0o777 and 0b111 as numbers. 679 // Whether we scan 0o777 and 0b111 as numbers.
656 bool harmony_numeric_literals_; 680 bool harmony_numeric_literals_;
657 // Whether we scan 'class', 'extends', 'static' and 'super' as keywords. 681 // Whether we scan 'class', 'extends', 'static' and 'super' as keywords.
658 bool harmony_classes_; 682 bool harmony_classes_;
659 }; 683 };
660 684
661 } } // namespace v8::internal 685 } } // namespace v8::internal
662 686
663 #endif // V8_SCANNER_H_ 687 #endif // V8_SCANNER_H_
OLDNEW
« no previous file with comments | « src/char-predicates.cc ('k') | test/intl/general/smp-identifier.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698