OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
336 var override = lastMatchInfoOverride; | 336 var override = lastMatchInfoOverride; |
337 start_index = override[override.length - 2]; | 337 start_index = override[override.length - 2]; |
338 subject = override[override.length - 1]; | 338 subject = override[override.length - 1]; |
339 } | 339 } |
340 return SubString(subject, 0, start_index); | 340 return SubString(subject, 0, start_index); |
341 } | 341 } |
342 | 342 |
343 | 343 |
344 function RegExpGetRightContext() { | 344 function RegExpGetRightContext() { |
345 var start_index; | 345 var start_index; |
346 var subject; | 346 var subject, pattern; |
Michael Starzinger
2012/04/12 12:10:28
The "pattern" variable could be moved into the els
| |
347 if (!lastMatchInfoOverride) { | 347 if (!lastMatchInfoOverride) { |
348 start_index = lastMatchInfo[CAPTURE1]; | 348 start_index = lastMatchInfo[CAPTURE1]; |
349 subject = LAST_SUBJECT(lastMatchInfo); | 349 subject = LAST_SUBJECT(lastMatchInfo); |
350 } else { | 350 } else { |
351 var override = lastMatchInfoOverride; | 351 var override = lastMatchInfoOverride; |
352 subject = override[override.length - 1]; | 352 subject = override[override.length - 1]; |
353 start_index = override[override.length - 2] + subject.length; | 353 pattern = override[override.length - 3]; |
Lasse Reichstein Nielsen
2012/04/13 06:59:52
I don't think this is correct in all cases.
The o
| |
354 start_index = override[override.length - 2] + pattern.length; | |
354 } | 355 } |
355 return SubString(subject, start_index, subject.length); | 356 return SubString(subject, start_index, subject.length); |
356 } | 357 } |
357 | 358 |
358 | 359 |
359 // The properties $1..$9 are the first nine capturing substrings of the last | 360 // The properties $1..$9 are the first nine capturing substrings of the last |
360 // successful match, or ''. The function RegExpMakeCaptureGetter will be | 361 // successful match, or ''. The function RegExpMakeCaptureGetter will be |
361 // called with indices from 1 to 9. | 362 // called with indices from 1 to 9. |
362 function RegExpMakeCaptureGetter(n) { | 363 function RegExpMakeCaptureGetter(n) { |
363 return function() { | 364 return function() { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
474 NoOpSetter, DONT_ENUM | DONT_DELETE); | 475 NoOpSetter, DONT_ENUM | DONT_DELETE); |
475 | 476 |
476 for (var i = 1; i < 10; ++i) { | 477 for (var i = 1; i < 10; ++i) { |
477 %DefineOrRedefineAccessorProperty($RegExp, '$' + i, | 478 %DefineOrRedefineAccessorProperty($RegExp, '$' + i, |
478 RegExpMakeCaptureGetter(i), NoOpSetter, | 479 RegExpMakeCaptureGetter(i), NoOpSetter, |
479 DONT_DELETE); | 480 DONT_DELETE); |
480 } | 481 } |
481 } | 482 } |
482 | 483 |
483 SetUpRegExp(); | 484 SetUpRegExp(); |
OLD | NEW |