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

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

Issue 1079253002: Use native behavior for dead code elimination (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 checkInt(startIndex); 152 checkInt(startIndex);
153 if (endIndex == null) endIndex = length; 153 if (endIndex == null) endIndex = length;
154 checkInt(endIndex); 154 checkInt(endIndex);
155 if (startIndex < 0 ) throw new RangeError.value(startIndex); 155 if (startIndex < 0 ) throw new RangeError.value(startIndex);
156 if (startIndex > endIndex) throw new RangeError.value(startIndex); 156 if (startIndex > endIndex) throw new RangeError.value(startIndex);
157 if (endIndex > length) throw new RangeError.value(endIndex); 157 if (endIndex > length) throw new RangeError.value(endIndex);
158 return JS('String', r'#.substring(#, #)', this, startIndex, endIndex); 158 return JS('String', r'#.substring(#, #)', this, startIndex, endIndex);
159 } 159 }
160 160
161 String toLowerCase() { 161 String toLowerCase() {
162 return JS('String', r'#.toLowerCase()', this); 162 return JS(
163 'returns:String;effects:none;depends:none;throws:null(1)',
164 r'#.toLowerCase()', this);
163 } 165 }
164 166
165 String toUpperCase() { 167 String toUpperCase() {
166 return JS('String', r'#.toUpperCase()', this); 168 return JS(
169 'returns:String;effects:none;depends:none;throws:null(1)',
170 r'#.toUpperCase()', this);
167 } 171 }
168 172
169 // Characters with Whitespace property (Unicode 6.2). 173 // Characters with Whitespace property (Unicode 6.2).
170 // 0009..000D ; White_Space # Cc <control-0009>..<control-000D> 174 // 0009..000D ; White_Space # Cc <control-0009>..<control-000D>
171 // 0020 ; White_Space # Zs SPACE 175 // 0020 ; White_Space # Zs SPACE
172 // 0085 ; White_Space # Cc <control-0085> 176 // 0085 ; White_Space # Cc <control-0085>
173 // 00A0 ; White_Space # Zs NO-BREAK SPACE 177 // 00A0 ; White_Space # Zs NO-BREAK SPACE
174 // 1680 ; White_Space # Zs OGHAM SPACE MARK 178 // 1680 ; White_Space # Zs OGHAM SPACE MARK
175 // 180E ; White_Space # Zs MONGOLIAN VOWEL SEPARATOR 179 // 180E ; White_Space # Zs MONGOLIAN VOWEL SEPARATOR
176 // 2000..200A ; White_Space # Zs EN QUAD..HAIR SPACE 180 // 2000..200A ; White_Space # Zs EN QUAD..HAIR SPACE
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 return stringContainsUnchecked(this, other, startIndex); 431 return stringContainsUnchecked(this, other, startIndex);
428 } 432 }
429 433
430 bool get isEmpty => length == 0; 434 bool get isEmpty => length == 0;
431 435
432 bool get isNotEmpty => !isEmpty; 436 bool get isNotEmpty => !isEmpty;
433 437
434 int compareTo(String other) { 438 int compareTo(String other) {
435 if (other is !String) throw new ArgumentError(other); 439 if (other is !String) throw new ArgumentError(other);
436 return this == other ? 0 440 return this == other ? 0
437 : JS('bool', r'# < #', this, other) ? -1 : 1; 441 : JS('bool', r'# < #', this, other) ? -1 : 1;
438 } 442 }
439 443
440 // Note: if you change this, also change the function [S]. 444 // Note: if you change this, also change the function [S].
441 String toString() => this; 445 String toString() => this;
442 446
443 /** 447 /**
444 * This is the [Jenkins hash function][1] but using masking to keep 448 * This is the [Jenkins hash function][1] but using masking to keep
445 * values in SMI range. 449 * values in SMI range.
446 * 450 *
447 * [1]: http://en.wikipedia.org/wiki/Jenkins_hash_function 451 * [1]: http://en.wikipedia.org/wiki/Jenkins_hash_function
(...skipping 15 matching lines...) Expand all
463 Type get runtimeType => String; 467 Type get runtimeType => String;
464 468
465 int get length => JS('int', r'#.length', this); 469 int get length => JS('int', r'#.length', this);
466 470
467 String operator [](int index) { 471 String operator [](int index) {
468 if (index is !int) throw new ArgumentError(index); 472 if (index is !int) throw new ArgumentError(index);
469 if (index >= length || index < 0) throw new RangeError.value(index); 473 if (index >= length || index < 0) throw new RangeError.value(index);
470 return JS('String', '#[#]', this, index); 474 return JS('String', '#[#]', this, index);
471 } 475 }
472 } 476 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698