OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 if (i < 0 || i > s.length) { | 206 if (i < 0 || i > s.length) { |
207 this.lastIndex = 0; | 207 this.lastIndex = 0; |
208 return null; | 208 return null; |
209 } | 209 } |
210 | 210 |
211 %_Log('regexp', 'regexp-exec,%0r,%1S,%2i', [this, s, lastIndex]); | 211 %_Log('regexp', 'regexp-exec,%0r,%1S,%2i', [this, s, lastIndex]); |
212 // matchIndices is either null or the lastMatchInfo array. | 212 // matchIndices is either null or the lastMatchInfo array. |
213 var matchIndices = %_RegExpExec(this, s, i, lastMatchInfo); | 213 var matchIndices = %_RegExpExec(this, s, i, lastMatchInfo); |
214 | 214 |
215 if (matchIndices == null) { | 215 if (matchIndices == null) { |
216 if (this.global) this.lastIndex = 0; | 216 if (this.global) { |
| 217 this.lastIndex = 0; |
| 218 if (lastIndex != 0) return matchIndices; |
| 219 } |
217 cache.lastIndex = lastIndex; | 220 cache.lastIndex = lastIndex; |
218 cache.regExp = this; | 221 cache.regExp = this; |
219 cache.subject = s; | 222 cache.subject = s; |
220 cache.answer = matchIndices; // Null. | 223 cache.answer = matchIndices; // Null. |
221 cache.type = 'exec'; | 224 cache.type = 'exec'; |
222 return matchIndices; // No match. | 225 return matchIndices; // No match. |
223 } | 226 } |
224 | 227 |
225 var numResults = NUMBER_OF_CAPTURES(lastMatchInfo) >> 1; | 228 var numResults = NUMBER_OF_CAPTURES(lastMatchInfo) >> 1; |
226 var result; | 229 var result; |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); | 522 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); |
520 | 523 |
521 for (var i = 1; i < 10; ++i) { | 524 for (var i = 1; i < 10; ++i) { |
522 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D
ELETE); | 525 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D
ELETE); |
523 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); | 526 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); |
524 } | 527 } |
525 } | 528 } |
526 | 529 |
527 | 530 |
528 SetupRegExp(); | 531 SetupRegExp(); |
OLD | NEW |