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

Side by Side Diff: runtime/lib/regexp_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 class _JSRegExpMatch implements Match { 5 class _JSRegExpMatch implements Match {
6 _JSRegExpMatch(this.regexp, this.str, this._match); 6 _JSRegExpMatch(this.regexp, this.str, this._match);
7 7
8 int get start => _start(0); 8 int get start => _start(0);
9 int get end => _end(0); 9 int get end => _end(0);
10 10
11 int _start(int groupIdx) { 11 int _start(int groupIdx) {
12 return _match[(groupIdx * MATCH_PAIR)]; 12 return _match[(groupIdx * MATCH_PAIR)];
13 } 13 }
14 14
15 int _end(int groupIdx) { 15 int _end(int groupIdx) {
16 return _match[(groupIdx * MATCH_PAIR) + 1]; 16 return _match[(groupIdx * MATCH_PAIR) + 1];
17 } 17 }
18 18
19 String group(int groupIdx) { 19 String group(int groupIdx) {
20 if (groupIdx < 0 || groupIdx > regexp._groupCount) { 20 if (groupIdx < 0 || groupIdx > regexp._groupCount) {
21 throw new IndexOutOfRangeException(groupIdx); 21 throw new IndexOutOfRangeException(groupIdx);
22 } 22 }
23 int startIndex = _start(groupIdx); 23 int startIndex = _start(groupIdx);
24 int endIndex = _end(groupIdx); 24 int endIndex = _end(groupIdx);
25 if (startIndex == -1) { 25 if (startIndex == -1) {
26 assert(endIndex == -1); 26 assert(endIndex == -1);
27 return null; 27 return null;
28 } 28 }
29 return str._substringUnchecked(startIndex, endIndex); 29 // TODO(ajohnsen): Use _substringUnchecked when regexp is in core.
30 return str.substring(startIndex, endIndex);
30 } 31 }
31 32
32 String operator [](int groupIdx) { 33 String operator [](int groupIdx) {
33 return this.group(groupIdx); 34 return this.group(groupIdx);
34 } 35 }
35 36
36 List<String> groups(List<int> groupsSpec) { 37 List<String> groups(List<int> groupsSpec) {
37 var groupsList = new List<String>(groupsSpec.length); 38 var groupsList = new List<String>(groupsSpec.length);
38 for (int i = 0; i < groupsSpec.length; i++) { 39 for (int i = 0; i < groupsSpec.length; i++) {
39 groupsList[i] = group(groupsSpec[i]); 40 groupsList[i] = group(groupsSpec[i]);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 /* patch */ bool hasMatch(String str) { 92 /* patch */ bool hasMatch(String str) {
92 List match = _ExecuteMatch(str, 0); 93 List match = _ExecuteMatch(str, 0);
93 return (match === null) ? false : true; 94 return (match === null) ? false : true;
94 } 95 }
95 96
96 /* patch */ String stringMatch(String str) { 97 /* patch */ String stringMatch(String str) {
97 List match = _ExecuteMatch(str, 0); 98 List match = _ExecuteMatch(str, 0);
98 if (match === null) { 99 if (match === null) {
99 return null; 100 return null;
100 } 101 }
101 return str._substringUnchecked(match[0], match[1]); 102 // TODO(ajohnsen): Use _substringUnchecked when regexp is in core.
103 return str.substring(match[0], match[1]);
102 } 104 }
103 105
104 /* patch */ String get pattern native "JSSyntaxRegExp_getPattern"; 106 /* patch */ String get pattern native "JSSyntaxRegExp_getPattern";
105 107
106 /* patch */ bool get multiLine native "JSSyntaxRegExp_multiLine"; 108 /* patch */ bool get multiLine native "JSSyntaxRegExp_multiLine";
107 109
108 /* patch */ bool get ignoreCase native "JSSyntaxRegExp_ignoreCase"; 110 /* patch */ bool get ignoreCase native "JSSyntaxRegExp_ignoreCase";
109 111
110 int get _groupCount native "JSSyntaxRegExp_getGroupCount"; 112 int get _groupCount native "JSSyntaxRegExp_getGroupCount";
111 113
112 List _ExecuteMatch(String str, int start_index) 114 List _ExecuteMatch(String str, int start_index)
113 native "JSSyntaxRegExp_ExecuteMatch"; 115 native "JSSyntaxRegExp_ExecuteMatch";
114 } 116 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698