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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/lib/js_string.dart

Issue 12261009: Added implementation of String.codeUnits. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix typos Created 7 years, 10 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
« no previous file with comments | « sdk/lib/_collection_dev/iterable.dart ('k') | sdk/lib/core/string.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 part of _interceptors; 5 part of _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
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 142 }
143 143
144 List<int> get charCodes { 144 List<int> get charCodes {
145 List<int> result = new List<int>.fixedLength(length); 145 List<int> result = new List<int>.fixedLength(length);
146 for (int i = 0; i < length; i++) { 146 for (int i = 0; i < length; i++) {
147 result[i] = JS('int', '#.charCodeAt(#)', this, i); 147 result[i] = JS('int', '#.charCodeAt(#)', this, i);
148 } 148 }
149 return result; 149 return result;
150 } 150 }
151 151
152 Iterable<int> get codeUnits { 152 Iterable<int> get codeUnits => new CodeUnits(this);
153 throw new UnimplementedError("String.codeUnits");
154 }
155 153
156 Runes get runes => new Runes(this); 154 Runes get runes => new Runes(this);
157 155
158 int indexOf(String other, [int start = 0]) { 156 int indexOf(String other, [int start = 0]) {
159 checkNull(other); 157 checkNull(other);
160 if (start is !int) throw new ArgumentError(start); 158 if (start is !int) throw new ArgumentError(start);
161 if (other is !String) throw new ArgumentError(other); 159 if (other is !String) throw new ArgumentError(other);
162 if (start < 0) return -1; 160 if (start < 0) return -1;
163 return JS('int', r'#.indexOf(#, #)', this, other, start); 161 return JS('int', r'#.indexOf(#, #)', this, other, start);
164 } 162 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 Type get runtimeType => String; 216 Type get runtimeType => String;
219 217
220 int get length => JS('int', r'#.length', this); 218 int get length => JS('int', r'#.length', this);
221 219
222 String operator [](int index) { 220 String operator [](int index) {
223 if (index is !int) throw new ArgumentError(index); 221 if (index is !int) throw new ArgumentError(index);
224 if (index >= length || index < 0) throw new RangeError.value(index); 222 if (index >= length || index < 0) throw new RangeError.value(index);
225 return JS('String', '#[#]', this, index); 223 return JS('String', '#[#]', this, index);
226 } 224 }
227 } 225 }
OLDNEW
« no previous file with comments | « sdk/lib/_collection_dev/iterable.dart ('k') | sdk/lib/core/string.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698