| OLD | NEW |
| 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 RangeError.value(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 // TODO(ajohnsen): Use _substringUnchecked when regexp is in core. | 29 // TODO(ajohnsen): Use _substringUnchecked when regexp is in core. |
| 30 return str.substring(startIndex, endIndex); | 30 return str.substring(startIndex, endIndex); |
| 31 } | 31 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 107 |
| 108 /* patch */ bool get multiLine native "JSSyntaxRegExp_multiLine"; | 108 /* patch */ bool get multiLine native "JSSyntaxRegExp_multiLine"; |
| 109 | 109 |
| 110 /* patch */ bool get ignoreCase native "JSSyntaxRegExp_ignoreCase"; | 110 /* patch */ bool get ignoreCase native "JSSyntaxRegExp_ignoreCase"; |
| 111 | 111 |
| 112 int get _groupCount native "JSSyntaxRegExp_getGroupCount"; | 112 int get _groupCount native "JSSyntaxRegExp_getGroupCount"; |
| 113 | 113 |
| 114 List _ExecuteMatch(String str, int start_index) | 114 List _ExecuteMatch(String str, int start_index) |
| 115 native "JSSyntaxRegExp_ExecuteMatch"; | 115 native "JSSyntaxRegExp_ExecuteMatch"; |
| 116 } | 116 } |
| OLD | NEW |