erik.corry@gmail.com | bbceb57 | 2012-03-09 10:52:05 +0000 | [diff] [blame] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | // Expect $Object = global.Object; |
| 29 | // Expect $Array = global.Array; |
| 30 | |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 31 | var $RegExp = global.RegExp; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 32 | |
| 33 | // A recursive descent parser for Patterns according to the grammar of |
| 34 | // ECMA-262 15.10.1, with deviations noted below. |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 35 | function DoConstructRegExp(object, pattern, flags) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 36 | // RegExp : Called as constructor; see ECMA-262, section 15.10.4. |
| 37 | if (IS_REGEXP(pattern)) { |
| 38 | if (!IS_UNDEFINED(flags)) { |
| 39 | throw MakeTypeError('regexp_flags', []); |
| 40 | } |
| 41 | flags = (pattern.global ? 'g' : '') |
| 42 | + (pattern.ignoreCase ? 'i' : '') |
| 43 | + (pattern.multiline ? 'm' : ''); |
| 44 | pattern = pattern.source; |
| 45 | } |
| 46 | |
| 47 | pattern = IS_UNDEFINED(pattern) ? '' : ToString(pattern); |
| 48 | flags = IS_UNDEFINED(flags) ? '' : ToString(flags); |
| 49 | |
| 50 | var global = false; |
| 51 | var ignoreCase = false; |
| 52 | var multiline = false; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 53 | for (var i = 0; i < flags.length; i++) { |
whesse@chromium.org | 7a392b3 | 2011-01-31 11:30:36 +0000 | [diff] [blame] | 54 | var c = %_CallFunction(flags, i, StringCharAt); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 55 | switch (c) { |
| 56 | case 'g': |
rossberg@chromium.org | 28a3708 | 2011-08-22 11:03:23 +0000 | [diff] [blame] | 57 | if (global) { |
| 58 | throw MakeSyntaxError("invalid_regexp_flags", [flags]); |
| 59 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 60 | global = true; |
| 61 | break; |
| 62 | case 'i': |
rossberg@chromium.org | 28a3708 | 2011-08-22 11:03:23 +0000 | [diff] [blame] | 63 | if (ignoreCase) { |
| 64 | throw MakeSyntaxError("invalid_regexp_flags", [flags]); |
| 65 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 66 | ignoreCase = true; |
| 67 | break; |
| 68 | case 'm': |
rossberg@chromium.org | 28a3708 | 2011-08-22 11:03:23 +0000 | [diff] [blame] | 69 | if (multiline) { |
| 70 | throw MakeSyntaxError("invalid_regexp_flags", [flags]); |
| 71 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 72 | multiline = true; |
| 73 | break; |
| 74 | default: |
rossberg@chromium.org | 28a3708 | 2011-08-22 11:03:23 +0000 | [diff] [blame] | 75 | throw MakeSyntaxError("invalid_regexp_flags", [flags]); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 76 | } |
| 77 | } |
| 78 | |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 79 | %RegExpInitializeObject(object, pattern, global, ignoreCase, multiline); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 80 | |
| 81 | // Call internal function to compile the pattern. |
| 82 | %RegExpCompile(object, pattern, flags); |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 83 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 84 | |
| 85 | |
| 86 | function RegExpConstructor(pattern, flags) { |
kasperl@chromium.org | 2abc450 | 2009-07-02 07:00:29 +0000 | [diff] [blame] | 87 | if (%_IsConstructCall()) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 88 | DoConstructRegExp(this, pattern, flags); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 89 | } else { |
| 90 | // RegExp : Called as function; see ECMA-262, section 15.10.3.1. |
| 91 | if (IS_REGEXP(pattern) && IS_UNDEFINED(flags)) { |
| 92 | return pattern; |
| 93 | } |
| 94 | return new $RegExp(pattern, flags); |
| 95 | } |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 96 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 97 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 98 | // Deprecated RegExp.prototype.compile method. We behave like the constructor |
| 99 | // were called again. In SpiderMonkey, this method returns the regexp object. |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 100 | // In JSC, it returns undefined. For compatibility with JSC, we match their |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 101 | // behavior. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 102 | function RegExpCompile(pattern, flags) { |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 103 | // Both JSC and SpiderMonkey treat a missing pattern argument as the |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 104 | // empty subject string, and an actual undefined value passed as the |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 105 | // pattern as the string 'undefined'. Note that JSC is inconsistent |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 106 | // here, treating undefined values differently in |
| 107 | // RegExp.prototype.compile and in the constructor, where they are |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 108 | // the empty string. For compatibility with JSC, we match their |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 109 | // behavior. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 110 | if (this == $RegExp.prototype) { |
| 111 | // We don't allow recompiling RegExp.prototype. |
| 112 | throw MakeTypeError('incompatible_method_receiver', |
| 113 | ['RegExp.prototype.compile', this]); |
| 114 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 115 | if (IS_UNDEFINED(pattern) && %_ArgumentsLength() != 0) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 116 | DoConstructRegExp(this, 'undefined', flags); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 117 | } else { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 118 | DoConstructRegExp(this, pattern, flags); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 119 | } |
| 120 | } |
| 121 | |
| 122 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 123 | function DoRegExpExec(regexp, string, index) { |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 124 | var result = %_RegExpExec(regexp, string, index, lastMatchInfo); |
| 125 | if (result !== null) lastMatchInfoOverride = null; |
| 126 | return result; |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 127 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 128 | |
| 129 | |
whesse@chromium.org | b6e43bb | 2010-04-14 09:36:28 +0000 | [diff] [blame] | 130 | function BuildResultFromMatchInfo(lastMatchInfo, s) { |
| 131 | var numResults = NUMBER_OF_CAPTURES(lastMatchInfo) >> 1; |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 132 | var start = lastMatchInfo[CAPTURE0]; |
| 133 | var end = lastMatchInfo[CAPTURE1]; |
| 134 | var result = %_RegExpConstructResult(numResults, start, s); |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 135 | result[0] = %_SubString(s, start, end); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 136 | var j = REGEXP_FIRST_CAPTURE + 2; |
| 137 | for (var i = 1; i < numResults; i++) { |
| 138 | start = lastMatchInfo[j++]; |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 139 | if (start != -1) { |
| 140 | end = lastMatchInfo[j]; |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 141 | result[i] = %_SubString(s, start, end); |
whesse@chromium.org | b6e43bb | 2010-04-14 09:36:28 +0000 | [diff] [blame] | 142 | } |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 143 | j++; |
whesse@chromium.org | b6e43bb | 2010-04-14 09:36:28 +0000 | [diff] [blame] | 144 | } |
| 145 | return result; |
| 146 | } |
| 147 | |
| 148 | |
| 149 | function RegExpExecNoTests(regexp, string, start) { |
| 150 | // Must be called with RegExp, string and positive integer as arguments. |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 151 | var matchInfo = %_RegExpExec(regexp, string, start, lastMatchInfo); |
whesse@chromium.org | b6e43bb | 2010-04-14 09:36:28 +0000 | [diff] [blame] | 152 | if (matchInfo !== null) { |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 153 | lastMatchInfoOverride = null; |
| 154 | return BuildResultFromMatchInfo(matchInfo, string); |
whesse@chromium.org | b6e43bb | 2010-04-14 09:36:28 +0000 | [diff] [blame] | 155 | } |
mstarzinger@chromium.org | 32280cf | 2012-12-06 17:32:37 +0000 | [diff] [blame] | 156 | regexp.lastIndex = 0; |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 157 | return null; |
whesse@chromium.org | b6e43bb | 2010-04-14 09:36:28 +0000 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 161 | function RegExpExec(string) { |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 162 | if (!IS_REGEXP(this)) { |
| 163 | throw MakeTypeError('incompatible_method_receiver', |
| 164 | ['RegExp.prototype.exec', this]); |
| 165 | } |
| 166 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 167 | string = TO_STRING_INLINE(string); |
lrn@chromium.org | fa943b7 | 2010-11-03 08:14:36 +0000 | [diff] [blame] | 168 | var lastIndex = this.lastIndex; |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 169 | |
vegorov@chromium.org | 4284196 | 2010-10-18 11:18:59 +0000 | [diff] [blame] | 170 | // Conversion is required by the ES5 specification (RegExp.prototype.exec |
| 171 | // algorithm, step 5) even if the value is discarded for non-global RegExps. |
| 172 | var i = TO_INTEGER(lastIndex); |
lrn@chromium.org | fa943b7 | 2010-11-03 08:14:36 +0000 | [diff] [blame] | 173 | |
| 174 | var global = this.global; |
vegorov@chromium.org | 4284196 | 2010-10-18 11:18:59 +0000 | [diff] [blame] | 175 | if (global) { |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 176 | if (i < 0 || i > string.length) { |
vegorov@chromium.org | 4284196 | 2010-10-18 11:18:59 +0000 | [diff] [blame] | 177 | this.lastIndex = 0; |
| 178 | return null; |
| 179 | } |
| 180 | } else { |
| 181 | i = 0; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 182 | } |
| 183 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 184 | %_Log('regexp', 'regexp-exec,%0r,%1S,%2i', [this, string, lastIndex]); |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 185 | // matchIndices is either null or the lastMatchInfo array. |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 186 | var matchIndices = %_RegExpExec(this, string, i, lastMatchInfo); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 187 | |
vegorov@chromium.org | 4284196 | 2010-10-18 11:18:59 +0000 | [diff] [blame] | 188 | if (matchIndices === null) { |
mstarzinger@chromium.org | 32280cf | 2012-12-06 17:32:37 +0000 | [diff] [blame] | 189 | this.lastIndex = 0; |
lrn@chromium.org | fa943b7 | 2010-11-03 08:14:36 +0000 | [diff] [blame] | 190 | return null; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 191 | } |
vegorov@chromium.org | 4284196 | 2010-10-18 11:18:59 +0000 | [diff] [blame] | 192 | |
| 193 | // Successful match. |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 194 | lastMatchInfoOverride = null; |
vegorov@chromium.org | 4284196 | 2010-10-18 11:18:59 +0000 | [diff] [blame] | 195 | if (global) { |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 196 | this.lastIndex = lastMatchInfo[CAPTURE1]; |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 197 | } |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 198 | return BuildResultFromMatchInfo(matchIndices, string); |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 199 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 200 | |
| 201 | |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 202 | // One-element cache for the simplified test regexp. |
| 203 | var regexp_key; |
| 204 | var regexp_val; |
| 205 | |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 206 | // Section 15.10.6.3 doesn't actually make sense, but the intention seems to be |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 207 | // that test is defined in terms of String.prototype.exec. However, it probably |
| 208 | // means the original value of String.prototype.exec, which is what everybody |
| 209 | // else implements. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 210 | function RegExpTest(string) { |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 211 | if (!IS_REGEXP(this)) { |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 212 | throw MakeTypeError('incompatible_method_receiver', |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 213 | ['RegExp.prototype.test', this]); |
| 214 | } |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 215 | string = TO_STRING_INLINE(string); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 216 | |
lrn@chromium.org | fa943b7 | 2010-11-03 08:14:36 +0000 | [diff] [blame] | 217 | var lastIndex = this.lastIndex; |
| 218 | |
vegorov@chromium.org | 4284196 | 2010-10-18 11:18:59 +0000 | [diff] [blame] | 219 | // Conversion is required by the ES5 specification (RegExp.prototype.exec |
| 220 | // algorithm, step 5) even if the value is discarded for non-global RegExps. |
| 221 | var i = TO_INTEGER(lastIndex); |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 222 | |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 223 | if (this.global) { |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 224 | if (i < 0 || i > string.length) { |
vegorov@chromium.org | 4284196 | 2010-10-18 11:18:59 +0000 | [diff] [blame] | 225 | this.lastIndex = 0; |
| 226 | return false; |
| 227 | } |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 228 | %_Log('regexp', 'regexp-exec,%0r,%1S,%2i', [this, string, lastIndex]); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 229 | // matchIndices is either null or the lastMatchInfo array. |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 230 | var matchIndices = %_RegExpExec(this, string, i, lastMatchInfo); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 231 | if (matchIndices === null) { |
| 232 | this.lastIndex = 0; |
| 233 | return false; |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 234 | } |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 235 | lastMatchInfoOverride = null; |
| 236 | this.lastIndex = lastMatchInfo[CAPTURE1]; |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 237 | return true; |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 238 | } else { |
| 239 | // Non-global regexp. |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 240 | // Remove irrelevant preceeding '.*' in a non-global test regexp. |
| 241 | // The expression checks whether this.source starts with '.*' and |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 242 | // that the third char is not a '?'. |
rossberg@chromium.org | 2c067b1 | 2012-03-19 11:01:52 +0000 | [diff] [blame] | 243 | var regexp = this; |
| 244 | if (%_StringCharCodeAt(regexp.source, 0) == 46 && // '.' |
| 245 | %_StringCharCodeAt(regexp.source, 1) == 42 && // '*' |
| 246 | %_StringCharCodeAt(regexp.source, 2) != 63) { // '?' |
| 247 | regexp = TrimRegExp(regexp); |
jkummerow@chromium.org | ddda9e8 | 2011-07-06 11:27:02 +0000 | [diff] [blame] | 248 | } |
rossberg@chromium.org | 2c067b1 | 2012-03-19 11:01:52 +0000 | [diff] [blame] | 249 | %_Log('regexp', 'regexp-exec,%0r,%1S,%2i', [regexp, string, lastIndex]); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 250 | // matchIndices is either null or the lastMatchInfo array. |
rossberg@chromium.org | 2c067b1 | 2012-03-19 11:01:52 +0000 | [diff] [blame] | 251 | var matchIndices = %_RegExpExec(regexp, string, 0, lastMatchInfo); |
mstarzinger@chromium.org | 32280cf | 2012-12-06 17:32:37 +0000 | [diff] [blame] | 252 | if (matchIndices === null) { |
| 253 | this.lastIndex = 0; |
| 254 | return false; |
| 255 | } |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 256 | lastMatchInfoOverride = null; |
| 257 | return true; |
lrn@chromium.org | 1af7e1b | 2010-06-07 11:12:01 +0000 | [diff] [blame] | 258 | } |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 259 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 260 | |
rossberg@chromium.org | 2c067b1 | 2012-03-19 11:01:52 +0000 | [diff] [blame] | 261 | function TrimRegExp(regexp) { |
| 262 | if (!%_ObjectEquals(regexp_key, regexp)) { |
| 263 | regexp_key = regexp; |
| 264 | regexp_val = |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 265 | new $RegExp(%_SubString(regexp.source, 2, regexp.source.length), |
rossberg@chromium.org | 2c067b1 | 2012-03-19 11:01:52 +0000 | [diff] [blame] | 266 | (regexp.ignoreCase ? regexp.multiline ? "im" : "i" |
| 267 | : regexp.multiline ? "m" : "")); |
| 268 | } |
| 269 | return regexp_val; |
| 270 | } |
| 271 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 272 | |
| 273 | function RegExpToString() { |
jkummerow@chromium.org | 777db6f | 2012-05-24 09:33:09 +0000 | [diff] [blame] | 274 | if (!IS_REGEXP(this)) { |
| 275 | throw MakeTypeError('incompatible_method_receiver', |
| 276 | ['RegExp.prototype.toString', this]); |
| 277 | } |
yangguo@chromium.org | efdb9d7 | 2012-04-26 08:21:05 +0000 | [diff] [blame] | 278 | var result = '/' + this.source + '/'; |
vegorov@chromium.org | 4284196 | 2010-10-18 11:18:59 +0000 | [diff] [blame] | 279 | if (this.global) result += 'g'; |
| 280 | if (this.ignoreCase) result += 'i'; |
| 281 | if (this.multiline) result += 'm'; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 282 | return result; |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 283 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 284 | |
| 285 | |
| 286 | // Getters for the static properties lastMatch, lastParen, leftContext, and |
| 287 | // rightContext of the RegExp constructor. The properties are computed based |
| 288 | // on the captures array of the last successful match and the subject string |
| 289 | // of the last successful match. |
| 290 | function RegExpGetLastMatch() { |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 291 | if (lastMatchInfoOverride !== null) { |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 292 | return OVERRIDE_MATCH(lastMatchInfoOverride); |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 293 | } |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 294 | var regExpSubject = LAST_SUBJECT(lastMatchInfo); |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 295 | return %_SubString(regExpSubject, |
| 296 | lastMatchInfo[CAPTURE0], |
| 297 | lastMatchInfo[CAPTURE1]); |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 298 | } |
| 299 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 300 | |
| 301 | function RegExpGetLastParen() { |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 302 | if (lastMatchInfoOverride) { |
| 303 | var override = lastMatchInfoOverride; |
| 304 | if (override.length <= 3) return ''; |
| 305 | return override[override.length - 3]; |
| 306 | } |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 307 | var length = NUMBER_OF_CAPTURES(lastMatchInfo); |
| 308 | if (length <= 2) return ''; // There were no captures. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 309 | // We match the SpiderMonkey behavior: return the substring defined by the |
| 310 | // last pair (after the first pair) of elements of the capture array even if |
| 311 | // it is empty. |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 312 | var regExpSubject = LAST_SUBJECT(lastMatchInfo); |
| 313 | var start = lastMatchInfo[CAPTURE(length - 2)]; |
| 314 | var end = lastMatchInfo[CAPTURE(length - 1)]; |
| 315 | if (start != -1 && end != -1) { |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 316 | return %_SubString(regExpSubject, start, end); |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 317 | } |
| 318 | return ""; |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 319 | } |
| 320 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 321 | |
| 322 | function RegExpGetLeftContext() { |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 323 | var start_index; |
| 324 | var subject; |
| 325 | if (!lastMatchInfoOverride) { |
| 326 | start_index = lastMatchInfo[CAPTURE0]; |
| 327 | subject = LAST_SUBJECT(lastMatchInfo); |
| 328 | } else { |
| 329 | var override = lastMatchInfoOverride; |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 330 | start_index = OVERRIDE_POS(override); |
| 331 | subject = OVERRIDE_SUBJECT(override); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 332 | } |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 333 | return %_SubString(subject, 0, start_index); |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 334 | } |
| 335 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 336 | |
| 337 | function RegExpGetRightContext() { |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 338 | var start_index; |
| 339 | var subject; |
| 340 | if (!lastMatchInfoOverride) { |
| 341 | start_index = lastMatchInfo[CAPTURE1]; |
| 342 | subject = LAST_SUBJECT(lastMatchInfo); |
| 343 | } else { |
| 344 | var override = lastMatchInfoOverride; |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 345 | subject = OVERRIDE_SUBJECT(override); |
| 346 | var match = OVERRIDE_MATCH(override); |
| 347 | start_index = OVERRIDE_POS(override) + match.length; |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 348 | } |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 349 | return %_SubString(subject, start_index, subject.length); |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 350 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 351 | |
| 352 | |
| 353 | // The properties $1..$9 are the first nine capturing substrings of the last |
| 354 | // successful match, or ''. The function RegExpMakeCaptureGetter will be |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 355 | // called with indices from 1 to 9. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 356 | function RegExpMakeCaptureGetter(n) { |
| 357 | return function() { |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 358 | if (lastMatchInfoOverride) { |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 359 | if (n < lastMatchInfoOverride.length - 2) { |
| 360 | return OVERRIDE_CAPTURE(lastMatchInfoOverride, n); |
| 361 | } |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 362 | return ''; |
| 363 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 364 | var index = n * 2; |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 365 | if (index >= NUMBER_OF_CAPTURES(lastMatchInfo)) return ''; |
| 366 | var matchStart = lastMatchInfo[CAPTURE(index)]; |
| 367 | var matchEnd = lastMatchInfo[CAPTURE(index + 1)]; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 368 | if (matchStart == -1 || matchEnd == -1) return ''; |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 369 | return %_SubString(LAST_SUBJECT(lastMatchInfo), matchStart, matchEnd); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 370 | }; |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 371 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 372 | |
| 373 | |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 374 | // Property of the builtins object for recording the result of the last |
| 375 | // regexp match. The property lastMatchInfo includes the matchIndices |
| 376 | // array of the last successful regexp match (an array of start/end index |
| 377 | // pairs for the match and all the captured substrings), the invariant is |
| 378 | // that there are at least two capture indeces. The array also contains |
| 379 | // the subject string for the last successful match. |
yangguo@chromium.org | c03a192 | 2013-02-19 13:55:47 +0000 | [diff] [blame] | 380 | var lastMatchInfo = new InternalPackedArray( |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 381 | 2, // REGEXP_NUMBER_OF_CAPTURES |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 382 | "", // Last subject. |
| 383 | void 0, // Last input - settable with RegExpSetInput. |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 384 | 0, // REGEXP_FIRST_CAPTURE + 0 |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 385 | 0 // REGEXP_FIRST_CAPTURE + 1 |
| 386 | ); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 387 | |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 388 | // Override last match info with an array of actual substrings. |
| 389 | // Used internally by replace regexp with function. |
| 390 | // The array has the format of an "apply" argument for a replacement |
| 391 | // function. |
| 392 | var lastMatchInfoOverride = null; |
| 393 | |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 394 | // ------------------------------------------------------------------- |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 395 | |
fschneider@chromium.org | 1805e21 | 2011-09-05 10:49:12 +0000 | [diff] [blame] | 396 | function SetUpRegExp() { |
| 397 | %CheckIsBootstrapping(); |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 398 | %FunctionSetInstanceClassName($RegExp, 'RegExp'); |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 399 | %SetProperty($RegExp.prototype, 'constructor', $RegExp, DONT_ENUM); |
| 400 | %SetCode($RegExp, RegExpConstructor); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 401 | |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 402 | InstallFunctions($RegExp.prototype, DONT_ENUM, $Array( |
| 403 | "exec", RegExpExec, |
| 404 | "test", RegExpTest, |
| 405 | "toString", RegExpToString, |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 406 | "compile", RegExpCompile |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 407 | )); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 408 | |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 409 | // The length of compile is 1 in SpiderMonkey. |
| 410 | %FunctionSetLength($RegExp.prototype.compile, 1); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 411 | |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 412 | // The properties input, $input, and $_ are aliases for each other. When this |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 413 | // value is set the value it is set to is coerced to a string. |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 414 | // Getter and setter for the input. |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 415 | var RegExpGetInput = function() { |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 416 | var regExpInput = LAST_INPUT(lastMatchInfo); |
ager@chromium.org | a74f0da | 2008-12-03 16:05:52 +0000 | [diff] [blame] | 417 | return IS_UNDEFINED(regExpInput) ? "" : regExpInput; |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 418 | }; |
| 419 | var RegExpSetInput = function(string) { |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 420 | LAST_INPUT(lastMatchInfo) = ToString(string); |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 421 | }; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 422 | |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 423 | %OptimizeObjectForAddingMultipleProperties($RegExp, 22); |
erik.corry@gmail.com | bbceb57 | 2012-03-09 10:52:05 +0000 | [diff] [blame] | 424 | %DefineOrRedefineAccessorProperty($RegExp, 'input', RegExpGetInput, |
| 425 | RegExpSetInput, DONT_DELETE); |
| 426 | %DefineOrRedefineAccessorProperty($RegExp, '$_', RegExpGetInput, |
| 427 | RegExpSetInput, DONT_ENUM | DONT_DELETE); |
| 428 | %DefineOrRedefineAccessorProperty($RegExp, '$input', RegExpGetInput, |
| 429 | RegExpSetInput, DONT_ENUM | DONT_DELETE); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 430 | |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 431 | // The properties multiline and $* are aliases for each other. When this |
| 432 | // value is set in SpiderMonkey, the value it is set to is coerced to a |
| 433 | // boolean. We mimic that behavior with a slight difference: in SpiderMonkey |
| 434 | // the value of the expression 'RegExp.multiline = null' (for instance) is the |
ulan@chromium.org | 2efb900 | 2012-01-19 15:36:35 +0000 | [diff] [blame] | 435 | // boolean false (i.e., the value after coercion), while in V8 it is the value |
| 436 | // null (i.e., the value before coercion). |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 437 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 438 | // Getter and setter for multiline. |
| 439 | var multiline = false; |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 440 | var RegExpGetMultiline = function() { return multiline; }; |
| 441 | var RegExpSetMultiline = function(flag) { multiline = flag ? true : false; }; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 442 | |
erik.corry@gmail.com | bbceb57 | 2012-03-09 10:52:05 +0000 | [diff] [blame] | 443 | %DefineOrRedefineAccessorProperty($RegExp, 'multiline', RegExpGetMultiline, |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 444 | RegExpSetMultiline, DONT_DELETE); |
erik.corry@gmail.com | bbceb57 | 2012-03-09 10:52:05 +0000 | [diff] [blame] | 445 | %DefineOrRedefineAccessorProperty($RegExp, '$*', RegExpGetMultiline, |
| 446 | RegExpSetMultiline, |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 447 | DONT_ENUM | DONT_DELETE); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 448 | |
| 449 | |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 450 | var NoOpSetter = function(ignored) {}; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 451 | |
| 452 | |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 453 | // Static properties set by a successful match. |
erik.corry@gmail.com | bbceb57 | 2012-03-09 10:52:05 +0000 | [diff] [blame] | 454 | %DefineOrRedefineAccessorProperty($RegExp, 'lastMatch', RegExpGetLastMatch, |
| 455 | NoOpSetter, DONT_DELETE); |
| 456 | %DefineOrRedefineAccessorProperty($RegExp, '$&', RegExpGetLastMatch, |
| 457 | NoOpSetter, DONT_ENUM | DONT_DELETE); |
| 458 | %DefineOrRedefineAccessorProperty($RegExp, 'lastParen', RegExpGetLastParen, |
| 459 | NoOpSetter, DONT_DELETE); |
| 460 | %DefineOrRedefineAccessorProperty($RegExp, '$+', RegExpGetLastParen, |
| 461 | NoOpSetter, DONT_ENUM | DONT_DELETE); |
| 462 | %DefineOrRedefineAccessorProperty($RegExp, 'leftContext', |
| 463 | RegExpGetLeftContext, NoOpSetter, |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 464 | DONT_DELETE); |
erik.corry@gmail.com | bbceb57 | 2012-03-09 10:52:05 +0000 | [diff] [blame] | 465 | %DefineOrRedefineAccessorProperty($RegExp, '$`', RegExpGetLeftContext, |
| 466 | NoOpSetter, DONT_ENUM | DONT_DELETE); |
| 467 | %DefineOrRedefineAccessorProperty($RegExp, 'rightContext', |
| 468 | RegExpGetRightContext, NoOpSetter, |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 469 | DONT_DELETE); |
erik.corry@gmail.com | bbceb57 | 2012-03-09 10:52:05 +0000 | [diff] [blame] | 470 | %DefineOrRedefineAccessorProperty($RegExp, "$'", RegExpGetRightContext, |
| 471 | NoOpSetter, DONT_ENUM | DONT_DELETE); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 472 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 473 | for (var i = 1; i < 10; ++i) { |
erik.corry@gmail.com | bbceb57 | 2012-03-09 10:52:05 +0000 | [diff] [blame] | 474 | %DefineOrRedefineAccessorProperty($RegExp, '$' + i, |
| 475 | RegExpMakeCaptureGetter(i), NoOpSetter, |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 476 | DONT_DELETE); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 477 | } |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 478 | %ToFastProperties($RegExp); |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 479 | } |
| 480 | |
fschneider@chromium.org | 1805e21 | 2011-09-05 10:49:12 +0000 | [diff] [blame] | 481 | SetUpRegExp(); |