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

Side by Side Diff: src/regexp.js

Issue 788043005: ES6 unicode escapes, part 2: Regexps. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: error reporting Created 5 years, 11 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
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;
11 11
12 // ------------------------------------------------------------------- 12 // -------------------------------------------------------------------
13 13
14 // A recursive descent parser for Patterns according to the grammar of 14 // A recursive descent parser for Patterns according to the grammar of
15 // ECMA-262 15.10.1, with deviations noted below. 15 // ECMA-262 15.10.1, with deviations noted below.
16 function DoConstructRegExp(object, pattern, flags) { 16 function DoConstructRegExp(object, pattern, flags) {
17 // RegExp : Called as constructor; see ECMA-262, section 15.10.4. 17 // RegExp : Called as constructor; see ECMA-262, section 15.10.4.
18 if (IS_REGEXP(pattern)) { 18 if (IS_REGEXP(pattern)) {
19 if (!IS_UNDEFINED(flags)) { 19 if (!IS_UNDEFINED(flags)) {
20 throw MakeTypeError('regexp_flags', []); 20 throw MakeTypeError('regexp_flags', []);
21 } 21 }
22 flags = (pattern.global ? 'g' : '') 22 flags = (pattern.global ? 'g' : '')
23 + (pattern.ignoreCase ? 'i' : '') 23 + (pattern.ignoreCase ? 'i' : '')
24 + (pattern.multiline ? 'm' : ''); 24 + (pattern.multiline ? 'm' : '');
25 if (harmony_regexps) 25 if (harmony_regexps)
26 flags += (pattern.sticky ? 'y' : ''); 26 flags += (pattern.sticky ? 'y' : '');
27 if (harmony_unicode)
28 flags += (pattern.unicode ? 'u' : '');
mathias 2015/01/08 12:29:07 `u` goes before `y`.
marja 2015/01/08 13:42:18 Done.
27 pattern = pattern.source; 29 pattern = pattern.source;
28 } 30 }
29 31
30 pattern = IS_UNDEFINED(pattern) ? '' : ToString(pattern); 32 pattern = IS_UNDEFINED(pattern) ? '' : ToString(pattern);
31 flags = IS_UNDEFINED(flags) ? '' : ToString(flags); 33 flags = IS_UNDEFINED(flags) ? '' : ToString(flags);
32 34
33 %RegExpInitializeAndCompile(object, pattern, flags); 35 %RegExpInitializeAndCompile(object, pattern, flags);
34 } 36 }
35 37
36 38
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 function RegExpToString() { 231 function RegExpToString() {
230 if (!IS_REGEXP(this)) { 232 if (!IS_REGEXP(this)) {
231 throw MakeTypeError('incompatible_method_receiver', 233 throw MakeTypeError('incompatible_method_receiver',
232 ['RegExp.prototype.toString', this]); 234 ['RegExp.prototype.toString', this]);
233 } 235 }
234 var result = '/' + this.source + '/'; 236 var result = '/' + this.source + '/';
235 if (this.global) result += 'g'; 237 if (this.global) result += 'g';
236 if (this.ignoreCase) result += 'i'; 238 if (this.ignoreCase) result += 'i';
237 if (this.multiline) result += 'm'; 239 if (this.multiline) result += 'm';
238 if (harmony_regexps && this.sticky) result += 'y'; 240 if (harmony_regexps && this.sticky) result += 'y';
241 if (harmony_unicode && this.unicode) result += 'u';
mathias 2015/01/08 12:29:07 Same here.
marja 2015/01/08 13:42:18 Done + updated mjsunit/harmony/regexp-flags.js to
239 return result; 242 return result;
240 } 243 }
241 244
242 245
243 // Getters for the static properties lastMatch, lastParen, leftContext, and 246 // Getters for the static properties lastMatch, lastParen, leftContext, and
244 // rightContext of the RegExp constructor. The properties are computed based 247 // rightContext of the RegExp constructor. The properties are computed based
245 // on the captures array of the last successful match and the subject string 248 // on the captures array of the last successful match and the subject string
246 // of the last successful match. 249 // of the last successful match.
247 function RegExpGetLastMatch() { 250 function RegExpGetLastMatch() {
248 if (lastMatchInfoOverride !== null) { 251 if (lastMatchInfoOverride !== null) {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 430
428 for (var i = 1; i < 10; ++i) { 431 for (var i = 1; i < 10; ++i) {
429 %DefineAccessorPropertyUnchecked($RegExp, '$' + i, 432 %DefineAccessorPropertyUnchecked($RegExp, '$' + i,
430 RegExpMakeCaptureGetter(i), NoOpSetter, 433 RegExpMakeCaptureGetter(i), NoOpSetter,
431 DONT_DELETE); 434 DONT_DELETE);
432 } 435 }
433 %ToFastProperties($RegExp); 436 %ToFastProperties($RegExp);
434 } 437 }
435 438
436 SetUpRegExp(); 439 SetUpRegExp();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698