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

Unified Diff: dart/frog/leg/lib/js_helper.dart

Issue 9426040: Improve String and RegExp implementations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: changes Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | dart/frog/leg/lib/mockimpl.dart » ('j') | dart/frog/leg/lib/mockimpl.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/frog/leg/lib/js_helper.dart
diff --git a/dart/frog/leg/lib/js_helper.dart b/dart/frog/leg/lib/js_helper.dart
index c81baafc7f2a0e2ed6f55f7b9096546e5440339c..d81866088c875a671399a787d88b57d9284a09ba 100644
--- a/dart/frog/leg/lib/js_helper.dart
+++ b/dart/frog/leg/lib/js_helper.dart
@@ -8,6 +8,7 @@
#source('date_helper.dart');
#source('regexp_helper.dart');
+#source('string_helper.dart');
/**
* Returns true if both arguments are numbers.
@@ -948,8 +949,8 @@ builtin$toRadixString$1(receiver, radix) {
builtin$allMatches$1(receiver, str) {
checkNull(receiver);
if (receiver is !String) return UNINTERCEPTED(receiver.allMatches(str));
-
- throw 'String.allMatches is not implemented';
+ checkString(str);
+ return allMatchesInStringUnchecked(receiver, str);
}
builtin$concat$1(receiver, other) {
@@ -960,19 +961,21 @@ builtin$concat$1(receiver, other) {
return JS('String', @'$0.concat($1)', receiver, other);
}
+builtin$contains$1(receiver, other) {
+ if (receiver is !String) {
+ checkNull(receiver);
+ return UNINTERCEPTED(receiver.contains(other));
+ }
+ return builtin$contains$2(receiver, other, 0);
+}
+
builtin$contains$2(receiver, other, startIndex) {
checkNull(receiver);
if (receiver is !String) {
return UNINTERCEPTED(receiver.contains(other, startIndex));
}
checkNull(other);
- if (other is !String) {
- throw 'String.contains with non-String is not implemented';
- }
- if ((startIndex !== null) && (startIndex is !num)) {
- throw new IllegalArgumentException(startIndex);
- }
- return receiver.indexOf(other, startIndex) >= 0;
+ return stringContainsUnchecked(receiver, other, startIndex);
}
builtin$endsWith$1(receiver, other) {
@@ -992,7 +995,9 @@ builtin$replaceAll$2(receiver, from, to) {
checkNull(receiver);
if (receiver is !String) return UNINTERCEPTED(receiver.replaceAll(from, to));
- throw 'String.replaceAll is not implemented';
+ checkNull(from);
+ checkString(to);
+ return stringReplaceAllUnchecked(receiver, from, to);
}
builtin$replaceFirst$2(receiver, from, to) {
@@ -1000,19 +1005,16 @@ builtin$replaceFirst$2(receiver, from, to) {
if (receiver is !String) {
return UNINTERCEPTED(receiver.replaceFirst(from, to));
}
- if (from is !String) throw new IllegalArgumentException(from);
- if (to is !String) throw new IllegalArgumentException(to);
-
- return JS('String', @'$0.replace($1, $2)', receiver, from, to);
+ checkNull(from);
+ checkString(to);
+ return stringReplaceFirstUnchecked(receiver, from, to);
}
builtin$split$1(receiver, pattern) {
checkNull(receiver);
if (receiver is !String) return UNINTERCEPTED(receiver.split(pattern));
checkNull(pattern);
- if (pattern is !String) throw new IllegalArgumentException(pattern);
-
- return JS('List', @'$0.split($1)', receiver, pattern);
+ return stringSplitUnchecked(receiver, pattern);
}
builtin$splitChars$0(receiver) {
« no previous file with comments | « no previous file | dart/frog/leg/lib/mockimpl.dart » ('j') | dart/frog/leg/lib/mockimpl.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698