| 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 /** | 5 /** |
| 6 * [_StringBase] contains common methods used by concrete String | 6 * [_StringBase] contains common methods used by concrete String |
| 7 * implementations, e.g., _OneByteString. | 7 * implementations, e.g., _OneByteString. |
| 8 */ | 8 */ |
| 9 class _StringBase { | 9 class _StringBase { |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 return _createFromCodePoints(objectArray); | 33 return _createFromCodePoints(objectArray); |
| 34 } | 34 } |
| 35 | 35 |
| 36 static String _createFromCodePoints(List<int> codePoints) | 36 static String _createFromCodePoints(List<int> codePoints) |
| 37 native "StringBase_createFromCodePoints"; | 37 native "StringBase_createFromCodePoints"; |
| 38 | 38 |
| 39 String operator [](int index) native "String_charAt"; | 39 String operator [](int index) native "String_charAt"; |
| 40 | 40 |
| 41 int charCodeAt(int index) native "String_charCodeAt"; | 41 int charCodeAt(int index) native "String_charCodeAt"; |
| 42 | 42 |
| 43 int codeUnitAt(int index) { |
| 44 return charCodeAt(index); |
| 45 } |
| 46 |
| 43 int get length native "String_getLength"; | 47 int get length native "String_getLength"; |
| 44 | 48 |
| 45 bool get isEmpty { | 49 bool get isEmpty { |
| 46 return this.length == 0; | 50 return this.length == 0; |
| 47 } | 51 } |
| 48 | 52 |
| 49 String concat(String other) native "String_concat"; | 53 String concat(String other) native "String_concat"; |
| 50 | 54 |
| 51 String toString() { | 55 String toString() { |
| 52 return this; | 56 return this; |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 | 426 |
| 423 List<int> get charCodes { | 427 List<int> get charCodes { |
| 424 int len = this.length; | 428 int len = this.length; |
| 425 final result = new List<int>.fixedLength(len); | 429 final result = new List<int>.fixedLength(len); |
| 426 for (int i = 0; i < len; i++) { | 430 for (int i = 0; i < len; i++) { |
| 427 result[i] = this.charCodeAt(i); | 431 result[i] = this.charCodeAt(i); |
| 428 } | 432 } |
| 429 return result; | 433 return result; |
| 430 } | 434 } |
| 431 | 435 |
| 436 Iterable<int> get codeUnits { |
| 437 throw new UnimplementedError("String.codeUnits"); |
| 438 } |
| 439 |
| 440 Iterable<int> get runes { |
| 441 throw new UnimplementedError("String.runes"); |
| 442 } |
| 443 |
| 432 String toUpperCase() native "String_toUpperCase"; | 444 String toUpperCase() native "String_toUpperCase"; |
| 433 | 445 |
| 434 String toLowerCase() native "String_toLowerCase"; | 446 String toLowerCase() native "String_toLowerCase"; |
| 435 | 447 |
| 436 // Implementations of Strings methods follow below. | 448 // Implementations of Strings methods follow below. |
| 437 static String join(Iterable<String> strings, String separator) { | 449 static String join(Iterable<String> strings, String separator) { |
| 438 bool first = true; | 450 bool first = true; |
| 439 List<String> stringsList = <String>[]; | 451 List<String> stringsList = <String>[]; |
| 440 for (String string in strings) { | 452 for (String string in strings) { |
| 441 if (first) { | 453 if (first) { |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 for (int g in groups) { | 624 for (int g in groups) { |
| 613 result.add(group(g)); | 625 result.add(group(g)); |
| 614 } | 626 } |
| 615 return result; | 627 return result; |
| 616 } | 628 } |
| 617 | 629 |
| 618 final int start; | 630 final int start; |
| 619 final String str; | 631 final String str; |
| 620 final String pattern; | 632 final String pattern; |
| 621 } | 633 } |
| OLD | NEW |