OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 | |
5 function native_JSSyntaxRegExp_firstMatch(str) { | |
6 var re = $DartRegExpToJSRegExp(this); | |
7 var m = re.exec(str); | |
8 if (m != null) { | |
9 var match = native_JSSyntaxMatch__new(this, str); | |
10 match.match_ = m; | |
11 match.lastIndex_ = re.lastIndex; | |
12 return match; | |
13 } | |
14 return $Dart$Null; | |
15 } | |
16 | |
17 function native_JSSyntaxRegExp_hasMatch(str) { | |
18 return $DartRegExpToJSRegExp(this).test(str); | |
19 } | |
20 | |
21 function native_JSSyntaxRegExp_stringMatch(str) { | |
22 var m = $DartRegExpToJSRegExp(this).exec(str); | |
23 return (m != null ? m[0] : $Dart$Null); | |
24 } | |
25 | |
26 function native_JSSyntaxMatch_group(nb) { | |
27 return this.match_[nb]; | |
28 } | |
29 | |
30 function native_JSSyntaxMatch_groupCount() { | |
31 return this.match_.length; | |
32 } | |
33 | |
34 function native_JSSyntaxMatch_start() { | |
35 return this.match_.index; | |
36 } | |
37 | |
38 function native_JSSyntaxMatch_end() { | |
39 return this.lastIndex_; | |
40 } | |
41 | |
42 function native__LazyAllMatchesIterator__jsInit(regExp) { | |
43 this.re = $DartRegExpToJSRegExp(regExp); | |
44 } | |
45 | |
46 // The given RegExp is only used to initialize a new Match. We use the | |
47 // cached JS regexp to compute the next match. | |
48 function native__LazyAllMatchesIterator__computeNextMatch(regExp, str) { | |
49 var re = this.re; | |
50 if (re === null) return $Dart$Null; | |
51 var m = re.exec(str); | |
52 if (m == null) { | |
53 this.re = null; | |
54 return $Dart$Null; | |
55 } | |
56 var match = native_JSSyntaxMatch__new(regExp, str); | |
57 match.match_ = m; | |
58 match.lastIndex_ = re.lastIndex; | |
59 return match; | |
60 } | |
61 | |
62 function $DartRegExpToJSRegExp(exp) { | |
63 var flags = "g"; | |
64 if (native_JSSyntaxRegExp__multiLine(exp)) flags += "m"; | |
65 if (native_JSSyntaxRegExp__ignoreCase(exp)) flags += "i"; | |
66 return new RegExp(native_JSSyntaxRegExp__pattern(exp), flags); | |
67 } | |
OLD | NEW |