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

Side by Side Diff: src/regexp.js

Issue 1065863003: Use array literals instead of array constructor in native javascript. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase and fix Created 5 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
« no previous file with comments | « src/object-observe.js ('k') | src/snapshot/serialize.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var $regexpExec; 5 var $regexpExec;
6 var $regexpExecNoTests; 6 var $regexpExecNoTests;
7 var $regexpLastMatchInfo; 7 var $regexpLastMatchInfo;
8 var $regexpLastMatchInfoOverride; 8 var $regexpLastMatchInfoOverride;
9 var harmony_regexps = false; 9 var harmony_regexps = false;
10 var harmony_unicode_regexps = false; 10 var harmony_unicode_regexps = false;
11 11
12 (function() { 12 (function() {
13 13
14 %CheckIsBootstrapping(); 14 %CheckIsBootstrapping();
15 15
16 var GlobalRegExp = global.RegExp; 16 var GlobalRegExp = global.RegExp;
17 var GlobalArray = global.Array;
18 17
19 // Property of the builtins object for recording the result of the last 18 // Property of the builtins object for recording the result of the last
20 // regexp match. The property $regexpLastMatchInfo includes the matchIndices 19 // regexp match. The property $regexpLastMatchInfo includes the matchIndices
21 // array of the last successful regexp match (an array of start/end index 20 // array of the last successful regexp match (an array of start/end index
22 // pairs for the match and all the captured substrings), the invariant is 21 // pairs for the match and all the captured substrings), the invariant is
23 // that there are at least two capture indeces. The array also contains 22 // that there are at least two capture indeces. The array also contains
24 // the subject string for the last successful match. 23 // the subject string for the last successful match.
25 $regexpLastMatchInfo = new InternalPackedArray( 24 $regexpLastMatchInfo = new InternalPackedArray(
26 2, // REGEXP_NUMBER_OF_CAPTURES 25 2, // REGEXP_NUMBER_OF_CAPTURES
27 "", // Last subject. 26 "", // Last subject.
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 }; 356 };
358 } 357 }
359 358
360 // ------------------------------------------------------------------- 359 // -------------------------------------------------------------------
361 360
362 %FunctionSetInstanceClassName(GlobalRegExp, 'RegExp'); 361 %FunctionSetInstanceClassName(GlobalRegExp, 'RegExp');
363 %AddNamedProperty( 362 %AddNamedProperty(
364 GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM); 363 GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM);
365 %SetCode(GlobalRegExp, RegExpConstructor); 364 %SetCode(GlobalRegExp, RegExpConstructor);
366 365
367 InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, GlobalArray( 366 InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [
368 "exec", RegExpExecJS, 367 "exec", RegExpExecJS,
369 "test", RegExpTest, 368 "test", RegExpTest,
370 "toString", RegExpToString, 369 "toString", RegExpToString,
371 "compile", RegExpCompileJS 370 "compile", RegExpCompileJS
372 )); 371 ]);
373 372
374 // The length of compile is 1 in SpiderMonkey. 373 // The length of compile is 1 in SpiderMonkey.
375 %FunctionSetLength(GlobalRegExp.prototype.compile, 1); 374 %FunctionSetLength(GlobalRegExp.prototype.compile, 1);
376 375
377 // The properties `input` and `$_` are aliases for each other. When this 376 // The properties `input` and `$_` are aliases for each other. When this
378 // value is set the value it is set to is coerced to a string. 377 // value is set the value it is set to is coerced to a string.
379 // Getter and setter for the input. 378 // Getter and setter for the input.
380 var RegExpGetInput = function() { 379 var RegExpGetInput = function() {
381 var regExpInput = LAST_INPUT($regexpLastMatchInfo); 380 var regExpInput = LAST_INPUT($regexpLastMatchInfo);
382 return IS_UNDEFINED(regExpInput) ? "" : regExpInput; 381 return IS_UNDEFINED(regExpInput) ? "" : regExpInput;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$' + i, 436 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$' + i,
438 RegExpMakeCaptureGetter(i), NoOpSetter, 437 RegExpMakeCaptureGetter(i), NoOpSetter,
439 DONT_DELETE); 438 DONT_DELETE);
440 } 439 }
441 %ToFastProperties(GlobalRegExp); 440 %ToFastProperties(GlobalRegExp);
442 441
443 $regexpExecNoTests = RegExpExecNoTests; 442 $regexpExecNoTests = RegExpExecNoTests;
444 $regexpExec = DoRegExpExec; 443 $regexpExec = DoRegExpExec;
445 444
446 })(); 445 })();
OLDNEW
« no previous file with comments | « src/object-observe.js ('k') | src/snapshot/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698