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 part of dart._interceptors; | 5 part of dart._interceptors; |
6 | 6 |
7 /** | 7 /** |
8 * The interceptor class for [String]. The compiler recognizes this | 8 * The interceptor class for [String]. The compiler recognizes this |
9 * class as an interceptor, and changes references to [:this:] to | 9 * class as an interceptor, and changes references to [:this:] to |
10 * actually use the receiver of the method, which is generated as an extra | 10 * actually use the receiver of the method, which is generated as an extra |
11 * argument added to each member. | 11 * argument added to each member. |
12 */ | 12 */ |
13 @JsPeerInterface(name: 'String') | 13 @JsPeerInterface(name: 'String') |
14 class JSString extends Interceptor implements String, JSIndexable { | 14 class JSString extends Interceptor implements String, JSIndexable<String> { |
15 const JSString(); | 15 const JSString(); |
16 | 16 |
17 int codeUnitAt(int index) { | 17 int codeUnitAt(int index) { |
18 if (index is !int) throw diagnoseIndexError(this, index); | 18 if (index is !int) throw diagnoseIndexError(this, index); |
19 if (index < 0) throw diagnoseIndexError(this, index); | 19 if (index < 0) throw diagnoseIndexError(this, index); |
20 if (index >= length) throw diagnoseIndexError(this, index); | 20 if (index >= length) throw diagnoseIndexError(this, index); |
21 return JS('int', r'#.charCodeAt(#)', this, index); | 21 return JS('int', r'#.charCodeAt(#)', this, index); |
22 } | 22 } |
23 | 23 |
24 Iterable<Match> allMatches(String string, [int start = 0]) { | 24 Iterable<Match> allMatches(String string, [int start = 0]) { |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 Type get runtimeType => String; | 464 Type get runtimeType => String; |
465 | 465 |
466 int get length => JS('int', r'#.length', this); | 466 int get length => JS('int', r'#.length', this); |
467 | 467 |
468 String operator [](int index) { | 468 String operator [](int index) { |
469 if (index is !int) throw diagnoseIndexError(this, index); | 469 if (index is !int) throw diagnoseIndexError(this, index); |
470 if (index >= length || index < 0) throw diagnoseIndexError(this, index); | 470 if (index >= length || index < 0) throw diagnoseIndexError(this, index); |
471 return JS('String', '#[#]', this, index); | 471 return JS('String', '#[#]', this, index); |
472 } | 472 } |
473 } | 473 } |
OLD | NEW |