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

Side by Side Diff: compiler/lib/implementation/string.dart

Issue 8286001: Changes "is" and equality checks to strictly check for primitive types, fix a couple of (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years, 2 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) 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 class StringImplementation implements String native "String" { 5 class StringImplementation implements String native "String" {
6 factory StringImplementation.fromValues(Array<int> values) { 6 factory StringImplementation.fromValues(Array<int> values) {
7 return _newFromValues(values); 7 return _newFromValues(values);
8 } 8 }
9 9
10 String operator[](int index) { 10 String operator[](int index) {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 138
139 Iterable<Match> allMatches(String str) { 139 Iterable<Match> allMatches(String str) {
140 List<Match> result = []; 140 List<Match> result = [];
141 if (this.isEmpty()) return result; 141 if (this.isEmpty()) return result;
142 int length = this.length; 142 int length = this.length;
143 143
144 int ix = 0; 144 int ix = 0;
145 while (ix < str.length) { 145 while (ix < str.length) {
146 int foundIx = str.indexOf(this, ix); 146 int foundIx = str.indexOf(this, ix);
147 if (foundIx < 0) break; 147 if (foundIx < 0) break;
148 result.add(new _StringMatch(foundIx, str, this)); 148 // call "toString" to coerse the "this" back to a primitive string
floitsch 2011/10/14 20:20:44 Call ... coerce ... string. (finish with dot).
John Lenz 2011/10/14 21:26:40 Done.
149 result.add(new _StringMatch(foundIx, str, this.toString()));
149 ix = foundIx + length; 150 ix = foundIx + length;
150 } 151 }
151 return result; 152 return result;
152 } 153 }
153 154
154 Array<String> splitChars() { 155 Array<String> splitChars() {
155 return _split(""); 156 return _split("");
156 } 157 }
157 158
158 Array<int> charCodes() { 159 Array<int> charCodes() {
(...skipping 18 matching lines...) Expand all
177 178
178 int compareTo(String other) native; 179 int compareTo(String other) native;
179 180
180 static String _newFromValues(Array<int> values) native; 181 static String _newFromValues(Array<int> values) native;
181 String _indexOperator(int index) native; 182 String _indexOperator(int index) native;
182 int _charCodeAt(int index) native; 183 int _charCodeAt(int index) native;
183 String _substringUnchecked(int startIndex, int endIndex) native; 184 String _substringUnchecked(int startIndex, int endIndex) native;
184 String _replace(Pattern from, String to) native; 185 String _replace(Pattern from, String to) native;
185 String _replaceAll(Pattern from, String to) native; 186 String _replaceAll(Pattern from, String to) native;
186 Array<String> _split(Pattern pattern) native; 187 Array<String> _split(Pattern pattern) native;
188
189 get dynamic() { return toString(); }
187 } 190 }
188 191
189 class _StringJsUtil { 192 class _StringJsUtil {
190 static String toDartString(o) native { 193 static String toDartString(o) native {
191 if (o === null) return "null"; 194 if (o === null) return "null";
192 return o.toString(); 195 return o.toString();
193 } 196 }
194 } 197 }
195 198
196 class _StringMatch implements Match { 199 class _StringMatch implements Match {
(...skipping 18 matching lines...) Expand all
215 for (int g in groups) { 218 for (int g in groups) {
216 result.add(group(g)); 219 result.add(group(g));
217 } 220 }
218 return result; 221 return result;
219 } 222 }
220 223
221 final int _start; 224 final int _start;
222 final String str; 225 final String str;
223 final String pattern; 226 final String pattern;
224 } 227 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698