Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/regexp.js

Issue 10105026: Version 3.10.3 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/property.h ('k') | src/runtime.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Modified: svn:mergeinfo
Merged /branches/bleeding_edge/src/regexp.js:r11308-11352
OLDNEW
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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 return result; 289 return result;
290 } 290 }
291 291
292 292
293 // Getters for the static properties lastMatch, lastParen, leftContext, and 293 // Getters for the static properties lastMatch, lastParen, leftContext, and
294 // rightContext of the RegExp constructor. The properties are computed based 294 // rightContext of the RegExp constructor. The properties are computed based
295 // on the captures array of the last successful match and the subject string 295 // on the captures array of the last successful match and the subject string
296 // of the last successful match. 296 // of the last successful match.
297 function RegExpGetLastMatch() { 297 function RegExpGetLastMatch() {
298 if (lastMatchInfoOverride !== null) { 298 if (lastMatchInfoOverride !== null) {
299 return lastMatchInfoOverride[0]; 299 return OVERRIDE_MATCH(lastMatchInfoOverride);
300 } 300 }
301 var regExpSubject = LAST_SUBJECT(lastMatchInfo); 301 var regExpSubject = LAST_SUBJECT(lastMatchInfo);
302 return SubString(regExpSubject, 302 return SubString(regExpSubject,
303 lastMatchInfo[CAPTURE0], 303 lastMatchInfo[CAPTURE0],
304 lastMatchInfo[CAPTURE1]); 304 lastMatchInfo[CAPTURE1]);
305 } 305 }
306 306
307 307
308 function RegExpGetLastParen() { 308 function RegExpGetLastParen() {
309 if (lastMatchInfoOverride) { 309 if (lastMatchInfoOverride) {
(...skipping 17 matching lines...) Expand all
327 327
328 328
329 function RegExpGetLeftContext() { 329 function RegExpGetLeftContext() {
330 var start_index; 330 var start_index;
331 var subject; 331 var subject;
332 if (!lastMatchInfoOverride) { 332 if (!lastMatchInfoOverride) {
333 start_index = lastMatchInfo[CAPTURE0]; 333 start_index = lastMatchInfo[CAPTURE0];
334 subject = LAST_SUBJECT(lastMatchInfo); 334 subject = LAST_SUBJECT(lastMatchInfo);
335 } else { 335 } else {
336 var override = lastMatchInfoOverride; 336 var override = lastMatchInfoOverride;
337 start_index = override[override.length - 2]; 337 start_index = OVERRIDE_POS(override);
338 subject = override[override.length - 1]; 338 subject = OVERRIDE_SUBJECT(override);
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;
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_SUBJECT(override);
353 var pattern = override[override.length - 3]; 353 var match = OVERRIDE_MATCH(override);
354 start_index = override[override.length - 2] + pattern.length; 354 start_index = OVERRIDE_POS(override) + match.length;
355 } 355 }
356 return SubString(subject, start_index, subject.length); 356 return SubString(subject, start_index, subject.length);
357 } 357 }
358 358
359 359
360 // 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
361 // successful match, or ''. The function RegExpMakeCaptureGetter will be 361 // successful match, or ''. The function RegExpMakeCaptureGetter will be
362 // called with indices from 1 to 9. 362 // called with indices from 1 to 9.
363 function RegExpMakeCaptureGetter(n) { 363 function RegExpMakeCaptureGetter(n) {
364 return function() { 364 return function() {
365 if (lastMatchInfoOverride) { 365 if (lastMatchInfoOverride) {
366 if (n < lastMatchInfoOverride.length - 2) return lastMatchInfoOverride[n]; 366 if (n < lastMatchInfoOverride.length - 2) {
367 return OVERRIDE_CAPTURE(lastMatchInfoOverride, n);
368 }
367 return ''; 369 return '';
368 } 370 }
369 var index = n * 2; 371 var index = n * 2;
370 if (index >= NUMBER_OF_CAPTURES(lastMatchInfo)) return ''; 372 if (index >= NUMBER_OF_CAPTURES(lastMatchInfo)) return '';
371 var matchStart = lastMatchInfo[CAPTURE(index)]; 373 var matchStart = lastMatchInfo[CAPTURE(index)];
372 var matchEnd = lastMatchInfo[CAPTURE(index + 1)]; 374 var matchEnd = lastMatchInfo[CAPTURE(index + 1)];
373 if (matchStart == -1 || matchEnd == -1) return ''; 375 if (matchStart == -1 || matchEnd == -1) return '';
374 return SubString(LAST_SUBJECT(lastMatchInfo), matchStart, matchEnd); 376 return SubString(LAST_SUBJECT(lastMatchInfo), matchStart, matchEnd);
375 }; 377 };
376 } 378 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 NoOpSetter, DONT_ENUM | DONT_DELETE); 477 NoOpSetter, DONT_ENUM | DONT_DELETE);
476 478
477 for (var i = 1; i < 10; ++i) { 479 for (var i = 1; i < 10; ++i) {
478 %DefineOrRedefineAccessorProperty($RegExp, '$' + i, 480 %DefineOrRedefineAccessorProperty($RegExp, '$' + i,
479 RegExpMakeCaptureGetter(i), NoOpSetter, 481 RegExpMakeCaptureGetter(i), NoOpSetter,
480 DONT_DELETE); 482 DONT_DELETE);
481 } 483 }
482 } 484 }
483 485
484 SetUpRegExp(); 486 SetUpRegExp();
OLDNEW
« no previous file with comments | « src/property.h ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698