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

Unified Diff: frog/lib/string_implementation.dart

Issue 9352016: Fix split with regexp for frog. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use existing style. 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 | frog/world.dart » ('j') | frog/world.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/lib/string_implementation.dart
diff --git a/frog/lib/string_implementation.dart b/frog/lib/string_implementation.dart
index 9d483d145ba632c2adfe7f69569e3b61bad3b534..b42409e2418a8e4b9fe483d5aea5acc691e42097 100644
--- a/frog/lib/string_implementation.dart
+++ b/frog/lib/string_implementation.dart
@@ -79,10 +79,18 @@ return this.replace(from, to);""";
}
// TODO(jimhug): Get correct reified generic list here.
- List<String> split(Pattern pattern) native {
- return []; // tell the compiler an array is created
+ List<String> split(Pattern pattern) {
+ if (pattern is String) return _split(pattern);
+ if (pattern is RegExp) return _splitRegExp(pattern);
+ throw "String.split(Pattern) unimplemented.";
}
+ List<String> _split(String pattern) native
+ "'use strict'; return this.split(pattern);";
+
+ List<String> _splitRegExp(RegExp pattern) native
+ "'use strict'; return this.split(pattern.re);";
+
/*
Iterable<Match> allMatches(String str) {
List<Match> result = [];
« no previous file with comments | « no previous file | frog/world.dart » ('j') | frog/world.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698