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

Side by Side Diff: runtime/lib/string_patch.dart

Issue 15333006: Rewrite double.parse. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add parenthesis. Created 7 years, 7 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
OLDNEW
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 patch class String { 5 patch class String {
6 /* patch */ factory String.fromCharCodes(Iterable<int> charCodes) { 6 /* patch */ factory String.fromCharCodes(Iterable<int> charCodes) {
7 return _StringBase.createFromCharCodes(charCodes); 7 return _StringBase.createFromCharCodes(charCodes);
8 } 8 }
9 } 9 }
10 10
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 static final int _classId = "A"._cid; 504 static final int _classId = "A"._cid;
505 505
506 factory _OneByteString._uninstantiable() { 506 factory _OneByteString._uninstantiable() {
507 throw new UnsupportedError( 507 throw new UnsupportedError(
508 "_OneByteString can only be allocated by the VM"); 508 "_OneByteString can only be allocated by the VM");
509 } 509 }
510 510
511 int get hashCode native "String_getHashCode"; 511 int get hashCode native "String_getHashCode";
512 512
513 // Checks for one-byte whitespaces only. 513 // Checks for one-byte whitespaces only.
514 // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
515 // whitespaces for one byte strings.
516 bool _isWhitespace(int codePoint) { 514 bool _isWhitespace(int codePoint) {
517 return 515 return
518 (codePoint == 32) || // Space. 516 (codePoint == 32) || // Space.
519 ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc. 517 ((9 <= codePoint) && (codePoint <= 13)) || // CR, LF, TAB, etc.
518 (codePoint == 0xA0); // NBSP.
520 } 519 }
521 520
522 String _substringUncheckedNative(int startIndex, int endIndex) 521 String _substringUncheckedNative(int startIndex, int endIndex)
523 native "OneByteString_substringUnchecked"; 522 native "OneByteString_substringUnchecked";
524 523
525 List<String> _splitWithCharCode(int charCode) 524 List<String> _splitWithCharCode(int charCode)
526 native "OneByteString_splitWithCharCode"; 525 native "OneByteString_splitWithCharCode";
527 526
528 List<String> split(Pattern pattern) { 527 List<String> split(Pattern pattern) {
529 if ((pattern._cid == _OneByteString._classId) && (pattern.length == 1)) { 528 if ((pattern._cid == _OneByteString._classId) && (pattern.length == 1)) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 void _setAt(int index, int codePoint) native "OneByteString_setAt"; 560 void _setAt(int index, int codePoint) native "OneByteString_setAt";
562 } 561 }
563 562
564 563
565 class _TwoByteString extends _StringBase implements String { 564 class _TwoByteString extends _StringBase implements String {
566 factory _TwoByteString._uninstantiable() { 565 factory _TwoByteString._uninstantiable() {
567 throw new UnsupportedError( 566 throw new UnsupportedError(
568 "_TwoByteString can only be allocated by the VM"); 567 "_TwoByteString can only be allocated by the VM");
569 } 568 }
570 569
571 // Checks for one-byte whitespaces only. 570 // Characters in the Zl category:
572 // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid 571 // U+0020 SPACE
573 // whitespaces. Add checking for multi-byte whitespace codepoints. 572 // U+00A0 NO-BREAK SPACE
573 // U+1680 OGHAM SPACE MARK
574 // U+180E MONGOLIAN VOWEL SEPARATOR
575 // U+2000 EN QUAD
576 // U+2001 EM QUAD
577 // U+2002 EN SPACE
578 // U+2003 EM SPACE
579 // U+2004 THREE-PER-EM SPACE
580 // U+2005 FOUR-PER-EM SPACE
581 // U+2006 SIX-PER-EM SPACE
582 // U+2007 FIGURE SPACE
583 // U+2008 PUNCTUATION SPACE
584 // U+2009 THIN SPACE
585 // U+200A HAIR SPACE
586 // U+202F NARROW NO-BREAK SPACE
587 // U+205F MEDIUM MATHEMATICAL SPACE
588 // U+3000 IDEOGRAPHIC SPACE
589 //
590 // Characters in the Zl category: 0x2028
591 // Characters in the Zp category: 0x2029
592 // BOM: 0xFEFF
574 bool _isWhitespace(int codePoint) { 593 bool _isWhitespace(int codePoint) {
575 return 594 return
576 (codePoint == 32) || // Space. 595 (codePoint == 32) || // Space.
577 ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc. 596 ((9 <= codePoint) && (codePoint <= 13)) || // CR, LF, TAB, etc.
597 (codePoint == 0xA0) || // NBSP.
598 // Characters in the Zs category:
599 (codePoint == 0x1680) ||
600 (codePoint == 0x180E) ||
601 ((0x2000 <= codePoint) && (codePoint <= 0x200A)) ||
602 (codePoint == 0x202F) ||
603 (codePoint == 0x205F) ||
604 (codePoint == 0x3000) ||
605 (codePoint == 0x2028) ||
606 (codePoint == 0x2029) ||
607 (codePoint == 0xFEFF);
578 } 608 }
579 } 609 }
580 610
581 611
582 class _FourByteString extends _StringBase implements String { 612 class _FourByteString extends _StringBase implements String {
583 factory _FourByteString._uninstantiable() { 613 factory _FourByteString._uninstantiable() {
584 throw new UnsupportedError( 614 throw new UnsupportedError(
585 "_FourByteString can only be allocated by the VM"); 615 "_FourByteString can only be allocated by the VM");
586 } 616 }
587 617
588 // Checks for one-byte whitespaces only.
589 // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
590 // whitespaces. Add checking for multi-byte whitespace codepoints.
591 bool _isWhitespace(int codePoint) { 618 bool _isWhitespace(int codePoint) {
592 return 619 return
593 (codePoint == 32) || // Space. 620 (codePoint == 32) || // Space.
594 ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc. 621 ((9 <= codePoint) && (codePoint <= 13)) || // CR, LF, TAB, etc.
622 (codePoint == 0xA0) || // NBSP.
623 // Characters in the Zs category:
624 (codePoint == 0x1680) ||
625 (codePoint == 0x180E) ||
626 ((0x2000 <= codePoint) && (codePoint <= 0x200A)) ||
627 (codePoint == 0x202F) ||
628 (codePoint == 0x205F) ||
629 (codePoint == 0x3000) ||
630 (codePoint == 0x2028) ||
631 (codePoint == 0x2029) ||
632 (codePoint == 0xFEFF);
595 } 633 }
596 } 634 }
597 635
598 636
599 class _ExternalOneByteString extends _StringBase implements String { 637 class _ExternalOneByteString extends _StringBase implements String {
600 factory _ExternalOneByteString._uninstantiable() { 638 factory _ExternalOneByteString._uninstantiable() {
601 throw new UnsupportedError( 639 throw new UnsupportedError(
602 "_ExternalOneByteString can only be allocated by the VM"); 640 "_ExternalOneByteString can only be allocated by the VM");
603 } 641 }
604 642
605 // Checks for one-byte whitespaces only. 643 // Checks for one-byte whitespaces only.
606 // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
607 // whitespaces for one byte strings.
608 bool _isWhitespace(int codePoint) { 644 bool _isWhitespace(int codePoint) {
609 return 645 return
610 (codePoint == 32) || // Space. 646 (codePoint == 32) || // Space.
611 ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc. 647 ((9 <= codePoint) && (codePoint <= 13)) || // CR, LF, TAB, etc.
648 (codePoint == 0xA0); // NBSP.
612 } 649 }
613 } 650 }
614 651
615 652
616 class _ExternalTwoByteString extends _StringBase implements String { 653 class _ExternalTwoByteString extends _StringBase implements String {
617 factory _ExternalTwoByteString._uninstantiable() { 654 factory _ExternalTwoByteString._uninstantiable() {
618 throw new UnsupportedError( 655 throw new UnsupportedError(
619 "_ExternalTwoByteString can only be allocated by the VM"); 656 "_ExternalTwoByteString can only be allocated by the VM");
620 } 657 }
621 658
622 // Checks for one-byte whitespaces only.
623 // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
624 // whitespaces. Add checking for multi-byte whitespace codepoints.
625 bool _isWhitespace(int codePoint) { 659 bool _isWhitespace(int codePoint) {
626 return 660 return
627 (codePoint == 32) || // Space. 661 (codePoint == 32) || // Space.
628 ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc. 662 ((9 <= codePoint) && (codePoint <= 13)) || // CR, LF, TAB, etc.
663 (codePoint == 0xA0) || // NBSP.
664 // Characters in the Zs category:
665 (codePoint == 0x1680) ||
666 (codePoint == 0x180E) ||
667 ((0x2000 <= codePoint) && (codePoint <= 0x200A)) ||
668 (codePoint == 0x202F) ||
669 (codePoint == 0x205F) ||
670 (codePoint == 0x3000) ||
671 (codePoint == 0x2028) ||
672 (codePoint == 0x2029) ||
673 (codePoint == 0xFEFF);
629 } 674 }
630 } 675 }
631 676
632 677
633 class _StringMatch implements Match { 678 class _StringMatch implements Match {
634 const _StringMatch(int this.start, 679 const _StringMatch(int this.start,
635 String this.str, 680 String this.str,
636 String this.pattern); 681 String this.pattern);
637 682
638 int get end => start + pattern.length; 683 int get end => start + pattern.length;
(...skipping 26 matching lines...) Expand all
665 class _CodeUnits extends Object with ListMixin<int>, 710 class _CodeUnits extends Object with ListMixin<int>,
666 UnmodifiableListMixin<int> { 711 UnmodifiableListMixin<int> {
667 /** The string that this is the code units of. */ 712 /** The string that this is the code units of. */
668 String _string; 713 String _string;
669 714
670 _CodeUnits(this._string); 715 _CodeUnits(this._string);
671 716
672 int get length => _string.length; 717 int get length => _string.length;
673 int operator[](int i) => _string.codeUnitAt(i); 718 int operator[](int i) => _string.codeUnitAt(i);
674 } 719 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698