OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/scanner.h" | 5 #include "vm/scanner.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
9 #include "vm/object.h" | 9 #include "vm/object.h" |
10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 } | 522 } |
523 if (is_valid && | 523 if (is_valid && |
524 ((*code_point > 0x10FFFF) || | 524 ((*code_point > 0x10FFFF) || |
525 ((*code_point & 0xFFFFF800) == 0xD800))) { | 525 ((*code_point & 0xFFFFF800) == 0xD800))) { |
526 ErrorMsg("invalid code point"); | 526 ErrorMsg("invalid code point"); |
527 } | 527 } |
528 } | 528 } |
529 | 529 |
530 | 530 |
531 void Scanner::ScanLiteralStringChars(bool is_raw) { | 531 void Scanner::ScanLiteralStringChars(bool is_raw) { |
532 GrowableArray<uint16_t> string_chars(64); | 532 GrowableArray<uint32_t> string_chars(64); |
533 | 533 |
534 ASSERT(IsScanningString()); | 534 ASSERT(IsScanningString()); |
535 // We are at the first character of a string literal piece. A string literal | 535 // We are at the first character of a string literal piece. A string literal |
536 // can be broken up into multiple pieces by string interpolation. | 536 // can be broken up into multiple pieces by string interpolation. |
537 while (true) { | 537 while (true) { |
538 if ((c0_ == '\0') || ((c0_ == '\n') && !string_is_multiline_)) { | 538 if ((c0_ == '\0') || ((c0_ == '\n') && !string_is_multiline_)) { |
539 ErrorMsg("unterminated string literal"); | 539 ErrorMsg("unterminated string literal"); |
540 EndStringLiteral(); | 540 EndStringLiteral(); |
541 return; | 541 return; |
542 } | 542 } |
(...skipping 15 matching lines...) Expand all Loading... |
558 escape_char = '\t'; | 558 escape_char = '\t'; |
559 break; | 559 break; |
560 case 'b': | 560 case 'b': |
561 escape_char = '\b'; | 561 escape_char = '\b'; |
562 break; | 562 break; |
563 case 'v': | 563 case 'v': |
564 escape_char = '\v'; | 564 escape_char = '\v'; |
565 break; | 565 break; |
566 case 'u': | 566 case 'u': |
567 case 'x': { | 567 case 'x': { |
568 uint32_t ch; | 568 ScanEscapedCodePoint(&escape_char); |
569 ScanEscapedCodePoint(&ch); | |
570 int32_t code_point = ch; | |
571 if (code_point > Utf16::kMaxCodeUnit) { | |
572 string_chars.Add(Utf16::LeadFromCodePoint(code_point)); | |
573 escape_char = Utf16::TrailFromCodePoint(code_point); | |
574 } else { | |
575 escape_char = code_point; | |
576 } | |
577 break; | 569 break; |
578 } | 570 } |
579 default: | 571 default: |
580 if ((c0_ == '\0') || ((c0_ == '\n') && !string_is_multiline_)) { | 572 if ((c0_ == '\0') || ((c0_ == '\n') && !string_is_multiline_)) { |
581 ErrorMsg("unterminated string literal"); | 573 ErrorMsg("unterminated string literal"); |
582 EndStringLiteral(); | 574 EndStringLiteral(); |
583 return; | 575 return; |
584 } | 576 } |
585 escape_char = c0_; | 577 escape_char = c0_; |
586 break; | 578 break; |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 "%c%#"Px"", kPrivateKeySeparator, key_value); | 986 "%c%#"Px"", kPrivateKeySeparator, key_value); |
995 const String& result = String::Handle(String::New(private_key, Heap::kOld)); | 987 const String& result = String::Handle(String::New(private_key, Heap::kOld)); |
996 return result.raw(); | 988 return result.raw(); |
997 } | 989 } |
998 | 990 |
999 | 991 |
1000 void Scanner::InitOnce() { | 992 void Scanner::InitOnce() { |
1001 } | 993 } |
1002 | 994 |
1003 } // namespace dart | 995 } // namespace dart |
OLD | NEW |