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

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

Issue 11348035: Move StringImplementation from coreimpl to core as _StringImpl. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 // Patch file for dart:coreimpl classes. 5 // Patch file for dart:coreimpl classes.
6 6
7 // Patch for String implementation.
8 // TODO(ager): Split out into date_patch.dart and allow #source
9 // in patch files?
10 patch class StringImplementation {
11 patch static String _fromCharCodes(List<int> charCodes) {
12 checkNull(charCodes);
13 if (!isJsArray(charCodes)) {
14 if (charCodes is !List) throw new ArgumentError(charCodes);
15 charCodes = new List.from(charCodes);
16 }
17 return Primitives.stringFromCharCodes(charCodes);
18 }
19
20 patch String join(List<String> strings, String separator) {
21 checkNull(strings);
22 checkNull(separator);
23 if (separator is !String) throw new ArgumentError(separator);
24 return stringJoinUnchecked(_toJsStringArray(strings), separator);
25 }
26
27 patch String concatAll(List<String> strings) {
28 return stringJoinUnchecked(_toJsStringArray(strings), "");
29 }
30
31 static List _toJsStringArray(List<String> strings) {
32 checkNull(strings);
33 var array;
34 final length = strings.length;
35 if (isJsArray(strings)) {
36 array = strings;
37 for (int i = 0; i < length; i++) {
38 final string = strings[i];
39 checkNull(string);
40 if (string is !String) throw new ArgumentError(string);
41 }
42 } else {
43 array = new List(length);
44 for (int i = 0; i < length; i++) {
45 final string = strings[i];
46 checkNull(string);
47 if (string is !String) throw new ArgumentError(string);
48 array[i] = string;
49 }
50 }
51 return array;
52 }
53 }
54
55
56 // Patch for RegExp implementation. 7 // Patch for RegExp implementation.
57 // TODO(ager): Split out into regexp_patch.dart and allow #source in 8 // TODO(ager): Split out into regexp_patch.dart and allow #source in
58 // patch files? 9 // patch files?
59 patch class JSSyntaxRegExp { 10 patch class JSSyntaxRegExp {
60 final String _pattern; 11 final String _pattern;
61 final bool _multiLine; 12 final bool _multiLine;
62 final bool _ignoreCase; 13 final bool _ignoreCase;
63 14
64 patch const JSSyntaxRegExp(String pattern, 15 patch const JSSyntaxRegExp(String pattern,
65 {bool multiLine: false, 16 {bool multiLine: false,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // hidden global flag. 122 // hidden global flag.
172 _next = _re.firstMatch(_str); 123 _next = _re.firstMatch(_str);
173 if (_next == null) { 124 if (_next == null) {
174 _done = true; 125 _done = true;
175 return false; 126 return false;
176 } else { 127 } else {
177 return true; 128 return true;
178 } 129 }
179 } 130 }
180 } 131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698