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

Side by Side Diff: src/js/regexp.js

Issue 1416093006: Unify setting accessor properties in native code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 years, 1 month 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/js/prologue.js ('k') | test/mjsunit/es6/regexp-flags.js » ('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 (function(global, utils) { 5 (function(global, utils) {
6 6
7 %CheckIsBootstrapping(); 7 %CheckIsBootstrapping();
8 8
9 // ------------------------------------------------------------------- 9 // -------------------------------------------------------------------
10 // Imports 10 // Imports
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM); 380 GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM);
381 %SetCode(GlobalRegExp, RegExpConstructor); 381 %SetCode(GlobalRegExp, RegExpConstructor);
382 382
383 utils.InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [ 383 utils.InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [
384 "exec", RegExpExecJS, 384 "exec", RegExpExecJS,
385 "test", RegExpTest, 385 "test", RegExpTest,
386 "toString", RegExpToString, 386 "toString", RegExpToString,
387 "compile", RegExpCompileJS 387 "compile", RegExpCompileJS
388 ]); 388 ]);
389 389
390 %DefineGetterPropertyUnchecked(GlobalRegExp.prototype, "global", 390 utils.InstallGetter(GlobalRegExp.prototype, 'global', RegExpGetGlobal);
391 RegExpGetGlobal, DONT_ENUM); 391 utils.InstallGetter(GlobalRegExp.prototype, 'ignoreCase', RegExpGetIgnoreCase);
392 %DefineGetterPropertyUnchecked(GlobalRegExp.prototype, "ignoreCase", 392 utils.InstallGetter(GlobalRegExp.prototype, 'multiline', RegExpGetMultiline);
393 RegExpGetIgnoreCase, DONT_ENUM); 393 utils.InstallGetter(GlobalRegExp.prototype, 'source', RegExpGetSource);
394 %DefineGetterPropertyUnchecked(GlobalRegExp.prototype, "multiline",
395 RegExpGetMultiline, DONT_ENUM);
396 %DefineGetterPropertyUnchecked(GlobalRegExp.prototype, "source",
397 RegExpGetSource, DONT_ENUM);
398 394
399 // The length of compile is 1 in SpiderMonkey. 395 // The length of compile is 1 in SpiderMonkey.
400 %FunctionSetLength(GlobalRegExp.prototype.compile, 1); 396 %FunctionSetLength(GlobalRegExp.prototype.compile, 1);
401 397
402 // The properties `input` and `$_` are aliases for each other. When this 398 // The properties `input` and `$_` are aliases for each other. When this
403 // value is set the value it is set to is coerced to a string. 399 // value is set the value it is set to is coerced to a string.
404 // Getter and setter for the input. 400 // Getter and setter for the input.
405 var RegExpGetInput = function() { 401 var RegExpGetInput = function() {
406 var regExpInput = LAST_INPUT(RegExpLastMatchInfo); 402 var regExpInput = LAST_INPUT(RegExpLastMatchInfo);
407 return IS_UNDEFINED(regExpInput) ? "" : regExpInput; 403 return IS_UNDEFINED(regExpInput) ? "" : regExpInput;
408 }; 404 };
409 var RegExpSetInput = function(string) { 405 var RegExpSetInput = function(string) {
410 LAST_INPUT(RegExpLastMatchInfo) = TO_STRING(string); 406 LAST_INPUT(RegExpLastMatchInfo) = TO_STRING(string);
411 }; 407 };
412 408
413 %OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22); 409 %OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22);
414 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'input', RegExpGetInput, 410 utils.InstallGetterSetter(GlobalRegExp, 'input', RegExpGetInput, RegExpSetInput,
415 RegExpSetInput, DONT_DELETE); 411 DONT_DELETE);
416 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$_', RegExpGetInput, 412 utils.InstallGetterSetter(GlobalRegExp, '$_', RegExpGetInput, RegExpSetInput,
417 RegExpSetInput, DONT_ENUM | DONT_DELETE); 413 DONT_ENUM | DONT_DELETE);
414
418 415
419 var NoOpSetter = function(ignored) {}; 416 var NoOpSetter = function(ignored) {};
420 417
421 418
422 // Static properties set by a successful match. 419 // Static properties set by a successful match.
423 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'lastMatch', RegExpGetLastMatch, 420 utils.InstallGetterSetter(GlobalRegExp, 'lastMatch', RegExpGetLastMatch,
424 NoOpSetter, DONT_DELETE); 421 NoOpSetter, DONT_DELETE);
425 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$&', RegExpGetLastMatch, 422 utils.InstallGetterSetter(GlobalRegExp, '$&', RegExpGetLastMatch, NoOpSetter,
426 NoOpSetter, DONT_ENUM | DONT_DELETE); 423 DONT_ENUM | DONT_DELETE);
427 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'lastParen', RegExpGetLastParen, 424 utils.InstallGetterSetter(GlobalRegExp, 'lastParen', RegExpGetLastParen,
428 NoOpSetter, DONT_DELETE); 425 NoOpSetter, DONT_DELETE);
429 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$+', RegExpGetLastParen, 426 utils.InstallGetterSetter(GlobalRegExp, '$+', RegExpGetLastParen, NoOpSetter,
430 NoOpSetter, DONT_ENUM | DONT_DELETE); 427 DONT_ENUM | DONT_DELETE);
431 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'leftContext', 428 utils.InstallGetterSetter(GlobalRegExp, 'leftContext', RegExpGetLeftContext,
432 RegExpGetLeftContext, NoOpSetter, 429 NoOpSetter, DONT_DELETE);
433 DONT_DELETE); 430 utils.InstallGetterSetter(GlobalRegExp, '$`', RegExpGetLeftContext, NoOpSetter,
434 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$`', RegExpGetLeftContext, 431 DONT_ENUM | DONT_DELETE);
435 NoOpSetter, DONT_ENUM | DONT_DELETE); 432 utils.InstallGetterSetter(GlobalRegExp, 'rightContext', RegExpGetRightContext,
436 %DefineAccessorPropertyUnchecked(GlobalRegExp, 'rightContext', 433 NoOpSetter, DONT_DELETE);
437 RegExpGetRightContext, NoOpSetter, 434 utils.InstallGetterSetter(GlobalRegExp, "$'", RegExpGetRightContext, NoOpSetter,
438 DONT_DELETE); 435 DONT_ENUM | DONT_DELETE);
439 %DefineAccessorPropertyUnchecked(GlobalRegExp, "$'", RegExpGetRightContext,
440 NoOpSetter, DONT_ENUM | DONT_DELETE);
441 436
442 for (var i = 1; i < 10; ++i) { 437 for (var i = 1; i < 10; ++i) {
443 %DefineAccessorPropertyUnchecked(GlobalRegExp, '$' + i, 438 utils.InstallGetterSetter(GlobalRegExp, '$' + i, RegExpMakeCaptureGetter(i),
444 RegExpMakeCaptureGetter(i), NoOpSetter, 439 NoOpSetter, DONT_DELETE);
445 DONT_DELETE);
446 } 440 }
447 %ToFastProperties(GlobalRegExp); 441 %ToFastProperties(GlobalRegExp);
448 442
449 // ------------------------------------------------------------------- 443 // -------------------------------------------------------------------
450 // Exports 444 // Exports
451 445
452 utils.Export(function(to) { 446 utils.Export(function(to) {
453 to.RegExpExec = DoRegExpExec; 447 to.RegExpExec = DoRegExpExec;
454 to.RegExpExecNoTests = RegExpExecNoTests; 448 to.RegExpExecNoTests = RegExpExecNoTests;
455 to.RegExpLastMatchInfo = RegExpLastMatchInfo; 449 to.RegExpLastMatchInfo = RegExpLastMatchInfo;
456 to.RegExpTest = RegExpTest; 450 to.RegExpTest = RegExpTest;
457 }); 451 });
458 452
459 }) 453 })
OLDNEW
« no previous file with comments | « src/js/prologue.js ('k') | test/mjsunit/es6/regexp-flags.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698