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 _js_helper; | 5 part of _js_helper; |
6 | 6 |
7 class StringMatch implements Match { | 7 class StringMatch implements Match { |
8 const StringMatch(int this.start, | 8 const StringMatch(int this.start, |
9 String this.str, | 9 String this.str, |
10 String this.pattern); | 10 String this.pattern); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 } else { | 195 } else { |
196 checkNull(from); | 196 checkNull(from); |
197 // TODO(floitsch): implement generic String.replace (with patterns). | 197 // TODO(floitsch): implement generic String.replace (with patterns). |
198 throw "String.replace(Pattern) UNIMPLEMENTED"; | 198 throw "String.replace(Pattern) UNIMPLEMENTED"; |
199 } | 199 } |
200 } | 200 } |
201 | 201 |
202 stringJoinUnchecked(array, separator) { | 202 stringJoinUnchecked(array, separator) { |
203 return JS('String', r'#.join(#)', array, separator); | 203 return JS('String', r'#.join(#)', array, separator); |
204 } | 204 } |
205 | |
206 class JsStringBuffer implements StringBuffer { | |
207 String _contents; | |
208 | |
209 JsStringBuffer(content) | |
210 : _contents = (content is String) ? content : '$content'; | |
211 | |
212 int get length => _contents.length; | |
213 | |
214 bool get isEmpty => length == 0; | |
215 | |
216 void add(Object obj) { | |
217 _contents = JS('String', '# + #', _contents, | |
218 (obj is String) ? obj : '$obj'); | |
219 } | |
220 | |
221 void addAll(Iterable objects) { | |
222 for (Object obj in objects) add(obj); | |
223 } | |
224 | |
225 void addCharCode(int charCode) { | |
226 add(new String.fromCharCodes([charCode])); | |
227 } | |
228 | |
229 void clear() { | |
230 _contents = ""; | |
231 } | |
232 | |
233 String toString() => _contents; | |
234 } | |
OLD | NEW |