| 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 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 /* patch */ factory String.fromCharCode(int charCode) { |
| 11 if (charCode >= 0) { |
| 12 if (charCode <= 0xff) { |
| 13 return _OneByteString._allocate(1).._setAt(0, charCode); |
| 14 } |
| 15 if (charCode <= 0xffff) { |
| 16 return _StringBase._createFromCodePoints(new _List(1)..[0] = charCode); |
| 17 } |
| 18 if (charCode <= 0x10ffff) { |
| 19 var low = 0xDC00 | (charCode & 0x3ff); |
| 20 int bits = charCode - 0x10000; |
| 21 var high = 0xD800 | (bits >> 10); |
| 22 return _StringBase._createFromCodePoints(new _List(2)..[0] = high |
| 23 ..[1] = low); |
| 24 } |
| 25 } |
| 26 throw new RangeError.range(charCode, 0, 0x10ffff); |
| 27 } |
| 28 |
| 10 /* patch */ const factory String.fromEnvironment(String name, | 29 /* patch */ const factory String.fromEnvironment(String name, |
| 11 {String defaultValue}) | 30 {String defaultValue}) |
| 12 native "String_fromEnvironment"; | 31 native "String_fromEnvironment"; |
| 13 } | 32 } |
| 14 | 33 |
| 15 | 34 |
| 16 /** | 35 /** |
| 17 * [_StringBase] contains common methods used by concrete String | 36 * [_StringBase] contains common methods used by concrete String |
| 18 * implementations, e.g., _OneByteString. | 37 * implementations, e.g., _OneByteString. |
| 19 */ | 38 */ |
| (...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 class _CodeUnits extends Object with ListMixin<int>, | 962 class _CodeUnits extends Object with ListMixin<int>, |
| 944 UnmodifiableListMixin<int> { | 963 UnmodifiableListMixin<int> { |
| 945 /** The string that this is the code units of. */ | 964 /** The string that this is the code units of. */ |
| 946 String _string; | 965 String _string; |
| 947 | 966 |
| 948 _CodeUnits(this._string); | 967 _CodeUnits(this._string); |
| 949 | 968 |
| 950 int get length => _string.length; | 969 int get length => _string.length; |
| 951 int operator[](int i) => _string.codeUnitAt(i); | 970 int operator[](int i) => _string.codeUnitAt(i); |
| 952 } | 971 } |
| OLD | NEW |