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 _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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 'returns:String;effects:none;depends:none;throws:null(1)', | 163 'returns:String;effects:none;depends:none;throws:null(1)', |
164 r'#.toLowerCase()', this); | 164 r'#.toLowerCase()', this); |
165 } | 165 } |
166 | 166 |
167 String toUpperCase() { | 167 String toUpperCase() { |
168 return JS( | 168 return JS( |
169 'returns:String;effects:none;depends:none;throws:null(1)', | 169 'returns:String;effects:none;depends:none;throws:null(1)', |
170 r'#.toUpperCase()', this); | 170 r'#.toUpperCase()', this); |
171 } | 171 } |
172 | 172 |
173 // Characters with Whitespace property (Unicode 6.2). | 173 // Characters with Whitespace property (Unicode 6.3). |
174 // 0009..000D ; White_Space # Cc <control-0009>..<control-000D> | 174 // 0009..000D ; White_Space # Cc <control-0009>..<control-000D> |
175 // 0020 ; White_Space # Zs SPACE | 175 // 0020 ; White_Space # Zs SPACE |
176 // 0085 ; White_Space # Cc <control-0085> | 176 // 0085 ; White_Space # Cc <control-0085> |
177 // 00A0 ; White_Space # Zs NO-BREAK SPACE | 177 // 00A0 ; White_Space # Zs NO-BREAK SPACE |
178 // 1680 ; White_Space # Zs OGHAM SPACE MARK | 178 // 1680 ; White_Space # Zs OGHAM SPACE MARK |
179 // 180E ; White_Space # Zs MONGOLIAN VOWEL SEPARATOR | |
180 // 2000..200A ; White_Space # Zs EN QUAD..HAIR SPACE | 179 // 2000..200A ; White_Space # Zs EN QUAD..HAIR SPACE |
181 // 2028 ; White_Space # Zl LINE SEPARATOR | 180 // 2028 ; White_Space # Zl LINE SEPARATOR |
182 // 2029 ; White_Space # Zp PARAGRAPH SEPARATOR | 181 // 2029 ; White_Space # Zp PARAGRAPH SEPARATOR |
183 // 202F ; White_Space # Zs NARROW NO-BREAK SPACE | 182 // 202F ; White_Space # Zs NARROW NO-BREAK SPACE |
184 // 205F ; White_Space # Zs MEDIUM MATHEMATICAL SPACE | 183 // 205F ; White_Space # Zs MEDIUM MATHEMATICAL SPACE |
185 // 3000 ; White_Space # Zs IDEOGRAPHIC SPACE | 184 // 3000 ; White_Space # Zs IDEOGRAPHIC SPACE |
186 // | 185 // |
187 // BOM: 0xFEFF | 186 // BOM: 0xFEFF |
188 static bool _isWhitespace(int codeUnit) { | 187 static bool _isWhitespace(int codeUnit) { |
189 // Most codeUnits should be less than 256. Special case with a smaller | 188 // Most codeUnits should be less than 256. Special case with a smaller |
190 // switch. | 189 // switch. |
191 if (codeUnit < 256) { | 190 if (codeUnit < 256) { |
192 switch (codeUnit) { | 191 switch (codeUnit) { |
193 case 0x09: | 192 case 0x09: |
194 case 0x0A: | 193 case 0x0A: |
195 case 0x0B: | 194 case 0x0B: |
196 case 0x0C: | 195 case 0x0C: |
197 case 0x0D: | 196 case 0x0D: |
198 case 0x20: | 197 case 0x20: |
199 case 0x85: | 198 case 0x85: |
200 case 0xA0: | 199 case 0xA0: |
201 return true; | 200 return true; |
202 default: | 201 default: |
203 return false; | 202 return false; |
204 } | 203 } |
205 } | 204 } |
206 switch (codeUnit) { | 205 switch (codeUnit) { |
207 case 0x1680: | 206 case 0x1680: |
208 case 0x180E: | |
209 case 0x2000: | 207 case 0x2000: |
210 case 0x2001: | 208 case 0x2001: |
211 case 0x2002: | 209 case 0x2002: |
212 case 0x2003: | 210 case 0x2003: |
213 case 0x2004: | 211 case 0x2004: |
214 case 0x2005: | 212 case 0x2005: |
215 case 0x2006: | 213 case 0x2006: |
216 case 0x2007: | 214 case 0x2007: |
217 case 0x2008: | 215 case 0x2008: |
218 case 0x2009: | 216 case 0x2009: |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 Type get runtimeType => String; | 465 Type get runtimeType => String; |
468 | 466 |
469 int get length => JS('int', r'#.length', this); | 467 int get length => JS('int', r'#.length', this); |
470 | 468 |
471 String operator [](int index) { | 469 String operator [](int index) { |
472 if (index is !int) throw diagnoseIndexError(this, index); | 470 if (index is !int) throw diagnoseIndexError(this, index); |
473 if (index >= length || index < 0) throw diagnoseIndexError(this, index); | 471 if (index >= length || index < 0) throw diagnoseIndexError(this, index); |
474 return JS('String', '#[#]', this, index); | 472 return JS('String', '#[#]', this, index); |
475 } | 473 } |
476 } | 474 } |
OLD | NEW |