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

Unified Diff: lib/compiler/implementation/lib/mockimpl.dart

Issue 10880020: Use patching for regexp implementation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Real VM fix from Ivan. Created 8 years, 4 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 | « lib/compiler/implementation/lib/coreimpl_patch.dart ('k') | runtime/lib/lib_impl_sources.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/lib/mockimpl.dart
diff --git a/lib/compiler/implementation/lib/mockimpl.dart b/lib/compiler/implementation/lib/mockimpl.dart
index 90f084ee82309edf106a982741a7633eb1658328..e3484cc7084cb31deb9c8b087178725221e2ac4a 100644
--- a/lib/compiler/implementation/lib/mockimpl.dart
+++ b/lib/compiler/implementation/lib/mockimpl.dart
@@ -6,123 +6,6 @@
// TODO(ahe): Remove this file.
-class JSSyntaxRegExp implements RegExp {
- final String pattern;
- final bool multiLine;
- final bool ignoreCase;
-
- const JSSyntaxRegExp(String pattern,
- [bool multiLine = false, bool ignoreCase = false])
- : this.pattern = pattern,
- this.multiLine = multiLine,
- this.ignoreCase = ignoreCase;
-
- JSSyntaxRegExp._globalVersionOf(JSSyntaxRegExp other)
- : this.pattern = other.pattern,
- this.multiLine = other.multiLine,
- this.ignoreCase = other.ignoreCase {
- regExpAttachGlobalNative(this);
- }
-
- Match firstMatch(String str) {
- List<String> m = regExpExec(this, checkString(str));
- if (m === null) return null;
- var matchStart = regExpMatchStart(m);
- // m.lastIndex only works with flag 'g'.
- var matchEnd = matchStart + m[0].length;
- return new MatchImplementation(pattern, str, matchStart, matchEnd, m);
- }
-
- bool hasMatch(String str) => regExpTest(this, checkString(str));
-
- String stringMatch(String str) {
- var match = firstMatch(str);
- return match === null ? null : match.group(0);
- }
-
- Iterable<Match> allMatches(String str) {
- checkString(str);
- return new _AllMatchesIterable(this, str);
- }
-
- _getNative() => regExpGetNative(this);
-}
-
-class MatchImplementation implements Match {
- const MatchImplementation(
- String this.pattern,
- String this.str,
- int this._start,
- int this._end,
- List<String> this._groups);
-
- final String pattern;
- final String str;
- final int _start;
- final int _end;
- final List<String> _groups;
-
- int start() => _start;
- int end() => _end;
- String group(int index) => _groups[index];
- String operator [](int index) => group(index);
- int groupCount() => _groups.length - 1;
-
- List<String> groups(List<int> groups) {
- List<String> out = [];
- for (int i in groups) {
- out.add(group(i));
- }
- return out;
- }
-}
-
-class _AllMatchesIterable implements Iterable<Match> {
- final JSSyntaxRegExp _re;
- final String _str;
-
- const _AllMatchesIterable(this._re, this._str);
-
- Iterator<Match> iterator() => new _AllMatchesIterator(_re, _str);
-}
-
-class _AllMatchesIterator implements Iterator<Match> {
- final RegExp _re;
- final String _str;
- Match _next;
- bool _done;
-
- _AllMatchesIterator(JSSyntaxRegExp re, String this._str)
- : _done = false, _re = new JSSyntaxRegExp._globalVersionOf(re);
-
- Match next() {
- if (!hasNext()) {
- throw const NoMoreElementsException();
- }
-
- // _next is set by #hasNext
- var next = _next;
- _next = null;
- return next;
- }
-
- bool hasNext() {
- if (_done) {
- return false;
- } else if (_next != null) {
- return true;
- }
-
- _next = _re.firstMatch(_str);
- if (_next == null) {
- _done = true;
- return false;
- } else {
- return true;
- }
- }
-}
-
class ReceivePortFactory {
factory ReceivePort() {
throw 'factory ReceivePort is not implemented';
« no previous file with comments | « lib/compiler/implementation/lib/coreimpl_patch.dart ('k') | runtime/lib/lib_impl_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698