OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 //String.prototype.get$length = function() { | 5 //String.prototype.get$length = function() { |
6 // return this.length; | 6 // return this.length; |
7 //} | 7 //} |
8 | 8 |
9 // TODO(jimhug): Unify with code from compiler/lib/implementation. | 9 // TODO(jimhug): Unify with code from compiler/lib/implementation. |
10 class StringImplementation implements String native "String" { | 10 class StringImplementation implements String native "String" { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 if (pattern is RegExp) return _splitRegExp(pattern); | 84 if (pattern is RegExp) return _splitRegExp(pattern); |
85 throw "String.split(Pattern) unimplemented."; | 85 throw "String.split(Pattern) unimplemented."; |
86 } | 86 } |
87 | 87 |
88 List<String> _split(String pattern) native | 88 List<String> _split(String pattern) native |
89 "'use strict'; return this.split(pattern);"; | 89 "'use strict'; return this.split(pattern);"; |
90 | 90 |
91 List<String> _splitRegExp(RegExp pattern) native | 91 List<String> _splitRegExp(RegExp pattern) native |
92 "'use strict'; return this.split(pattern.re);"; | 92 "'use strict'; return this.split(pattern.re);"; |
93 | 93 |
| 94 Iterable<Match> allMatches(String str) { |
| 95 throw "String.allMatches(String str) unimplemented."; |
| 96 } |
94 /* | 97 /* |
95 Iterable<Match> allMatches(String str) { | 98 Iterable<Match> allMatches(String str) { |
96 List<Match> result = []; | 99 List<Match> result = []; |
97 if (this.isEmpty()) return result; | 100 if (this.isEmpty()) return result; |
98 int length = this.length; | 101 int length = this.length; |
99 | 102 |
100 int ix = 0; | 103 int ix = 0; |
101 while (ix < str.length) { | 104 while (ix < str.length) { |
102 int foundIx = str.indexOf(this, ix); | 105 int foundIx = str.indexOf(this, ix); |
103 if (foundIx < 0) break; | 106 if (foundIx < 0) break; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 result.add(group(g)); | 175 result.add(group(g)); |
173 } | 176 } |
174 return result; | 177 return result; |
175 } | 178 } |
176 | 179 |
177 final int _start; | 180 final int _start; |
178 final String str; | 181 final String str; |
179 final String pattern; | 182 final String pattern; |
180 } | 183 } |
181 */ | 184 */ |
OLD | NEW |