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

Side by Side Diff: src/regexp.js

Issue 770333005: Implement the `RegExp.prototype.flags` getter (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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/messages.js ('k') | test/mjsunit/harmony/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 // This file relies on the fact that the following declaration has been made 5 // This file relies on the fact that the following declaration has been made
6 // in runtime.js: 6 // in runtime.js:
7 // var $Object = global.Object; 7 // var $Object = global.Object;
8 // var $Array = global.Array; 8 // var $Array = global.Array;
9 9
10 var $RegExp = global.RegExp; 10 var $RegExp = global.RegExp;
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 DONT_DELETE); 424 DONT_DELETE);
425 %DefineAccessorPropertyUnchecked($RegExp, "$'", RegExpGetRightContext, 425 %DefineAccessorPropertyUnchecked($RegExp, "$'", RegExpGetRightContext,
426 NoOpSetter, DONT_ENUM | DONT_DELETE); 426 NoOpSetter, DONT_ENUM | DONT_DELETE);
427 427
428 for (var i = 1; i < 10; ++i) { 428 for (var i = 1; i < 10; ++i) {
429 %DefineAccessorPropertyUnchecked($RegExp, '$' + i, 429 %DefineAccessorPropertyUnchecked($RegExp, '$' + i,
430 RegExpMakeCaptureGetter(i), NoOpSetter, 430 RegExpMakeCaptureGetter(i), NoOpSetter,
431 DONT_DELETE); 431 DONT_DELETE);
432 } 432 }
433 %ToFastProperties($RegExp); 433 %ToFastProperties($RegExp);
434
435
436 // ES6 draft 12-06-13, section 21.2.5.3
437 // + https://bugs.ecmascript.org/show_bug.cgi?id=3423
438 var RegExpGetFlags = function() {
439 if (!IS_SPEC_OBJECT(this)) {
440 throw MakeTypeError('home_object_non_object',
441 'RegExp.prototype.flags',
442 [%ToString(this)]);
443 }
444 var result = '';
445 if (this.global) result += 'g';
446 if (this.ignoreCase) result += 'i';
447 if (this.multiline) result += 'm';
448 if (this.unicode) result += 'u';
449 if (this.sticky) result += 'y';
450 return result;
451 };
452 //if (harmony_regexps) {
Dmitry Lomov (no reviews) 2014/12/09 23:02:00 harmony_regexps should not be used in bootstrappin
453 %DefineAccessorPropertyUnchecked($RegExp.prototype, 'flags', RegExpGetFlags,
454 NoOpSetter, DONT_DELETE);
455 %SetNativeFlag(RegExpGetFlags);
456 //}
mathias 2014/12/09 22:50:48 Uncommenting the `if` statement breaks the build.
434 } 457 }
435 458
436 SetUpRegExp(); 459 SetUpRegExp();
OLDNEW
« no previous file with comments | « src/messages.js ('k') | test/mjsunit/harmony/regexp-flags.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698