| Index: sdk/lib/_internal/compiler/implementation/lib/interceptors.dart
|
| diff --git a/sdk/lib/_internal/compiler/implementation/lib/interceptors.dart b/sdk/lib/_internal/compiler/implementation/lib/interceptors.dart
|
| index 690fb093a69e160d1f1a472a0f1056f9e57adde6..8085d380727d871e39a13b5700c6a8696044db97 100644
|
| --- a/sdk/lib/_internal/compiler/implementation/lib/interceptors.dart
|
| +++ b/sdk/lib/_internal/compiler/implementation/lib/interceptors.dart
|
| @@ -15,7 +15,7 @@
|
| class JSString implements String {
|
| const JSString();
|
|
|
| - int charCodeAt(index) {
|
| + int codeUnitAt(index) {
|
| if (index is !num) throw new ArgumentError(index);
|
| if (index < 0) throw new RangeError.value(index);
|
| if (index >= length) throw new RangeError.value(index);
|
| @@ -88,10 +88,32 @@ class JSString implements String {
|
| return JS('String', r'#.trim()', this);
|
| }
|
|
|
| - List<int> get charCodes {
|
| + int charCodeAt(int index) {
|
| + if (index is !num) throw new ArgumentError(index);
|
| + if (index < 0) throw new RangeError.value(index);
|
| + if (index >= length) throw new RangeError.value(index);
|
| + int codeUnit = JS('int', r'#.charCodeAt(#)', this, index);
|
| + if (codeUnit < 0xd800 || codeUnit >= 0xe000) return codeUnit;
|
| + if (index + 1 == length) return codeUnit;
|
| + int codeUnit2 = JS('int', r'#.charCodeAt(#)', this, index + 1);
|
| + return 0x10000 + ((codeUnit & 0x3ff) << 10) + (codeUnit2 & 0x3ff);
|
| + }
|
| +
|
| + List<int> get codeUnits {
|
| List<int> result = new List<int>(length);
|
| for (int i = 0; i < length; i++) {
|
| - result[i] = charCodeAt(i);
|
| + result[i] = JS('int', r'#.charCodeAt(#)', this, i);
|
| + }
|
| + return result;
|
| + }
|
| +
|
| + List<int> get charCodes {
|
| + int len = length;
|
| + List<int> result = <int>[];
|
| + for (int i = 0, j = 0; i < len; i++, j++) {
|
| + int code = charCodeAt(i);
|
| + if (code >= 0x10000) i++;
|
| + result.add(code);
|
| }
|
| return result;
|
| }
|
|
|